Neo4j
План Cypher – Создание – Запросы Neo4j embedded in Java Немного о релизации (Neo4j Internals) – Native Graph Processing – Native Graph Storage
Neo4j
Cypher: Создание CREATE: Creates nodes and relationships. MERGE: Creates nodes uniquely. CREATE UNIQUE: Creates relationships uniquely. DELETE: Removes nodes, relationships. SET: Updates properties and labels. REMOVE: Removes properties and labels. FOREACH: Performs updating actions once per element in a list. WITH: Divides a query into multiple, distinct parts and passes results from one to the next.
Cypher: запросы MATCH: Matches the given graph pattern in the graph data. WHERE: Filters using predicates or anchors pattern elements. RETURN: Returns and projects result data, also handles aggregation. ORDER BY: Sorts the query result. SKIP/LIMIT: Paginates the query result.
Paths ()-[]->() ()<-[]-() ()-[:RelationshipType*N]->() ()-[]->()<-[]-()
Aggregates count(x) Count the number of occurrences min(x) Get the lowest value max(x) Get the highest value avg(x) Get the average of a numeric value sum(x) Sum up values collect(x) Collect all the values into an collection
Native Graph Storage Store files: – Nodes – Relationships – Properties – etc Fixed-sized records (node 9 bytes, rel 33 bytes,…) -> быстрый поиск по ID: – node {id:90} - > в store file его запись начинается с 900 байта - > поиск нода за O(1)
Движение по store files Node (9 bytes)
Native Graph Processing Index-free adjacency
O(log n)
O(1)
Источники Ian Robinson, Jim Webber, and Emil Eifrém Graph Databases The Definitive Book onGraph Databases