Redis Graph A graph database built on top of redis Whats Redis? - - PowerPoint PPT Presentation

redis graph
SMART_READER_LITE
LIVE PREVIEW

Redis Graph A graph database built on top of redis Whats Redis? - - PowerPoint PPT Presentation

Redis Graph A graph database built on top of redis Whats Redis? Open source in-memory database Key => Data Structure server Key features: Fast, Flexible, Simple A Lego for your database Strings/Blobs/Bitmaps "I'm a Plain Text


slide-1
SLIDE 1

Redis Graph

A graph database built on top of redis

slide-2
SLIDE 2

Open source in-memory database Key => Data Structure server Key features: Fast, Flexible, Simple

What’s Redis?

slide-3
SLIDE 3

A Lego for your database

Key

"I'm a Plain Text String!" { A: “foo”, B: “bar”, C: “baz” }

Strings/Blobs/Bitmaps Hash Tables (objects!) Linked Lists Sets Sorted Sets Geo Sets HyperLogLog

{ A , B , C , D , E } [ A → B → C → D → E ] { A: 0.1, B: 0.3, C: 100, D: 1337 } { A: (51.5, 0.12), B: (32.1, 34.7) } 00110101 11001110 10101010

slide-4
SLIDE 4

Node

“Jerry Seinfeld”: { First_Name: “Jerry”, Age: 62 }

Jerry Seinfeld

slide-5
SLIDE 5

Relations

Jerry Berlin Visit

slide-6
SLIDE 6

SPO SOP OPS OSP PSO POS

Hexastore

S

Subject

P

Predicate

O

Object 6

slide-7
SLIDE 7

Hexastore

Triplets

SPO:Jerry:Visit:Berlin SOP:Jerry:Berlin:Visit OPS:Berlin:Visit:Jerry OSP:Berlin:Jerry:Visit PSO:Visit:Jerry:Berlin POS:Visit:Berlin:Jerry

Jerry S Berlin O

Visit P

slide-8
SLIDE 8

Places Jerry been to? SPO:Jerry:Visit:* Who visited Berlin? OPS:Berlin:Visit:* Who travels and to where? PSO:Visit:*

Hexastore

Jerry S Berlin O

Visit P

slide-9
SLIDE 9

Cypher*

MATCH (Jerry:’Jerry Seinfeld’)-[friend]->(F)-[visit]->(country) WHERE (F.age >= Jerry.age AND country.continent = ‘Europe’) RETURN F.name, count(country.name) AS countriesVisited ORDER BY countriesVisited, F.age DESC LIMIT 2

Query language

slide-10
SLIDE 10

Tokenizer - Lex Parser - Lemon, SQLite LALR(1) parser generator for C

  • pencypher

Query language

slide-11
SLIDE 11

End to end

MATCH (Jerry:’Jerry Seinfeld’)-[friend]->(F)-[visit]->(Country) WHERE F.age >= 50 AND Country.continent = “Europe” RETURN F.name, F.age, Country.name ORDER BY F.age DESC LIMIT 5

slide-12
SLIDE 12

End to end

Lexer Query Parser AST

slide-13
SLIDE 13

End to end AST

Root Match Where Return Order

slide-14
SLIDE 14

End to end

MATCH (Jerry:"Jerry Seinfeld")-[friend]->(F)-[visit]->(Country) Alias: Jerry ID: Jerry Seinfeld Alias: F ID: ? Alias: Country ID: ? visit friend

slide-15
SLIDE 15

End to end

Alias: Jerry ID: Jerry Seinfeld Alias: F ID: ? Alias: Country ID: ? visit friend

SPO:Jerry Seinfeld:friend:* SPO:Jerry Seinfeld:friend:Cosmo Kramer SPO:Jerry Seinfeld:friend:George Costanza

slide-16
SLIDE 16

End to end

Alias: Jerry ID: Jerry Seinfeld Alias: F ID: Cosmo Kramer Alias: Country ID: ? visit friend

slide-17
SLIDE 17

End to end

WHERE F.age >= 50 AND Country.continent = “Europe”

AND

age >= 50 continent = “Europe”

Filter tree

slide-18
SLIDE 18

End to end

AND

Kramer .age >= 50 continent = “Europe”

Cosmo Kramer: { Name: ‘Cosmo Kramer’, Age: 48 }

slide-19
SLIDE 19

End to end

AND

Kramer .age >= 50

F

continent = “Europe”

Cosmo Kramer: { Name: ‘Cosmo Kramer’, Age: 48 }

slide-20
SLIDE 20

End to end

AND

F

Kramer .age >= 50

F

continent = “Europe”

Cosmo Kramer: { Name: ‘Cosmo Kramer’, Age: 48 }

slide-21
SLIDE 21

End to end

Alias: Jerry ID: Jerry Seinfeld Alias: F ID: ? Alias: Country ID: ? visit friend

SPO:Jerry Seinfeld:friend:* SPO:Jerry Seinfeld:friend:Cosmo Kramer SPO:Jerry Seinfeld:friend:George Costanza

slide-22
SLIDE 22

End to end

Alias: Jerry ID: Jerry Seinfeld Alias: F ID: George Costanza Alias: Country ID: ? visit friend

slide-23
SLIDE 23

End to end

AND

George .age >= 50 continent = “Europe”

George Costanza:{ Name: ‘George Costanza’, Age: 52 }

slide-24
SLIDE 24

End to end

AND

George .age >= 50

T

continent = “Europe”

George Costanza:{ Name: ‘George Costanza’, Age: 52 }

slide-25
SLIDE 25

End to end

AND

T

George .age >= 50

T

continent = “Europe”

T

George Costanza:{ Name: ‘George Costanza’, Age: 52 }

slide-26
SLIDE 26

End to end

Alias: Jerry ID: Jerry Seinfeld Alias: F ID: George Costanza Alias: Country ID: ? visit friend

SPO:George Costanza:visit:* SPO:George Costanza:visit:Italy SPO:George Costanza:visit:Cuba

slide-27
SLIDE 27

End to end

Alias: Jerry ID: Jerry Seinfeld Alias: F ID: George Costanza Alias: Country ID: Italy visit friend

slide-28
SLIDE 28

End to end

AND

T

George .age >= 50

T

Italy .continent = “Europe”

T

George Costanza:{ Name: ‘George Costanza’, Age: 52 } Italy: { Continent: ‘Europe’, Population: 1000, Name: ‘Italy’ }

slide-29
SLIDE 29

End to end

TOP K heap RETURN F.name, F.age, Country.name ORDER BY F.age DESC LIMIT 5 [‘George Costanza’, 52, Italy]

slide-30
SLIDE 30

Features

Multi hop, multi entry point (A)-[R1]->(C)<-[R2]-(B) (Nicolas:’Nicolas Cage’)-[act]->(Movie)<-[act]-(Actor) Aggregations, Group bys RETURN F.gender, AVG(F.age) AS average_age Order bys, Distinct

slide-31
SLIDE 31

Benchmark

150K inserts per second 15K simple queries per second

slide-32
SLIDE 32

There’s still work to be done

  • Single node query:

MATCH (A) RETURN A

  • OPTIONAL MATCH
  • WITH, SKIP, UNION
  • Curly brackets filters

(john {name: ‘John’})

  • In place evaluations

WHERE Me.age > F.age + X

  • Shortest path between nodes (A)-[*]-(B)
  • A number of aggregation functions: stdev, precentileCount
slide-33
SLIDE 33

Roadmap

  • Hexastore sorted-set -> Trie
  • Indexed entities
  • Single node query
  • Python lib
slide-34
SLIDE 34

Contribute/Contact

https://github.com/swilly22/redis-module-graph @roilipman