Repository: cayleygraph/cayley
Pull request #873 (2019-10-15 09:13:34)

Rename query-related package
Rename `graph/path` and `graph/shape` to `query/path` and `query/shape` accordingly. This should make a purpose of those packages more clear.

A reparation for #863

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/cayleygraph/cayley/873)
<!-- Reviewable:end -->



Patch:
diff --git a/cmd/cayley/command/dedup.go b/cmd/cayley/command/dedup.go
index 9c7f576..d0481ae 100644
--- a/cmd/cayley/command/dedup.go
+++ b/cmd/cayley/command/dedup.go
@@ -14,7 +14,7 @@ import (
 
 	"github.com/cayleygraph/cayley/clog"
 	"github.com/cayleygraph/cayley/graph"
-	"github.com/cayleygraph/cayley/graph/path"
+	"github.com/cayleygraph/cayley/query/path"
 	"github.com/cayleygraph/quad"
 	"github.com/cayleygraph/quad/voc/rdf"
 )
diff --git a/docs/glossary.md b/docs/glossary.md
index 4c9efe2..e33d454 100644
--- a/docs/glossary.md
+++ b/docs/glossary.md
@@ -98,7 +98,7 @@ _Note: this definitions in this glossary are sequenced so that they build on eac
 ## path
 
 1. Paths are just a set of helpers to build a query, but they are not that good for building something more complex. You can try using [Shapes](glossary.md#shape) for this - it will give you a full control of what the query actually does. [source](https://discourse.cayley.io/t/a-variety-of-questions/1183/2)
-2. Path represents either a morphism \(a pre-defined path stored for later use\), or a concrete path, consisting of a morphism and an underlying QuadStore. [source](https://godoc.org/github.com/cayleygraph/cayley/graph/path#Path)
+2. Path represents either a morphism \(a pre-defined path stored for later use\), or a concrete path, consisting of a morphism and an underlying QuadStore. [source](https://godoc.org/github.com/cayleygraph/cayley/query/path#Path)
 3. Underlying code:
 
    ```go
@@ -118,7 +118,7 @@ _Note: this definitions in this glossary are sequenced so that they build on eac
    type applyMorphism func(shape.Shape, *pathContext) (shape.Shape, *pathContext)
    ```
 
-   So, as previously stated, the [path](https://godoc.org/github.com/cayleygraph/cayley/graph/path) package is just helper methods on top of the [shape](https://godoc.org/github.com/cayleygraph/cayley/graph/shape) package.
+   So, as previously stated, the [path](https://godoc.org/github.com/cayleygraph/cayley/query/path) package is just helper methods on top of the [shape](https://godoc.org/github.com/cayleygraph/cayley/graph/shape) package.
 
 ## morphism
 
diff --git a/graph/kv/iterators.go b/graph/kv/iterators.go
index 81d61a7..7e2f3eb 100644
--- a/graph/kv/iterators.go
+++ b/graph/kv/iterators.go
@@ -8,7 +8,7 @@ import (
 
 	"github.com/cayleygraph/cayley/graph"
 	"github.com/cayleygraph/cayley/graph/iterator"
-	"github.com/cayleygraph/cayley/graph/shape"
+	"github.com/cayleygraph/cayley/query/shape"
 	"github.com/cayleygraph/quad"
 )
 
diff --git a/graph/kv/quadstore.go b/graph/kv/quadstore.go
index fb72ae6..dbc7042 100644
--- a/graph/kv/quadstore.go
+++ b/graph/kv/quadstore.go
@@ -26,8 +26,8 @@ import (
 	"github.com/cayleygraph/cayley/clog"
 	"github.com/cayleygraph/cayley/graph"
 	"github.com/cayleygraph/cayley/graph/proto"
-	"github.com/cayleygraph/cayley/graph/shape"
 	"github.com/cayleygraph/cayley/internal/lru"
+	"github.com/cayleygraph/cayley/query/shape"
 	"github.com/cayleygraph/quad"
 	"github.com/cayleygraph/quad/pquads"
 	"github.com/hidal-go/hidalgo/kv"
diff --git a/graph/nosql/shapes.go b/graph/nosql/shapes.go
index 130d082..8dcfeb7 100644
--- a/graph/nosql/shapes.go
+++ b/graph/nosql/shapes.go
@@ -9,7 +9,7 @@ import (
 
 	"github.com/cayleygraph/cayley/graph"
 	"github.com/cayleygraph/cayley/graph/iterator"
-	"github.com/cayleygraph/cayley/graph/shape"
+	"github.com/cayleygraph/cayley/query/shape"
 	"github.com/cayleygraph/quad"
 )
 
diff --git a/graph/sql/iterator.go b/graph/sql/iterator.go
index 740eca9..a151901 100644
--- a/graph/sql/iterator.go
+++ b/graph/sql/iterator.go
@@ -21,7 +21,7 @@ import (
 	"strings"
 
 	"github.com/cayleygraph/cayley/graph"
-	"github.com/cayleygraph/cayley/graph/shape"
+	"github.com/cayleygraph/cayley/query/shape"
 	"github.com/cayleygraph/quad"
 )
 
diff --git a/graph/sql/optimizer.go b/graph/sql/optimizer.go
index 30a436e..4409a36 100644
--- a/graph/sql/optimizer.go
+++ b/graph/sql/optimizer.go
@@ -20,7 +20,7 @@ import (
 	"strings"
 
 	"github.com/cayleygraph/cayley/graph/iterator"
-	"github.com/cayleygraph/cayley/graph/shape"
+	"github.com/cayleygraph/cayley/query/shape"
 	"github.com/cayleygraph/quad"
 )
 
diff --git a/graph/sql/shape.go b/graph/sql/shape.go
index 9aa80e0..69c5a1a 100644
--- a/graph/sql/shape.go
+++ b/graph/sql/shape.go
@@ -21,7 +21,7 @@ import (
 
 	"github.com/cayleygraph/cayley/graph"
 	"github.com/cayleygraph/cayley/graph/iterator"
-	"github.com/cayleygraph/cayley/graph/shape"
+	"github.com/cayleygraph/cayley/query/shape"
 	"github.com/cayleygraph/quad"
 )
 
diff --git a/imports.go b/imports.go
index 8d8216f..a3a4c3f 100644
--- a/imports.go
+++ b/imports.go
@@ -3,7 +3,7 @@ package cayley
 import (
 	"github.com/cayleygraph/cayley/graph"
 	_ "github.com/cayleygraph/cayley/graph/memstore"
-	"github.com/cayleygraph/cayley/graph/path"
+	"github.com/cayleygraph/cayley/query/path"
 	_ "github.com/cayleygraph/cayley/writer"
 	"github.com/cayleygraph/quad"
 )
diff --git a/internal/gephi/stream.go b/internal/gephi/stream.go
index 4ff1455..a34f0c4 100644
--- a/internal/gephi/stream.go
+++ b/internal/gephi/stream.go
@@ -16,8 +16,8 @@ import (
 	"github.com/cayleygraph/cayley/clog"
 	"github.com/cayleygraph/cayley/graph"
 	"github.com/cayleygraph/cayley/graph/iterator"
-	"github.com/cayleygraph/cayley/graph/path"
-	"github.com/cayleygraph/cayley/graph/shape"
+	"github.com/cayleygraph/cayley/query/path"
+	"github.com/cayleygraph/cayley/query/shape"
 	"github.com/cayleygraph/quad"
 	"github.com/cayleygraph/quad/voc/rdf"
 	"github.com/cayleygraph/quad/voc/rdfs"
diff --git a/query/gizmo/environ.go b/query/gizmo/environ.go
index 1c22bf5..d13c64e 100644
--- a/query/gizmo/environ.go
+++ b/query/gizmo/environ.go
@@ -24,8 +24,8 @@ import (
 	"github.com/dop251/goja"
 
 	"github.com/cayleygraph/cayley/graph/iterator"
-	"github.com/cayleygraph/cayley/graph/path"
-	"github.com/cayleygraph/cayley/graph/shape"
+	"github.com/cayleygraph/cayley/query/path"
+	"github.com/cayleygraph/cayley/query/shape"
 	"github.com/cayleygraph/quad"
 	"github.com/cayleygraph/quad/voc"
 )
diff --git a/query/gizmo/traversals.go b/query/gizmo/traversals.go
index 5676ee3..154d762 100644
--- a/query/gizmo/traversals.go
+++ b/query/gizmo/traversals.go
@@ -24,9 +24,9 @@ import (
 
 	"github.com/cayleygraph/cayley/graph"
 	"github.com/cayleygraph/cayley/graph/iterator"
-	"github.com/cayleygraph/cayley/graph/path"
-	"github.com/cayleygraph/cayley/graph/shape"
 	"github.com/cayleygraph/cayley/query"
+	"github.com/cayleygraph/cayley/query/path"
+	"github.com/cayleygraph/cayley/query/shape"
 	"github.com/cayleygraph/quad"
 )
 
diff --git a/query/graphql/graphql.go b/query/graphql/graphql.go
index 79cd1e3..4b611f0 100644
--- a/query/graphql/graphql.go
+++ b/query/graphql/graphql.go
@@ -15,8 +15,8 @@ import (
 	"github.com/dennwc/graphql/language/parser"
 
 	"github.com/cayleygraph/cayley/graph"
-	"github.com/cayleygraph/cayley/graph/path"
 	"github.com/cayleygraph/cayley/query"
+	"github.com/cayleygraph/cayley/query/path"
 	"github.com/cayleygraph/quad"
 )
 
diff --git a/query/mql/build_iterator.go b/query/mql/build_iterator.go
index 4eadd8d..ea5b61a 100644
--- a/query/mql/build_iterator.go
+++ b/query/mql/build_iterator.go
@@ -20,7 +20,7 @@ import (
 	"math"
 	"strings"
 
-	"github.com/cayleygraph/cayley/graph/shape"
+	"github.com/cayleygraph/cayley/query/shape"
 	"github.com/cayleygraph/quad"
 )
 
diff --git a/graph/path/morphism_apply_functions.go b/query/path/morphism_apply_functions.go
similarity index 99%
rename from graph/path/morphism_apply_functions.go
rename to query/path/morphism_apply_functions.go
index 7c17b95..e8703b5 100644
--- a/graph/path/morphism_apply_functions.go
+++ b/query/path/morphism_apply_functions.go
@@ -19,7 +19,7 @@ import (
 
 	"github.com/cayleygraph/cayley/graph"
 	"github.com/cayleygraph/cayley/graph/iterator"
-	"github.com/cayleygraph/cayley/graph/shape"
+	"github.com/cayleygraph/cayley/query/shape"
 	"github.com/cayleygraph/quad"
 )
 
diff --git a/graph/path/path.go b/query/path/path.go
similarity index 99%
rename from graph/path/path.go
rename to query/path/path.go
index 96f1ba1..e228ac0 100644
--- a/graph/path/path.go
+++ b/query/path/path.go
@@ -20,7 +20,7 @@ import (
 
 	"github.com/cayleygraph/cayley/graph"
 	"github.com/cayleygraph/cayley/graph/iterator"
-	"github.com/cayleygraph/cayley/graph/shape"
+	"github.com/cayleygraph/cayley/query/shape"
 	"github.com/cayleygraph/quad"
 )
 
diff --git a/query/sexp/parser.go b/query/sexp/parser.go
index 471655b..9bf79ab 100644
--- a/query/sexp/parser.go
+++ b/query/sexp/parser.go
@@ -19,7 +19,7 @@ import (
 
 	"github.com/cayleygraph/cayley/graph"
 	"github.com/cayleygraph/cayley/graph/iterator"
-	"github.com/cayleygraph/cayley/graph/shape"
+	"github.com/cayleygraph/cayley/query/shape"
 	"github.com/cayleygraph/quad"
 )
 
diff --git a/graph/shape/path.go b/query/shape/path.go
similarity index 99%
rename from graph/shape/path.go
rename to query/shape/path.go
index 9688001..5711267 100644
--- a/graph/shape/path.go
+++ b/query/shape/path.go
@@ -240,4 +240,4 @@ func Compare(nodes Shape, op iterator.Operator, v quad.Value) Shape {
 func Iterate(ctx context.Context, qs graph.QuadStore, s Shape) *graph.IterateChain {
 	it := BuildIterator(qs, s)
 	return graph.Iterate(ctx, it).On(qs)
-}
\ No newline at end of file
+}
diff --git a/schema/loader.go b/schema/loader.go
index ff0fba2..8533232 100644
--- a/schema/loader.go
+++ b/schema/loader.go
@@ -6,7 +6,7 @@ import (
 	"fmt"
 	"reflect"
 
-	"github.com/cayleygraph/cayley/graph/path"
+	"github.com/cayleygraph/cayley/query/path"
 	"github.com/cayleygraph/quad"
 
 	"github.com/cayleygraph/cayley/graph"
diff --git a/schema/schema.go b/schema/schema.go
index 663ba7a..3e88730 100644
--- a/schema/schema.go
+++ b/schema/schema.go
@@ -13,7 +13,7 @@ import (
 	"unicode/utf8"
 
 	"github.com/cayleygraph/cayley/graph"
-	"github.com/cayleygraph/cayley/graph/path"
+	"github.com/cayleygraph/cayley/query/path"
 	"github.com/cayleygraph/quad"
 	"github.com/cayleygraph/quad/voc/rdf"
 )
diff --git a/server/http/api_v2.go b/server/http/api_v2.go
index b6f3fa8..5fe8eab 100644
--- a/server/http/api_v2.go
+++ b/server/http/api_v2.go
@@ -30,8 +30,8 @@ import (
 
 	"github.com/cayleygraph/cayley/clog"
 	"github.com/cayleygraph/cayley/graph"
-	"github.com/cayleygraph/cayley/graph/shape"
 	"github.com/cayleygraph/cayley/query"
+	"github.com/cayleygraph/cayley/query/shape"
 	_ "github.com/cayleygraph/cayley/writer"
 	"github.com/cayleygraph/quad"
 )


Test patch:
diff --git a/graph/graphtest/graphtest.go b/graph/graphtest/graphtest.go
index 02a8fb5..71a55f8 100644
--- a/graph/graphtest/graphtest.go
+++ b/graph/graphtest/graphtest.go
@@ -11,8 +11,8 @@ import (
 	"github.com/cayleygraph/cayley/graph"
 	"github.com/cayleygraph/cayley/graph/graphtest/testutil"
 	"github.com/cayleygraph/cayley/graph/iterator"
-	"github.com/cayleygraph/cayley/graph/path/pathtest"
-	"github.com/cayleygraph/cayley/graph/shape"
+	"github.com/cayleygraph/cayley/query/path/pathtest"
+	"github.com/cayleygraph/cayley/query/shape"
 	"github.com/cayleygraph/cayley/schema"
 	"github.com/cayleygraph/cayley/writer"
 	"github.com/cayleygraph/quad"
diff --git a/graph/kv/kvtest/kvtest.go b/graph/kv/kvtest/kvtest.go
index c3a18cb..eab3901 100644
--- a/graph/kv/kvtest/kvtest.go
+++ b/graph/kv/kvtest/kvtest.go
@@ -9,7 +9,7 @@ import (
 	"github.com/cayleygraph/cayley/graph/graphtest"
 	"github.com/cayleygraph/cayley/graph/graphtest/testutil"
 	"github.com/cayleygraph/cayley/graph/kv"
-	"github.com/cayleygraph/cayley/graph/shape"
+	"github.com/cayleygraph/cayley/query/shape"
 	"github.com/cayleygraph/quad"
 	hkv "github.com/hidal-go/hidalgo/kv"
 	"github.com/stretchr/testify/require"
diff --git a/graph/memstore/quadstore_test.go b/graph/memstore/quadstore_test.go
index 31e2499..814f73f 100644
--- a/graph/memstore/quadstore_test.go
+++ b/graph/memstore/quadstore_test.go
@@ -23,7 +23,7 @@ import (
 	"github.com/cayleygraph/cayley/graph"
 	"github.com/cayleygraph/cayley/graph/graphtest"
 	"github.com/cayleygraph/cayley/graph/iterator"
-	"github.com/cayleygraph/cayley/graph/shape"
+	"github.com/cayleygraph/cayley/query/shape"
 	"github.com/cayleygraph/cayley/writer"
 	"github.com/cayleygraph/quad"
 	"github.com/stretchr/testify/require"
diff --git a/graph/sql/shape_test.go b/graph/sql/shape_test.go
index b5a08dc..5bc3a63 100644
--- a/graph/sql/shape_test.go
+++ b/graph/sql/shape_test.go
@@ -6,7 +6,7 @@ import (
 
 	"github.com/cayleygraph/cayley/graph"
 	"github.com/cayleygraph/cayley/graph/iterator"
-	"github.com/cayleygraph/cayley/graph/shape"
+	"github.com/cayleygraph/cayley/query/shape"
 	"github.com/cayleygraph/quad"
 	"github.com/stretchr/testify/require"
 )
diff --git a/graph/path/path_test.go b/query/path/path_test.go
similarity index 93%
rename from graph/path/path_test.go
rename to query/path/path_test.go
index 823b886..3c66616 100644
--- a/graph/path/path_test.go
+++ b/query/path/path_test.go
@@ -18,7 +18,7 @@ import (
 	"testing"
 
 	_ "github.com/cayleygraph/cayley/graph/memstore"
-	"github.com/cayleygraph/cayley/graph/path/pathtest"
+	"github.com/cayleygraph/cayley/query/path/pathtest"
 )
 
 func TestMorphisms(t *testing.T) {
diff --git a/graph/path/pathtest/pathtest.go b/query/path/pathtest/pathtest.go
similarity index 99%
rename from graph/path/pathtest/pathtest.go
rename to query/path/pathtest/pathtest.go
index aeaa058..03dcc3d 100644
--- a/graph/path/pathtest/pathtest.go
+++ b/query/path/pathtest/pathtest.go
@@ -22,12 +22,12 @@ import (
 	"testing"
 	"time"
 
-	. "github.com/cayleygraph/cayley/graph/path"
+	. "github.com/cayleygraph/cayley/query/path"
 
 	"github.com/cayleygraph/cayley/graph"
 	"github.com/cayleygraph/cayley/graph/graphtest/testutil"
 	"github.com/cayleygraph/cayley/graph/iterator"
-	"github.com/cayleygraph/cayley/graph/shape"
+	"github.com/cayleygraph/cayley/query/shape"
 	_ "github.com/cayleygraph/cayley/writer"
 	"github.com/cayleygraph/quad"
 	"github.com/stretchr/testify/require"
diff --git a/query/sexp/parser_test.go b/query/sexp/parser_test.go
index 04925c3..b8d7b1e 100644
--- a/query/sexp/parser_test.go
+++ b/query/sexp/parser_test.go
@@ -23,7 +23,7 @@ import (
 
 	"github.com/cayleygraph/cayley/graph/graphtest/testutil"
 	_ "github.com/cayleygraph/cayley/graph/memstore"
-	sh "github.com/cayleygraph/cayley/graph/shape"
+	sh "github.com/cayleygraph/cayley/query/shape"
 	_ "github.com/cayleygraph/cayley/writer"
 	"github.com/stretchr/testify/require"
 )
diff --git a/graph/shape/shape.go b/query/shape/shape.go
similarity index 100%
rename from graph/shape/shape.go
rename to query/shape/shape.go
diff --git a/graph/shape/shape_test.go b/query/shape/shape_test.go
similarity index 99%
rename from graph/shape/shape_test.go
rename to query/shape/shape_test.go
index ce810a8..1920898 100644
--- a/graph/shape/shape_test.go
+++ b/query/shape/shape_test.go
@@ -21,7 +21,7 @@ import (
 
 	"github.com/cayleygraph/cayley/graph"
 	"github.com/cayleygraph/cayley/graph/graphmock"
-	. "github.com/cayleygraph/cayley/graph/shape"
+	. "github.com/cayleygraph/cayley/query/shape"
 	"github.com/cayleygraph/quad"
 	"github.com/stretchr/testify/assert"
 	"github.com/stretchr/testify/require"