Skip to content

Commit b153bcf

Browse files
committed
added support for background indexes, ttl indexes and some more
collection attributes
1 parent cc17088 commit b153bcf

File tree

5 files changed

+349
-46
lines changed

5 files changed

+349
-46
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
Release notes for the ArangoDB-PHP driver 3.5.x
2+
===============================================
3+
4+
The `CollectionHandler` class got a new method `createTtlIndex` for creating time-to-live (TTL)
5+
indexes on the server.
6+
7+
All methods for index creation also got an extra optional attribute `$inBackground` that enables
8+
background index creation.
9+
10+
Added support for the following attributes on collection level:
11+
12+
- distributeShardsLike
13+
- smartJoinAttribute (only effective in ArangoDB enterprise edition)
14+
15+
116
Release notes for the ArangoDB-PHP driver 3.4.x
217
===============================================
318

lib/ArangoDBClient/Collection.php

Lines changed: 102 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ class Collection
6868
* @var bool - isVolatile value
6969
*/
7070
private $_isVolatile;
71+
72+
/**
73+
* The distributeShardsLike value (might be NULL for new collections)
74+
*
75+
* @var mixed - distributeShardsLike value
76+
*/
77+
private $_distributeShardsLike;
7178

7279
/**
7380
* The collection numberOfShards value (might be NULL for new collections)
@@ -96,6 +103,13 @@ class Collection
96103
* @var array - shardKeys value
97104
*/
98105
private $_shardKeys;
106+
107+
/**
108+
* The smartJoinAttribute value (might be NULL for new collections)
109+
*
110+
* @var mixed - smartJoinAttribute value
111+
*/
112+
private $_smartJoinAttribute;
99113

100114
/**
101115
* The collection status value
@@ -155,6 +169,11 @@ class Collection
155169
* Collection 'isVolatile' index
156170
*/
157171
const ENTRY_IS_VOLATILE = 'isVolatile';
172+
173+
/**
174+
* Collection 'distributeShardsLike' index
175+
*/
176+
const ENTRY_DISTRIBUTE_SHARDS_LIKE = 'distributeShardsLike';
158177

159178
/**
160179
* Collection 'numberOfShards' index
@@ -170,11 +189,16 @@ class Collection
170189
* Collection 'shardingStrategy' index
171190
*/
172191
const ENTRY_SHARDING_STRATEGY = 'shardingStrategy';
173-
192+
174193
/**
175194
* Collection 'shardKeys' index
176195
*/
177196
const ENTRY_SHARD_KEYS = 'shardKeys';
197+
198+
/**
199+
* Collection 'smartJoinAttribute' index
200+
*/
201+
const ENTRY_SMART_JOIN_ATTRIBUTE = 'smartJoinAttribute';
178202

179203
/**
180204
* properties option
@@ -271,16 +295,18 @@ public static function getDefaultType()
271295
*/
272296
public function __clone()
273297
{
274-
$this->_id = null;
275-
$this->_name = null;
276-
$this->_waitForSync = null;
277-
$this->_journalSize = null;
278-
$this->_isSystem = null;
279-
$this->_isVolatile = null;
280-
$this->_numberOfShards = null;
281-
$this->_replicationFactor = null;
282-
$this->_shardingStrategy = null;
283-
$this->_shardKeys = null;
298+
$this->_id = null;
299+
$this->_name = null;
300+
$this->_waitForSync = null;
301+
$this->_journalSize = null;
302+
$this->_isSystem = null;
303+
$this->_isVolatile = null;
304+
$this->_distributeShardsLike = null;
305+
$this->_numberOfShards = null;
306+
$this->_replicationFactor = null;
307+
$this->_shardingStrategy = null;
308+
$this->_shardKeys = null;
309+
$this->_smartJoinAttribute = null;
284310
}
285311

286312
/**
@@ -335,6 +361,10 @@ public function getAll()
335361
self::ENTRY_STATUS => $this->_status,
336362
self::ENTRY_KEY_OPTIONS => $this->_keyOptions
337363
];
364+
365+
if (null !== $this->_distributeShardsLike) {
366+
$result[self::ENTRY_DISTRIBUTE_SHARDS_LIKE] = $this->_distributeShardsLike;
367+
}
338368

339369
if (null !== $this->_numberOfShards) {
340370
$result[self::ENTRY_NUMBER_OF_SHARDS] = $this->_numberOfShards;
@@ -347,10 +377,14 @@ public function getAll()
347377
if (null !== $this->_shardingStrategy) {
348378
$result[self::ENTRY_SHARDING_STRATEGY] = $this->_shardingStrategy;
349379
}
350-
380+
351381
if (is_array($this->_shardKeys)) {
352382
$result[self::ENTRY_SHARD_KEYS] = $this->_shardKeys;
353383
}
384+
385+
if (null !== $this->_smartJoinAttribute) {
386+
$result[self::ENTRY_SMART_JOIN_ATTRIBUTE] = $this->_smartJoinAttribute;
387+
}
354388

355389
return $result;
356390
}
@@ -378,79 +412,76 @@ public function set($key, $value)
378412

379413
if ($key === self::ENTRY_ID) {
380414
$this->setId($value);
381-
382415
return;
383416
}
384417

385418
if ($key === self::ENTRY_NAME) {
386419
$this->setName($value);
387-
388420
return;
389421
}
390422

391423
if ($key === self::ENTRY_WAIT_SYNC) {
392424
$this->setWaitForSync($value);
393-
394425
return;
395426
}
396427

397428
if ($key === self::ENTRY_JOURNAL_SIZE) {
398429
$this->setJournalSize($value);
399-
400430
return;
401431
}
402432

403433
if ($key === self::ENTRY_IS_SYSTEM) {
404434
$this->setIsSystem($value);
405-
406435
return;
407436
}
408437

409438
if ($key === self::ENTRY_IS_VOLATILE) {
410439
$this->setIsVolatile($value);
411-
412440
return;
413441
}
414442

415443
if ($key === self::ENTRY_TYPE) {
416444
$this->setType($value);
417-
418445
return;
419446
}
420447

421448
if ($key === self::ENTRY_STATUS) {
422449
$this->setStatus($value);
423-
424450
return;
425451
}
426452

427453
if ($key === self::ENTRY_KEY_OPTIONS) {
428454
$this->setKeyOptions($value);
429-
455+
return;
456+
}
457+
458+
if ($key === self::ENTRY_DISTRIBUTE_SHARDS_LIKE) {
459+
$this->setDistributeShardsLike($value);
430460
return;
431461
}
432462

433463
if ($key === self::ENTRY_NUMBER_OF_SHARDS) {
434464
$this->setNumberOfShards($value);
435-
436465
return;
437466
}
438467

439468
if ($key === self::ENTRY_REPLICATION_FACTOR) {
440469
$this->setReplicationFactor($value);
441-
442470
return;
443471
}
444472

445473
if ($key === self::ENTRY_SHARDING_STRATEGY) {
446474
$this->setShardingStrategy($value);
447-
448475
return;
449476
}
450-
477+
451478
if ($key === self::ENTRY_SHARD_KEYS) {
452479
$this->setShardKeys($value);
453-
480+
return;
481+
}
482+
483+
if ($key === self::ENTRY_SMART_JOIN_ATTRIBUTE) {
484+
$this->setSmartJoinAttribute($value);
454485
return;
455486
}
456487
// unknown attribute, will be ignored
@@ -726,6 +757,28 @@ public function getIsVolatile()
726757
{
727758
return $this->_isVolatile;
728759
}
760+
761+
/**
762+
* Set the distribute shards like value
763+
*
764+
* @param string $value - distributeShardsLike value
765+
*
766+
* @return void
767+
*/
768+
public function setDistributeShardsLike($value)
769+
{
770+
$this->_distributeShardsLike = $value;
771+
}
772+
773+
/**
774+
* Get the distributeShardsLike (if already known)
775+
*
776+
* @return mixed - distributeShardsLike value
777+
*/
778+
public function getDistributeShardsLike()
779+
{
780+
return $this->_distributeShardsLike;
781+
}
729782

730783
/**
731784
* Set the numberOfShards value
@@ -795,7 +848,7 @@ public function getShardingStrategy()
795848
{
796849
return $this->_shardingStrategy;
797850
}
798-
851+
799852
/**
800853
* Set the shardKeys value
801854
*
@@ -818,6 +871,28 @@ public function getShardKeys()
818871
{
819872
return $this->_shardKeys;
820873
}
874+
875+
/**
876+
* Set the smart join attribute value
877+
*
878+
* @param string $value - smartJoinAttribute value
879+
*
880+
* @return void
881+
*/
882+
public function setSmartJoinAttribute($value)
883+
{
884+
$this->_smartJoinAttribute = $value;
885+
}
886+
887+
/**
888+
* Get the smart join attribute value (if already known)
889+
*
890+
* @return mixed - smart join attribute value
891+
*/
892+
public function getSmartJoinAttribute()
893+
{
894+
return $this->_smartJoinAttribute;
895+
}
821896
}
822897

823898
class_alias(Collection::class, '\triagens\ArangoDb\Collection');

0 commit comments

Comments
 (0)