Skip to content

Commit b49911c

Browse files
authored
GT-318 Implement Index API in V2 drivers (#465)
1 parent 98669d7 commit b49911c

19 files changed

+1626
-23
lines changed

v2/README.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,17 @@ Implementation of Driver V2 make use of runtime JSON/VPACK serialization, reduci
44

55
## Features
66

7-
| Implemented | Test Coverage | Description |
8-
|-------------|---------------|-------------------------------------------------------------------------|
9-
||| HTTP JSON & VPACK Connection |
10-
| - | - | HTTP2 JSON & VPACK Connection |
11-
| - | - | VST Connection |
12-
| + | - | Database API Implementation |
13-
| + | - | Collection API Implementation |
14-
||| Collection Document Creation |
15-
| + | - | Collection Document Update |
16-
||| Collection Document Read |
17-
||| Query Execution |
18-
| + | - | Transaction Execution |
19-
| - | - | ArangoDB Operations (Views, Users, Graphs) |
7+
| Implemented | Test Coverage | Description |
8+
|-------------|---------------|--------------------------------------------|
9+
||| HTTP JSON & VPACK Connection |
10+
| - | - | HTTP2 JSON & VPACK Connection |
11+
| - | - | VST Connection |
12+
| + | - | Database API Implementation |
13+
| + | - | Collection API Implementation |
14+
||| Collection Document Creation |
15+
| + | - | Collection Document Update |
16+
||| Collection Document Read |
17+
||| Collection Index |
18+
||| Query Execution |
19+
| + | - | Transaction Execution |
20+
| - | - | ArangoDB Operations (Views, Users, Graphs) |

v2/arangodb/analyzers.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//
2+
// DISCLAIMER
3+
//
4+
// Copyright 2023 ArangoDB GmbH, Cologne, Germany
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
//
20+
// Author Jakub Wierzbowski
21+
//
22+
23+
package arangodb
24+
25+
// AnalyzerFeature specifies a feature to an analyzer
26+
type AnalyzerFeature string
27+
28+
const (
29+
// AnalyzerFeatureFrequency how often a term is seen, required for PHRASE()
30+
AnalyzerFeatureFrequency AnalyzerFeature = "frequency"
31+
32+
// AnalyzerFeatureNorm the field normalization factor
33+
AnalyzerFeatureNorm AnalyzerFeature = "norm"
34+
35+
// AnalyzerFeaturePosition sequentially increasing term position, required for PHRASE(). If present then the frequency feature is also required
36+
AnalyzerFeaturePosition AnalyzerFeature = "position"
37+
38+
// AnalyzerFeatureOffset can be specified if 'position' feature is set
39+
AnalyzerFeatureOffset AnalyzerFeature = "offset"
40+
)

v2/arangodb/collection.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,5 @@ type Collection interface {
3737
Remove(ctx context.Context) error
3838

3939
CollectionDocuments
40+
CollectionIndexes
4041
}

v2/arangodb/collection_documents_create.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ type CollectionDocumentCreate interface {
3838
// A ConflictError is returned when a `_key` field contains a duplicate key, other any other field violates an index constraint.
3939
CreateDocument(ctx context.Context, document interface{}) (CollectionDocumentCreateResponse, error)
4040

41-
// CreateDocument creates a single document in the collection.
41+
// CreateDocumentWithOptions creates a single document in the collection.
4242
// The document data is loaded from the given document, the document meta data is returned.
4343
// If the document data already contains a `_key` field, this will be used as key of the new document,
4444
// otherwise a unique key is created.
@@ -57,7 +57,7 @@ type CollectionDocumentCreate interface {
5757
// If the create request itself fails or one of the arguments is invalid, an error is returned.
5858
CreateDocuments(ctx context.Context, documents interface{}) (CollectionDocumentCreateResponseReader, error)
5959

60-
// CreateDocuments creates multiple documents in the collection.
60+
// CreateDocumentsWithOptions creates multiple documents in the collection.
6161
// The document data is loaded from the given documents slice, the documents meta data is returned.
6262
// If a documents element already contains a `_key` field, this will be used as key of the new document,
6363
// otherwise a unique key is created.

v2/arangodb/collection_documents_impl.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ func (c collectionDocuments) DocumentExists(ctx context.Context, key string) (bo
6666
switch code := resp.Code(); code {
6767
case http.StatusOK:
6868
return true, nil
69+
case http.StatusNotFound:
70+
return false, nil
6971
default:
7072
return false, shared.NewResponseStruct().AsArangoErrorWithCode(code)
7173
}

v2/arangodb/collection_documents_read.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ type CollectionDocumentRead interface {
3434
// If no document exists with given key, a NotFoundError is returned.
3535
ReadDocument(ctx context.Context, key string, result interface{}) (DocumentMeta, error)
3636

37-
// ReadDocument reads a single document with given key from the collection.
37+
// ReadDocumentWithOptions reads a single document with given key from the collection.
3838
// The document data is stored into result, the document meta data is returned.
3939
// If no document exists with given key, a NotFoundError is returned.
4040
ReadDocumentWithOptions(ctx context.Context, key string, result interface{}, opts *CollectionDocumentReadOptions) (DocumentMeta, error)
@@ -45,7 +45,7 @@ type CollectionDocumentRead interface {
4545
// If no document exists with a given key, a NotFoundError is returned at its errors index.
4646
ReadDocuments(ctx context.Context, keys []string) (CollectionDocumentReadResponseReader, error)
4747

48-
// ReadDocuments reads multiple documents with given keys from the collection.
48+
// ReadDocumentsWithOptions reads multiple documents with given keys from the collection.
4949
// The documents data is stored into elements of the given results slice,
5050
// the documents meta data is returned.
5151
// If no document exists with a given key, a NotFoundError is returned at its errors index.

v2/arangodb/collection_documents_update.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ type CollectionDocumentUpdate interface {
3636
// If no document exists with given key, a NotFoundError is returned.
3737
UpdateDocument(ctx context.Context, key string, document interface{}) (CollectionDocumentUpdateResponse, error)
3838

39-
// UpdateDocument updates a single document with given key in the collection.
39+
// UpdateDocumentWithOptions updates a single document with given key in the collection.
4040
// The document meta data is returned.
4141
// If no document exists with given key, a NotFoundError is returned.
4242
UpdateDocumentWithOptions(ctx context.Context, key string, document interface{}, options *CollectionDocumentUpdateOptions) (CollectionDocumentUpdateResponse, error)
@@ -47,7 +47,7 @@ type CollectionDocumentUpdate interface {
4747
// If keys is nil, each element in the updates slice must contain a `_key` field.
4848
UpdateDocuments(ctx context.Context, documents interface{}) (CollectionDocumentUpdateResponseReader, error)
4949

50-
// UpdateDocuments updates multiple document with given keys in the collection.
50+
// UpdateDocumentsWithOptions updates multiple document with given keys in the collection.
5151
// The updates are loaded from the given updates slice, the documents meta data are returned.
5252
// If no document exists with a given key, a NotFoundError is returned at its errors index.
5353
// If keys is nil, each element in the updates slice must contain a `_key` field.

v2/arangodb/collection_impl.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ func newCollection(db *database, name string, modifiers ...connection.RequestMod
3737
d := &collection{db: db, name: name, modifiers: append(db.modifiers, modifiers...)}
3838

3939
d.collectionDocuments = newCollectionDocuments(d)
40+
d.collectionIndexes = newCollectionIndexes(d)
4041

4142
return d
4243
}
@@ -51,6 +52,7 @@ type collection struct {
5152
modifiers []connection.RequestModifier
5253

5354
*collectionDocuments
55+
*collectionIndexes
5456
}
5557

5658
func (c collection) Remove(ctx context.Context) error {

0 commit comments

Comments
 (0)