From 1ac59dc5500d048f64b05bd91a6c380fbd512188 Mon Sep 17 00:00:00 2001 From: Sacha Morard Date: Thu, 23 Mar 2017 11:12:03 +0100 Subject: [PATCH] Cassandra driver v1.3.0 --- .gitignore | 1 + Library/Cassandra.php | 253 ++++++++----- Library/Cassandra/Aggregate.php | 44 ++- Library/Cassandra/BatchStatement.php | 13 +- Library/Cassandra/Bigint.php | 84 ++--- Library/Cassandra/Blob.php | 25 +- Library/Cassandra/Cluster.php | 11 +- Library/Cassandra/Cluster/Builder.php | 143 ++++--- Library/Cassandra/Collection.php | 61 +-- Library/Cassandra/Column.php | 36 +- Library/Cassandra/Custom.php | 33 ++ Library/Cassandra/Date.php | 32 +- Library/Cassandra/Decimal.php | 63 ++-- Library/Cassandra/DefaultAggregate.php | 35 +- Library/Cassandra/DefaultCluster.php | 15 +- Library/Cassandra/DefaultColumn.php | 29 +- Library/Cassandra/DefaultFunction.php | 31 +- Library/Cassandra/DefaultIndex.php | 30 +- Library/Cassandra/DefaultKeyspace.php | 94 ++++- Library/Cassandra/DefaultMaterializedView.php | 219 +++++++++++ Library/Cassandra/DefaultSchema.php | 20 +- Library/Cassandra/DefaultSession.php | 68 ++-- Library/Cassandra/DefaultTable.php | 123 +++--- Library/Cassandra/Duration.php | 24 +- Library/Cassandra/Exception.php | 8 +- .../Exception/AlreadyExistsException.php | 23 +- .../Exception/AuthenticationException.php | 23 +- .../Exception/ConfigurationException.php | 23 +- .../Exception/DivideByZeroException.php | 25 +- .../Cassandra/Exception/DomainException.php | 27 +- .../Exception/ExecutionException.php | 23 +- .../Exception/InvalidArgumentException.php | 27 +- .../Exception/InvalidQueryException.php | 23 +- .../Exception/InvalidSyntaxException.php | 23 +- .../Exception/IsBootstrappingException.php | 23 +- .../Cassandra/Exception/LogicException.php | 27 +- .../Exception/OverloadedException.php | 23 +- .../Cassandra/Exception/ProtocolException.php | 29 +- .../Cassandra/Exception/RangeException.php | 27 +- .../Exception/ReadTimeoutException.php | 23 +- .../Cassandra/Exception/RuntimeException.php | 27 +- .../Cassandra/Exception/ServerException.php | 25 +- .../Cassandra/Exception/TimeoutException.php | 23 +- .../Cassandra/Exception/TruncateException.php | 23 +- .../Exception/UnauthorizedException.php | 23 +- .../Exception/UnavailableException.php | 23 +- .../Exception/UnpreparedException.php | 23 +- .../Exception/ValidationException.php | 35 +- .../Exception/WriteTimeoutException.php | 23 +- Library/Cassandra/ExecutionOptions.php | 39 +- Library/Cassandra/Float.php | 93 +++-- Library/Cassandra/Function.php | 37 +- Library/Cassandra/Future.php | 13 +- Library/Cassandra/FutureClose.php | 17 +- Library/Cassandra/FuturePreparedStatement.php | 19 +- Library/Cassandra/FutureRows.php | 17 +- Library/Cassandra/FutureSession.php | 17 +- Library/Cassandra/FutureValue.php | 15 +- Library/Cassandra/Index.php | 38 +- Library/Cassandra/Inet.php | 23 +- Library/Cassandra/Keyspace.php | 100 ++++- Library/Cassandra/Map.php | 68 ++-- Library/Cassandra/MaterializedView.php | 197 +++++++++- Library/Cassandra/Numeric.php | 42 +-- Library/Cassandra/PreparedStatement.php | 8 +- Library/Cassandra/RetryPolicy.php | 6 +- .../Cassandra/RetryPolicy/DefaultPolicy.php | 9 +- .../RetryPolicy/DowngradingConsistency.php | 9 +- Library/Cassandra/RetryPolicy/Fallthrough.php | 8 +- Library/Cassandra/RetryPolicy/Logging.php | 14 +- Library/Cassandra/Rows.php | 61 +-- Library/Cassandra/SSLOptions.php | 8 +- Library/Cassandra/SSLOptions/Builder.php | 47 +-- Library/Cassandra/Schema.php | 20 +- Library/Cassandra/Session.php | 92 +++-- Library/Cassandra/Set.php | 31 +- Library/Cassandra/SimpleStatement.php | 9 +- Library/Cassandra/Smallint.php | 79 ++-- Library/Cassandra/Statement.php | 6 +- Library/Cassandra/Table.php | 112 +++--- Library/Cassandra/Time.php | 35 +- Library/Cassandra/Timestamp.php | 25 +- Library/Cassandra/TimestampGenerator.php | 6 +- .../TimestampGenerator/Monotonic.php | 8 +- .../TimestampGenerator/ServerSide.php | 11 +- Library/Cassandra/Timeuuid.php | 30 +- Library/Cassandra/Tinyint.php | 79 ++-- Library/Cassandra/Tuple.php | 37 +- Library/Cassandra/Type.php | 350 +++++++++++------- Library/Cassandra/Type/Collection.php | 41 +- Library/Cassandra/Type/Custom.php | 26 +- Library/Cassandra/Type/Map.php | 56 +-- Library/Cassandra/Type/Scalar.php | 34 +- Library/Cassandra/Type/Set.php | 40 +- Library/Cassandra/Type/Tuple.php | 34 +- Library/Cassandra/Type/UserType.php | 55 ++- Library/Cassandra/UserTypeValue.php | 38 +- Library/Cassandra/Uuid.php | 17 +- Library/Cassandra/UuidInterface.php | 7 +- Library/Cassandra/Value.php | 9 +- Library/Cassandra/Varint.php | 50 ++- 101 files changed, 2896 insertions(+), 1435 deletions(-) create mode 100644 .gitignore create mode 100644 Library/Cassandra/Custom.php create mode 100644 Library/Cassandra/DefaultMaterializedView.php diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..723ef36 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea \ No newline at end of file diff --git a/Library/Cassandra.php b/Library/Cassandra.php index b0ea2f7..2cae842 100644 --- a/Library/Cassandra.php +++ b/Library/Cassandra.php @@ -1,7 +1,7 @@ schema() will always return an empty object. This * can be useful for reducing the startup overhead of short-lived sessions. * - * @param bool $enable whether the driver fetches and maintains schema metadata. + * @param bool $enabled whether the driver fetches and maintains schema metadata. * * @return Builder self */ - public function withSchemaMetadata($enable = true) {} + public function withSchemaMetadata($enabled) { } /** * Enables/disables Hostname Resolution. @@ -280,11 +323,11 @@ public function withSchemaMetadata($enable = true) {} * reverse IP lookup. This is useful for authentication (Kerberos) or * encryption SSL services that require a valid hostname for verification. * - * @param bool $enable whether the driver uses hostname resolution. + * @param bool $enabled whether the driver uses hostname resolution. * * @return Builder self */ - public function withHostnameResolution($enable = true) {} + public function withHostnameResolution($enabled) { } /** * Enables/disables Randomized Contact Points. @@ -295,11 +338,11 @@ public function withHostnameResolution($enable = true) {} * * Note: This setting should only be disabled for debugging and testing. * - * @param bool $enable whether the driver uses randomized contact points. + * @param bool $enabled whether the driver uses randomized contact points. * * @return Builder self */ - public function withRandomizedContactPoints($enable = true) {} + public function withRandomizedContactPoints($enabled) { } /** * Specify interval in seconds that the driver should wait before attempting @@ -311,6 +354,6 @@ public function withRandomizedContactPoints($enable = true) {} * * @return Builder self */ - public function withConnectionHeartbeatInterval($interval) {} + public function withConnectionHeartbeatInterval($interval) { } } diff --git a/Library/Cassandra/Collection.php b/Library/Cassandra/Collection.php index 83eeeb9..81a0bb0 100644 --- a/Library/Cassandra/Collection.php +++ b/Library/Cassandra/Collection.php @@ -1,7 +1,7 @@ assertEquals(21, $decimal->scale()); - * $this->assertEquals("1313123123234234234234234234123", $decimal->value()); * ~~~ * * @param string $value Any decimal string */ - public function __construct($value) {} + public function __construct($value) { } /** - * The type of this decimal. + * String representation of this decimal. * - * @return Type + * @return string Decimal value */ - public function type() {} + public function __toString() { } /** - * String representation of this decimal. + * The type of this decimal. * - * @return string Decimal value + * @return Type */ - public function __toString() {} + public function type() { } /** * Numeric value of this decimal as string. * * @return string Numeric value */ - public function value() {} + public function value() { } /** * Scale of this decimal as int. * * @return int Scale */ - public function scale() {} + public function scale() { } /** - * @param Numeric $addend a number to add to this one - * + * @param Numeric $num a number to add to this one * @return Numeric sum */ - public function add(Numeric $addend) {} + public function add($num) { } /** - * @param Numeric $subtrahend a number to subtract from this one - * + * @param Numeric $num a number to subtract from this one * @return Numeric difference */ - public function sub(Numeric $subtrahend) {} + public function sub($num) { } /** - * @param Numeric $multiplier a number to multiply this one by - * + * @param Numeric $num a number to multiply this one by * @return Numeric product */ - public function mul(Numeric $multiplier) {} + public function mul($num) { } /** - * @param Numeric $divisor a number to divide this one by - * + * @param Numeric $num a number to divide this one by * @return Numeric quotient */ - public function div(Numeric $divisor) {} + public function div($num) { } /** - * @param Numeric $divisor a number to divide this one by - * + * @param Numeric $num a number to divide this one by * @return Numeric remainder */ - public function mod(Numeric $divisor) {} + public function mod($num) { } /** * @return Numeric absolute value */ - public function abs() {} + public function abs() { } /** * @return Numeric negative value */ - public function neg() {} + public function neg() { } /** * @return Numeric square root */ - public function sqrt() {} + public function sqrt() { } /** * @return int this number as int */ - public function toInt() {} + public function toInt() { } /** * @return float this number as float */ - public function toDouble() {} + public function toDouble() { } + } diff --git a/Library/Cassandra/DefaultAggregate.php b/Library/Cassandra/DefaultAggregate.php index 6d69fc3..75e2aa0 100644 --- a/Library/Cassandra/DefaultAggregate.php +++ b/Library/Cassandra/DefaultAggregate.php @@ -1,7 +1,7 @@ create(1, 2, 3, 4, 5, 6, 7, 8, 9); * * var_dump($collection); * @endcode - * @param Type $type The type of values - * @return Type The collection type + * + * @param Type $type The type of values + * + * @return Type The collection type */ - final static function collection(Type $type) {} + public static final function collection($type) { } + + /** + * Initialize a set type + * @code{.php} + * create("a", "b", "c", "d", "e", "f", "g", "h", "i", "j"); + * + * var_dump($set); + * @endcode + * + * @param Type $type The types of values + * + * @return Type The set type + */ + public static final function set($type) { } /** * Initialize a map type * @code{.php} * create(1, "a", 2, "b", 3, "c", 4, "d", 5, "e", 6, "f") * * var_dump($map); * @endcode - * @param Type $key_type The type of keys - * @param Type $value_type The type of values - * @return Type The map type + * + * @param Type $keyType The type of keys + * @param Type $valueType The type of values + * + * @return Type The map type */ - final static function map(Type $key_type, Type $value_type) {} + public static final function map($keyType, $valueType) { } /** - * Initialize a set type + * Initialize a tuple type * @code{.php} * create("a", "b", "c", "d", "e", "f", "g", "h", "i", "j"); + * $tuple = Type::tuple(Type::varchar(), Type::int()) + * ->create("a", 123); * - * var_dump($set); + * var_dump($tuple); * @endcode - * @param Type $type [description] - */ - final static function set(Type $type) {} - - /** - * Returns the name of this type as string. - * @return string Name of this type - */ - function name() {} - - /** - * Returns string representation of this type. - * @return string String representation of this type + * + * @param Type $types A variadic list of types + * + * @return Type The tuple type */ - function __toString() {} + public static final function tuple($types) { } /** - * Instantiate a value of this type from provided value(s). + * Initialize a user type + * @code{.php} + * create("a", "abc", "b", 123); * - * @param mixed $value,... one or more values to coerce into this type - * @return mixed a value of this type + * var_dump($userType); + * @endcode + * + * @param Type $types A variadic list of name/type pairs + * + * @return Type The user type */ - function create($value = null) {} + public static final function userType($types) { } + } diff --git a/Library/Cassandra/Type/Collection.php b/Library/Cassandra/Type/Collection.php index 31c345a..4e13965 100644 --- a/Library/Cassandra/Type/Collection.php +++ b/Library/Cassandra/Type/Collection.php @@ -1,7 +1,7 @@ ` - * @return string Type representation in CQL + * Returns type of values + * + * @return Type Type of values */ - public function __toString() {} + public function valueType() { } /** - * Returns type of values - * @return Type Type of values + * Returns type representation in CQL, e.g. `list` + * + * @return string Type representation in CQL */ - public function valueType() {} + public function __toString() { } /** - * Creates a new Cassandra\Collection from the given values. + * Creates a new Collection from the given values. When no values + * given, creates an empty list. + * + * @param mixed $value ,... One or more values to be added to the list. * * @throws Exception\InvalidArgumentException when values given are of a * different type than what this * list type expects. * - * @param mixed $value,... One or more values to be added to the list. - * When no values given, creates an empty list. - * @return Cassandra\Collection A list with given values. + * @return Collection A list with given values. */ - public function create($value = null) {} + public function create($value) { } + } diff --git a/Library/Cassandra/Type/Custom.php b/Library/Cassandra/Type/Custom.php index a2b1206..e208a16 100644 --- a/Library/Cassandra/Type/Custom.php +++ b/Library/Cassandra/Type/Custom.php @@ -1,7 +1,7 @@ ` - * @return string Type representation in CQL - */ - public function __toString() {} + public function name() { } /** * Returns type of keys + * * @return Type Type of keys */ - public function keyType() {} + public function keyType() { } /** * Returns type of values + * * @return Type Type of values */ - public function valueType() {} + public function valueType() { } /** - * Creates a new Cassandra\Map from the given values. + * Returns type representation in CQL, e.g. `map` + * + * @return string Type representation in CQL + */ + public function __toString() { } + + /** + * Creates a new Map from the given values. * * @code{.php} * create(new Uuid(), 'first uuid', @@ -62,15 +70,19 @@ public function valueType() {} * var_dump($map); * @endcode * - * @throws Exception\InvalidArgumentException when keys or values given are - * of a different type than what - * this map type expects. * - * @param mixed $value,... An even number of values, where each odd value * is a key and each even value is a value for the * map, e.g. `create(key, value, key, value)`. * When no values given, creates an empty map. - * @return Cassandra\Map A set with given values. + * + * @param mixed $value ,... An even number of values, where each odd value + * + * @throws Exception\InvalidArgumentException when keys or values given are + * of a different type than what + * this map type expects. + * + * @return Map A set with given values. */ - public function create($value = null) {} + public function create($value) { } + } diff --git a/Library/Cassandra/Type/Scalar.php b/Library/Cassandra/Type/Scalar.php index d741f2c..21e262e 100644 --- a/Library/Cassandra/Type/Scalar.php +++ b/Library/Cassandra/Type/Scalar.php @@ -1,7 +1,7 @@ ` - * @return string Type representation in CQL + * Returns type of values + * + * @return Type Type of values */ - public function __toString() {} + public function valueType() { } /** - * Returns type of values - * @return Type Type of values + * Returns type representation in CQL, e.g. `set` + * + * @return string Type representation in CQL */ - public function valueType() {} + public function __toString() { } /** - * Creates a new Cassandra\Set from the given values. + * Creates a new Set from the given values. + * + * @param mixed $value ,... One or more values to be added to the set. When no values are given, creates an empty set. * * @throws Exception\InvalidArgumentException when values given are of a * different type than what this * set type expects. * - * @param mixed $value,... One or more values to be added to the set. When - * no values are given, creates an empty set. - * @return Cassandra\Set A set with given values. + * @return Set A set with given values. */ - public function create($value = null) {} + public function create($value) { } + } diff --git a/Library/Cassandra/Type/Tuple.php b/Library/Cassandra/Type/Tuple.php index 64d0359..1634653 100644 --- a/Library/Cassandra/Type/Tuple.php +++ b/Library/Cassandra/Type/Tuple.php @@ -1,7 +1,7 @@ ` + * * @return string Type representation in CQL */ - public function __toString() {} + public function __toString() { } /** * Returns types of values + * * @return array An array of types */ - public function types() {} + public function types() { } /** - * Creates a new Cassandra\Tuple from the given values. + * Creates a new Tuple from the given values. When no values given, + * creates a tuple with null for the values. + * + * @param mixed $values {@inheritDoc} * * @throws Exception\InvalidArgumentException when values given are of a * different type than what the * tuple expects. * - * @param mixed $value,... One or more values to be added to the tuple. - * When no values given, creates a tuple with - * null for the values. - * @return Cassandra\Tuple A tuple with given values. + * @return Tuple A tuple with given values. */ - public function create($value = null) {} + public function create($values) { } + } diff --git a/Library/Cassandra/Type/UserType.php b/Library/Cassandra/Type/UserType.php index e861693..731753f 100644 --- a/Library/Cassandra/Type/UserType.php +++ b/Library/Cassandra/Type/UserType.php @@ -1,7 +1,7 @@ `. * * @return string Type representation in CQL */ - public function __toString() {} + public function __toString() { } /** * Returns types of values + * * @return array An array of types */ - public function types() {} + public function types() { } /** - * Creates a new Cassandra\UserTypeValue from the given name/value pairs. + * Creates a new UserTypeValue from the given name/value pairs. When + * no values given, creates an empty user type. + * + * @param mixed $value ,... One or more name/value pairs to be added to the user type. * * @throws Exception\InvalidArgumentException when values given are of a * different types than what the * user type expects. * - * @param mixed $value,... One or more name/value pairs to be added to the user type. - * When no values given, creates an empty user type. - * @return Cassandra\UserTypeValue A user type value with given name/value pairs. + * @return UserTypeValue A user type value with given name/value pairs. */ - public function create($value = null) {} + public function create($value) { } + } diff --git a/Library/Cassandra/UserTypeValue.php b/Library/Cassandra/UserTypeValue.php index b4fcf16..62c2f14 100644 --- a/Library/Cassandra/UserTypeValue.php +++ b/Library/Cassandra/UserTypeValue.php @@ -1,7 +1,7 @@