Skip to content

Commit e985a4b

Browse files
authored
[Feature] Tg 224/disjoint smart graphs (#371)
* add missing fields to collection inventory * test * adjust create collection options to 3.9 * fix deprecated comments * Create collections with only important fields * Improve creating collections in v2
1 parent a948f05 commit e985a4b

File tree

5 files changed

+270
-236
lines changed

5 files changed

+270
-236
lines changed

cluster.go

Lines changed: 49 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -188,42 +188,62 @@ func (i InventoryCollection) IndexByFieldsAndType(fields []string, indexType str
188188

189189
// InventoryCollectionParameters contains all configuration parameters of a collection in a database inventory.
190190
type InventoryCollectionParameters struct {
191-
Deleted bool `json:"deleted,omitempty"`
192-
DoCompact bool `json:"doCompact,omitempty"`
193-
ID string `json:"id,omitempty"`
194-
IndexBuckets int `json:"indexBuckets,omitempty"`
195-
Indexes []InventoryIndex `json:"indexes,omitempty"`
196-
IsSmart bool `json:"isSmart,omitempty"`
197-
SmartGraphAttribute string `json:"smartGraphAttribute,omitempty"`
198-
IsSystem bool `json:"isSystem,omitempty"`
199-
IsVolatile bool `json:"isVolatile,omitempty"`
200-
JournalSize int64 `json:"journalSize,omitempty"`
201-
KeyOptions struct {
202-
Type string `json:"type,omitempty"`
191+
// Available from 3.7 ArangoD version.
192+
CacheEnabled bool `json:"cacheEnabled,omitempty"`
193+
Deleted bool `json:"deleted,omitempty"`
194+
DistributeShardsLike string `json:"distributeShardsLike,omitempty"`
195+
// Deprecated: since 3.7 version. It is related only to MMFiles.
196+
DoCompact bool `json:"doCompact,omitempty"`
197+
// Available from 3.7 ArangoD version.
198+
GloballyUniqueId string `json:"globallyUniqueId,omitempty"`
199+
ID string `json:"id,omitempty"`
200+
// Deprecated: since 3.7 version. It is related only to MMFiles.
201+
IndexBuckets int `json:"indexBuckets,omitempty"`
202+
Indexes []InventoryIndex `json:"indexes,omitempty"`
203+
// Available from 3.9 ArangoD version.
204+
InternalValidatorType int `json:"internalValidatorType,omitempty"`
205+
// Available from 3.7 ArangoD version.
206+
IsDisjoint bool `json:"isDisjoint,omitempty"`
207+
IsSmart bool `json:"isSmart,omitempty"`
208+
// Available from 3.7 ArangoD version.
209+
IsSmartChild bool `json:"isSmartChild,omitempty"`
210+
IsSystem bool `json:"isSystem,omitempty"`
211+
// Deprecated: since 3.7 version. It is related only to MMFiles.
212+
IsVolatile bool `json:"isVolatile,omitempty"`
213+
// Deprecated: since 3.7 version. It is related only to MMFiles.
214+
JournalSize int64 `json:"journalSize,omitempty"`
215+
KeyOptions struct {
203216
AllowUserKeys bool `json:"allowUserKeys,omitempty"`
204217
LastValue int64 `json:"lastValue,omitempty"`
218+
Type string `json:"type,omitempty"`
205219
} `json:"keyOptions"`
206-
Name string `json:"name,omitempty"`
207-
NumberOfShards int `json:"numberOfShards,omitempty"`
220+
// Deprecated: use 'WriteConcern' instead.
221+
MinReplicationFactor int `json:"minReplicationFactor,omitempty"`
222+
Name string `json:"name,omitempty"`
223+
NumberOfShards int `json:"numberOfShards,omitempty"`
224+
// Deprecated: since 3.7 ArangoD version.
208225
Path string `json:"path,omitempty"`
209226
PlanID string `json:"planId,omitempty"`
210227
ReplicationFactor int `json:"replicationFactor,omitempty"`
211-
// Deprecated: use 'WriteConcern' instead
212-
MinReplicationFactor int `json:"minReplicationFactor,omitempty"`
213-
// Available from 3.6 arangod version.
214-
WriteConcern int `json:"writeConcern,omitempty"`
215-
ShardKeys []string `json:"shardKeys,omitempty"`
216-
Shards map[ShardID][]ServerID `json:"shards,omitempty"`
217-
Status CollectionStatus `json:"status,omitempty"`
218-
Type CollectionType `json:"type,omitempty"`
219-
WaitForSync bool `json:"waitForSync,omitempty"`
220-
DistributeShardsLike string `json:"distributeShardsLike,omitempty"`
221-
SmartJoinAttribute string `json:"smartJoinAttribute,omitempty"`
222-
ShardingStrategy ShardingStrategy `json:"shardingStrategy,omitempty"`
223-
// Available from 3.7 arangod version
228+
// Schema for collection validation.
229+
Schema *CollectionSchemaOptions `json:"schema,omitempty"`
230+
ShadowCollections []int `json:"shadowCollections,omitempty"`
231+
ShardingStrategy ShardingStrategy `json:"shardingStrategy,omitempty"`
232+
ShardKeys []string `json:"shardKeys,omitempty"`
233+
Shards map[ShardID][]ServerID `json:"shards,omitempty"`
234+
// Optional only for some collections.
235+
SmartGraphAttribute string `json:"smartGraphAttribute,omitempty"`
236+
// Optional only for some collections.
237+
SmartJoinAttribute string `json:"smartJoinAttribute,omitempty"`
238+
Status CollectionStatus `json:"status,omitempty"`
239+
// Available from 3.7 ArangoD version.
240+
SyncByRevision bool `json:"syncByRevision,omitempty"`
241+
Type CollectionType `json:"type,omitempty"`
242+
// Available from 3.7 ArangoD version.
224243
UsesRevisionsAsDocumentIds bool `json:"usesRevisionsAsDocumentIds,omitempty"`
225-
// Available from 3.7 arangod version
226-
SyncByRevision bool `json:"syncByRevision,omitempty"`
244+
WaitForSync bool `json:"waitForSync,omitempty"`
245+
// Available from 3.6 ArangoD version.
246+
WriteConcern int `json:"writeConcern,omitempty"`
227247
}
228248

229249
// IsSatellite returns true if the collection is a satellite collection

cluster_impl.go

Lines changed: 78 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -266,74 +266,98 @@ func (c *cluster) RemoveServer(ctx context.Context, serverID ServerID) error {
266266
type replicationFactor int
267267

268268
type inventoryCollectionParametersInternal struct {
269-
Deleted bool `json:"deleted,omitempty"`
270-
DoCompact bool `json:"doCompact,omitempty"`
271-
ID string `json:"id,omitempty"`
272-
IndexBuckets int `json:"indexBuckets,omitempty"`
273-
Indexes []InventoryIndex `json:"indexes,omitempty"`
274-
IsSmart bool `json:"isSmart,omitempty"`
275-
SmartGraphAttribute string `json:"smartGraphAttribute,omitempty"`
276-
IsSystem bool `json:"isSystem,omitempty"`
277-
IsVolatile bool `json:"isVolatile,omitempty"`
278-
JournalSize int64 `json:"journalSize,omitempty"`
279-
KeyOptions struct {
280-
Type string `json:"type,omitempty"`
269+
// Available from 3.7 ArangoD version.
270+
CacheEnabled bool `json:"cacheEnabled,omitempty"`
271+
Deleted bool `json:"deleted,omitempty"`
272+
DistributeShardsLike string `json:"distributeShardsLike,omitempty"`
273+
DoCompact bool `json:"doCompact,omitempty"`
274+
// Available from 3.7 ArangoD version.
275+
GloballyUniqueId string `json:"globallyUniqueId,omitempty"`
276+
ID string `json:"id,omitempty"`
277+
IndexBuckets int `json:"indexBuckets,omitempty"`
278+
Indexes []InventoryIndex `json:"indexes,omitempty"`
279+
// Available from 3.9 ArangoD version.
280+
InternalValidatorType int `json:"internalValidatorType,omitempty"`
281+
// Available from 3.7 ArangoD version.
282+
IsDisjoint bool `json:"isDisjoint,omitempty"`
283+
IsSmart bool `json:"isSmart,omitempty"`
284+
// Available from 3.7 ArangoD version.
285+
IsSmartChild bool `json:"isSmartChild,omitempty"`
286+
IsSystem bool `json:"isSystem,omitempty"`
287+
// Deprecated: since 3.7 version. It is related only to MMFiles.
288+
IsVolatile bool `json:"isVolatile,omitempty"`
289+
// Deprecated: since 3.7 version. It is related only to MMFiles.
290+
JournalSize int64 `json:"journalSize,omitempty"`
291+
KeyOptions struct {
281292
AllowUserKeys bool `json:"allowUserKeys,omitempty"`
282293
LastValue int64 `json:"lastValue,omitempty"`
294+
Type string `json:"type,omitempty"`
283295
} `json:"keyOptions"`
284-
Name string `json:"name,omitempty"`
285-
NumberOfShards int `json:"numberOfShards,omitempty"`
286-
Path string `json:"path,omitempty"`
287-
PlanID string `json:"planId,omitempty"`
288-
ReplicationFactor replicationFactor `json:"replicationFactor,omitempty"`
289296
// Deprecated: use 'WriteConcern' instead
290-
MinReplicationFactor int `json:"minReplicationFactor,omitempty"`
291-
// Available from 3.6 arangod version.
292-
WriteConcern int `json:"writeConcern,omitempty"`
293-
ShardKeys []string `json:"shardKeys,omitempty"`
294-
Shards map[ShardID][]ServerID `json:"shards,omitempty"`
295-
Status CollectionStatus `json:"status,omitempty"`
296-
Type CollectionType `json:"type,omitempty"`
297-
WaitForSync bool `json:"waitForSync,omitempty"`
298-
DistributeShardsLike string `json:"distributeShardsLike,omitempty"`
299-
SmartJoinAttribute string `json:"smartJoinAttribute,omitempty"`
300-
ShardingStrategy ShardingStrategy `json:"shardingStrategy,omitempty"`
301-
// Available from 3.7 arangod version
297+
MinReplicationFactor int `json:"minReplicationFactor,omitempty"`
298+
Name string `json:"name,omitempty"`
299+
NumberOfShards int `json:"numberOfShards,omitempty"`
300+
Path string `json:"path,omitempty"`
301+
PlanID string `json:"planId,omitempty"`
302+
ReplicationFactor replicationFactor `json:"replicationFactor,omitempty"`
303+
// Schema for collection validation
304+
Schema *CollectionSchemaOptions `json:"schema,omitempty"`
305+
ShadowCollections []int `json:"shadowCollections,omitempty"`
306+
ShardingStrategy ShardingStrategy `json:"shardingStrategy,omitempty"`
307+
ShardKeys []string `json:"shardKeys,omitempty"`
308+
Shards map[ShardID][]ServerID `json:"shards,omitempty"`
309+
// Optional only for some collections.
310+
SmartGraphAttribute string `json:"smartGraphAttribute,omitempty"`
311+
// Optional only for some collections.
312+
SmartJoinAttribute string `json:"smartJoinAttribute,omitempty"`
313+
Status CollectionStatus `json:"status,omitempty"`
314+
// Available from 3.7 ArangoD version
315+
SyncByRevision bool `json:"syncByRevision,omitempty"`
316+
Type CollectionType `json:"type,omitempty"`
317+
// Available from 3.7 ArangoD version
302318
UsesRevisionsAsDocumentIds bool `json:"usesRevisionsAsDocumentIds,omitempty"`
303-
// Available from 3.7 arangod version
304-
SyncByRevision bool `json:"syncByRevision,omitempty"`
319+
WaitForSync bool `json:"waitForSync,omitempty"`
320+
// Available from 3.6 ArangoD version.
321+
WriteConcern int `json:"writeConcern,omitempty"`
305322
}
306323

307324
func (p *InventoryCollectionParameters) asInternal() inventoryCollectionParametersInternal {
308325
return inventoryCollectionParametersInternal{
326+
CacheEnabled: p.CacheEnabled,
309327
Deleted: p.Deleted,
328+
DistributeShardsLike: p.DistributeShardsLike,
310329
DoCompact: p.DoCompact,
330+
GloballyUniqueId: p.GloballyUniqueId,
311331
ID: p.ID,
312332
IndexBuckets: p.IndexBuckets,
313333
Indexes: p.Indexes,
334+
InternalValidatorType: p.InternalValidatorType,
335+
IsDisjoint: p.IsDisjoint,
314336
IsSmart: p.IsSmart,
315-
SmartGraphAttribute: p.SmartGraphAttribute,
337+
IsSmartChild: p.IsSmartChild,
316338
IsSystem: p.IsSystem,
317339
IsVolatile: p.IsVolatile,
318340
JournalSize: p.JournalSize,
319341
KeyOptions: p.KeyOptions,
342+
MinReplicationFactor: p.MinReplicationFactor,
320343
Name: p.Name,
321344
NumberOfShards: p.NumberOfShards,
322345
Path: p.Path,
323346
PlanID: p.PlanID,
324347
ReplicationFactor: replicationFactor(p.ReplicationFactor),
325-
MinReplicationFactor: p.MinReplicationFactor,
326-
WriteConcern: p.WriteConcern,
348+
Schema: p.Schema,
349+
ShadowCollections: p.ShadowCollections,
350+
ShardingStrategy: p.ShardingStrategy,
327351
ShardKeys: p.ShardKeys,
328352
Shards: p.Shards,
353+
SmartGraphAttribute: p.SmartGraphAttribute,
354+
SmartJoinAttribute: p.SmartJoinAttribute,
329355
Status: p.Status,
356+
SyncByRevision: p.SyncByRevision,
330357
Type: p.Type,
331-
WaitForSync: p.WaitForSync,
332-
DistributeShardsLike: p.DistributeShardsLike,
333-
SmartJoinAttribute: p.SmartJoinAttribute,
334-
ShardingStrategy: p.ShardingStrategy,
335358
UsesRevisionsAsDocumentIds: p.UsesRevisionsAsDocumentIds,
336-
SyncByRevision: p.SyncByRevision,
359+
WaitForSync: p.WaitForSync,
360+
WriteConcern: p.WriteConcern,
337361
}
338362
}
339363

@@ -343,34 +367,41 @@ func (p *InventoryCollectionParameters) fromInternal(i inventoryCollectionParame
343367

344368
func (p *inventoryCollectionParametersInternal) asExternal() InventoryCollectionParameters {
345369
return InventoryCollectionParameters{
370+
CacheEnabled: p.CacheEnabled,
346371
Deleted: p.Deleted,
372+
DistributeShardsLike: p.DistributeShardsLike,
347373
DoCompact: p.DoCompact,
374+
GloballyUniqueId: p.GloballyUniqueId,
348375
ID: p.ID,
349376
IndexBuckets: p.IndexBuckets,
350377
Indexes: p.Indexes,
378+
InternalValidatorType: p.InternalValidatorType,
379+
IsDisjoint: p.IsDisjoint,
351380
IsSmart: p.IsSmart,
352-
SmartGraphAttribute: p.SmartGraphAttribute,
381+
IsSmartChild: p.IsSmartChild,
353382
IsSystem: p.IsSystem,
354383
IsVolatile: p.IsVolatile,
355384
JournalSize: p.JournalSize,
356385
KeyOptions: p.KeyOptions,
386+
MinReplicationFactor: p.MinReplicationFactor,
357387
Name: p.Name,
358388
NumberOfShards: p.NumberOfShards,
359389
Path: p.Path,
360390
PlanID: p.PlanID,
361391
ReplicationFactor: int(p.ReplicationFactor),
362-
MinReplicationFactor: p.MinReplicationFactor,
363-
WriteConcern: p.WriteConcern,
392+
Schema: p.Schema,
393+
ShadowCollections: p.ShadowCollections,
394+
ShardingStrategy: p.ShardingStrategy,
364395
ShardKeys: p.ShardKeys,
365396
Shards: p.Shards,
397+
SmartGraphAttribute: p.SmartGraphAttribute,
398+
SmartJoinAttribute: p.SmartJoinAttribute,
366399
Status: p.Status,
400+
SyncByRevision: p.SyncByRevision,
367401
Type: p.Type,
368-
WaitForSync: p.WaitForSync,
369-
DistributeShardsLike: p.DistributeShardsLike,
370-
SmartJoinAttribute: p.SmartJoinAttribute,
371-
ShardingStrategy: p.ShardingStrategy,
372402
UsesRevisionsAsDocumentIds: p.UsesRevisionsAsDocumentIds,
373-
SyncByRevision: p.SyncByRevision,
403+
WaitForSync: p.WaitForSync,
404+
WriteConcern: p.WriteConcern,
374405
}
375406
}
376407

0 commit comments

Comments
 (0)