Skip to content

Commit 5ae4bc4

Browse files
authored
overview and basic use case additions (#4)
1 parent e8d4165 commit 5ae4bc4

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

content/_index.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ flatgraph is developed and maintained as the underlying database for the code an
2525

2626
## Glimpse of a simple use case
2727
We have a history in [tinkerpop](https://tinkerpop.apache.org), so allow us to use a very simple graph domain from there to show how to get started with flatgraph. Working code is typically better than prose: the full setup is part of the tests in the [flatgraph repository](https://github.com/joernio/flatgraph).
28-
{{< figure src="/grateful-dead-schema.png" caption="grateful dead sample domain">}}
28+
{{< figure src="/grateful-dead-schema.png" caption="grateful dead sample domain" width="600px">}}
2929

3030
Excerpt from the [GratefulDead domain schema](https://github.com/joernio/flatgraph/blob/44005cf16373dfaf629da8628071ebbfaf02b551/test-schemas/src/main/scala/flatgraph/testdomains/GratefulDead.scala):
3131
```scala
@@ -42,7 +42,9 @@ song.addOutEdge(
4242
stepNameOut = "sungBy",
4343
stepNameIn = "sang")
4444
```
45-
The code generator takes the schema as input and generates [domain specific classes](https://github.com/joernio/flatgraph/tree/44005cf16373dfaf629da8628071ebbfaf02b551/test-schemas-domain-classes/src/main/scala/testdomains/gratefuldead) that can e.g. be used like this:
45+
46+
The code generator takes the schema as input and generates [domain specific classes](https://github.com/joernio/flatgraph/tree/44005cf16373dfaf629da8628071ebbfaf02b551/test-schemas-domain-classes/src/main/scala/testdomains/gratefuldead) that can e.g. be used as follows:
47+
4648
```scala
4749
val gratefulDead = GratefulDead.empty
4850

@@ -61,7 +63,20 @@ gratefulDead.artist.name.sorted shouldBe List("Bo_Diddley", "Garcia")
6163
gratefulDead.artist.name("Garcia").sang.name.l shouldBe List("HEY BO DIDDLEY")
6264
gratefulDead.song.writtenBy.name.l shouldBe List("Bo_Diddley")
6365
```
64-
Note that the properties (e.g. `name` and `performances`) have the respective types as defined in the schema, and relationships between nodes have named steps, e.g. `sang`. If you didn't provide a name for a relationship, there are some alternative auto-generated options like `sungbyOut` and `artistViaSungbyOut`.
66+
67+
{{% notice note %}}
68+
By defining your domain in a schema we enable the compiler to help us write domain-specific code, i.e. the compiler ensures that our traversals are valid and we also get domain-specific code completion. Additionally, we ensure that no schema-invalid graph can be constructed.
69+
{{% /notice %}}
70+
Some examples for what return types the compiler derives, based on the information given in the schema:
71+
* `gratefulDead.artist: Iterator[Artist]`
72+
* `gratefulDead.artist.name: Iterator[String]`
73+
* `gratefulDead.artist.name("Garcia"): Iterator[Artist]` - note that `name(String)` is a filter step
74+
* `gratefulDead.song.performances: Iterator[Int]`
75+
* `gratefulDead.artist.performances` does not compile
76+
* `gratefulDead.song.writtenBy: Iterator[Artist]`
77+
* `gratefulDead.artist.writtenBy` does not compile
78+
79+
If you didn't provide a name for a relationship in the schema definition, there are some alternative auto-generated options like `sungbyOut` and `artistViaSungbyOut`.
6580
The full working test is [here](https://github.com/joernio/flatgraph/blob/92f4cc4b84bf6b8315971128995a75872376dcff/tests/src/test/scala/flatgraph/GratefulDeadTests.scala).
6681

6782
## Memory footprint

content/benchmarks/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title = "Benchmarks"
33
weight = 4
44
+++
55

6-
In the past, many initial attempts at marrying a graph database with static analysis was done with TinkerGraph or Neo4j (see [Related Work](_index.md/#related-work)), however these databases have been proven to be slow and inefficient. This was motivation enough to create [OverfowDB](https://github.com/ShiftLeftSecurity/overflowdb), and now [flatgraph](https://github.com/joernio/flatgraph).
6+
In the past, many initial attempts at marrying a graph database with static analysis was done with TinkerGraph or Neo4j (see [Related Work](_index.md/#related-work)), however these databases have been proven to be slow and inefficient. This was motivation enough to create [OverflowDB](https://github.com/ShiftLeftSecurity/overflowdb), and now [flatgraph](https://github.com/joernio/flatgraph).
77

88
Below are benchmarks measuring various properties of how each database performs.
99

hugo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ theme = 'relearn'
99
disableShortcutsTitle = true
1010

1111
[[menu.shortcuts]]
12-
name = "<i class='fa-fw fab fa-github'></i> GitHub repo"
12+
name = "<i class='fa-fw fab fa-github'></i> git repository"
1313
url = "https://github.com/joernio/flatgraph"
1414
weight = 10
1515

0 commit comments

Comments
 (0)