Comments (5)
I'm not 100% sure what you are asking...once you create an index on a property key you should be able to use it normally to retrieve vertices:
v = await g.V().has('indexed_key', value).next()
from goblin.
Thanks! I have solved this problem!
I want to ask how to increase the efficiency insert Vertex and Edge into the graph database.
I inserted 2 Millions Vertex,it seems too slow.Do you have sample code about insert Millions Vertex and Edge.
Sorry about my English, I am not very good at it!
import goblin
from goblin import Vertex
import asyncio
import pymysql
def get_hashable_id(val):
result = val
if isinstance(val, dict) and "@type" in val and "@value" in val:
if val["@type"] == "janusgraph:RelationIdentifier":
result = val["@value"]["value"]
return result
loop = asyncio.get_event_loop()
app = loop.run_until_complete(goblin.Goblin.open(loop, get_hashable_id=get_hashable_id))
session = loop.run_until_complete(app.session())
class Suspector(Vertex):
id_number = goblin.Property(goblin.String)
class Relation(goblin.Edge):
relationship = goblin.Property(goblin.String, default='unkonwn')
db = pymysql.connect("localhost", "root", "peptalk", "Person")
cursor = db.cursor()
cursor.execute("select * from sus_relation where id>200387")
data = cursor.fetchall()
count = 1
for i in data:
count += 1
print(count)
suspector1 = Suspector()
suspector2 = Suspector()
suspector1.id_number = i[1]
suspector2.id_number = i[2]
two_suspector_relationship = Relation(suspector1, suspector2)
session.add(suspector1, suspector2, two_suspector_relationship)
app.register(Suspector, Relation)
loop.run_until_complete(session.flush())
It's my code.It seems very slow
from goblin.
Hi, i am trapped with this problem.I hope you can help me!Thanks
from goblin.
Well, Goblin is not made for bulk loading or ETL purposes. Instead, it is designed to make data modeling for applications transparent and intuitive. There are multiple approaches you could take here, some of which use the aiogremlin.driver
module to submit raw scripts to the server, others would probably use the Gremlin Language Variant (also included with aiogremlin
) to submit traversals to the server. Moral of the story, Goblin is not made for bulk loading. You can bulk load, and then use Goblin on the data that already exists in your database as long as you assign labels properly during the bulk load process. I would start by checking out JanusGraph's docs about bulk loading. Then there should be a variety of options. Off the top of my head I can think of:
-
Write the data to a file, and then use Gremlin I/O to load data into your graph instance. This is quick and easy with small graphs, but I have never done it with a larger sample.
-
You could try the BulkLoaderVertexProgram implementation provided with TinkerPop. I have never used it, but it presumably works.
-
Submit a custom gremlin-groovy script to the server that loads your data. There should be tons of examples of this if you look at the mailing lists.
I am happy to help you with Goblin/Gremlin related issues, but for stuff like this honestly the best place to start would be the mailing lists:
https://groups.google.com/forum/#!forum/gremlin-users
https://groups.google.com/forum/#!forum/janusgraph-users
Hopefully this leads you in the right direction. Again, I would stress, don't use Goblin for bulk loading. Choose a more appropriate tool, and then you can use Goblin later in your application to model data and interact with the graph based on your business requirements.
from goblin.
Thank you so much! I will think of another way for bulk loading!
from goblin.
Related Issues (20)
- Reference instance to test goblin against HOT 3
- How to change version of Goblin OGM Serializer for Janusgraph (TinkerPop 3.2.6) HOT 3
- TypeError: unhashable type: 'dict' when creating an Edge HOT 10
- goblin does not work with aiohttp>=3.0.0 HOT 5
- Question about using a multi-value/set VertexProperty HOT 6
- Vertex property gets changed from Gremlin Console but not from Python/Goblin script HOT 2
- goblin not working with aiohttp (server) HOT 2
- Mocking JanusGraph Connection for unit tests
- Add method to easily remove Vertex HOT 1
- The project appears idle, can I take over? HOT 10
- Problem with Edge data type HOT 5
- App/Cluster configuration using URL HOT 3
- Schema generator HOT 3
- Belated License change HOT 5
- Question: Extent to which OO modeling is supported in Goblin HOT 7
- How to use mixed index in goblin? HOT 4
- AttributeError: AsyncGraphTraversal.last_traverser HOT 1
- [Proposal] - OGM distinct from driver HOT 7
- Ability to set vertex or edge ID HOT 5
- Unexpected results when updating property HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from goblin.