You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by is...@apache.org on 2021/03/15 08:26:01 UTC
[ignite] branch master updated: IGNITE-13767: Removed PHP,
Node.js and Python from main repo
This is an automated email from the ASF dual-hosted git repository.
isapego pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push:
new 61bb218 IGNITE-13767: Removed PHP, Node.js and Python from main repo
61bb218 is described below
commit 61bb218e012391c6d077ae5f39da111cd3f61aa8
Author: Igor Sapego <is...@apache.org>
AuthorDate: Mon Mar 15 11:24:25 2021 +0300
IGNITE-13767: Removed PHP, Node.js and Python from main repo
This closes #8512
---
README.txt | 3 -
assembly/release-apache-ignite-base.xml | 76 -
docs/_docs/quick-start/nodejs.adoc | 6 +-
docs/_docs/quick-start/php.adoc | 17 +-
docs/_docs/quick-start/python.adoc | 2 +-
docs/_docs/thin-clients/nodejs-thin-client.adoc | 4 +-
docs/_docs/thin-clients/php-thin-client.adoc | 14 +-
docs/_docs/thin-clients/python-thin-client.adoc | 8 +-
modules/platforms/nodejs/README.md | 32 -
modules/platforms/nodejs/api_spec/conf.json | 12 -
.../platforms/nodejs/examples/AuthTlsExample.js | 128 -
.../nodejs/examples/CachePutGetExample.js | 186 --
.../platforms/nodejs/examples/FailoverExample.js | 59 -
modules/platforms/nodejs/examples/SqlExample.js | 242 --
.../nodejs/examples/SqlQueryEntriesExample.js | 136 --
modules/platforms/nodejs/examples/certs/ca.crt | 32 -
modules/platforms/nodejs/examples/certs/client.crt | 30 -
modules/platforms/nodejs/examples/certs/client.key | 51 -
.../platforms/nodejs/examples/certs/keystore.jks | Bin 3828 -> 0 bytes
.../platforms/nodejs/examples/certs/truststore.jks | Bin 1477 -> 0 bytes
modules/platforms/nodejs/index.js | 43 -
modules/platforms/nodejs/lib/BinaryObject.js | 530 -----
modules/platforms/nodejs/lib/CacheClient.js | 759 ------
modules/platforms/nodejs/lib/CacheConfiguration.js | 1734 --------------
modules/platforms/nodejs/lib/Cursor.js | 307 ---
modules/platforms/nodejs/lib/EnumItem.js | 212 --
modules/platforms/nodejs/lib/Errors.js | 133 --
modules/platforms/nodejs/lib/IgniteClient.js | 290 ---
.../nodejs/lib/IgniteClientConfiguration.js | 112 -
modules/platforms/nodejs/lib/ObjectType.js | 600 -----
modules/platforms/nodejs/lib/Query.js | 508 ----
modules/platforms/nodejs/lib/Timestamp.js | 76 -
.../nodejs/lib/internal/ArgumentChecker.js | 83 -
.../nodejs/lib/internal/BinaryCommunicator.js | 409 ----
.../platforms/nodejs/lib/internal/BinaryType.js | 483 ----
.../nodejs/lib/internal/BinaryTypeStorage.js | 112 -
.../platforms/nodejs/lib/internal/BinaryUtils.js | 602 -----
.../nodejs/lib/internal/ClientFailoverSocket.js | 134 --
.../platforms/nodejs/lib/internal/ClientSocket.js | 454 ----
modules/platforms/nodejs/lib/internal/Logger.js | 45 -
.../platforms/nodejs/lib/internal/MessageBuffer.js | 293 ---
modules/platforms/nodejs/package.json | 40 -
modules/platforms/nodejs/spec/ExamplesExecutor.js | 28 -
modules/platforms/nodejs/spec/TestingHelper.js | 391 ---
.../nodejs/spec/cache/BinaryObject.spec.js | 176 --
modules/platforms/nodejs/spec/cache/Cache.spec.js | 262 ---
.../nodejs/spec/cache/CacheKeyValueOps.spec.js | 1022 --------
.../nodejs/spec/cache/CachePutGetDiffTypes.spec.js | 686 ------
.../nodejs/spec/cache/ComplexObject.spec.js | 540 -----
modules/platforms/nodejs/spec/cache/UUID.spec.js | 105 -
modules/platforms/nodejs/spec/config.js | 27 -
.../nodejs/spec/examples/AuthExample.spec.js | 33 -
.../nodejs/spec/examples/Examples.spec.js | 45 -
.../platforms/nodejs/spec/query/ScanQuery.spec.js | 207 --
.../nodejs/spec/query/SqlFieldsQuery.spec.js | 266 ---
.../platforms/nodejs/spec/query/SqlQuery.spec.js | 247 --
modules/platforms/nodejs/spec/support/jasmine.json | 11 -
modules/platforms/php/.gitignore | 2 -
modules/platforms/php/README.md | 37 -
modules/platforms/php/api_docs/Doxyfile | 2487 --------------------
modules/platforms/php/composer.json | 27 -
modules/platforms/php/examples/AuthTlsExample.php | 129 -
.../platforms/php/examples/CachePutGetExample.php | 184 --
modules/platforms/php/examples/FailoverExample.php | 67 -
modules/platforms/php/examples/SqlExample.php | 237 --
.../php/examples/SqlQueryEntriesExample.php | 127 -
modules/platforms/php/examples/certs/ca.pem | 32 -
modules/platforms/php/examples/certs/client.pem | 81 -
modules/platforms/php/examples/certs/keystore.jks | Bin 3828 -> 0 bytes
.../platforms/php/examples/certs/truststore.jks | Bin 1477 -> 0 bytes
.../src/Apache/Ignite/Cache/CacheConfiguration.php | 1011 --------
.../php/src/Apache/Ignite/Cache/CacheEntry.php | 60 -
.../php/src/Apache/Ignite/Cache/CacheInterface.php | 379 ---
.../Apache/Ignite/Cache/CacheKeyConfiguration.php | 107 -
.../php/src/Apache/Ignite/Cache/QueryEntity.php | 315 ---
.../php/src/Apache/Ignite/Cache/QueryField.php | 279 ---
.../php/src/Apache/Ignite/Cache/QueryIndex.php | 191 --
modules/platforms/php/src/Apache/Ignite/Client.php | 243 --
.../php/src/Apache/Ignite/ClientConfiguration.php | 294 ---
.../php/src/Apache/Ignite/Data/BinaryObject.php | 469 ----
.../platforms/php/src/Apache/Ignite/Data/Date.php | 83 -
.../php/src/Apache/Ignite/Data/EnumItem.php | 155 --
.../platforms/php/src/Apache/Ignite/Data/Time.php | 58 -
.../php/src/Apache/Ignite/Data/Timestamp.php | 66 -
.../Apache/Ignite/Exception/ClientException.php | 35 -
.../Ignite/Exception/NoConnectionException.php | 35 -
.../Apache/Ignite/Exception/OperationException.php | 35 -
.../Exception/OperationStatusUnknownException.php | 35 -
.../Ignite/Internal/Binary/BinaryCommunicator.php | 493 ----
.../Apache/Ignite/Internal/Binary/BinaryField.php | 78 -
.../Ignite/Internal/Binary/BinaryObjectField.php | 113 -
.../Apache/Ignite/Internal/Binary/BinarySchema.php | 145 --
.../Apache/Ignite/Internal/Binary/BinaryType.php | 233 --
.../Ignite/Internal/Binary/BinaryTypeBuilder.php | 207 --
.../Ignite/Internal/Binary/BinaryTypeStorage.php | 123 -
.../Apache/Ignite/Internal/Binary/BinaryUtils.php | 450 ----
.../Ignite/Internal/Binary/ClientOperation.php | 64 -
.../Ignite/Internal/Binary/MessageBuffer.php | 307 ---
.../src/Apache/Ignite/Internal/Binary/Request.php | 85 -
.../src/Apache/Ignite/Internal/Binary/TypeInfo.php | 312 ---
.../php/src/Apache/Ignite/Internal/Cache.php | 387 ---
.../Internal/Connection/ClientFailoverSocket.php | 134 --
.../Ignite/Internal/Connection/ClientSocket.php | 247 --
.../Ignite/Internal/Connection/ProtocolVersion.php | 82 -
.../src/Apache/Ignite/Internal/Query/Cursor.php | 166 --
.../Ignite/Internal/Query/SqlFieldsCursor.php | 75 -
.../Ignite/Internal/Utils/ArgumentChecker.php | 87 -
.../src/Apache/Ignite/Internal/Utils/Logger.php | 62 -
.../src/Apache/Ignite/Query/CursorInterface.php | 56 -
.../php/src/Apache/Ignite/Query/Query.php | 70 -
.../php/src/Apache/Ignite/Query/ScanQuery.php | 88 -
.../Ignite/Query/SqlFieldsCursorInterface.php | 82 -
.../php/src/Apache/Ignite/Query/SqlFieldsQuery.php | 206 --
.../php/src/Apache/Ignite/Query/SqlQuery.php | 225 --
.../Apache/Ignite/Type/CollectionObjectType.php | 142 --
.../src/Apache/Ignite/Type/ComplexObjectType.php | 165 --
.../php/src/Apache/Ignite/Type/MapObjectType.php | 123 -
.../php/src/Apache/Ignite/Type/ObjectArrayType.php | 68 -
.../php/src/Apache/Ignite/Type/ObjectType.php | 442 ----
modules/platforms/php/tests/BinaryObjectTest.php | 196 --
.../platforms/php/tests/CacheKeyValueOpsTest.php | 763 ------
modules/platforms/php/tests/CachePutGetTest.php | 765 ------
modules/platforms/php/tests/CacheTest.php | 240 --
modules/platforms/php/tests/ComplexObjectTest.php | 428 ----
modules/platforms/php/tests/ScanQueryTest.php | 167 --
modules/platforms/php/tests/SqlFieldsQueryTest.php | 224 --
modules/platforms/php/tests/SqlQueryTest.php | 204 --
modules/platforms/php/tests/TestConfig.php | 37 -
modules/platforms/php/tests/TestingHelper.php | 363 ---
.../php/tests/examples/ExecuteAuthTlsExample.php | 36 -
.../php/tests/examples/ExecuteExamples.php | 61 -
modules/platforms/python/LICENSE | 202 --
modules/platforms/python/README.md | 75 -
modules/platforms/python/docs/Makefile | 20 -
modules/platforms/python/docs/conf.py | 176 --
.../python/docs/datatypes/cache_props.rst | 163 --
.../platforms/python/docs/datatypes/parsers.rst | 175 --
modules/platforms/python/docs/examples.rst | 624 -----
modules/platforms/python/docs/index.rst | 33 -
modules/platforms/python/docs/modules.rst | 31 -
modules/platforms/python/docs/readme.rst | 202 --
modules/platforms/python/docs/source/modules.rst | 7 -
.../python/docs/source/pyignite.api.binary.rst | 7 -
.../docs/source/pyignite.api.cache_config.rst | 7 -
.../python/docs/source/pyignite.api.key_value.rst | 7 -
.../python/docs/source/pyignite.api.result.rst | 7 -
.../platforms/python/docs/source/pyignite.api.rst | 19 -
.../python/docs/source/pyignite.api.sql.rst | 7 -
.../python/docs/source/pyignite.binary.rst | 7 -
.../python/docs/source/pyignite.cache.rst | 7 -
.../python/docs/source/pyignite.client.rst | 7 -
.../docs/source/pyignite.connection.generators.rst | 7 -
.../docs/source/pyignite.connection.handshake.rst | 7 -
.../python/docs/source/pyignite.connection.rst | 17 -
.../python/docs/source/pyignite.connection.ssl.rst | 7 -
.../python/docs/source/pyignite.constants.rst | 7 -
.../python/docs/source/pyignite.datatypes.base.rst | 7 -
.../docs/source/pyignite.datatypes.binary.rst | 7 -
.../source/pyignite.datatypes.cache_config.rst | 7 -
.../source/pyignite.datatypes.cache_properties.rst | 7 -
.../docs/source/pyignite.datatypes.complex.rst | 7 -
.../docs/source/pyignite.datatypes.internal.rst | 7 -
.../docs/source/pyignite.datatypes.key_value.rst | 7 -
.../docs/source/pyignite.datatypes.null_object.rst | 7 -
.../docs/source/pyignite.datatypes.primitive.rst | 7 -
.../source/pyignite.datatypes.primitive_arrays.rst | 7 -
.../pyignite.datatypes.primitive_objects.rst | 7 -
.../docs/source/pyignite.datatypes.prop_codes.rst | 7 -
.../python/docs/source/pyignite.datatypes.rst | 29 -
.../python/docs/source/pyignite.datatypes.sql.rst | 7 -
.../docs/source/pyignite.datatypes.standard.rst | 7 -
.../docs/source/pyignite.datatypes.type_codes.rst | 7 -
.../python/docs/source/pyignite.exceptions.rst | 7 -
.../docs/source/pyignite.queries.op_codes.rst | 7 -
.../python/docs/source/pyignite.queries.rst | 15 -
modules/platforms/python/docs/source/pyignite.rst | 30 -
.../python/docs/source/pyignite.utils.rst | 7 -
modules/platforms/python/examples/binary_basics.py | 53 -
modules/platforms/python/examples/create_binary.py | 103 -
modules/platforms/python/examples/failover.py | 61 -
modules/platforms/python/examples/get_and_put.py | 41 -
.../platforms/python/examples/migrate_binary.py | 190 --
modules/platforms/python/examples/read_binary.py | 275 ---
modules/platforms/python/examples/readme.md | 17 -
modules/platforms/python/examples/scans.py | 55 -
modules/platforms/python/examples/sql.py | 298 ---
modules/platforms/python/examples/type_hints.py | 51 -
modules/platforms/python/pyignite/__init__.py | 17 -
modules/platforms/python/pyignite/api/__init__.py | 71 -
modules/platforms/python/pyignite/api/binary.py | 209 --
.../platforms/python/pyignite/api/cache_config.py | 279 ---
modules/platforms/python/pyignite/api/key_value.py | 995 --------
modules/platforms/python/pyignite/api/result.py | 38 -
modules/platforms/python/pyignite/api/sql.py | 475 ----
modules/platforms/python/pyignite/binary.py | 136 --
modules/platforms/python/pyignite/cache.py | 595 -----
modules/platforms/python/pyignite/client.py | 406 ----
.../python/pyignite/connection/__init__.py | 333 ---
.../python/pyignite/connection/generators.py | 48 -
.../python/pyignite/connection/handshake.py | 91 -
.../platforms/python/pyignite/connection/ssl.py | 49 -
modules/platforms/python/pyignite/constants.py | 52 -
.../python/pyignite/datatypes/__init__.py | 27 -
.../platforms/python/pyignite/datatypes/base.py | 24 -
.../platforms/python/pyignite/datatypes/binary.py | 45 -
.../python/pyignite/datatypes/cache_config.py | 153 --
.../python/pyignite/datatypes/cache_properties.py | 287 ---
.../platforms/python/pyignite/datatypes/complex.py | 526 -----
.../python/pyignite/datatypes/internal.py | 472 ----
.../python/pyignite/datatypes/key_value.py | 24 -
.../python/pyignite/datatypes/null_object.py | 64 -
.../python/pyignite/datatypes/primitive.py | 106 -
.../python/pyignite/datatypes/primitive_arrays.py | 208 --
.../python/pyignite/datatypes/primitive_objects.py | 158 --
.../python/pyignite/datatypes/prop_codes.py | 51 -
modules/platforms/python/pyignite/datatypes/sql.py | 23 -
.../python/pyignite/datatypes/standard.py | 739 ------
.../python/pyignite/datatypes/type_codes.py | 57 -
modules/platforms/python/pyignite/exceptions.py | 80 -
.../platforms/python/pyignite/queries/__init__.py | 339 ---
.../platforms/python/pyignite/queries/op_codes.py | 65 -
modules/platforms/python/pyignite/utils.py | 172 --
modules/platforms/python/requirements/docs.txt | 6 -
modules/platforms/python/requirements/install.txt | 4 -
modules/platforms/python/requirements/setup.txt | 3 -
modules/platforms/python/requirements/tests.txt | 5 -
modules/platforms/python/setup.py | 104 -
modules/platforms/python/tests/config/ssl.xml | 58 -
.../platforms/python/tests/config/ssl/README.txt | 3 -
.../python/tests/config/ssl/client_full.pem | 52 -
.../tests/config/ssl/client_with_pass_full.pem | 54 -
.../platforms/python/tests/config/ssl/server.jks | Bin 2380 -> 0 bytes
.../platforms/python/tests/config/ssl/trust.jks | Bin 1346 -> 0 bytes
modules/platforms/python/tests/conftest.py | 227 --
modules/platforms/python/tests/test_binary.py | 280 ---
modules/platforms/python/tests/test_cache_class.py | 221 --
.../platforms/python/tests/test_cache_class_sql.py | 103 -
.../platforms/python/tests/test_cache_config.py | 75 -
modules/platforms/python/tests/test_datatypes.py | 176 --
modules/platforms/python/tests/test_examples.py | 57 -
.../platforms/python/tests/test_generic_object.py | 33 -
modules/platforms/python/tests/test_get_names.py | 30 -
modules/platforms/python/tests/test_handshake.py | 64 -
modules/platforms/python/tests/test_key_value.py | 400 ----
modules/platforms/python/tests/test_scan.py | 66 -
modules/platforms/python/tests/test_sql.py | 184 --
parent/pom.xml | 9 -
247 files changed, 28 insertions(+), 42076 deletions(-)
diff --git a/README.txt b/README.txt
index c7a2cdf..de1385a 100644
--- a/README.txt
+++ b/README.txt
@@ -52,9 +52,6 @@ for Transparent Data Encryption of data on disk
and for AWS S3 Client Side Encryprion.
(https://java.sun.com/javase/technologies/security/)
-* Python client uses Python's SSL lib (https://docs.python.org/3/library/ssl.html) which is a wrapper over OpenSSL;
-* NodeJS client uses NodeJS's TLS module (https://nodejs.org/api/tls.html) which is a wrapper over OpenSSL;
-* PHP client uses PHP OpenSSL extension (https://www.php.net/manual/en/book.openssl.php);
* C++ thin client and ODBC use OpenSSL to establish secure connection with the cluster.
The OpenSSL Project (https://www.openssl.org/)
diff --git a/assembly/release-apache-ignite-base.xml b/assembly/release-apache-ignite-base.xml
index 834d782..27294b5 100644
--- a/assembly/release-apache-ignite-base.xml
+++ b/assembly/release-apache-ignite-base.xml
@@ -41,44 +41,6 @@
<destName>CMakeLists.txt</destName>
</file>
- <!-- Copy Node.js files. -->
- <file>
- <source>modules/platforms/nodejs/index.js</source>
- <outputDirectory>/platforms/nodejs</outputDirectory>
- </file>
-
- <file>
- <source>modules/platforms/nodejs/package.json</source>
- <outputDirectory>/platforms/nodejs</outputDirectory>
- </file>
-
- <file>
- <source>modules/platforms/nodejs/README.md</source>
- <outputDirectory>/platforms/nodejs</outputDirectory>
- </file>
-
- <!-- Copy PHP files. -->
- <file>
- <source>modules/platforms/php/composer.json</source>
- <outputDirectory>/platforms/php</outputDirectory>
- </file>
-
- <!-- Copy Python files. -->
- <file>
- <source>modules/platforms/python/LICENSE</source>
- <outputDirectory>/platforms/python</outputDirectory>
- </file>
-
- <file>
- <source>modules/platforms/python/README.md</source>
- <outputDirectory>/platforms/python</outputDirectory>
- </file>
-
- <file>
- <source>modules/platforms/python/setup.py</source>
- <outputDirectory>/platforms/python</outputDirectory>
- </file>
-
<!-- Other files. -->
<file>
<source>assembly/LICENSE_IGNITE</source>
@@ -224,44 +186,6 @@
<outputDirectory>/platforms/cpp/bin</outputDirectory>
</fileSet>
- <!-- Copy Node.js binaries. -->
- <fileSet>
- <directory>modules/platforms/nodejs/lib</directory>
- <outputDirectory>/platforms/nodejs/lib</outputDirectory>
- </fileSet>
-
- <fileSet>
- <directory>modules/platforms/nodejs/examples</directory>
- <outputDirectory>/platforms/nodejs/examples</outputDirectory>
- </fileSet>
-
- <!-- Copy PHP sources. -->
- <fileSet>
- <directory>modules/platforms/php/src</directory>
- <outputDirectory>/platforms/php/src</outputDirectory>
- </fileSet>
-
- <fileSet>
- <directory>modules/platforms/php/examples</directory>
- <outputDirectory>/platforms/php/examples</outputDirectory>
- </fileSet>
-
- <!-- Copy Python sources. -->
- <fileSet>
- <directory>modules/platforms/python/pyignite</directory>
- <outputDirectory>/platforms/python/pyignite</outputDirectory>
- </fileSet>
-
- <fileSet>
- <directory>modules/platforms/python/requirements</directory>
- <outputDirectory>/platforms/python/requirements</outputDirectory>
- </fileSet>
-
- <fileSet>
- <directory>modules/platforms/python/examples</directory>
- <outputDirectory>/platforms/python/examples</outputDirectory>
- </fileSet>
-
<!-- Other files. -->
<fileSet>
<directory>bin</directory>
diff --git a/docs/_docs/quick-start/nodejs.adoc b/docs/_docs/quick-start/nodejs.adoc
index 355c958..1e1a339 100644
--- a/docs/_docs/quick-start/nodejs.adoc
+++ b/docs/_docs/quick-start/nodejs.adoc
@@ -51,11 +51,11 @@ include::includes/starting-node.adoc[]
Once the cluster is started, you can use the Ignite Node.js thin client to perform cache operations.
-Your Ignite installation includes several ready-to-run Node.JS examples in the `{ignite_nodejs_dir}/platforms/nodejs/examples` directory. For example,
+Your Ignite installation includes several ready-to-run Node.JS examples in the `{client_dir}/examples` directory. For example,
[source,shell]
----
-cd {IGNITE_HOME}/platforms/nodejs/examples
+cd {client_dir}/examples
node CachePutGetExample.js
----
@@ -100,5 +100,5 @@ performCacheKeyValueOperations();
From here, you may want to:
* Read more about using Ignite Node.js Thin Client link:thin-clients/nodejs-thin-client[here]
-//* Explore the link:https://github.com/gridgain/nodejs-thin-client/tree/master/examples[additional examples] included with Ignite
+* Explore the link:https://github.com/apache/ignite-nodejs-thin-client/tree/master/examples[additional examples]
diff --git a/docs/_docs/quick-start/php.adoc b/docs/_docs/quick-start/php.adoc
index ec8a6eb..12314d2 100644
--- a/docs/_docs/quick-start/php.adoc
+++ b/docs/_docs/quick-start/php.adoc
@@ -38,12 +38,9 @@ and:
include::includes/install-ignite.adoc[]
-Once that's done, go to `{IGNITE_HOME}/platforms/php` and install Ignite PHP Thin Client as a Composer package using the command below:
+Once that's done, install PHP Thin Client as a Composer package using the command below:
-[source, ruby]
-----
-composer install --no-dev
-----
+include::includes/install-php-composer.adoc[]
You're almost ready to run your first application.
@@ -56,7 +53,8 @@ include::includes/starting-node.adoc[]
== Running Your First Application
Once at least one node is started, you can use the Ignite PHP thin client to perform cache operations.
-Your Ignite installation includes several ready-to-run PHP examples in the `{IGNITE_HOME}/platforms/php/examples` directory. For example,
+Your Ignite installation includes several ready-to-run PHP examples in the `{client_dir}/examples` directory.
+Here is example how to run one of them:
[tabs]
@@ -64,14 +62,13 @@ Your Ignite installation includes several ready-to-run PHP examples in the `{IGN
tab:Unix[]
[source,shell]
----
-cd {IGNITE_HOME}/platforms/php/examples
+cd {client_dir}/examples
php CachePutGetExample.php
----
-
tab:Windows[]
[source,shell]
----
-cd {IGNITE_HOME}\platforms\php\examples
+cd {client_dir}\examples
php CachePutGetExample.php
----
--
@@ -121,5 +118,5 @@ performCacheKeyValueOperations();
From here, you may want to:
* Read more about using link:thin-clients/php-thin-client[PHP Thin Client]
-//* Explore the link:https://github.com/gridgain/php-thin-client/tree/master/examples[additional examples] included with GridGain
+* Explore the link:https://github.com/apache/ignite-php-thin-client/tree/master/examples[additional examples] included with GridGain
diff --git a/docs/_docs/quick-start/python.adoc b/docs/_docs/quick-start/python.adoc
index ef96e7c..c77fd76 100644
--- a/docs/_docs/quick-start/python.adoc
+++ b/docs/_docs/quick-start/python.adoc
@@ -85,4 +85,4 @@ Or you can enter the example into your Python interpreter/shell (IDLE on Windows
== Further Examples
-Explore more Ignite Python examples link:{githubUrl}/modules/platforms/python/examples[here^].
+Explore more Ignite Python examples link:https://github.com/apache/ignite-python-thin-client/tree/master/examples[here^].
diff --git a/docs/_docs/thin-clients/nodejs-thin-client.adoc b/docs/_docs/thin-clients/nodejs-thin-client.adoc
index 67ad09a..4f7d9bc 100644
--- a/docs/_docs/thin-clients/nodejs-thin-client.adoc
+++ b/docs/_docs/thin-clients/nodejs-thin-client.adoc
@@ -39,8 +39,8 @@ npm install -g apache-ignite-client
The thin client can be installed from the zip archive available for download from the Ignite website:
-* Download the link:https://ignite.apache.org/download.cgi#binaries[Apache Ignite binary package,window=_blank].
-* Unpack the archive and navigate to the `{IGNITE_HOME}/platforms/nodejs` folder.
+* Download the link:https://ignite.apache.org/download.cgi#binaries[Apache Ignite Node.js Thin Client,window=_blank].
+* Unpack the archive and navigate to the root folder.
* Run the commands below to finish the installation.
[source,shell]
diff --git a/docs/_docs/thin-clients/php-thin-client.adoc b/docs/_docs/thin-clients/php-thin-client.adoc
index 819a5e9..3b99ad5 100644
--- a/docs/_docs/thin-clients/php-thin-client.adoc
+++ b/docs/_docs/thin-clients/php-thin-client.adoc
@@ -22,10 +22,18 @@ Depending on your PHP configuration, you may need to additionally install/config
== Installation
-The thin client can be installed from the zip archive:
+The PHP thin client is shipped as a Composer package and a zip archive. Use any of the methods to install the client in your environment.
-* Download the link:https://ignite.apache.org/download.cgi#binaries[Apache Ignite binary package,window=_blank].
-* Unpack the archive and navigate to the `{IGNITE_HOME}/platforms/php` folder.
+=== Using Composer
+
+include::includes/install-php-composer.adoc[]
+
+=== Using ZIP Archive
+
+The thin client can be installed from the zip archive available for download from the Apache Ignite website:
+
+* Download the link:https://ignite.apache.org/download.cgi#binaries[Apache Ignite PHP Thin Client,window=_blank].
+* Unpack the archive and navigate to the root folder.
* Use the command below to install the package.
[source,shell]
diff --git a/docs/_docs/thin-clients/python-thin-client.adoc b/docs/_docs/thin-clients/python-thin-client.adoc
index f04a567..4bbbd8c 100644
--- a/docs/_docs/thin-clients/python-thin-client.adoc
+++ b/docs/_docs/thin-clients/python-thin-client.adoc
@@ -32,9 +32,9 @@ include::includes/install-python-pip.adoc[]
=== Using ZIP Archive
-The thin client can be installed from the zip archive:
+The thin client can be installed from the zip archive available for download from the Apache Ignite website:
-* Download the link:https://ignite.apache.org/download.cgi#binaries[Apache Ignite binary package,window=_blank].
+* Download the link:https://ignite.apache.org/download.cgi#binaries[Apache Ignite Python Thin Client,window=_blank].
* Unpack the archive and navigate to the root folder.
* Install the client using the command below.
@@ -78,8 +78,8 @@ Refer to the https://setuptools.readthedocs.io/en/latest/[Setuptools manual] for
== Connecting to Cluster
-The distribution package contains runnable examples that demonstrate basic usage scenarios of the Python thin client.
-The examples are located in the `{ROOT_FOLDER}/examples` directory.
+The ZIP distribution package contains runnable examples that demonstrate basic usage scenarios of the Python thin client.
+The examples are located in the `{client_dir}/examples` directory.
The following code snippet shows how to connect to a cluster from the Python thin client:
diff --git a/modules/platforms/nodejs/README.md b/modules/platforms/nodejs/README.md
deleted file mode 100644
index 4792caa..0000000
--- a/modules/platforms/nodejs/README.md
+++ /dev/null
@@ -1,32 +0,0 @@
-# NodeJS Client for Apache Ignite #
-
-## Installation ##
-
-[Node.js](https://nodejs.org/en/) version 8 or higher is required. Either download the Node.js [pre-built binary](https://nodejs.org/en/download/) for the target platform, or install Node.js via [package manager](https://nodejs.org/en/download/package-manager).
-
-Once `node` and `npm` are installed, you can use one of the following installation options.
-
-### Installation via npm ###
-
-Execute the following command to install the Node.js Thin Client package:
-
-```
-npm install -g apache-ignite-client
-```
-
-### Installation from Sources ###
-
-If you want to install the Thin Client library from Ignite sources, please follow the steps:
-
-1. Download Ignite sources to `local_ignite_path`
-2. Go to `local_ignite_path/modules/platforms/nodejs` folder
-3. Execute `npm link` command
-4. Execute `npm link apache-ignite-client` command (needed only for examples)
-
-```bash
-cd local_ignite_path/modules/platforms/nodejs
-npm link
-npm link apache-ignite-client #linking examples (optional)
-```
-
-For more information, see [Apache Ignite Node.JS Thin Client documentation](https://apacheignite.readme.io/docs/nodejs-thin-client).
diff --git a/modules/platforms/nodejs/api_spec/conf.json b/modules/platforms/nodejs/api_spec/conf.json
deleted file mode 100644
index 1cc1db0..0000000
--- a/modules/platforms/nodejs/api_spec/conf.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "plugins": [
- "plugins/markdown"
- ],
- "source": {
- "include": [ "../lib" ],
- "includePattern": ".+\\.js$"
- },
- "opts": {
- "destination": "."
- }
-}
diff --git a/modules/platforms/nodejs/examples/AuthTlsExample.js b/modules/platforms/nodejs/examples/AuthTlsExample.js
deleted file mode 100644
index b47df61..0000000
--- a/modules/platforms/nodejs/examples/AuthTlsExample.js
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-const FS = require('fs');
-const IgniteClient = require('apache-ignite-client');
-const ObjectType = IgniteClient.ObjectType;
-const ComplexObjectType = IgniteClient.ComplexObjectType;
-const BinaryObject = IgniteClient.BinaryObject;
-const CacheEntry = IgniteClient.CacheEntry;
-const ScanQuery = IgniteClient.ScanQuery;
-const IgniteClientConfiguration = IgniteClient.IgniteClientConfiguration;
-
-const ENDPOINT = 'localhost:10800';
-const USER_NAME = 'ignite';
-const PASSWORD = 'ignite';
-
-const TLS_KEY_FILE_NAME = __dirname + '/certs/client.key';
-const TLS_CERT_FILE_NAME = __dirname + '/certs/client.crt';
-const TLS_CA_FILE_NAME = __dirname + '/certs/ca.crt';
-
-const CACHE_NAME = 'AuthTlsExample_cache';
-
-// This example demonstrates how to establish a secure connection to an Ignite node and use username/password authentication,
-// as well as basic Key-Value Queries operations for primitive types:
-// - connects to a node using TLS and providing username/password
-// - creates a cache, if it doesn't exist
-// - specifies key and value type of the cache
-// - put data of primitive types into the cache
-// - get data from the cache
-// - destroys the cache
-class AuthTlsExample {
-
- async start() {
- const igniteClient = new IgniteClient(this.onStateChanged.bind(this));
- try {
- const connectionOptions = {
- 'key' : FS.readFileSync(TLS_KEY_FILE_NAME),
- 'cert' : FS.readFileSync(TLS_CERT_FILE_NAME),
- 'ca' : FS.readFileSync(TLS_CA_FILE_NAME)
- };
- await igniteClient.connect(new IgniteClientConfiguration(ENDPOINT).
- setUserName(USER_NAME).
- setPassword(PASSWORD).
- setConnectionOptions(true, connectionOptions));
-
- const cache = (await igniteClient.getOrCreateCache(CACHE_NAME)).
- setKeyType(ObjectType.PRIMITIVE_TYPE.INTEGER).
- setValueType(ObjectType.PRIMITIVE_TYPE.SHORT_ARRAY);
-
- await this.putGetData(cache);
-
- await igniteClient.destroyCache(CACHE_NAME);
- }
- catch (err) {
- console.log('ERROR: ' + err.message);
- }
- finally {
- igniteClient.disconnect();
- }
- }
-
- async putGetData(cache) {
- let keys = [1, 2, 3];
- let values = keys.map(key => this.generateValue(key));
-
- // put multiple values in parallel
- await Promise.all([
- await cache.put(keys[0], values[0]),
- await cache.put(keys[1], values[1]),
- await cache.put(keys[2], values[2])
- ]);
- console.log('Cache values put successfully');
-
- // get values sequentially
- let value;
- for (let i = 0; i < keys.length; i++) {
- value = await cache.get(keys[i]);
- if (!this.compareValues(value, values[i])) {
- console.log('Unexpected cache value!');
- return;
- }
- }
- console.log('Cache values get successfully');
- }
-
- compareValues(array1, array2) {
- return array1.length === array2.length &&
- array1.every((value1, index) => value1 === array2[index]);
- }
-
- generateValue(key) {
- const length = key + 5;
- const result = new Array(length);
- for (let i = 0; i < length; i++) {
- result[i] = key * 10 + i;
- }
- return result;
- }
-
- onStateChanged(state, reason) {
- if (state === IgniteClient.STATE.CONNECTED) {
- console.log('Client is started');
- }
- else if (state === IgniteClient.STATE.DISCONNECTED) {
- console.log('Client is stopped');
- if (reason) {
- console.log(reason);
- }
- }
- }
-}
-
-const authTlsExample = new AuthTlsExample();
-authTlsExample.start();
diff --git a/modules/platforms/nodejs/examples/CachePutGetExample.js b/modules/platforms/nodejs/examples/CachePutGetExample.js
deleted file mode 100644
index b37f573..0000000
--- a/modules/platforms/nodejs/examples/CachePutGetExample.js
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-const IgniteClient = require('apache-ignite-client');
-const ObjectType = IgniteClient.ObjectType;
-const ComplexObjectType = IgniteClient.ComplexObjectType;
-const BinaryObject = IgniteClient.BinaryObject;
-const CacheEntry = IgniteClient.CacheEntry;
-const ScanQuery = IgniteClient.ScanQuery;
-const IgniteClientConfiguration = IgniteClient.IgniteClientConfiguration;
-
-const ENDPOINT = '127.0.0.1:10800';
-
-const CACHE_NAME = 'CachePutGetExample_person';
-const PERSON_TYPE_NAME = 'Person';
-
-class Person {
- constructor(firstName = null, lastName = null, salary = null) {
- this.id = Person.generateId();
- this.firstName = firstName;
- this.lastName = lastName;
- this.salary = salary;
- }
-
- static generateId() {
- if (!Person.id) {
- Person.id = 0;
- }
- const id = Person.id;
- Person.id++;
- return id;
- }
-}
-
-// This example demonstrates basic Cache, Key-Value Queries and Scan Query operations:
-// - connects to a node
-// - creates a cache, if it doesn't exist
-// - specifies key type as Integer
-// - executes different cache operations with Complex Objects and Binary Objects
-// - put several objects in parallel
-// - putAll
-// - get
-// - getAll
-// - ScanQuery
-// - destroys the cache
-class CachePutGetExample {
-
- constructor() {
- this._personCache = null;
- this._personObjectType = null;
- this._binaryObjectCache = null;
- }
-
- async start() {
- const igniteClient = new IgniteClient(this.onStateChanged.bind(this));
- try {
- await igniteClient.connect(new IgniteClientConfiguration(ENDPOINT));
-
- this._personObjectType = new ComplexObjectType(new Person(), PERSON_TYPE_NAME).
- setFieldType('id', ObjectType.PRIMITIVE_TYPE.INTEGER);
-
- this._personCache = (await igniteClient.getOrCreateCache(CACHE_NAME)).
- setKeyType(ObjectType.PRIMITIVE_TYPE.INTEGER).
- setValueType(this._personObjectType);
-
- this._binaryObjectCache = igniteClient.getCache(CACHE_NAME).
- setKeyType(ObjectType.PRIMITIVE_TYPE.INTEGER);
-
- await this.putComplexObjects();
- await this.putAllBinaryObjects();
-
- await this.getAllComplexObjects();
- await this.getBinaryObjects();
-
- await this.scanQuery();
-
- await igniteClient.destroyCache(CACHE_NAME);
- }
- catch (err) {
- console.log('ERROR: ' + err.message);
- }
- finally {
- igniteClient.disconnect();
- }
- }
-
- async putComplexObjects() {
- const person1 = new Person('John', 'Doe', 1000);
- const person2 = new Person('Jane', 'Roe', 2000);
-
- // put multiple values in parallel
- await Promise.all([
- await this._personCache.put(person1.id, person1),
- await this._personCache.put(person2.id, person2)
- ]);
-
- console.log('Complex Objects put successfully');
- }
-
- async putAllBinaryObjects() {
- // create binary object from scratch
- const personBinaryObject1 = new BinaryObject(PERSON_TYPE_NAME).
- setField('id', Person.generateId(), ObjectType.PRIMITIVE_TYPE.INTEGER).
- setField('firstName', 'Mary').
- setField('lastName', 'Major').
- setField('salary', 1500);
-
- // create binary object from complex object
- const personBinaryObject2 = await BinaryObject.fromObject(
- new Person('Richard', 'Miles', 800), this._personObjectType);
-
- await this._binaryObjectCache.putAll([
- new CacheEntry(await personBinaryObject1.getField('id'), personBinaryObject1),
- new CacheEntry(await personBinaryObject2.getField('id'), personBinaryObject2)
- ]);
-
- console.log('Binary Objects put successfully using putAll()');
- }
-
- async getAllComplexObjects() {
- const persons = await this._personCache.getAll([2, 3]);
- console.log('Complex Objects getAll:');
- for (let person of persons) {
- this.printPersonObject(person.getValue());
- }
- }
-
- async getBinaryObjects() {
- const personBinaryObject = await this._binaryObjectCache.get(3);
- console.log('Binary Object get:');
- console.log(' ' + personBinaryObject.getTypeName());
- let fieldValue;
- for (let fieldName of personBinaryObject.getFieldNames()) {
- fieldValue = await personBinaryObject.getField(fieldName);
- this.printPersonField(fieldName, fieldValue);
- }
- }
-
- async scanQuery() {
- const cursor = await this._personCache.query(new ScanQuery());
- console.log('Scan query results:');
- for (let cacheEntry of await cursor.getAll()) {
- this.printPersonObject(cacheEntry.getValue());
- }
- }
-
- onStateChanged(state, reason) {
- if (state === IgniteClient.STATE.CONNECTED) {
- console.log('Client is started');
- }
- else if (state === IgniteClient.STATE.DISCONNECTED) {
- console.log('Client is stopped');
- if (reason) {
- console.log(reason);
- }
- }
- }
-
- printPersonObject(person) {
- console.log(' ' + PERSON_TYPE_NAME);
- for (let key in person) {
- this.printPersonField(key, person[key]);
- }
- }
-
- printPersonField(fieldName, fieldValue) {
- console.log(' ' + fieldName + ' : ' + fieldValue);
- }
-}
-
-const cachePutGetExample = new CachePutGetExample();
-cachePutGetExample.start();
diff --git a/modules/platforms/nodejs/examples/FailoverExample.js b/modules/platforms/nodejs/examples/FailoverExample.js
deleted file mode 100644
index 25db544..0000000
--- a/modules/platforms/nodejs/examples/FailoverExample.js
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-const IgniteClient = require('apache-ignite-client');
-const IgniteClientConfiguration = IgniteClient.IgniteClientConfiguration;
-
-const ENDPOINT1 = 'localhost:10800';
-const ENDPOINT2 = 'localhost:10801';
-const ENDPOINT3 = 'localhost:10802';
-
-// This example demonstrates failover behavior of the client
-// - configures the client to connect to a set of nodes
-// - connects to a node
-// - if connection is broken, the client automatically tries to reconnect to another node
-// - if no specified nodes are available, stops the client
-async function connectClient() {
- const igniteClient = new IgniteClient(onStateChanged);
- igniteClient.setDebug(true);
- try {
- const igniteClientConfiguration = new IgniteClientConfiguration(
- ENDPOINT1, ENDPOINT2, ENDPOINT3);
- // connect to Ignite a node
- await igniteClient.connect(igniteClientConfiguration);
- }
- catch (err) {
- console.log(err.message);
- }
-}
-
-function onStateChanged(state, reason) {
- if (state === IgniteClient.STATE.CONNECTED) {
- console.log('Client is started');
- }
- else if (state === IgniteClient.STATE.CONNECTING) {
- console.log('Client is connecting');
- }
- else if (state === IgniteClient.STATE.DISCONNECTED) {
- console.log('Client is stopped');
- if (reason) {
- console.log(reason);
- }
- }
-}
-
-connectClient();
\ No newline at end of file
diff --git a/modules/platforms/nodejs/examples/SqlExample.js b/modules/platforms/nodejs/examples/SqlExample.js
deleted file mode 100644
index 92f59d7..0000000
--- a/modules/platforms/nodejs/examples/SqlExample.js
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-const Util = require('util');
-const IgniteClient = require('apache-ignite-client');
-const ObjectType = IgniteClient.ObjectType;
-const IgniteClientConfiguration = IgniteClient.IgniteClientConfiguration;
-const CacheConfiguration = IgniteClient.CacheConfiguration;
-const SqlFieldsQuery = IgniteClient.SqlFieldsQuery;
-const SqlQuery = IgniteClient.SqlQuery;
-
-const ENDPOINT = '127.0.0.1:10800';
-
-const COUNTRY_CACHE_NAME = 'Country';
-const CITY_CACHE_NAME = 'City';
-const COUNTRY_LANGUAGE_CACHE_NAME = 'CountryLng';
-const DUMMY_CACHE_NAME = 'SqlExample_Dummy';
-
-// This example shows primary APIs to use with Ignite as with an SQL database:
-// - connects to a node
-// - creates a cache, if it doesn't exist
-// - creates tables (CREATE TABLE)
-// - creates indices (CREATE INDEX)
-// - writes data of primitive types into the tables (INSERT INTO table)
-// - reads data from the tables (SELECT ...)
-// - deletes tables (DROP TABLE)
-// - destroys the cache
-class SqlExample {
- async start() {
- const igniteClient = new IgniteClient(this.onStateChanged.bind(this));
- try {
- await igniteClient.connect(new IgniteClientConfiguration(ENDPOINT));
-
- const cache = await igniteClient.getOrCreateCache(
- DUMMY_CACHE_NAME,
- new CacheConfiguration().setSqlSchema('PUBLIC'));
-
- await this.createDatabaseObjects(cache);
- await this.insertData(cache);
-
- const countryCache = igniteClient.getCache(COUNTRY_CACHE_NAME);
- const cityCache = igniteClient.getCache(CITY_CACHE_NAME);
-
- await this.getMostPopulatedCities(countryCache);
- await this.getTopCitiesInThreeCountries(cityCache);
- await this.getCityDetails(cityCache, 5);
-
- await this.deleteDatabaseObjects(cache);
- await igniteClient.destroyCache(DUMMY_CACHE_NAME);
- }
- catch (err) {
- console.log('ERROR: ' + err.message);
- }
- finally {
- igniteClient.disconnect();
- }
- }
-
- async createDatabaseObjects(cache) {
- const createCountryTable = `CREATE TABLE Country (
- Code CHAR(3) PRIMARY KEY,
- Name CHAR(52),
- Continent CHAR(50),
- Region CHAR(26),
- SurfaceArea DECIMAL(10,2),
- IndepYear SMALLINT(6),
- Population INT(11),
- LifeExpectancy DECIMAL(3,1),
- GNP DECIMAL(10,2),
- GNPOld DECIMAL(10,2),
- LocalName CHAR(45),
- GovernmentForm CHAR(45),
- HeadOfState CHAR(60),
- Capital INT(11),
- Code2 CHAR(2)
- ) WITH "template=partitioned, backups=1, CACHE_NAME=${COUNTRY_CACHE_NAME}"`;
-
- const createCityTable = `CREATE TABLE City (
- ID INT(11),
- Name CHAR(35),
- CountryCode CHAR(3),
- District CHAR(20),
- Population INT(11),
- PRIMARY KEY (ID, CountryCode)
- ) WITH "template=partitioned, backups=1, affinityKey=CountryCode, CACHE_NAME=${CITY_CACHE_NAME}"`;
-
- const createCountryLanguageTable = `CREATE TABLE CountryLanguage (
- CountryCode CHAR(3),
- Language CHAR(30),
- IsOfficial CHAR(2),
- Percentage DECIMAL(4,1),
- PRIMARY KEY (CountryCode, Language)
- ) WITH "template=partitioned, backups=1, affinityKey=CountryCode, CACHE_NAME=${COUNTRY_LANGUAGE_CACHE_NAME}"`;
-
- // create tables
- (await cache.query(new SqlFieldsQuery(createCountryTable))).getAll();
- (await cache.query(new SqlFieldsQuery(createCityTable))).getAll();
- (await cache.query(new SqlFieldsQuery(createCountryLanguageTable))).getAll();
-
- // create indices
- (await cache.query(new SqlFieldsQuery(
- 'CREATE INDEX idx_country_code ON city (CountryCode)'))).getAll();
- (await cache.query(new SqlFieldsQuery(
- 'CREATE INDEX idx_lang_country_code ON CountryLanguage (CountryCode)'))).getAll();
-
- console.log('Database objects created');
- }
-
- async insertData(cache) {
- const cities = [
- ['New York', 'USA', 'New York', 8008278],
- ['Los Angeles', 'USA', 'California', 3694820],
- ['Chicago', 'USA', 'Illinois', 2896016],
- ['Houston', 'USA', 'Texas', 1953631],
- ['Philadelphia', 'USA', 'Pennsylvania', 1517550],
- ['Moscow', 'RUS', 'Moscow (City)', 8389200],
- ['St Petersburg', 'RUS', 'Pietari', 4694000],
- ['Novosibirsk', 'RUS', 'Novosibirsk', 1398800],
- ['Nizni Novgorod', 'RUS', 'Nizni Novgorod', 1357000],
- ['Jekaterinburg', 'RUS', 'Sverdlovsk', 1266300],
- ['Shanghai', 'CHN', 'Shanghai', 9696300],
- ['Peking', 'CHN', 'Peking', 7472000],
- ['Chongqing', 'CHN', 'Chongqing', 6351600],
- ['Tianjin', 'CHN', 'Tianjin', 5286800],
- ['Wuhan', 'CHN', 'Hubei', 4344600]
- ];
-
- const cityQuery = new SqlFieldsQuery(`INSERT INTO City(ID, Name, CountryCode, District, Population)
- VALUES (?, ?, ?, ?, ?)`);
-
- for (let i = 0; i < cities.length; i++) {
- (await cache.query(cityQuery.setArgs(i, ...cities[i]))).getAll();
- }
-
- const countries = [
- ['USA', 'United States', 'North America', 'North America',
- 9363520.00, 1776, 278357000, 77.1, 8510700.00, 8110900.00,
- 'United States', 'Federal Republic', 'George W. Bush', 3813, 'US'],
- ['RUS', 'Russian Federation', 'Europe', 'Eastern Europe',
- 17075400.00, 1991, 146934000, 67.2, 276608.00, 442989.00,
- 'Rossija', 'Federal Republic', 'Vladimir Putin', 3580, 'RU'],
- ['CHN', 'China', 'Asia', 'Eastern Asia',
- 9572900.00, -1523, 1277558000, 71.4, 982268.00, 917719.00,
- 'Zhongquo', 'PeoplesRepublic', 'Jiang Zemin', 1891, 'CN']
- ];
-
- const countryQuery = new SqlFieldsQuery(`INSERT INTO Country(
- Code, Name, Continent, Region, SurfaceArea,
- IndepYear, Population, LifeExpectancy, GNP, GNPOld,
- LocalName, GovernmentForm, HeadOfState, Capital, Code2)
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`);
-
- for (let country of countries) {
- (await cache.query(countryQuery.setArgs(...country))).getAll();
- }
-
- console.log('Data are inserted');
- }
-
- async getMostPopulatedCities(countryCache) {
- const query = new SqlFieldsQuery(
- 'SELECT name, population FROM City ORDER BY population DESC LIMIT 10');
-
- const cursor = await countryCache.query(query);
-
- console.log("10 Most Populated Cities:");
-
- let row;
- do {
- row = await cursor.getValue();
- console.log(" " + row[1] + " people live in " + row[0]);
- } while (cursor.hasMore());
- }
-
- async getTopCitiesInThreeCountries(countryCache) {
- const query = new SqlFieldsQuery(
- `SELECT country.name, city.name, MAX(city.population) as max_pop FROM country
- JOIN city ON city.countrycode = country.code
- WHERE country.code IN ('USA','RUS','CHN')
- GROUP BY country.name, city.name ORDER BY max_pop DESC LIMIT 3`);
-
- const cursor = await countryCache.query(query);
-
- console.log("3 Most Populated Cities in US, RUS and CHN:");
-
- for (let row of await cursor.getAll()) {
- console.log(" " + row[2] + " people live in " + row[1] + ", " + row[0]);
- }
- }
-
- async getCityDetails(cityCache, cityId) {
- const query = new SqlFieldsQuery('SELECT * FROM City WHERE id = ?').
- setArgs(cityId);
-
- const cursor = await cityCache.query(query);
-
- const fieldNames = cursor.getFieldNames();
-
- for (let city of await cursor.getAll()) {
- console.log('City Info:');
- for (let column of city) {
- console.log(" " + column);
- }
- }
- }
-
- async deleteDatabaseObjects(cache) {
- (await cache.query(new SqlFieldsQuery('DROP TABLE IF EXISTS Country'))).getAll();
- (await cache.query(new SqlFieldsQuery('DROP TABLE IF EXISTS City'))).getAll();
- (await cache.query(new SqlFieldsQuery('DROP TABLE IF EXISTS CountryLanguage'))).getAll();
- console.log('Database objects dropped');
- }
-
- onStateChanged(state, reason) {
- if (state === IgniteClient.STATE.CONNECTED) {
- console.log('Client is started');
- }
- else if (state === IgniteClient.STATE.DISCONNECTED) {
- console.log('Client is stopped');
- if (reason) {
- console.log(reason);
- }
- }
- }
-}
-
-const sqlExample = new SqlExample();
-sqlExample.start();
diff --git a/modules/platforms/nodejs/examples/SqlQueryEntriesExample.js b/modules/platforms/nodejs/examples/SqlQueryEntriesExample.js
deleted file mode 100644
index ecbcbd5..0000000
--- a/modules/platforms/nodejs/examples/SqlQueryEntriesExample.js
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-const Util = require('util');
-const IgniteClient = require('apache-ignite-client');
-const ObjectType = IgniteClient.ObjectType;
-const ComplexObjectType = IgniteClient.ComplexObjectType;
-const IgniteClientConfiguration = IgniteClient.IgniteClientConfiguration;
-const CacheConfiguration = IgniteClient.CacheConfiguration;
-const QueryEntity = IgniteClient.QueryEntity;
-const QueryField = IgniteClient.QueryField;
-const SqlFieldsQuery = IgniteClient.SqlFieldsQuery;
-const SqlQuery = IgniteClient.SqlQuery;
-
-const ENDPOINT = '127.0.0.1:10800';
-
-const PERSON_CACHE_NAME = 'SqlQueryEntriesExample_person';
-
-class Person {
- constructor(firstName = null, lastName = null, salary = null) {
- this.id = Person.generateId();
- this.firstName = firstName;
- this.lastName = lastName;
- this.salary = salary;
- }
-
- static generateId() {
- if (!Person.id) {
- Person.id = 0;
- }
- const id = Person.id;
- Person.id++;
- return id;
- }
-}
-
-// This example demonstrates basic Cache, Key-Value Queries and SQL Query operations:
-// - connects to a node
-// - creates a cache from CacheConfiguration, if it doesn't exist
-// - writes data of primitive and Complex Object types into the cache using Key-Value put operation
-// - reads data from the cache using SQL Query
-// - destroys the cache
-class SqlQueryEntriesExample {
- constructor() {
- this._cache = null;
- }
-
- async start() {
- const igniteClient = new IgniteClient(this.onStateChanged.bind(this));
- try {
- await igniteClient.connect(new IgniteClientConfiguration(ENDPOINT));
-
- const cacheCfg = new CacheConfiguration().
- setQueryEntities(
- new QueryEntity().
- setValueTypeName('Person').
- setFields([
- new QueryField('id', 'java.lang.Integer'),
- new QueryField('firstName', 'java.lang.String'),
- new QueryField('lastName', 'java.lang.String'),
- new QueryField('salary', 'java.lang.Double')
- ]));
- this._cache = (await igniteClient.getOrCreateCache(PERSON_CACHE_NAME, cacheCfg)).
- setKeyType(ObjectType.PRIMITIVE_TYPE.INTEGER).
- setValueType(new ComplexObjectType(new Person()).
- setFieldType('id', ObjectType.PRIMITIVE_TYPE.INTEGER));
-
- await this.generateData();
-
- const sqlCursor = await this._cache.query(
- new SqlQuery('Person', 'salary > ? and salary <= ?').
- setArgs(900, 1600));
-
- console.log('SqlQuery results (salary between 900 and 1600):');
- let person;
- do {
- person = (await sqlCursor.getValue()).getValue();
- console.log(Util.format(' name: %s %s, salary: %d',
- person.firstName, person.lastName, person.salary));
- } while (sqlCursor.hasMore());
-
- await igniteClient.destroyCache(PERSON_CACHE_NAME);
- }
- catch (err) {
- console.log('ERROR: ' + err.message);
- }
- finally {
- igniteClient.disconnect();
- }
- }
-
- async generateData() {
- const persons = [
- ['John', 'Doe', 1000],
- ['Jane', 'Roe', 2000],
- ['Mary', 'Major', 1500],
- ['Richard', 'Miles', 800]
- ];
-
- for (let data of persons) {
- let person = new Person(...data);
- await this._cache.put(person.id, person);
- }
-
- console.log('Data is generated');
- }
-
- onStateChanged(state, reason) {
- if (state === IgniteClient.STATE.CONNECTED) {
- console.log('Client is started');
- }
- else if (state === IgniteClient.STATE.DISCONNECTED) {
- console.log('Client is stopped');
- if (reason) {
- console.log(reason);
- }
- }
- }
-}
-
-const sqlQueryEntriesExample = new SqlQueryEntriesExample();
-sqlQueryEntriesExample.start();
diff --git a/modules/platforms/nodejs/examples/certs/ca.crt b/modules/platforms/nodejs/examples/certs/ca.crt
deleted file mode 100644
index ba90793..0000000
--- a/modules/platforms/nodejs/examples/certs/ca.crt
+++ /dev/null
@@ -1,32 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIFfzCCA2egAwIBAgIJAIH05meRt7kjMA0GCSqGSIb3DQEBCwUAMFYxCzAJBgNV
-BAYTAkZSMQowCAYDVQQIDAEuMQowCAYDVQQHDAEuMSMwIQYDVQQKDBpBQ01FIFNp
-Z25pbmcgQXV0aG9yaXR5IEluYzEKMAgGA1UEAwwBLjAeFw0xODA0MTIyMDUxMDFa
-Fw0yODA0MDkyMDUxMDFaMFYxCzAJBgNVBAYTAkZSMQowCAYDVQQIDAEuMQowCAYD
-VQQHDAEuMSMwIQYDVQQKDBpBQ01FIFNpZ25pbmcgQXV0aG9yaXR5IEluYzEKMAgG
-A1UEAwwBLjCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAMoilf6lWZt8
-F+QkZj2zW8PTEiOzqjLDCmEhnoVOPXAbCucaHuqQfK8xHL2FjlkeRWO1egzXBQ/V
-K+p2+ck/1D98qL8gYfR8Zf1WUUkgBYjnch9r+BPqIjSwBD8e3HyTIq+DGQ8tYqh0
-1GtP6tooZYF2VBKu7aY69vOOgM16k+2GLR7ILz5MtHARNshu/YYWU8GgIIKXVK8e
-DJU1swVhzCWDxX8S9BNuT13WoajOk6GhTkbKIQs0e32arHVfTV0G5s/FlAjtze4r
-kWsK+W/IJky98QLZqdHfoXxlPD4Ir6wuRjIZWfuliLmud5umhRdfT18vtApOiPR/
-nxFdITM914MubR6p0jEvnbF2PCQTKQVsGqpPRrsnqQwsLGUJKOGlS+Njwv6zUvJq
-xH5AjJcPNnwhc3dwcWoiYgswCcttUWz/a9h2SI5zggfyC3aVl72WmcsDbNgsAIJr
-ML5d5EIr+RvbTzQEaqLOHj1q8rysrRx8+HdtKRjXTJsTqpqCkAm+UWnLdlEnxvNW
-Asy0TZ65aGAR8ysyEO8s2xq0m2eTai1BPj91Yt3YnozWjvC0fdC6QL8Ksxka7HYO
-MYLXkwtlpi3m/dXVEk9Xd9SAE77+9aPN+MYAEvCG6WA2Drb7nOBVm31ATY20cEln
-I2YqiMBn05sjohacEww+7LVqYeez1xRvAgMBAAGjUDBOMB0GA1UdDgQWBBSy3uNf
-iwlv/7mjyiglCjKMq5kJDDAfBgNVHSMEGDAWgBSy3uNfiwlv/7mjyiglCjKMq5kJ
-DDAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUAA4ICAQACrOj3S0CpJVuCsgsZ
-JKCnPn0HVfJ0nU8tKMb43xq6r7V7GsUvdJIvzgiBC19ld+mWNUp25B9M9zOf1glL
-L9h2Tlu8gg+0DJ/1/ipZLNc36Q77Te8KECDKt8k9eI5N6HLS57mCZgE6CmGhc7zg
-notGQxzjfW8XQWDUwqwhfMZ9CjL+Tz7rHbvTCNrg9T0Ha57ajNxONlHsVUSMnbB6
-mN2n2pbpf40X4LL5j+mxxr0v6hfAF89U6hekeRf/8LMDApIc/6iVxGskwCOHZhkc
-w761WDHC4gh64cAWUni7YDJSCP8Djgdi34WQs4bk05f3u/86V702doR9JPJsRoQg
-P1juHur8vedjSQTqvA5TAt3ct6wkgVmeeqnIDTH2JFNCnssVWtJburOibUHgKvqe
-ZH0y3JF2eCcVXPPq6M6qM7W2IziArsZs22tkos2ARaDDU8ekmsEOH9SNphVICAet
-AT6b8YyOutTXO4LIN1TUeXmeKMpOAA2+YNCp+/OxbzkqvZxYuvbBtoSiIfrHyW4k
-rE0rRTYpB1Mk7R4+hwPnJim1OvZ+vLeLzvgGIyZKKiku2bp0YB8KGsAchnnJVlyo
-Oca/YSkKIBYCiQjxg5rX1/ZonhAkRbuqzmQdb9bJoGoN8kUdN9wvZHC3YPtox1Nd
-GoJSdO3MNkK5EwafrMAGh2Jmxg==
------END CERTIFICATE-----
diff --git a/modules/platforms/nodejs/examples/certs/client.crt b/modules/platforms/nodejs/examples/certs/client.crt
deleted file mode 100644
index f88e11c..0000000
--- a/modules/platforms/nodejs/examples/certs/client.crt
+++ /dev/null
@@ -1,30 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIFJTCCAw0CAQEwDQYJKoZIhvcNAQELBQAwVjELMAkGA1UEBhMCRlIxCjAIBgNV
-BAgMAS4xCjAIBgNVBAcMAS4xIzAhBgNVBAoMGkFDTUUgU2lnbmluZyBBdXRob3Jp
-dHkgSW5jMQowCAYDVQQDDAEuMB4XDTE4MDQxMjIwNTEwNFoXDTI4MDQwOTIwNTEw
-NFowWzELMAkGA1UEBhMCRlIxCjAIBgNVBAgMAS4xCjAIBgNVBAcMAS4xIzAhBgNV
-BAoMGkFDTUUgU2lnbmluZyBBdXRob3JpdHkgSW5jMQ8wDQYDVQQDDAZDTElFTlQw
-ggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCp1yTtzT01KDx6qyidy4GQ
-C/NbPcOkPHYYfTPkPy4xvdfPfx0FHBHxY5iqg7V2q5dbpVH1NOablC/sWOjwMXlQ
-Hs0M48Q0SRXgJA2a4wqKMfpJ6q8fxVbFENmm8d7YA3dXq6KxXq5yDxCy7pZk/ILP
-CbOobSHxA8NI0Dla9zMA12b6pdu2d0aK6fD98FdUU56Dn8re8YOlEEtRZmUZjIkt
-yoIP+RymKttz9opbSeY4gy/na9JziS2Ij6SVwnpdFIVvMXtux61WlIe9jy/JRWXL
-dmY8qz7ooTUofgV8wd+E9iTIYwJa26C8+AV1XGuI7aQHPSQwyRm0PGJaC4Bdutkf
-eeTu5KVxIQFgAUV2a7EYR9xiSiMW2DjCjTEShZkxs13jTG4tnr6KxUYCoNIy42XH
-WVmb7TKVkhpBKM+icqFRQ/0OhqZcYl1VKlYSutu7z32jGta+AgedMagV4sSzhHJf
-U8lBReZkFVo0Bh5wgZbmgwykW1YzqoMVxOZtaoF/4NyPfIo7icmI9SfM7Jbo/0zs
-CdWgetIPM8iEwXr4W1TjDRM6VLDnEMo77HUNHqJi9YQhIy0exsBdlfJnVpPGS3fj
-jA90qoUDoEFScDmAYsD8pyrSFkE13KBClUjQKn6KdNQfRxQApf972X7tqkMbX5KQ
-Np0GKuaTHt2xxirgJroeiQIDAQABMA0GCSqGSIb3DQEBCwUAA4ICAQAT5wABZANT
-GUScEJo9NK2+nEVVCrf3YcirwB4uw2log/DamQnHeC2W7/YOQ+RAmqp0m4VX39pA
-jxUlQb546rBKL8mfzc88ReN/g/EoDEri1PKToGF+rntwtgpoj+ID2sK4kDyJRemJ
-d6lrNTIvB1zu6Ra6P5Y5Iq5swSZtigFkevwHfHACEs6EemWz8xsipBjOK+oX3sen
-N8t/KGiw0rsFXoXv/bKFaB3s9VcX8lbMG7FgPqlFCQnkEPqGSmoT8hNSqK1ZM3VK
-ueRkZVHaynZqoGIU1hglDWtObTUiz7Kgwv3MTbduoZE7hBzBSokn7aGjypdrTFuZ
-jrSKNe+sJePw7IfvuSo5Nnk5VNh26FS0C9EeeqCCAT1B/+u9M0DkmK6EPDUIly9f
-XjTlR04UaWf0EHgTroDY/KuDBR2ZKx344fr/52xZMDUoqNT2t/HW7cX2ff8vbsME
-IykmzSfVjE50gRAZMqAhDlWKR56VyuAwjpBBGAo7Zw3eyAQjVLYU0/f7/HONYchx
-wWPXCn1isRDFtzxx8WhuhtXUnSHgwnro+79W75mv9c6bkHoAH3pVbA9Wx4+hQv18
-V8SHa9CJn8absmNTSBGMXo+lFDDRnsjRDBCPElfkS5+ilvcJtfuqdtRvkR1ERil0
-N6gW1Y8iaVI7pfPeyWoM9GLTuvLmAYcuKQ==
------END CERTIFICATE-----
diff --git a/modules/platforms/nodejs/examples/certs/client.key b/modules/platforms/nodejs/examples/certs/client.key
deleted file mode 100644
index b08c63c..0000000
--- a/modules/platforms/nodejs/examples/certs/client.key
+++ /dev/null
@@ -1,51 +0,0 @@
------BEGIN RSA PRIVATE KEY-----
-MIIJKQIBAAKCAgEAqdck7c09NSg8eqsoncuBkAvzWz3DpDx2GH0z5D8uMb3Xz38d
-BRwR8WOYqoO1dquXW6VR9TTmm5Qv7Fjo8DF5UB7NDOPENEkV4CQNmuMKijH6Seqv
-H8VWxRDZpvHe2AN3V6uisV6ucg8Qsu6WZPyCzwmzqG0h8QPDSNA5WvczANdm+qXb
-tndGiunw/fBXVFOeg5/K3vGDpRBLUWZlGYyJLcqCD/kcpirbc/aKW0nmOIMv52vS
-c4ktiI+klcJ6XRSFbzF7bsetVpSHvY8vyUVly3ZmPKs+6KE1KH4FfMHfhPYkyGMC
-WtugvPgFdVxriO2kBz0kMMkZtDxiWguAXbrZH3nk7uSlcSEBYAFFdmuxGEfcYkoj
-Ftg4wo0xEoWZMbNd40xuLZ6+isVGAqDSMuNlx1lZm+0ylZIaQSjPonKhUUP9Doam
-XGJdVSpWErrbu899oxrWvgIHnTGoFeLEs4RyX1PJQUXmZBVaNAYecIGW5oMMpFtW
-M6qDFcTmbWqBf+Dcj3yKO4nJiPUnzOyW6P9M7AnVoHrSDzPIhMF6+FtU4w0TOlSw
-5xDKO+x1DR6iYvWEISMtHsbAXZXyZ1aTxkt344wPdKqFA6BBUnA5gGLA/Kcq0hZB
-NdygQpVI0Cp+inTUH0cUAKX/e9l+7apDG1+SkDadBirmkx7dscYq4Ca6HokCAwEA
-AQKCAgAul8oWvtZKzfYBhREIcPrjRJQHdONGHBwdzcM9m6OVm8onr2yLqU621Sbd
-qHJQ0vQb/TeFuHSHO9kF0sJcmoX4V+rS3W1HFsG8ksd0tVJ/5QQP4SUX5zBNsbi0
-FuiWhCTqVTi1xg6/Vai0HcX+gFN2buftjbrg/rJFOHJzpRtF4NHsczHaVdBxbYpi
-b9vVU3dKDr09+i2uS9ENzLRxlN9RQ5v4u9ODNoCryHfeYWCaIkszBp5eecSXESkK
-uKaPAIE2pvGAy6Ce/vJaK3zlj3dEoP+dJzGD6i3GJQRmXF1wgYJHwvmzaUsobDY7
-IxaRIvh7z+csxw6ZJnOo1jzp+cd0a7iMSjz6BHjQuStnrTeUfFF9ZYyq3vV9vbKY
-5hvoeKuIj7LY/g5KV223vx5aojxiJFTgJ8DyJVYAC8LiMhF61Koua/S6WTpPR6Ga
-V56sF9JVqefVFGwOl4npK0TUUFqrHo8/grkxbO5KddgUU4CW4R/PK1jHDXo9d1pj
-fTD04kfBS6gAjEYdc+Va7YO1T72Ejjw0p0H5e/0xP/4j8xE6r/Kaq0nw3RppIY8d
-EuZDMRG/fvY/8/BakJr5xHZLIt7nLppP9rH4qZKVBylTy5P0kLcenDu6yYYBqUkt
-SAwOK4al/NYfAO4kgNa16uEmNexRmS6IVKUfZn0PJbbcTB/NnQKCAQEA0XR9GqiH
-VhI4td9qitxLSsM4lukLl1f2seJKsGGkyiJ7SgMXbpe5wmamPKT/8cYlcMD0gPjL
-jKZP5CQqTVuI2Zwsy6/KH3/UlCjVp7qOHeVcHLJs95JS+hiBqGK56shNpdRWoG/g
-7z3lnZuEFY5gfEWOjXGQOJIHp3b64njDAln31zjXNpHEpv0RPsmkUi1jNxpi1XDp
-J7M1ocoB22jn6voXxP6jvg48tQqz5FPN5fGr+WqkBPwcgtf2pN+weGAc4APrTxM2
-CsWk/aI2eGte1Ednk0Ci+RthgICS+cxj6cWgSQBnesbEH9+MOsn3Tp6rPGZ6FHsZ
-PSqnVMszXrvEtwKCAQEAz5UNaITyiw+ocOM8hgMnAg3C+whCTlts6NDJcjBLax5e
-uPCqYyMJmbB78mgmu5ZCB0CUcppxm73hGKiX+/wOPaAobJcqs+mG4YtmfgjZMYZQ
-s0C1gaZFc+mAXMFaR4Gqr9EXNtwh+zaHVUupAdATS0VZ2XSv4t2bDoeDZWnGPCZb
-9wfGMuorR8po8Fv8kH3G771DqZXSXbgVgsYUdIrchGYhPRaSyhvdGcRFootwEEjv
-PJ2S3E2uJQlZKlWAnQ5SGxKMWOWPSAGSK284pR9+HlvQpFD3SH1Ue5bAQWhRsVyW
-uMKnH0XpMOmYzUcXEKy1A41IbA9ZpoQoUbTZ+bp2vwKCAQEAvd3qyg+bHtrFrZgo
-7FdlqQ/ubF40s6x5ZCbNrbXVu6YmPKEwzH+dVCvY5YBswq3roppHCeJ+IbFhGl3u
-OtGO7DQ2Jy3i+0rVWLjrdHAYA+G17g2P2Zw6u5sbbZiRD9MjD/+7xxOjwztIueYP
-hbram8wxvOYE5kL5zUR9iG4P2EHV+LL94+mfagBdcZ0354ZdOcYhcXo44FQDefW0
-WUBvewHaKijqJY6iWTqqd3/AVYENc7rHk/01myZJ3osnXPdDNY5X8AZqJrmjJoe0
-+NPb0nIn4cPl+ApqCCKFGQu+RltvQL2tEA6+GmZ6p5ANLqeGceozH/22k0vnA2Zv
-2qA7YQKCAQBnPde8WxsShMge1TXd5SV6hQOrvNDVje0d4fG/BDwOW716t9/WjK+S
-q88JojlZZQMT/k+WrC/C6O5SSE/G+PbQOZ7BW3HWp1f5R07Dcn0rf4UVkiJ0CBFU
-9BZui4/uLpSI+zJTi6qu+dDXYFj/WNCvyB9G4x0zdUpQMJ/uSWxZsC5fL5Oo8QRz
-oT0OBoIYDyZpSDWl26kUCaFROFkmGYZRp0Xyzw5UzQTrcs27aSRkRRIPkMNhJJVv
-QDYDsyDTfDLj2hbJg+r+QiHDzn5ayc39JWcgwlAq0oK5MSIPpeWzk7w2ykE6cZfo
-RtZDio7zMSKaUKNrczsAcYxoDs22wcGbAoIBAQCKlVIcL3e7exSFVRNORbnLosWh
-cYQquUZlxq6TkS14lJsGQ+pT02gAEpJktYEfiiBMG/mHXeaGQmMbAYgF7J79VcvN
-CJ1qZvvtSCSnWdMGlhs5zHzjCqk9sywtxRB8XJpp19cM7oTl4PU+ditoGTRlo0Ea
-cMuqdfg/SH/VExUyJzjyFKI5qKUnaTa83PZz4h0kt48oa4tlXzwBVKZYy/77qfQk
-ajH+THYPZ+32iDEVCpiJ9Cg8yTWGT7VxtgFRvEOBPY28T6zenl9Djl8omCOAz07a
-Ozq7QkTy4L0eCZrQ1BPHcmulHUuL+tZqKRukyBrtkTPanZEOHZ5RTfF32BVL
------END RSA PRIVATE KEY-----
diff --git a/modules/platforms/nodejs/examples/certs/keystore.jks b/modules/platforms/nodejs/examples/certs/keystore.jks
deleted file mode 100644
index 1da610f..0000000
Binary files a/modules/platforms/nodejs/examples/certs/keystore.jks and /dev/null differ
diff --git a/modules/platforms/nodejs/examples/certs/truststore.jks b/modules/platforms/nodejs/examples/certs/truststore.jks
deleted file mode 100644
index 4d25cf7..0000000
Binary files a/modules/platforms/nodejs/examples/certs/truststore.jks and /dev/null differ
diff --git a/modules/platforms/nodejs/index.js b/modules/platforms/nodejs/index.js
deleted file mode 100644
index cce86ab..0000000
--- a/modules/platforms/nodejs/index.js
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-'use strict';
-
-module.exports = require('./lib/IgniteClient');
-module.exports.ObjectType = require('./lib/ObjectType').ObjectType;
-module.exports.MapObjectType = require('./lib/ObjectType').MapObjectType;
-module.exports.CollectionObjectType = require('./lib/ObjectType').CollectionObjectType;
-module.exports.ComplexObjectType = require('./lib/ObjectType').ComplexObjectType;
-module.exports.ObjectArrayType = require('./lib/ObjectType').ObjectArrayType;
-module.exports.BinaryObject = require('./lib/BinaryObject');
-module.exports.Timestamp = require('./lib/Timestamp');
-module.exports.EnumItem = require('./lib/EnumItem');
-module.exports.Decimal = require('decimal.js');
-module.exports.Errors = require('./lib/Errors');
-module.exports.IgniteClientConfiguration = require('./lib/IgniteClientConfiguration');
-module.exports.CacheClient = require('./lib/CacheClient');
-module.exports.CacheEntry = require('./lib/CacheClient').CacheEntry;
-module.exports.CacheConfiguration = require('./lib/CacheConfiguration');
-module.exports.QueryEntity = require('./lib/CacheConfiguration').QueryEntity;
-module.exports.QueryField = require('./lib/CacheConfiguration').QueryField;
-module.exports.QueryIndex = require('./lib/CacheConfiguration').QueryIndex;
-module.exports.CacheKeyConfiguration = require('./lib/CacheConfiguration').CacheKeyConfiguration;
-module.exports.SqlQuery = require('./lib/Query').SqlQuery;
-module.exports.SqlFieldsQuery = require('./lib/Query').SqlFieldsQuery;
-module.exports.ScanQuery = require('./lib/Query').ScanQuery;
-module.exports.Cursor = require('./lib/Cursor').Cursor;
-module.exports.SqlFieldsCursor = require('./lib/Cursor').SqlFieldsCursor;
diff --git a/modules/platforms/nodejs/lib/BinaryObject.js b/modules/platforms/nodejs/lib/BinaryObject.js
deleted file mode 100644
index 478dbaf..0000000
--- a/modules/platforms/nodejs/lib/BinaryObject.js
+++ /dev/null
@@ -1,530 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-'use strict';
-
-const Util = require('util');
-const ObjectType = require('./ObjectType').ObjectType;
-const ComplexObjectType = require('./ObjectType').ComplexObjectType;
-const Errors = require('./Errors');
-const BinaryUtils = require('./internal/BinaryUtils');
-const BinaryType = require('./internal/BinaryType');
-const BinaryField = require('./internal/BinaryType').BinaryField;
-const BinaryTypeBuilder = require('./internal/BinaryType').BinaryTypeBuilder;
-const ArgumentChecker = require('./internal/ArgumentChecker');
-const Logger = require('./internal/Logger');
-
-const HEADER_LENGTH = 24;
-const VERSION = 1;
-
-// user type
-const FLAG_USER_TYPE = 0x0001;
-// schema exists
-const FLAG_HAS_SCHEMA = 0x0002;
-// object contains raw data
-const FLAG_HAS_RAW_DATA = 0x0004;
-// offsets take 1 byte
-const FLAG_OFFSET_ONE_BYTE = 0x0008;
-// offsets take 2 bytes
-const FLAG_OFFSET_TWO_BYTES = 0x0010;
-// compact footer, no field IDs
-const FLAG_COMPACT_FOOTER = 0x0020;
-
-/**
- * Class representing a complex Ignite object in the binary form.
- *
- * It corresponds to COMPOSITE_TYPE.COMPLEX_OBJECT {@link ObjectType.COMPOSITE_TYPE},
- * has mandatory type Id, which corresponds to a name of the complex type,
- * and includes optional fields.
- *
- * An instance of the BinaryObject can be obtained/created by the following ways:
- * - returned by the client when a complex object is received from Ignite cache
- * and is not deserialized to another JavaScript object.
- * - created using the public constructor. Fields may be added to such an instance using setField() method.
- * - created from a JavaScript object using static fromObject() method.
- */
-class BinaryObject {
-
- /**
- * Creates an instance of the BinaryObject without any fields.
- *
- * Fields may be added later using setField() method.
- *
- * @param {string} typeName - name of the complex type to generate the type Id.
- *
- * @return {BinaryObject} - new BinaryObject instance.
- *
- * @throws {IgniteClientError} if error.
- */
- constructor(typeName) {
- ArgumentChecker.notEmpty(typeName, 'typeName');
- this._buffer = null;
- this._fields = new Map();
- this._typeBuilder = BinaryTypeBuilder.fromTypeName(typeName);
- this._modified = false;
- this._schemaOffset = null;
- this._hasSchema = false;
- this._compactFooter = false;
- this._hasRawData = false;
- }
-
- /**
- * Creates an instance of the BinaryObject from the specified instance of JavaScript Object.
- *
- * All fields of the JavaScript Object instance with their values are added to the BinaryObject.
- * Fields may be added or removed later using setField() and removeField() methods.
- *
- * If complexObjectType parameter is specified, then the type Id is taken from it.
- * Otherwise, the type Id is generated from the name of the JavaScript Object.
- *
- * @async
- *
- * @param {object} jsObject - instance of JavaScript Object
- * which adds and initializes the fields of the BinaryObject instance.
- * @param {ComplexObjectType} [complexObjectType] - instance of complex type definition
- * which specifies non-standard mapping of the fields of the BinaryObject instance
- * to/from the Ignite types.
- *
- * @return {BinaryObject} - new BinaryObject instance.
- *
- * @throws {IgniteClientError} if error.
- */
- static async fromObject(jsObject, complexObjectType = null) {
- ArgumentChecker.notEmpty(jsObject, 'jsObject');
- ArgumentChecker.hasType(complexObjectType, 'complexObjectType', false, ComplexObjectType);
- const typeBuilder = BinaryTypeBuilder.fromObject(jsObject, complexObjectType);
- const result = new BinaryObject(typeBuilder.getTypeName());
- result._typeBuilder = typeBuilder;
- let fieldName;
- for (let field of result._typeBuilder.getFields()) {
- fieldName = field.name;
- if (jsObject && jsObject[fieldName] !== undefined) {
- result.setField(
- fieldName,
- jsObject[fieldName],
- complexObjectType ? complexObjectType._getFieldType(fieldName) : null);
- }
- else {
- throw Errors.IgniteClientError.serializationError(
- true, Util.format('field "%s" is undefined', fieldName));
- }
- }
- return result;
- }
-
- /**
- * Sets the new value of the specified field.
- * Adds the specified field, if it did not exist before.
- *
- * Optionally, specifies a type of the field.
- * If the type is not specified then during operations the Ignite client
- * will try to make automatic mapping between JavaScript types and Ignite object types -
- * according to the mapping table defined in the description of the {@link ObjectType} class.
- *
- * @param {string} fieldName - name of the field.
- * @param {*} fieldValue - new value of the field.
- * @param {ObjectType.PRIMITIVE_TYPE | CompositeType} [fieldType] - type of the field:
- * - either a type code of primitive (simple) type
- * - or an instance of class representing non-primitive (composite) type
- * - or null (or not specified) that means the type is not specified.
- *
- * @return {BinaryObject} - the same instance of BinaryObject
- *
- * @throws {IgniteClientError} if error.
- */
- setField(fieldName, fieldValue, fieldType = null) {
- ArgumentChecker.notEmpty(fieldName, 'fieldName');
- this._modified = true;
- const field = new BinaryObjectField(fieldName, fieldValue, fieldType);
- this._fields.set(field.id, field);
- this._typeBuilder.setField(fieldName, field.typeCode);
- return this;
- }
-
- /**
- * Removes the specified field.
- * Does nothing if the field does not exist.
- *
- * @param {string} fieldName - name of the field.
- *
- * @return {BinaryObject} - the same instance of BinaryObject
- *
- * @throws {IgniteClientError} if error.
- */
- removeField(fieldName) {
- ArgumentChecker.notEmpty(fieldName, 'fieldName');
- this._modified = true;
- this._fields.delete(BinaryField._calculateId(fieldName));
- this._typeBuilder.removeField(fieldName);
- return this;
- }
-
- /**
- * Checks if the specified field exists in this BinaryObject instance.
- *
- * @param {string} fieldName - name of the field.
- *
- * @return {boolean} - true if exists, false otherwise.
- *
- * @throws {IgniteClientError} if error.
- */
- hasField(fieldName) {
- ArgumentChecker.notEmpty(fieldName, 'fieldName');
- return this._fields.has(BinaryField._calculateId(fieldName));
- }
-
- /**
- * Returns a value of the specified field.
- *
- * Optionally, specifies a type of the field.
- * If the type is not specified then the Ignite client
- * will try to make automatic mapping between JavaScript types and Ignite object types -
- * according to the mapping table defined in the description of the {@link ObjectType} class.
- *
- * @async
- *
- * @param {string} fieldName - name of the field.
- * @param {ObjectType.PRIMITIVE_TYPE | CompositeType} [fieldType] - type of the field:
- * - either a type code of primitive (simple) type
- * - or an instance of class representing non-primitive (composite) type
- * - or null (or not specified) that means the type is not specified.
- *
- * @return {*} - value of the field or JavaScript undefined if the field does not exist.
- *
- * @throws {IgniteClientError} if error.
- */
- async getField(fieldName, fieldType = null) {
- ArgumentChecker.notEmpty(fieldName, 'fieldName');
- const field = this._fields.get(BinaryField._calculateId(fieldName));
- return field ? await field.getValue(fieldType) : undefined;
- }
-
- /**
- * Deserializes this BinaryObject instance into an instance of the specified complex object type.
- *
- * @async
- *
- * @param {ComplexObjectType} complexObjectType - instance of class representing complex object type.
- *
- * @return {object} - instance of the JavaScript object
- * which corresponds to the specified complex object type.
- *
- * @throws {IgniteClientError} if error.
- */
- async toObject(complexObjectType) {
- ArgumentChecker.notNull(complexObjectType, 'complexObjectType');
- ArgumentChecker.hasType(complexObjectType, 'complexObjectType', false, ComplexObjectType);
- const result = new (complexObjectType._objectConstructor);
- let binaryField;
- let fieldName;
- for (let field of this._fields.values()) {
- binaryField = this._typeBuilder.getField(field.id);
- if (!binaryField) {
- throw Errors.IgniteClientError.serializationError(
- false, Util.format('field with id "%s" can not be deserialized', field.id));
- }
- fieldName = binaryField.name;
- result[fieldName] = await field.getValue(complexObjectType._getFieldType(fieldName));
- }
- return result;
- }
-
- /**
- * Returns type name of this BinaryObject instance.
- *
- * @return {string} - type name.
- */
- getTypeName() {
- return this._typeBuilder.getTypeName();
- }
-
- /**
- * Returns names of all fields of this BinaryObject instance.
- *
- * @return {Array<string>} - names of all fields.
- *
- * @throws {IgniteClientError} if error.
- */
- getFieldNames() {
- return this._typeBuilder._schema.fieldIds.map(fieldId => {
- const field = this._typeBuilder.getField(fieldId);
- if (field) {
- return field.name;
- }
- else {
- throw Errors.IgniteClientError.internalError(
- Util.format('Field "%s" is absent in binary type fields', fieldId));
- }
- });
- }
-
- /** Private methods */
-
- /**
- * @ignore
- */
- static _isFlagSet(flags, flag) {
- return (flags & flag) === flag;
- }
-
- /**
- * @ignore
- */
- static async _fromBuffer(communicator, buffer) {
- const result = new BinaryObject(new ComplexObjectType({})._typeName);
- result._buffer = buffer;
- result._startPos = buffer.position;
- await result._read(communicator);
- return result;
- }
-
- /**
- * @ignore
- */
- async _write(communicator, buffer) {
- if (this._buffer && !this._modified) {
- buffer.writeBuffer(this._buffer.buffer, this._startPos, this._startPos + this._length);
- }
- else {
- await this._typeBuilder.finalize(communicator);
- this._startPos = buffer.position;
- buffer.position = this._startPos + HEADER_LENGTH;
- this._hasSchema = (this._fields.size > 0);
- if (this._hasSchema) {
- let field;
- // write fields
- for (field of this._fields.values()) {
- await field._writeValue(communicator, buffer, this._typeBuilder.getField(field.id).typeCode);
- }
- this._schemaOffset = buffer.position - this._startPos;
- this._offsetType = field.getOffsetType(this._startPos);
- // write schema
- for (let field of this._fields.values()) {
- field._writeOffset(buffer, this._startPos, this._offsetType);
- }
- }
- else {
- this._schemaOffset = 0;
- }
- this._length = buffer.position - this._startPos;
- this._buffer = buffer;
- // write header
- this._writeHeader();
- this._buffer.position = this._startPos + this._length;
- this._modified = false;
- }
-
- if (Logger.debug) {
- Logger.logDebug('BinaryObject._write [' + [...this._buffer.getSlice(this._startPos, this._startPos + this._length)] + ']');
- }
- }
-
- /**
- * @ignore
- */
- _writeHeader() {
- this._buffer.position = this._startPos;
- // type code
- this._buffer.writeByte(BinaryUtils.TYPE_CODE.COMPLEX_OBJECT);
- // version
- this._buffer.writeByte(VERSION);
- // flags
- let flags = FLAG_USER_TYPE;
- if (this._hasSchema) {
- flags = flags | FLAG_HAS_SCHEMA | FLAG_COMPACT_FOOTER;
- }
- if (this._offsetType === BinaryUtils.TYPE_CODE.BYTE) {
- flags = flags | FLAG_OFFSET_ONE_BYTE;
- }
- else if (this._offsetType === BinaryUtils.TYPE_CODE.SHORT) {
- flags = flags | FLAG_OFFSET_TWO_BYTES;
- }
- this._buffer.writeShort(flags);
- // type id
- this._buffer.writeInteger(this._typeBuilder.getTypeId());
- // hash code
- this._buffer.writeInteger(BinaryUtils.contentHashCode(
- this._buffer, this._startPos + HEADER_LENGTH, this._schemaOffset - 1));
- // length
- this._buffer.writeInteger(this._length);
- // schema id
- this._buffer.writeInteger(this._hasSchema ? this._typeBuilder.getSchemaId() : 0);
- // schema offset
- this._buffer.writeInteger(this._schemaOffset);
- }
-
- /**
- * @ignore
- */
- async _read(communicator) {
- await this._readHeader(communicator);
- if (this._hasSchema) {
- this._buffer.position = this._startPos + this._schemaOffset;
- const fieldOffsets = new Array();
- const fieldIds = this._typeBuilder._schema.fieldIds;
- let index = 0;
- let fieldId;
- let schemaEndOffset = this._startPos + this._length;
- if (this._hasRawData) {
- schemaEndOffset -= BinaryUtils.getSize(BinaryUtils.TYPE_CODE.INTEGER);
- }
- while (this._buffer.position < schemaEndOffset) {
- if (!this._compactFooter) {
- fieldId = this._buffer.readInteger();
- this._typeBuilder._schema.addField(fieldId);
- }
- else {
- if (index >= fieldIds.length) {
- throw Errors.IgniteClientError.serializationError(
- false, 'wrong number of fields in schema');
- }
- fieldId = fieldIds[index];
- index++;
- }
- fieldOffsets.push([fieldId, this._buffer.readNumber(this._offsetType, false)]);
- }
- fieldOffsets.sort((val1, val2) => val1[1] - val2[1]);
- let offset;
- let nextOffset;
- let field;
- for (let i = 0; i < fieldOffsets.length; i++) {
- fieldId = fieldOffsets[i][0];
- offset = fieldOffsets[i][1];
- nextOffset = i + 1 < fieldOffsets.length ? fieldOffsets[i + 1][1] : this._schemaOffset;
- field = BinaryObjectField._fromBuffer(
- communicator,this._buffer, this._startPos + offset, nextOffset - offset, fieldId);
- this._fields.set(field.id, field);
- }
- }
- this._buffer.position = this._startPos + this._length;
- }
-
- /**
- * @ignore
- */
- async _readHeader(communicator) {
- // type code
- this._buffer.readByte();
- // version
- const version = this._buffer.readByte();
- if (version !== VERSION) {
- throw Errors.IgniteClientError.internalError();
- }
- // flags
- const flags = this._buffer.readShort();
- // type id
- const typeId = this._buffer.readInteger();
- // hash code
- this._buffer.readInteger();
- // length
- this._length = this._buffer.readInteger();
- // schema id
- const schemaId = this._buffer.readInteger();
- // schema offset
- this._schemaOffset = this._buffer.readInteger();
- this._hasSchema = BinaryObject._isFlagSet(flags, FLAG_HAS_SCHEMA);
- this._compactFooter = BinaryObject._isFlagSet(flags, FLAG_COMPACT_FOOTER);
- this._hasRawData = BinaryObject._isFlagSet(flags, FLAG_HAS_RAW_DATA);
- this._offsetType = BinaryObject._isFlagSet(flags, FLAG_OFFSET_ONE_BYTE) ?
- BinaryUtils.TYPE_CODE.BYTE :
- BinaryObject._isFlagSet(flags, FLAG_OFFSET_TWO_BYTES) ?
- BinaryUtils.TYPE_CODE.SHORT :
- BinaryUtils.TYPE_CODE.INTEGER;
- this._typeBuilder = await BinaryTypeBuilder.fromTypeId(communicator, typeId, this._compactFooter ? schemaId : null);
- }
-}
-
-/**
- * @ignore
- */
-class BinaryObjectField {
- constructor(name, value = undefined, type = null) {
- this._name = name;
- this._id = BinaryField._calculateId(name);
- this._value = value;
- this._type = type;
- if (!type && value !== undefined && value !== null) {
- this._type = BinaryUtils.calcObjectType(value);
- }
- this._typeCode = null;
- if (this._type) {
- this._typeCode = BinaryUtils.getTypeCode(this._type);
- }
- }
-
- get id() {
- return this._id;
- }
-
- get typeCode() {
- return this._typeCode;
- }
-
- async getValue(type = null) {
- if (this._value === undefined || this._buffer && this._type !== type) {
- this._buffer.position = this._offset;
- this._value = await this._communicator.readObject(this._buffer, type);
- this._type = type;
- }
- return this._value;
- }
-
- getOffsetType(headerStartPos) {
- let offset = this._offset - headerStartPos;
- if (offset < 0x100) {
- return BinaryUtils.TYPE_CODE.BYTE;
- }
- else if (offset < 0x10000) {
- return BinaryUtils.TYPE_CODE.SHORT;
- }
- return BinaryUtils.TYPE_CODE.INTEGER;
- }
-
- static _fromBuffer(communicator, buffer, offset, length, id) {
- const result = new BinaryObjectField(null);
- result._id = id;
- result._communicator = communicator;
- result._buffer = buffer;
- result._offset = offset;
- result._length = length;
- return result;
- }
-
- async _writeValue(communicator, buffer, expectedTypeCode) {
- const offset = buffer.position;
- if (this._buffer && this._communicator === communicator) {
- buffer.writeBuffer(this._buffer.buffer, this._offset, this._offset + this._length);
- }
- else {
- if (this._value === undefined) {
- await this.getValue();
- }
- BinaryUtils.checkCompatibility(this._value, expectedTypeCode);
- await communicator.writeObject(buffer, this._value, this._type);
- }
- this._communicator = communicator;
- this._buffer = buffer;
- this._length = buffer.position - offset;
- this._offset = offset;
- }
-
- _writeOffset(buffer, headerStartPos, offsetType) {
- buffer.writeNumber(this._offset - headerStartPos, offsetType, false);
- }
-}
-
-module.exports = BinaryObject;
diff --git a/modules/platforms/nodejs/lib/CacheClient.js b/modules/platforms/nodejs/lib/CacheClient.js
deleted file mode 100644
index fad8e71..0000000
--- a/modules/platforms/nodejs/lib/CacheClient.js
+++ /dev/null
@@ -1,759 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-'use strict';
-
-const BinaryUtils = require('./internal/BinaryUtils');
-const ArgumentChecker = require('./internal/ArgumentChecker');
-const SqlQuery = require('./Query').SqlQuery;
-const SqlFieldsQuery = require('./Query').SqlFieldsQuery;
-const ScanQuery = require('./Query').ScanQuery;
-
-/**
- * Peek modes
- * @typedef CacheClient.PEEK_MODE
- * @enum
- * @readonly
- * @property ALL 0
- * @property NEAR 1
- * @property PRIMARY 2
- * @property BACKUP 3
- */
-const PEEK_MODE = Object.freeze({
- ALL : 0,
- NEAR : 1,
- PRIMARY : 2,
- BACKUP : 3
-});
-
-/**
- * Class representing and providing access to Ignite cache.
- *
- * The class has no public constructor. An instance of this class should be obtained
- * via the methods of {@link IgniteClient} objects.
- * One instance of this class provides access to one Ignite cache which is specified
- * during the instance obtaining and cannot be changed after that.
- *
- * There are three groups of methods in the cache client:
- * - methods to configure the cache client
- * - methods to operate with the cache using Key-Value Queries
- * - methods to operate with the cache using SQL and Scan Queries
- *
- * @hideconstructor
- */
-class CacheClient {
-
- static get PEEK_MODE() {
- return PEEK_MODE;
- }
-
- /* Methods to configure the cache client */
-
- /**
- * Specifies a type of the cache key.
- *
- * The cache client assumes that keys in all further operations with the cache
- * will have the specified type.
- * Eg. the cache client will convert keys provided as input parameters of the methods
- * to the specified object type before sending them to a server.
- *
- * After the cache client creation a type of the cache key is not specified (null).
- *
- * If the type is not specified then during operations the cache client
- * will do automatic mapping between some of the JavaScript types and object types -
- * according to the mapping table defined in the description of the {@link ObjectType} class.
- *
- * @param {ObjectType.PRIMITIVE_TYPE | CompositeType} type - type of the keys in the cache:
- * - either a type code of primitive (simple) type
- * - or an instance of class representing non-primitive (composite) type
- * - or null (means the type is not specified).
- *
- * @return {CacheClient} - the same instance of the cache client.
- *
- * @throws {IgniteClientError} if error.
- */
- setKeyType(type) {
- BinaryUtils.checkObjectType(type, 'type');
- this._keyType = type;
- return this;
- }
-
- /**
- * Specifies a type of the cache value.
- *
- * The cache client assumes that values in all further operations with the cache
- * will have the specified type.
- * Eg. the cache client will convert values provided as input parameters of the methods
- * to the specified object type before sending them to a server.
- *
- * After the cache client creation a type of the cache value is not specified (null).
- *
- * If the type is not specified then during operations the cache client
- * will do automatic mapping between some of the JavaScript types and object types -
- * according to the mapping table defined in the description of the {@link ObjectType} class.
- *
- * @param {ObjectType.PRIMITIVE_TYPE | CompositeType} type - type of the values in the cache:
- * - either a type code of primitive (simple) type
- * - or an instance of class representing non-primitive (composite) type
- * - or null (means the type is not specified).
- *
- * @return {CacheClient} - the same instance of the cache client.
- *
- * @throws {IgniteClientError} if error.
- */
- setValueType(type) {
- BinaryUtils.checkObjectType(type, 'type');
- this._valueType = type;
- return this;
- }
-
- /* Methods to operate with the cache using Key-Value Queries */
-
- /**
- * Retrieves a value associated with the specified key from the cache.
- *
- * @async
- *
- * @param {*} key - key.
- *
- * @return {Promise<*>} - value associated with the specified key, or null if it does not exist.
- *
- * @throws {IgniteClientError} if error.
- */
- async get(key) {
- return await this._writeKeyReadValueOp(BinaryUtils.OPERATION.CACHE_GET, key);
- }
-
- /**
- * Retrieves entries associated with the specified keys from the cache.
- *
- * @async
- *
- * @param {Array<*>} keys - keys.
- *
- * @return {Promise<Array<CacheEntry>>} - the retrieved entries (key-value pairs).
- * Entries with the keys which do not exist in the cache are not included into the array.
- *
- * @throws {IgniteClientError} if error.
- */
- async getAll(keys) {
- ArgumentChecker.notEmpty(keys, 'keys');
- ArgumentChecker.hasType(keys, 'keys', false, Array);
- let result = null;
- await this._communicator.send(
- BinaryUtils.OPERATION.CACHE_GET_ALL,
- async (payload) => {
- this._writeCacheInfo(payload);
- await this._writeKeys(payload, keys);
- },
- async (payload) => {
- const resultCount = payload.readInteger();
- result = new Array(resultCount);
- for (let i = 0; i < resultCount; i++) {
- result[i] = new CacheEntry(
- await this._communicator.readObject(payload, this._getKeyType()),
- await this._communicator.readObject(payload, this._getValueType()));
- }
- });
- return result;
- }
-
- /**
- * Associates the specified value with the specified key in the cache.
- *
- * Overwrites the previous value if the key exists in the cache,
- * otherwise creates new entry (key-value pair).
- *
- * @async
- *
- * @param {*} key - key.
- * @param {*} value - value to be associated with the specified key.
- *
- * @throws {IgniteClientError} if error.
- */
- async put(key, value) {
- await this._writeKeyValueOp(BinaryUtils.OPERATION.CACHE_PUT, key, value);
- }
-
- /**
- * Associates the specified values with the specified keys in the cache.
- *
- * Overwrites the previous value if a key exists in the cache,
- * otherwise creates new entry (key-value pair).
- *
- * @async
- *
- * @param {Array<CacheEntry>} entries - entries (key-value pairs) to be put into the cache.
- *
- * @throws {IgniteClientError} if error.
- */
- async putAll(entries) {
- ArgumentChecker.notEmpty(entries, 'entries');
- ArgumentChecker.hasType(entries, 'entries', true, CacheEntry);
- await this._communicator.send(
- BinaryUtils.OPERATION.CACHE_PUT_ALL,
- async (payload) => {
- this._writeCacheInfo(payload);
- payload.writeInteger(entries.length);
- for (let entry of entries) {
- await this._writeKeyValue(payload, entry.getKey(), entry.getValue());
- }
- });
- }
-
- /**
- * Checks if the specified key exists in the cache.
- *
- * @async
- *
- * @param {*} key - key to check.
- *
- * @return {Promise<boolean>} - true if the key exists, false otherwise.
- *
- * @throws {IgniteClientError} if error.
- */
- async containsKey(key) {
- return await this._writeKeyReadBooleanOp(BinaryUtils.OPERATION.CACHE_CONTAINS_KEY, key);
- }
-
- /**
- * Checks if all the specified keys exist in the cache.
- *
- * @async
- *
- * @param {Array<*>} keys - keys to check.
- *
- * @return {Promise<boolean>} - true if all the keys exist,
- * false if at least one of the keys does not exist in the cache.
- *
- * @throws {IgniteClientError} if error.
- */
- async containsKeys(keys) {
- return await this._writeKeysReadBooleanOp(BinaryUtils.OPERATION.CACHE_CONTAINS_KEYS, keys);
- }
-
- /**
- * Associates the specified value with the specified key in the cache
- * and returns the previous associated value, if any.
- *
- * Overwrites the previous value if the key exists in the cache,
- * otherwise creates new entry (key-value pair).
- *
- * @async
- *
- * @param {*} key - key.
- * @param {*} value - value to be associated with the specified key.
- *
- * @return {Promise<*>} - the previous value associated with the specified key, or null if it did not exist.
- *
- * @throws {IgniteClientError} if error.
- */
- async getAndPut(key, value) {
- return await this._writeKeyValueReadValueOp(BinaryUtils.OPERATION.CACHE_GET_AND_PUT, key, value);
- }
-
- /**
- * Associates the specified value with the specified key in the cache
- * and returns the previous associated value, if the key exists in the cache.
- * Otherwise does nothing and returns null.
- *
- * @async
- *
- * @param {*} key - key.
- * @param {*} value - value to be associated with the specified key.
- *
- * @return {Promise<*>} - the previous value associated with the specified key, or null if it did not exist.
- *
- * @throws {IgniteClientError} if error.
- */
- async getAndReplace(key, value) {
- return await this._writeKeyValueReadValueOp(BinaryUtils.OPERATION.CACHE_GET_AND_REPLACE, key, value);
- }
-
- /**
- * Removes the cache entry with the specified key
- * and returns the last associated value, if any.
- *
- * @async
- *
- * @param {*} key - key of the entry to be removed.
- *
- * @return {Promise<*>} - the last value associated with the specified key, or null if it did not exist.
- *
- * @throws {IgniteClientError} if error.
- */
- async getAndRemove(key) {
- return await this._writeKeyReadValueOp(BinaryUtils.OPERATION.CACHE_GET_AND_REMOVE, key);
- }
-
- /**
- * Creates new entry (key-value pair) if the specified key does not exist in the cache.
- * Otherwise does nothing.
- *
- * @async
- *
- * @param {*} key - key.
- * @param {*} value - value to be associated with the specified key.
- *
- * @return {Promise<boolean>} - true if the operation has been done, false otherwise.
- *
- * @throws {IgniteClientError} if error.
- */
- async putIfAbsent(key, value) {
- return await this._writeKeyValueReadBooleanOp(BinaryUtils.OPERATION.CACHE_PUT_IF_ABSENT, key, value);
- }
-
- /**
- * Creates new entry (key-value pair) if the specified key does not exist in the cache.
- * Otherwise returns the current value associated with the existing key.
- *
- * @async
- *
- * @param {*} key - key.
- * @param {*} value - value to be associated with the specified key.
- *
- * @return {Promise<*>} - the current value associated with the key if it already exists in the cache,
- * null if the new entry is created.
- *
- * @throws {IgniteClientError} if error.
- */
- async getAndPutIfAbsent(key, value) {
- return await this._writeKeyValueReadValueOp(BinaryUtils.OPERATION.CACHE_GET_AND_PUT_IF_ABSENT, key, value);
- }
-
- /**
- * Associates the specified value with the specified key, if the key exists in the cache.
- * Otherwise does nothing.
- *
- * @async
- *
- * @param {*} key - key.
- * @param {*} value - value to be associated with the specified key.
- *
- * @return {Promise<boolean>} - true if the operation has been done, false otherwise.
- *
- * @throws {IgniteClientError} if error.
- */
- async replace(key, value) {
- return await this._writeKeyValueReadBooleanOp(BinaryUtils.OPERATION.CACHE_REPLACE, key, value);
- }
-
- /**
- * Associates the new value with the specified key, if the key exists in the cache
- * and the current value equals to the provided one.
- * Otherwise does nothing.
- *
- * @async
- *
- * @param {*} key - key.
- * @param {*} value - value to be compared with the current value associated with the specified key.
- * @param {*} newValue - new value to be associated with the specified key.
- *
- * @return {Promise<boolean>} - true if the operation has been done, false otherwise.
- *
- * @throws {IgniteClientError} if error.
- */
- async replaceIfEquals(key, value, newValue) {
- ArgumentChecker.notNull(key, 'key');
- ArgumentChecker.notNull(value, 'value');
- ArgumentChecker.notNull(newValue, 'newValue');
- let result;
- await this._communicator.send(
- BinaryUtils.OPERATION.CACHE_REPLACE_IF_EQUALS,
- async (payload) => {
- this._writeCacheInfo(payload);
- await this._writeKeyValue(payload, key, value);
- await this._communicator.writeObject(payload, newValue, this._getValueType());
- },
- async (payload) => {
- result = payload.readBoolean();
- });
- return result;
- }
-
- /**
- * Removes all entries from the cache, without notifying listeners and cache writers.
- *
- * @async
- *
- * @throws {IgniteClientError} if error.
- */
- async clear() {
- await this._communicator.send(
- BinaryUtils.OPERATION.CACHE_CLEAR,
- async (payload) => {
- this._writeCacheInfo(payload);
- });
- }
-
- /**
- * Removes entry with the specified key from the cache, without notifying listeners and cache writers.
- *
- * @async
- *
- * @param {*} key - key to be removed.
- *
- * @throws {IgniteClientError} if error.
- */
- async clearKey(key) {
- await this._writeKeyOp(BinaryUtils.OPERATION.CACHE_CLEAR_KEY, key);
- }
-
- /**
- * Removes entries with the specified keys from the cache, without notifying listeners and cache writers.
- *
- * @async
- *
- * @param {Array<*>} keys - keys to be removed.
- *
- * @throws {IgniteClientError} if error.
- */
- async clearKeys(keys) {
- await this._writeKeysOp(BinaryUtils.OPERATION.CACHE_CLEAR_KEYS, keys);
- }
-
- /**
- * Removes entry with the specified key from the cache, notifying listeners and cache writers.
- *
- * @async
- *
- * @param {*} key - key to be removed.
- *
- * @return {Promise<boolean>} - true if the operation has been done, false otherwise.
- *
- * @throws {IgniteClientError} if error.
- */
- async removeKey(key) {
- return await this._writeKeyReadBooleanOp(BinaryUtils.OPERATION.CACHE_REMOVE_KEY, key);
- }
-
- /**
- * Removes entry with the specified key from the cache, if the current value equals to the provided one.
- * Notifies listeners and cache writers.
- *
- * @async
- *
- * @param {*} key - key to be removed.
- * @param {*} value - value to be compared with the current value associated with the specified key.
- *
- * @return {Promise<boolean>} - true if the operation has been done, false otherwise.
- *
- * @throws {IgniteClientError} if error.
- */
- async removeIfEquals(key, value) {
- return await this._writeKeyValueReadBooleanOp(BinaryUtils.OPERATION.CACHE_REMOVE_IF_EQUALS, key, value);
- }
-
- /**
- * Removes entries with the specified keys from the cache, notifying listeners and cache writers.
- *
- * @async
- *
- * @param {Array<*>} keys - keys to be removed.
- *
- * @throws {IgniteClientError} if error.
- */
- async removeKeys(keys) {
- await this._writeKeysOp(BinaryUtils.OPERATION.CACHE_REMOVE_KEYS, keys);
- }
-
- /**
- * Removes all entries from the cache, notifying listeners and cache writers.
- *
- * @async
- *
- * @throws {IgniteClientError} if error.
- */
- async removeAll() {
- await this._communicator.send(
- BinaryUtils.OPERATION.CACHE_REMOVE_ALL,
- async (payload) => {
- this._writeCacheInfo(payload);
- });
- }
-
- /**
- * Returns the number of the entries in the cache.
- *
- * @async
- *
- * @param {...CacheClient.PEEK_MODE} [peekModes] - peek modes.
- *
- * @return {Promise<number>} - the number of the entries in the cache.
- *
- * @throws {IgniteClientError} if error.
- */
- async getSize(...peekModes) {
- ArgumentChecker.hasValueFrom(peekModes, 'peekModes', true, CacheClient.PEEK_MODE);
- let result;
- await this._communicator.send(
- BinaryUtils.OPERATION.CACHE_GET_SIZE,
- async (payload) => {
- this._writeCacheInfo(payload);
- payload.writeInteger(peekModes.length);
- for (let mode of peekModes) {
- payload.writeByte(mode);
- }
- },
- async (payload) => {
- result = payload.readLong().toNumber();
- });
- return result;
- }
-
- /* Methods to operate with the cache using SQL and Scan Queries */
-
- /**
- * Starts an SQL or Scan query operation.
- *
- * @async
- *
- * @param {SqlQuery | SqlFieldsQuery | ScanQuery} query - query to be executed.
- *
- * @return {Promise<Cursor>} - cursor to obtain the results of the query operation:
- * - {@link SqlFieldsCursor} in case of {@link SqlFieldsQuery} query
- * - {@link Cursor} in case of other types of query
- *
- * @throws {IgniteClientError} if error.
- */
- async query(query) {
- ArgumentChecker.notNull(query, 'query');
- ArgumentChecker.hasType(query, 'query', false, SqlQuery, SqlFieldsQuery, ScanQuery);
-
- let value = null;
- await this._communicator.send(
- query._operation,
- async (payload) => {
- this._writeCacheInfo(payload);
- await query._write(this._communicator, payload);
- },
- async (payload) => {
- value = await query._getCursor(this._communicator, payload, this._keyType, this._valueType);
- });
- return value;
- }
-
- /** Private methods */
-
- /**
- * @ignore
- */
- constructor(name, config, communicator) {
- this._name = name;
- this._cacheId = CacheClient._calculateId(this._name);
- this._config = config;
- this._keyType = null;
- this._valueType = null;
- this._communicator = communicator;
- }
-
- /**
- * @ignore
- */
- static _calculateId(name) {
- return BinaryUtils.hashCode(name);
- }
-
- /**
- * @ignore
- */
- _writeCacheInfo(payload) {
- payload.writeInteger(this._cacheId);
- payload.writeByte(0);
- }
-
- /**
- * @ignore
- */
- async _writeKeyValue(payload, key, value) {
- await this._communicator.writeObject(payload, key, this._getKeyType());
- await this._communicator.writeObject(payload, value, this._getValueType());
- }
-
- /**
- * @ignore
- */
- async _writeKeys(payload, keys) {
- payload.writeInteger(keys.length);
- for (let key of keys) {
- await this._communicator.writeObject(payload, key, this._getKeyType());
- }
- }
-
- /**
- * @ignore
- */
- _getKeyType() {
- return this._keyType;
- }
-
- /**
- * @ignore
- */
- _getValueType() {
- return this._valueType;
- }
-
- /**
- * @ignore
- */
- async _writeKeyValueOp(operation, key, value, payloadReader = null) {
- ArgumentChecker.notNull(key, 'key');
- ArgumentChecker.notNull(value, 'value');
- await this._communicator.send(
- operation,
- async (payload) => {
- this._writeCacheInfo(payload);
- await this._writeKeyValue(payload, key, value);
- },
- payloadReader);
- }
-
- /**
- * @ignore
- */
- async _writeKeyValueReadValueOp(operation, key, value) {
- let result = null;
- await this._writeKeyValueOp(
- operation, key, value,
- async (payload) => {
- result = await this._communicator.readObject(payload, this._getValueType());
- });
- return result;
- }
-
- /**
- * @ignore
- */
- async _writeKeyValueReadBooleanOp(operation, key, value) {
- let result = false;
- await this._writeKeyValueOp(
- operation, key, value,
- async (payload) => {
- result = payload.readBoolean();
- });
- return result;
- }
-
- /**
- * @ignore
- */
- async _writeKeyOp(operation, key, payloadReader = null) {
- ArgumentChecker.notNull(key, 'key');
- await this._communicator.send(
- operation,
- async (payload) => {
- this._writeCacheInfo(payload);
- await this._communicator.writeObject(payload, key, this._getKeyType());
- },
- payloadReader);
- }
-
- /**
- * @ignore
- */
- async _writeKeyReadValueOp(operation, key) {
- let value = null;
- await this._writeKeyOp(
- operation, key,
- async (payload) => {
- value = await this._communicator.readObject(payload, this._getValueType());
- });
- return value;
- }
-
- /**
- * @ignore
- */
- async _writeKeyReadBooleanOp(operation, key) {
- let result = false;
- await this._writeKeyOp(
- operation, key,
- async (payload) => {
- result = payload.readBoolean();
- });
- return result;
- }
-
- /**
- * @ignore
- */
- async _writeKeysOp(operation, keys, payloadReader = null) {
- ArgumentChecker.notEmpty(keys, 'keys');
- ArgumentChecker.hasType(keys, 'keys', false, Array);
- await this._communicator.send(
- operation,
- async (payload) => {
- this._writeCacheInfo(payload);
- await this._writeKeys(payload, keys);
- },
- payloadReader);
- }
-
- /**
- * @ignore
- */
- async _writeKeysReadBooleanOp(operation, keys) {
- let result = false;
- await this._writeKeysOp(
- operation, keys,
- async (payload) => {
- result = payload.readBoolean();
- });
- return result;
- }
-}
-
-/**
- * A cache entry (key-value pair).
- */
-class CacheEntry {
-
- /**
- * Public constructor.
- *
- * @param {*} key - key corresponding to this entry.
- * @param {*} value - value associated with the key.
- *
- * @return {CacheEntry} - new CacheEntry instance
- */
- constructor(key, value) {
- this._key = key;
- this._value = value;
- }
-
- /**
- * Returns the key corresponding to this entry.
- *
- * @return {*} - the key corresponding to this entry.
- */
- getKey() {
- return this._key;
- }
-
- /**
- * Returns the value corresponding to this entry.
- *
- * @return {*} - the value corresponding to this entry.
- */
- getValue() {
- return this._value;
- }
-}
-
-module.exports = CacheClient;
-module.exports.CacheEntry = CacheEntry;
diff --git a/modules/platforms/nodejs/lib/CacheConfiguration.js b/modules/platforms/nodejs/lib/CacheConfiguration.js
deleted file mode 100644
index 75f0155..0000000
--- a/modules/platforms/nodejs/lib/CacheConfiguration.js
+++ /dev/null
@@ -1,1734 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-'use strict';
-
-const ComplexObjectType = require('./ObjectType').ComplexObjectType;
-const ObjectArrayType = require('./ObjectType').ObjectArrayType;
-const BinaryUtils = require('./internal/BinaryUtils');
-const BinaryCommunicator = require('./internal/BinaryCommunicator');
-const ArgumentChecker = require('./internal/ArgumentChecker');
-const Errors = require('./Errors');
-
-/**
- * Class representing Cache Key part of Ignite {@link CacheConfiguration}.
- *
- * All configuration settings are optional and have defaults which are defined on a server side.
- *
- * See Apache Ignite documentation for details of every configuration setting.
- */
-class CacheKeyConfiguration {
-
- /**
- * Public constructor.
- *
- * @param {string} [typeName=null]
- * @param {string} [affinityKeyFieldName=null]
- *
- * @return {CacheKeyConfiguration} - new CacheKeyConfiguration instance.
- */
- constructor(typeName = null, affinityKeyFieldName = null) {
- this._typeName = typeName;
- this._affinityKeyFieldName = affinityKeyFieldName;
- }
-
- /**
- *
- *
- * @param {string} typeName
- *
- * @return {CacheKeyConfiguration} - the same instance of the CacheKeyConfiguration.
- */
- setTypeName(typeName) {
- this._typeName = typeName;
- return this;
- }
-
- /**
- *
- *
- * @return {string}
- */
- getTypeName() {
- return this._typeName;
- }
-
- /**
- *
- *
- * @param {string} affinityKeyFieldName
- *
- * @return {CacheKeyConfiguration} - the same instance of the CacheKeyConfiguration.
- */
- setAffinityKeyFieldName(affinityKeyFieldName) {
- this._affinityKeyFieldName = affinityKeyFieldName;
- return this;
- }
-
- /**
- *
- *
- * @return {string}
- */
- getAffinityKeyFieldName() {
- return this._affinityKeyFieldName;
- }
-
- /** Private methods */
-
- /**
- * @ignore
- */
- async _write(communicator, buffer) {
- BinaryCommunicator.writeString(buffer, this._typeName);
- BinaryCommunicator.writeString(buffer, this._affinityKeyFieldName);
- }
-
- /**
- * @ignore
- */
- async _read(communicator, buffer) {
- this._typeName = BinaryCommunicator.readString(buffer);
- this._affinityKeyFieldName = BinaryCommunicator.readString(buffer);
- }
-}
-
-/**
- * Class representing one Query Entity element of Ignite {@link CacheConfiguration}.
- *
- * All configuration settings are optional and have defaults which are defined on a server side.
- *
- * See Apache Ignite documentation for details of every configuration setting.
- */
-class QueryEntity {
-
- /**
- * Public constructor.
- *
- * @return {QueryEntity} - new QueryEntity instance.
- */
- constructor() {
- this._keyTypeName = null;
- this._valueTypeName = null;
- this._tableName = null;
- this._keyFieldName = null;
- this._valueFieldName = null;
- this._fields = null;
- this._aliases = null;
- this._indexes = null;
- }
-
- /**
- *
- *
- * @param {string} keyTypeName
- *
- * @return {QueryEntity} - the same instance of the QueryEntity.
- */
- setKeyTypeName(keyTypeName) {
- this._keyTypeName = keyTypeName;
- return this;
- }
-
- /**
- *
- *
- * @return {string}
- */
- getKeyTypeName() {
- return this._keyTypeName;
- }
-
- /**
- *
- *
- * @param {string} valueTypeName
- *
- * @return {QueryEntity} - the same instance of the QueryEntity.
- */
- setValueTypeName(valueTypeName) {
- this._valueTypeName = valueTypeName;
- return this;
- }
-
- /**
- *
- *
- * @return {string}
- */
- getValueTypeName() {
- return this._valueTypeName;
- }
-
- /**
- *
- *
- * @param {string} tableName
- *
- * @return {QueryEntity} - the same instance of the QueryEntity.
- */
- setTableName(tableName) {
- this._tableName = tableName;
- return this;
- }
-
- /**
- *
- *
- * @return {string}
- */
- getTableName() {
- return this._tableName;
- }
-
- /**
- *
- *
- * @param {string} keyFieldName
- *
- * @return {QueryEntity} - the same instance of the QueryEntity.
- */
- setKeyFieldName(keyFieldName) {
- this._keyFieldName = keyFieldName;
- return this;
- }
-
- /**
- *
- *
- * @return {string}
- */
- getKeyFieldName() {
- return this._keyFieldName;
- }
-
- /**
- *
- *
- * @param {string} valueFieldName
- *
- * @return {QueryEntity} - the same instance of the QueryEntity.
- */
- setValueFieldName(valueFieldName) {
- this._valueFieldName = valueFieldName;
- return this;
- }
-
- /**
- *
- *
- * @return {string}
- */
- getValueFieldName() {
- return this._valueFieldName;
- }
-
- /**
- *
- *
- * @param {Array<QueryField>} fields
- *
- * @return {QueryEntity} - the same instance of the QueryEntity.
- */
- setFields(fields) {
- this._fields = fields;
- return this;
- }
-
- /**
- *
- *
- * @return {Array<QueryField>}
- */
- getFields() {
- return this._fields;
- }
-
- /**
- *
- *
- * @param {Map<string, string>} aliases
- *
- * @return {QueryEntity} - the same instance of the QueryEntity.
- */
- setAliases(aliases) {
- this._aliases = aliases;
- return this;
- }
-
- /**
- *
- *
- * @return {Map<string, string>}
- */
- getAliases() {
- return this._aliases;
- }
-
- /**
- *
- *
- * @param {Array<QueryIndex>} indexes
- *
- * @return {QueryEntity} - the same instance of the QueryEntity.
- */
- setIndexes(indexes) {
- this._indexes = indexes;
- return this;
- }
-
- /**
- *
- *
- * @return {Array<QueryIndex>}
- */
- getIndexes() {
- return this._indexes;
- }
-
- /** Private methods */
-
- /**
- * @ignore
- */
- async _write(communicator, buffer) {
- BinaryCommunicator.writeString(buffer, this._keyTypeName);
- BinaryCommunicator.writeString(buffer, this._valueTypeName);
- BinaryCommunicator.writeString(buffer, this._tableName);
- BinaryCommunicator.writeString(buffer, this._keyFieldName);
- BinaryCommunicator.writeString(buffer, this._valueFieldName);
- await this._writeSubEntities(communicator, buffer, this._fields);
- await this._writeAliases(communicator, buffer);
- await this._writeSubEntities(communicator, buffer, this._indexes);
- }
-
- /**
- * @ignore
- */
- async _writeAliases(communicator, buffer) {
- const length = this._aliases ? this._aliases.size : 0;
- buffer.writeInteger(length);
- if (length > 0) {
- for (let [key, value] of this._aliases.entries()) {
- BinaryCommunicator.writeString(buffer, key);
- BinaryCommunicator.writeString(buffer, value);
- }
- }
- }
-
- /**
- * @ignore
- */
- async _writeSubEntities(communicator, buffer, entities) {
- const length = entities ? entities.length : 0;
- buffer.writeInteger(length);
- if (length > 0) {
- for (let entity of entities) {
- await entity._write(communicator, buffer);
- }
- }
- }
-
- /**
- * @ignore
- */
- async _read(communicator, buffer) {
- this._keyTypeName = await communicator.readObject(buffer);
- this._valueTypeName = await communicator.readObject(buffer);
- this._tableName = await communicator.readObject(buffer);
- this._keyFieldName = await communicator.readObject(buffer);
- this._valueFieldName = await communicator.readObject(buffer);
- this._fields = await this._readSubEntities(communicator, buffer, QueryField);
- await this._readAliases(communicator, buffer);
- this._indexes = await this._readSubEntities(communicator, buffer, QueryIndex);
- }
-
- /**
- * @ignore
- */
- async _readSubEntities(communicator, buffer, objectConstructor) {
- const length = buffer.readInteger(buffer);
- const result = new Array(length);
- if (length > 0) {
- let res;
- for (let i = 0; i < length; i++) {
- res = new objectConstructor();
- await res._read(communicator, buffer);
- result[i] = res;
- }
- }
- return result;
- }
-
- /**
- * @ignore
- */
- async _readAliases(communicator, buffer) {
- const length = buffer.readInteger(buffer);
- this._aliases = new Map();
- if (length > 0) {
- let res;
- for (let i = 0; i < length; i++) {
- this._aliases.set(await communicator.readObject(buffer), await communicator.readObject(buffer));
- }
- }
- }
-}
-
-/**
- * Class representing one Query Field element of {@link QueryEntity} of Ignite {@link CacheConfiguration}.
- *
- * All configuration settings are optional and have defaults which are defined on a server side.
- *
- * See Apache Ignite documentation for details of every configuration setting.
- */
-class QueryField {
-
- /**
- * Public constructor.
- *
- * @param {string} [name=null]
- * @param {string} [typeName=null]
- *
- * @return {QueryField} - new QueryField instance.
- */
- constructor(name = null, typeName = null) {
- this._name = name;
- this._typeName = typeName;
- this._isKeyField = false;
- this._isNotNull = false;
- this._defaultValue = undefined;
- this._precision = -1;
- this._scale = -1;
- this._valueType = null;
- this._communicator = null;
- this._buffer = null;
- this._index = null;
- }
-
- /**
- *
- *
- * @param {string} name
- *
- * @return {QueryField} - the same instance of the QueryField.
- */
- setName(name) {
- this._name = name;
- return this;
- }
-
- /**
- *
- *
- * @return {string}
- */
- getName() {
- return this._name;
- }
-
- /**
- *
- *
- * @param {string} typeName
- *
- * @return {QueryField} - the same instance of the QueryField.
- */
- setTypeName(typeName) {
- this._typeName = typeName;
- return this;
- }
-
- /**
- *
- *
- * @return {string}
- */
- getTypeName() {
- return this._typeName;
- }
-
- /**
- *
- *
- * @param {boolean} isKeyField
- *
- * @return {QueryField} - the same instance of the QueryField.
- */
- setIsKeyField(isKeyField) {
- this._isKeyField = isKeyField;
- return this;
- }
-
- /**
- *
- *
- * @return {boolean}
- */
- getIsKeyField() {
- return this._isKeyField;
- }
-
- /**
- *
- *
- * @param {boolean} isNotNull
- *
- * @return {QueryField} - the same instance of the QueryField.
- */
- setIsNotNull(isNotNull) {
- this._isNotNull = isNotNull;
- return this;
- }
-
- /**
- *
- *
- * @return {boolean}
- */
- getIsNotNull() {
- return this._isNotNull;
- }
-
- /**
- *
- *
- * @param {*} defaultValue
- * @param {ObjectType.PRIMITIVE_TYPE | CompositeType} [valueType=null] - type of the default value:
- * - either a type code of primitive (simple) type
- * - or an instance of class representing non-primitive (composite) type
- * - or null (or not specified) that means the type is not specified
- *
- * @return {QueryField} - the same instance of the QueryField.
- */
- setDefaultValue(defaultValue, valueType = null) {
- this._defaultValue = defaultValue;
- this._valueType = valueType;
- return this;
- }
-
- /**
- *
- *
- * @param {ObjectType.PRIMITIVE_TYPE | CompositeType} [valueType=null] - type of the default value:
- * - either a type code of primitive (simple) type
- * - or an instance of class representing non-primitive (composite) type
- * - or null (or not specified) that means the type is not specified
- *
- * @async
- *
- * @return {*}
- */
- async getDefaultValue(valueType = null) {
- if (this._defaultValue === undefined) {
- if (this._buffer) {
- const position = this._buffer.position;
- this._buffer.position = this._index;
- const result = await this._communicator.readObject(this._buffer, valueType);
- this._buffer.position = position;
- return result;
- }
- else {
- return null;
- }
- }
- else {
- return this._defaultValue;
- }
- }
-
- /**
- *
- *
- * @param {number} precision
- *
- * @return {QueryField} - the same instance of the QueryField.
- */
- setPrecision(precision) {
- ArgumentChecker.isInteger(precision, 'precision');
- this._precision = precision;
- return this;
- }
-
- /**
- *
- *
- * @return {number}
- */
- getPrecision() {
- return this._precision;
- }
-
- /**
- *
- *
- * @param {number} scale
- *
- * @return {QueryField} - the same instance of the QueryField.
- */
- setScale(scale) {
- ArgumentChecker.isInteger(scale, 'scale');
- this._scale = scale;
- return this;
- }
-
- /**
- *
- *
- * @return {number}
- */
- getScale() {
- return this._scale;
- }
-
- /** Private methods */
-
- /**
- * @ignore
- */
- async _write(communicator, buffer) {
- BinaryCommunicator.writeString(buffer, this._name);
- BinaryCommunicator.writeString(buffer, this._typeName);
- buffer.writeBoolean(this._isKeyField);
- buffer.writeBoolean(this._isNotNull);
- await communicator.writeObject(buffer, this._defaultValue ? this._defaultValue : null, this._valueType);
- buffer.writeInteger(this._precision);
- buffer.writeInteger(this._scale);
- }
-
- /**
- * @ignore
- */
- async _read(communicator, buffer) {
- this._name = await communicator.readObject(buffer);
- this._typeName = await communicator.readObject(buffer);
- this._isKeyField = buffer.readBoolean();
- this._isNotNull = buffer.readBoolean();
- this._defaultValue = undefined;
- this._communicator = communicator;
- this._buffer = buffer;
- this._index = buffer.position;
- await communicator.readObject(buffer);
- this._precision = buffer.readInteger();
- this._scale = buffer.readInteger();
- }
-}
-
-/**
- *
- * @typedef QueryIndex.INDEX_TYPE
- * @enum
- * @readonly
- * @property SORTED 0
- * @property FULLTEXT 1
- * @property GEOSPATIAL 2
- */
- const INDEX_TYPE = Object.freeze({
- SORTED : 0,
- FULLTEXT : 1,
- GEOSPATIAL : 2
-});
-
-/**
- * Class representing one Query Index element of {@link QueryEntity} of Ignite {@link CacheConfiguration}.
- *
- * All configuration settings are optional and have defaults which are defined on a server side.
- *
- * See Apache Ignite documentation for details of every configuration setting.
- */
-class QueryIndex {
-
- /**
- * Public constructor.
- *
- * @param {string} [name=null]
- * @param {string} [typeName=QueryIndex.INDEX_TYPE.SORTED]
- *
- * @return {QueryIndex} - new QueryIndex instance.
- */
- constructor(name = null, type = QueryIndex.INDEX_TYPE.SORTED) {
- this._name = name;
- this.setType(type);
- this._inlineSize = -1;
- this._fields = null;
- }
-
- static get INDEX_TYPE() {
- return INDEX_TYPE;
- }
-
- /**
- *
- *
- * @param {string} name
- *
- * @return {QueryIndex} - the same instance of the QueryIndex.
- */
- setName(name) {
- this._name = name;
- return this;
- }
-
- /**
- *
- *
- * @return {string}
- */
- getName() {
- return this._name;
- }
-
- /**
- *
- *
- * @param {QueryIndex.INDEX_TYPE} type
- *
- * @return {QueryIndex} - the same instance of the QueryIndex.
- *
- * @throws {IgniteClientError} if error.
- */
- setType(type) {
- ArgumentChecker.hasValueFrom(type, 'type', false, QueryIndex.INDEX_TYPE);
- this._type = type;
- return this;
- }
-
- /**
- *
- *
- * @return {QueryIndex.INDEX_TYPE}
- */
- getType() {
- return this._type;
- }
-
- /**
- *
- *
- * @param {number} inlineSize
- *
- * @return {QueryIndex} - the same instance of the QueryIndex.
- */
- setInlineSize(inlineSize) {
- this._inlineSize = inlineSize;
- return this;
- }
-
- /**
- *
- *
- * @return {number}
- */
- getInlineSize() {
- return this._inlineSize;
- }
-
- /**
- *
- *
- * @param {Map<string, boolean>} fields
- *
- * @return {QueryIndex} - the same instance of the QueryIndex.
- */
- setFields(fields) {
- this._fields = fields;
- return this;
- }
-
- /**
- *
- *
- * @return {Map<string, boolean>}
- */
- getFields() {
- return this._fields;
- }
-
- /** Private methods */
-
- /**
- * @ignore
- */
- async _write(communicator, buffer) {
- BinaryCommunicator.writeString(buffer, this._name);
- buffer.writeByte(this._type);
- buffer.writeInteger(this._inlineSize);
- // write fields
- const length = this._fields ? this._fields.size : 0;
- buffer.writeInteger(length);
- if (length > 0) {
- for (let [key, value] of this._fields.entries()) {
- BinaryCommunicator.writeString(buffer, key);
- buffer.writeBoolean(value);
- }
- }
- }
-
- /**
- * @ignore
- */
- async _read(communicator, buffer) {
- this._name = await communicator.readObject(buffer);
- this._type = buffer.readByte();
- this._inlineSize = buffer.readInteger();
- // read fields
- const length = buffer.readInteger(buffer);
- this._fields = new Map();
- if (length > 0) {
- let res;
- for (let i = 0; i < length; i++) {
- this._fields.set(await communicator.readObject(buffer), buffer.readBoolean());
- }
- }
- }
-}
-
-const PROP_NAME = 0;
-const PROP_CACHE_MODE = 1;
-const PROP_ATOMICITY_MODE = 2;
-const PROP_BACKUPS = 3;
-const PROP_WRITE_SYNCHRONIZATION_MODE = 4;
-const PROP_COPY_ON_READ = 5;
-const PROP_READ_FROM_BACKUP = 6;
-const PROP_DATA_REGION_NAME = 100;
-const PROP_IS_ONHEAP_CACHE_ENABLED = 101;
-const PROP_QUERY_ENTITY = 200;
-const PROP_QUERY_PARALLELISM = 201;
-const PROP_QUERY_DETAIL_METRICS_SIZE = 202;
-const PROP_SQL_SCHEMA = 203;
-const PROP_SQL_INDEX_INLINE_MAX_SIZE = 204;
-const PROP_SQL_ESCAPE_ALL = 205;
-const PROP_MAX_QUERY_ITERATORS = 206;
-const PROP_REBALANCE_MODE = 300;
-const PROP_REBALANCE_DELAY = 301;
-const PROP_REBALANCE_TIMEOUT = 302;
-const PROP_REBALANCE_BATCH_SIZE = 303;
-const PROP_REBALANCE_BATCHES_PREFETCH_COUNT = 304;
-const PROP_REBALANCE_ORDER = 305;
-const PROP_REBALANCE_THROTTLE = 306;
-const PROP_GROUP_NAME = 400;
-const PROP_CACHE_KEY_CONFIGURATION = 401;
-const PROP_DEFAULT_LOCK_TIMEOUT = 402;
-const PROP_MAX_CONCURRENT_ASYNC_OPS = 403;
-const PROP_PARTITION_LOSS_POLICY = 404;
-const PROP_EAGER_TTL = 405;
-const PROP_STATISTICS_ENABLED = 406;
-
-const PROP_TYPES = Object.freeze({
- [PROP_NAME] : BinaryUtils.TYPE_CODE.STRING,
- [PROP_CACHE_MODE] : BinaryUtils.TYPE_CODE.INTEGER,
- [PROP_ATOMICITY_MODE] : BinaryUtils.TYPE_CODE.INTEGER,
- [PROP_BACKUPS] : BinaryUtils.TYPE_CODE.INTEGER,
- [PROP_WRITE_SYNCHRONIZATION_MODE] : BinaryUtils.TYPE_CODE.INTEGER,
- [PROP_COPY_ON_READ] : BinaryUtils.TYPE_CODE.BOOLEAN,
- [PROP_READ_FROM_BACKUP] : BinaryUtils.TYPE_CODE.BOOLEAN,
- [PROP_DATA_REGION_NAME] : BinaryUtils.TYPE_CODE.STRING,
- [PROP_IS_ONHEAP_CACHE_ENABLED] : BinaryUtils.TYPE_CODE.BOOLEAN,
- [PROP_QUERY_ENTITY] : new ObjectArrayType(new ComplexObjectType(new QueryEntity())),
- [PROP_QUERY_PARALLELISM] : BinaryUtils.TYPE_CODE.INTEGER,
- [PROP_QUERY_DETAIL_METRICS_SIZE] : BinaryUtils.TYPE_CODE.INTEGER,
- [PROP_SQL_SCHEMA] : BinaryUtils.TYPE_CODE.STRING,
- [PROP_SQL_INDEX_INLINE_MAX_SIZE] : BinaryUtils.TYPE_CODE.INTEGER,
- [PROP_SQL_ESCAPE_ALL] : BinaryUtils.TYPE_CODE.BOOLEAN,
- [PROP_MAX_QUERY_ITERATORS] : BinaryUtils.TYPE_CODE.INTEGER,
- [PROP_REBALANCE_MODE] : BinaryUtils.TYPE_CODE.INTEGER,
- [PROP_REBALANCE_DELAY] : BinaryUtils.TYPE_CODE.LONG,
- [PROP_REBALANCE_TIMEOUT] : BinaryUtils.TYPE_CODE.LONG,
- [PROP_REBALANCE_BATCH_SIZE] : BinaryUtils.TYPE_CODE.INTEGER,
- [PROP_REBALANCE_BATCHES_PREFETCH_COUNT] : BinaryUtils.TYPE_CODE.LONG,
- [PROP_REBALANCE_ORDER] : BinaryUtils.TYPE_CODE.INTEGER,
- [PROP_REBALANCE_THROTTLE] : BinaryUtils.TYPE_CODE.LONG,
- [PROP_GROUP_NAME] : BinaryUtils.TYPE_CODE.STRING,
- [PROP_CACHE_KEY_CONFIGURATION] : new ObjectArrayType(new ComplexObjectType(new CacheKeyConfiguration())),
- [PROP_DEFAULT_LOCK_TIMEOUT] : BinaryUtils.TYPE_CODE.LONG,
- [PROP_MAX_CONCURRENT_ASYNC_OPS] : BinaryUtils.TYPE_CODE.INTEGER,
- [PROP_PARTITION_LOSS_POLICY] : BinaryUtils.TYPE_CODE.INTEGER,
- [PROP_EAGER_TTL] : BinaryUtils.TYPE_CODE.BOOLEAN,
- [PROP_STATISTICS_ENABLED] : BinaryUtils.TYPE_CODE.BOOLEAN
-});
-
-/**
- *
- * @typedef CacheConfiguration.CACHE_ATOMICITY_MODE
- * @enum
- * @readonly
- * @property TRANSACTIONAL 0
- * @property ATOMIC 1
- */
-const CACHE_ATOMICITY_MODE = Object.freeze({
- TRANSACTIONAL : 0,
- ATOMIC : 1
-});
-
-/**
- *
- * @typedef CacheConfiguration.CACHE_MODE
- * @enum
- * @readonly
- * @property LOCAL 0
- * @property REPLICATED 1
- * @property PARTITIONED 2
- */
-const CACHE_MODE = Object.freeze({
- LOCAL : 0,
- REPLICATED : 1,
- PARTITIONED : 2
-});
-
-/**
- *
- * @typedef CacheConfiguration.PARTITION_LOSS_POLICY
- * @enum
- * @readonly
- * @property READ_ONLY_SAFE 0
- * @property READ_ONLY_ALL 1
- * @property READ_WRITE_SAFE 2
- * @property READ_WRITE_ALL 3
- * @property IGNORE 4
- */
-const PARTITION_LOSS_POLICY = Object.freeze({
- READ_ONLY_SAFE : 0,
- READ_ONLY_ALL : 1,
- READ_WRITE_SAFE : 2,
- READ_WRITE_ALL : 3,
- IGNORE : 4
-});
-
-/**
- *
- * @typedef CacheConfiguration.REABALANCE_MODE
- * @enum
- * @readonly
- * @property SYNC 0
- * @property ASYNC 1
- * @property NONE 2
- */
-const REABALANCE_MODE = Object.freeze({
- SYNC : 0,
- ASYNC : 1,
- NONE : 2
-});
-
-/**
- *
- * @typedef CacheConfiguration.WRITE_SYNCHRONIZATION_MODE
- * @enum
- * @readonly
- * @property FULL_SYNC 0
- * @property FULL_ASYNC 1
- * @property PRIMARY_SYNC 2
- */
-const WRITE_SYNCHRONIZATION_MODE = Object.freeze({
- FULL_SYNC : 0,
- FULL_ASYNC : 1,
- PRIMARY_SYNC : 2
-});
-
-/**
- * Class representing Ignite cache configuration on a server.
- *
- * All configuration settings are optional and have defaults which are defined on a server side.
- *
- * See Apache Ignite documentation for details of every configuration setting.
- */
-class CacheConfiguration {
-
- /**
- * Public constructor.
- *
- * @return {CacheConfiguration} - new CacheConfiguration instance.
- */
- constructor() {
- this._properties = new Map();
- }
-
- static get CACHE_ATOMICITY_MODE() {
- return CACHE_ATOMICITY_MODE;
- }
-
- static get CACHE_MODE() {
- return CACHE_MODE;
- }
-
- static get PARTITION_LOSS_POLICY() {
- return PARTITION_LOSS_POLICY;
- }
-
- static get REABALANCE_MODE() {
- return REABALANCE_MODE;
- }
-
- static get WRITE_SYNCHRONIZATION_MODE() {
- return WRITE_SYNCHRONIZATION_MODE;
- }
-
- /**
- *
- *
- * @param {CacheConfiguration.CACHE_ATOMICITY_MODE} atomicityMode
- *
- * @return {CacheConfiguration} - the same instance of the CacheConfiguration.
- *
- * @throws {IgniteClientError} if error.
- */
- setAtomicityMode(atomicityMode) {
- ArgumentChecker.hasValueFrom(atomicityMode, 'atomicityMode', false, CACHE_ATOMICITY_MODE);
- this._properties.set(PROP_ATOMICITY_MODE, atomicityMode);
- return this;
- }
-
- /**
- *
- *
- * @return {CacheConfiguration.CACHE_ATOMICITY_MODE}
- */
- getAtomicityMode() {
- return this._properties.get(PROP_ATOMICITY_MODE);
- }
-
- /**
- *
- *
- * @param {number} backups
- *
- * @return {CacheConfiguration} - the same instance of the CacheConfiguration.
- */
- setBackups(backups) {
- this._properties.set(PROP_BACKUPS, backups);
- return this;
- }
-
- /**
- *
- *
- * @return {number}
- */
- getBackups() {
- return this._properties.get(PROP_BACKUPS);
- }
-
- /**
- *
- *
- * @param {CacheConfiguration.CACHE_MODE} cacheMode
- *
- * @return {CacheConfiguration} - the same instance of the CacheConfiguration.
- *
- * @throws {IgniteClientError} if error.
- */
- setCacheMode(cacheMode) {
- ArgumentChecker.hasValueFrom(cacheMode, 'cacheMode', false, CACHE_MODE);
- this._properties.set(PROP_CACHE_MODE, cacheMode);
- return this;
- }
-
- /**
- *
- *
- * @return {CacheConfiguration.CACHE_MODE}
- */
- getCacheMode() {
- return this._properties.get(PROP_CACHE_MODE);
- }
-
- /**
- *
- *
- * @param {boolean} copyOnRead
- *
- * @return {CacheConfiguration} - the same instance of the CacheConfiguration.
- */
- setCopyOnRead(copyOnRead) {
- this._properties.set(PROP_COPY_ON_READ, copyOnRead);
- return this;
- }
-
- /**
- *
- *
- * @return {boolean}
- */
- getCopyOnRead() {
- return this._properties.get(PROP_COPY_ON_READ);
- }
-
- /**
- *
- *
- * @param {string} dataRegionName
- *
- * @return {CacheConfiguration} - the same instance of the CacheConfiguration.
- */
- setDataRegionName(dataRegionName) {
- this._properties.set(PROP_DATA_REGION_NAME, dataRegionName);
- return this;
- }
-
- /**
- *
- *
- * @return {string}
- */
- getDataRegionName() {
- return this._properties.get(PROP_DATA_REGION_NAME);
- }
-
- /**
- *
- *
- * @param {boolean} eagerTtl
- *
- * @return {CacheConfiguration} - the same instance of the CacheConfiguration.
- */
- setEagerTtl(eagerTtl) {
- this._properties.set(PROP_EAGER_TTL, eagerTtl);
- return this;
- }
-
- /**
- *
- *
- * @return {boolean}
- */
- getEagerTtl() {
- return this._properties.get(PROP_EAGER_TTL);
- }
-
- /**
- *
- *
- * @param {boolean} statisticsEnabled
- *
- * @return {CacheConfiguration} - the same instance of the CacheConfiguration.
- */
- setStatisticsEnabled(statisticsEnabled) {
- this._properties.set(PROP_STATISTICS_ENABLED, statisticsEnabled);
- return this;
- }
-
- /**
- *
- *
- * @return {boolean}
- */
- getStatisticsEnabled() {
- return this._properties.get(PROP_STATISTICS_ENABLED);
- }
-
- /**
- *
- *
- * @param {string} groupName
- *
- * @return {CacheConfiguration} - the same instance of the CacheConfiguration.
- */
- setGroupName(groupName) {
- this._properties.set(PROP_GROUP_NAME, groupName);
- return this;
- }
-
- /**
- *
- *
- * @return {string}
- */
- getGroupName() {
- return this._properties.get(PROP_GROUP_NAME);
- }
-
- /**
- *
- *
- * @param {number} lockTimeout
- *
- * @return {CacheConfiguration} - the same instance of the CacheConfiguration.
- */
- setDefaultLockTimeout(lockTimeout) {
- this._properties.set(PROP_DEFAULT_LOCK_TIMEOUT, lockTimeout);
- return this;
- }
-
- /**
- *
- *
- * @return {number}
- */
- getDefaultLockTimeout() {
- return this._properties.get(PROP_DEFAULT_LOCK_TIMEOUT);
- }
-
- /**
- *
- *
- * @param {number} maxConcurrentAsyncOperations
- *
- * @return {CacheConfiguration} - the same instance of the CacheConfiguration.
- */
- setMaxConcurrentAsyncOperations(maxConcurrentAsyncOperations) {
- this._properties.set(PROP_MAX_CONCURRENT_ASYNC_OPS, maxConcurrentAsyncOperations);
- return this;
- }
-
- /**
- *
- *
- * @return {number}
- */
- getMaxConcurrentAsyncOperations() {
- return this._properties.get(PROP_MAX_CONCURRENT_ASYNC_OPS);
- }
-
- /**
- *
- *
- * @param {number} maxQueryIterators
- *
- * @return {CacheConfiguration} - the same instance of the CacheConfiguration.
- */
- setMaxQueryIterators(maxQueryIterators) {
- this._properties.set(PROP_MAX_QUERY_ITERATORS, maxQueryIterators);
- return this;
- }
-
- /**
- *
- *
- * @return {number}
- */
- getMaxQueryIterators() {
- return this._properties.get(PROP_MAX_QUERY_ITERATORS);
- }
-
- /**
- *
- *
- * @param {boolean} isOnheapCacheEnabled
- *
- * @return {CacheConfiguration} - the same instance of the CacheConfiguration.
- */
- setIsOnheapCacheEnabled(isOnheapCacheEnabled) {
- this._properties.set(PROP_IS_ONHEAP_CACHE_ENABLED, isOnheapCacheEnabled);
- return this;
- }
-
- /**
- *
- *
- * @return {boolean}
- */
- getIsOnheapCacheEnabled() {
- return this._properties.get(PROP_IS_ONHEAP_CACHE_ENABLED);
- }
-
- /**
- *
- *
- * @param {CacheConfiguration.PARTITION_LOSS_POLICY} partitionLossPolicy
- *
- * @return {CacheConfiguration} - the same instance of the CacheConfiguration.
- *
- * @throws {IgniteClientError} if error.
- */
- setPartitionLossPolicy(partitionLossPolicy) {
- ArgumentChecker.hasValueFrom(partitionLossPolicy, 'partitionLossPolicy', false, PARTITION_LOSS_POLICY);
- this._properties.set(PROP_PARTITION_LOSS_POLICY, partitionLossPolicy);
- return this;
- }
-
- /**
- *
- *
- * @return {CacheConfiguration.PARTITION_LOSS_POLICY}
- */
- getPartitionLossPolicy() {
- return this._properties.get(PROP_PARTITION_LOSS_POLICY);
- }
-
- /**
- *
- *
- * @param {number} queryDetailMetricsSize
- *
- * @return {CacheConfiguration} - the same instance of the CacheConfiguration.
- */
- setQueryDetailMetricsSize(queryDetailMetricsSize) {
- this._properties.set(PROP_QUERY_DETAIL_METRICS_SIZE, queryDetailMetricsSize);
- return this;
- }
-
- /**
- *
- *
- * @return {number}
- */
- getQueryDetailMetricsSize() {
- return this._properties.get(PROP_QUERY_DETAIL_METRICS_SIZE);
- }
-
- /**
- *
- *
- * @param {number} queryParallelism
- *
- * @return {CacheConfiguration} - the same instance of the CacheConfiguration.
- */
- setQueryParallelism(queryParallelism) {
- this._properties.set(PROP_QUERY_PARALLELISM, queryParallelism);
- return this;
- }
-
- /**
- *
- *
- * @return {number}
- */
- getQueryParallelism() {
- return this._properties.get(PROP_QUERY_PARALLELISM);
- }
-
- /**
- *
- *
- * @param {boolean} readFromBackup
- *
- * @return {CacheConfiguration} - the same instance of the CacheConfiguration.
- */
- setReadFromBackup(readFromBackup) {
- this._properties.set(PROP_READ_FROM_BACKUP, readFromBackup);
- return this;
- }
-
- /**
- *
- *
- * @return {boolean}
- */
- getReadFromBackup() {
- return this._properties.get(PROP_READ_FROM_BACKUP);
- }
-
- /**
- *
- *
- * @param {number} rebalanceBatchSize
- *
- * @return {CacheConfiguration} - the same instance of the CacheConfiguration.
- */
- setRebalanceBatchSize(rebalanceBatchSize) {
- this._properties.set(PROP_REBALANCE_BATCH_SIZE, rebalanceBatchSize);
- return this;
- }
-
- /**
- *
- *
- * @return {number}
- */
- getRebalanceBatchSize() {
- return this._properties.get(PROP_REBALANCE_BATCH_SIZE);
- }
-
- /**
- *
- *
- * @param {number} rebalanceBatchesPrefetchCount
- *
- * @return {CacheConfiguration} - the same instance of the CacheConfiguration.
- */
- setRebalanceBatchesPrefetchCount(rebalanceBatchesPrefetchCount) {
- this._properties.set(PROP_REBALANCE_BATCHES_PREFETCH_COUNT, rebalanceBatchesPrefetchCount);
- return this;
- }
-
- /**
- *
- *
- * @return {number}
- */
- getRebalanceBatchesPrefetchCount() {
- return this._properties.get(PROP_REBALANCE_BATCHES_PREFETCH_COUNT);
- }
-
- /**
- *
- *
- * @param {number} rebalanceDelay
- *
- * @return {CacheConfiguration} - the same instance of the CacheConfiguration.
- */
- setRebalanceDelay(rebalanceDelay) {
- this._properties.set(PROP_REBALANCE_DELAY, rebalanceDelay);
- return this;
- }
-
- /**
- *
- *
- * @return {number}
- */
- getRebalanceDelay() {
- return this._properties.get(PROP_REBALANCE_DELAY);
- }
-
- /**
- *
- *
- * @param {CacheConfiguration.REABALANCE_MODE} rebalanceMode
- *
- * @return {CacheConfiguration} - the same instance of the CacheConfiguration.
- *
- * @throws {IgniteClientError} if error.
- */
- setRebalanceMode(rebalanceMode) {
- ArgumentChecker.hasValueFrom(rebalanceMode, 'rebalanceMode', false, REABALANCE_MODE);
- this._properties.set(PROP_REBALANCE_MODE, rebalanceMode);
- return this;
- }
-
- /**
- *
- *
- * @return {CacheConfiguration.REABALANCE_MODE}
- */
- getRebalanceMode() {
- return this._properties.get(PROP_REBALANCE_MODE);
- }
-
- /**
- *
- *
- * @param {number} rebalanceOrder
- *
- * @return {CacheConfiguration} - the same instance of the CacheConfiguration.
- */
- setRebalanceOrder(rebalanceOrder) {
- this._properties.set(PROP_REBALANCE_ORDER, rebalanceOrder);
- return this;
- }
-
- /**
- *
- *
- * @return {number}
- */
- getRebalanceOrder() {
- return this._properties.get(PROP_REBALANCE_ORDER);
- }
-
- /**
- *
- *
- * @param {number} rebalanceThrottle
- *
- * @return {CacheConfiguration} - the same instance of the CacheConfiguration.
- */
- setRebalanceThrottle(rebalanceThrottle) {
- this._properties.set(PROP_REBALANCE_THROTTLE, rebalanceThrottle);
- return this;
- }
-
- /**
- *
- *
- * @return {number}
- */
- getRebalanceThrottle() {
- return this._properties.get(PROP_REBALANCE_THROTTLE);
- }
-
- /**
- *
- *
- * @param {number} rebalanceTimeout
- *
- * @return {CacheConfiguration} - the same instance of the CacheConfiguration.
- */
- setRebalanceTimeout(rebalanceTimeout) {
- this._properties.set(PROP_REBALANCE_TIMEOUT, rebalanceTimeout);
- return this;
- }
-
- /**
- *
- *
- * @return {number}
- */
- getRebalanceTimeout() {
- return this._properties.get(PROP_REBALANCE_TIMEOUT);
- }
-
- /**
- *
- *
- * @param {boolean} sqlEscapeAll
- *
- * @return {CacheConfiguration} - the same instance of the CacheConfiguration.
- */
- setSqlEscapeAll(sqlEscapeAll) {
- this._properties.set(PROP_SQL_ESCAPE_ALL, sqlEscapeAll);
- return this;
- }
-
- /**
- *
- *
- * @return {boolean}
- */
- getSqlEscapeAll() {
- return this._properties.get(PROP_SQL_ESCAPE_ALL);
- }
-
- /**
- *
- *
- * @param {number} sqlIndexInlineMaxSize
- *
- * @return {CacheConfiguration} - the same instance of the CacheConfiguration.
- */
- setSqlIndexInlineMaxSize(sqlIndexInlineMaxSize) {
- this._properties.set(PROP_SQL_INDEX_INLINE_MAX_SIZE, sqlIndexInlineMaxSize);
- return this;
- }
-
- /**
- *
- *
- * @return {number}
- */
- getSqlIndexInlineMaxSize() {
- return this._properties.get(PROP_SQL_INDEX_INLINE_MAX_SIZE);
- }
-
- /**
- *
- *
- * @param {string} sqlSchema
- *
- * @return {CacheConfiguration} - the same instance of the CacheConfiguration.
- */
- setSqlSchema(sqlSchema) {
- this._properties.set(PROP_SQL_SCHEMA, sqlSchema);
- return this;
- }
-
- /**
- *
- *
- * @return {string}
- */
- getSqlSchema() {
- return this._properties.get(PROP_SQL_SCHEMA);
- }
-
- /**
- *
- *
- * @param {CacheConfiguration.WRITE_SYNCHRONIZATION_MODE} writeSynchronizationMode
- *
- * @return {CacheConfiguration} - the same instance of the CacheConfiguration.
- *
- * @throws {IgniteClientError} if error.
- */
- setWriteSynchronizationMode(writeSynchronizationMode) {
- ArgumentChecker.hasValueFrom(writeSynchronizationMode, 'writeSynchronizationMode', false, WRITE_SYNCHRONIZATION_MODE);
- this._properties.set(PROP_WRITE_SYNCHRONIZATION_MODE, writeSynchronizationMode);
- return this;
- }
-
- /**
- *
- *
- * @return {CacheConfiguration.WRITE_SYNCHRONIZATION_MODE}
- */
- getWriteSynchronizationMode() {
- return this._properties.get(PROP_WRITE_SYNCHRONIZATION_MODE);
- }
-
- /**
- *
- *
- * @param {...CacheKeyConfiguration} keyConfigurations
- *
- * @return {CacheConfiguration} - the same instance of the CacheConfiguration.
- *
- * @throws {IgniteClientError} if error.
- */
- setKeyConfigurations(...keyConfigurations) {
- ArgumentChecker.hasType(keyConfigurations, 'keyConfigurations', true, CacheKeyConfiguration);
- this._properties.set(PROP_CACHE_KEY_CONFIGURATION, keyConfigurations);
- return this;
- }
-
- /**
- *
- *
- * @return {Array<CacheKeyConfiguration>}
- */
- getKeyConfigurations() {
- return this._properties.get(PROP_CACHE_KEY_CONFIGURATION);
- }
-
- /**
- *
- *
- * @param {...QueryEntity} queryEntities
- *
- * @return {CacheConfiguration} - the same instance of the CacheConfiguration.
- *
- * @throws {IgniteClientError} if error.
- */
- setQueryEntities(...queryEntities) {
- ArgumentChecker.hasType(queryEntities, 'queryEntities', true, QueryEntity);
- this._properties.set(PROP_QUERY_ENTITY, queryEntities);
- return this;
- }
-
- /**
- *
- *
- * @return {Array<QueryEntity>}
- */
- getQueryEntities() {
- return this._properties.get(PROP_QUERY_ENTITY);
- }
-
- /** Private methods */
-
- /**
- * @ignore
- */
- async _write(communicator, buffer, name) {
- this._properties.set(PROP_NAME, name);
-
- const startPos = buffer.position;
- buffer.position = buffer.position +
- BinaryUtils.getSize(BinaryUtils.TYPE_CODE.INTEGER) +
- BinaryUtils.getSize(BinaryUtils.TYPE_CODE.SHORT);
-
- for (let [propertyCode, property] of this._properties) {
- await this._writeProperty(communicator, buffer, propertyCode, property);
- }
-
- const length = buffer.position - startPos;
- buffer.position = startPos;
-
- buffer.writeInteger(length);
- buffer.writeShort(this._properties.size);
- }
-
- /**
- * @ignore
- */
- async _writeProperty(communicator, buffer, propertyCode, property) {
- buffer.writeShort(propertyCode);
- const propertyType = PROP_TYPES[propertyCode];
- switch (BinaryUtils.getTypeCode(propertyType)) {
- case BinaryUtils.TYPE_CODE.INTEGER:
- case BinaryUtils.TYPE_CODE.LONG:
- case BinaryUtils.TYPE_CODE.BOOLEAN:
- await communicator.writeObject(buffer, property, propertyType, false);
- return;
- case BinaryUtils.TYPE_CODE.STRING:
- await communicator.writeObject(buffer, property, propertyType);
- return;
- case BinaryUtils.TYPE_CODE.OBJECT_ARRAY:
- const length = property ? property.length : 0;
- buffer.writeInteger(length);
- for (let prop of property) {
- await prop._write(communicator, buffer);
- }
- return;
- default:
- throw Errors.IgniteClientError.internalError();
- }
- }
-
- /**
- * @ignore
- */
- async _read(communicator, buffer) {
- // length
- buffer.readInteger();
- await this._readProperty(communicator, buffer, PROP_ATOMICITY_MODE);
- await this._readProperty(communicator, buffer, PROP_BACKUPS);
- await this._readProperty(communicator, buffer, PROP_CACHE_MODE);
- await this._readProperty(communicator, buffer, PROP_COPY_ON_READ);
- await this._readProperty(communicator, buffer, PROP_DATA_REGION_NAME);
- await this._readProperty(communicator, buffer, PROP_EAGER_TTL);
- await this._readProperty(communicator, buffer, PROP_STATISTICS_ENABLED);
- await this._readProperty(communicator, buffer, PROP_GROUP_NAME);
- await this._readProperty(communicator, buffer, PROP_DEFAULT_LOCK_TIMEOUT);
- await this._readProperty(communicator, buffer, PROP_MAX_CONCURRENT_ASYNC_OPS);
- await this._readProperty(communicator, buffer, PROP_MAX_QUERY_ITERATORS);
- await this._readProperty(communicator, buffer, PROP_NAME);
- await this._readProperty(communicator, buffer, PROP_IS_ONHEAP_CACHE_ENABLED);
- await this._readProperty(communicator, buffer, PROP_PARTITION_LOSS_POLICY);
- await this._readProperty(communicator, buffer, PROP_QUERY_DETAIL_METRICS_SIZE);
- await this._readProperty(communicator, buffer, PROP_QUERY_PARALLELISM);
- await this._readProperty(communicator, buffer, PROP_READ_FROM_BACKUP);
- await this._readProperty(communicator, buffer, PROP_REBALANCE_BATCH_SIZE);
- await this._readProperty(communicator, buffer, PROP_REBALANCE_BATCHES_PREFETCH_COUNT);
- await this._readProperty(communicator, buffer, PROP_REBALANCE_DELAY);
- await this._readProperty(communicator, buffer, PROP_REBALANCE_MODE);
- await this._readProperty(communicator, buffer, PROP_REBALANCE_ORDER);
- await this._readProperty(communicator, buffer, PROP_REBALANCE_THROTTLE);
- await this._readProperty(communicator, buffer, PROP_REBALANCE_TIMEOUT);
- await this._readProperty(communicator, buffer, PROP_SQL_ESCAPE_ALL);
- await this._readProperty(communicator, buffer, PROP_SQL_INDEX_INLINE_MAX_SIZE);
- await this._readProperty(communicator, buffer, PROP_SQL_SCHEMA);
- await this._readProperty(communicator, buffer, PROP_WRITE_SYNCHRONIZATION_MODE);
- await this._readProperty(communicator, buffer, PROP_CACHE_KEY_CONFIGURATION);
- await this._readProperty(communicator, buffer, PROP_QUERY_ENTITY);
- }
-
- /**
- * @ignore
- */
- async _readProperty(communicator, buffer, propertyCode) {
- const propertyType = PROP_TYPES[propertyCode];
- switch (BinaryUtils.getTypeCode(propertyType)) {
- case BinaryUtils.TYPE_CODE.INTEGER:
- case BinaryUtils.TYPE_CODE.LONG:
- case BinaryUtils.TYPE_CODE.BOOLEAN:
- this._properties.set(propertyCode, await communicator._readTypedObject(buffer, propertyType));
- return;
- case BinaryUtils.TYPE_CODE.STRING:
- this._properties.set(propertyCode, await communicator.readObject(buffer, propertyType));
- return;
- case BinaryUtils.TYPE_CODE.OBJECT_ARRAY:
- const length = buffer.readInteger();
- if (length > 0) {
- const properties = new Array(length);
- for (let i = 0; i < length; i++) {
- const property = new propertyType._elementType._objectConstructor();
- await property._read(communicator, buffer);
- properties[i] = property;
- }
- this._properties.set(propertyCode, properties);
- }
- return;
- default:
- throw Errors.IgniteClientError.internalError();
- }
- }
-}
-
-module.exports = CacheConfiguration;
-module.exports.QueryEntity = QueryEntity;
-module.exports.QueryField = QueryField;
-module.exports.QueryIndex = QueryIndex;
-module.exports.CacheKeyConfiguration = CacheKeyConfiguration;
diff --git a/modules/platforms/nodejs/lib/Cursor.js b/modules/platforms/nodejs/lib/Cursor.js
deleted file mode 100644
index 39eea21..0000000
--- a/modules/platforms/nodejs/lib/Cursor.js
+++ /dev/null
@@ -1,307 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-'use strict';
-
-const Errors = require('./Errors');
-const BinaryUtils = require('./internal/BinaryUtils');
-const BinaryObject = require('./BinaryObject');
-
-/**
- * Class representing a cursor to obtain results of SQL and Scan query operations.
- *
- * The class has no public constructor. An instance of this class is obtained
- * via query() method of {@link CacheClient} objects.
- * One instance of this class returns results of one SQL or Scan query operation.
- *
- * @hideconstructor
- */
-class Cursor {
-
- /**
- * Returns one element (cache entry - key-value pair) from the query results.
- *
- * Every new call returns the next cache entry from the query results.
- * If the method returns null, no more entries are available.
- *
- * @async
- *
- * @return {Promise<CacheEntry>} - a cache entry (key-value pair).
- */
- async getValue() {
- if (!this._values || this._valueIndex >= this._values.length) {
- await this._getValues();
- this._valueIndex = 0;
- }
- if (this._values && this._values.length > 0) {
- const value = this._values[this._valueIndex];
- this._valueIndex++;
- return value;
- }
- return null;
- }
-
- /**
- * Checks if more elements are available in the query results.
- *
- * @return {boolean} - true if more cache entries are available, false otherwise.
- */
- hasMore() {
- return this._hasNext ||
- this._values && this._valueIndex < this._values.length;
- }
-
- /**
- * Returns all elements (cache entries - key-value pairs) from the query results.
- *
- * May be used instead of getValue() method if the number of returned entries
- * is relatively small and will not cause memory utilization issues.
- *
- * @async
- *
- * @return {Promise<Array<CacheEntry>>} - all cache entries (key-value pairs)
- * returned by SQL or Scan query.
- */
- async getAll() {
- let result = new Array();
- let values;
- do {
- values = await this._getValues();
- if (values) {
- result = result.concat(values);
- }
- } while (this._hasNext);
- return result;
- }
-
- /**
- * Closes the cursor. Obtaining elements from the results is not possible after this.
- *
- * This method should be called if no more elements are needed.
- * It is not neccessary to call it if all elements have been already obtained.
- *
- * @async
- */
- async close() {
- // Close cursor only if the server has more pages: the server closes cursor automatically on last page
- if (this._id && this._hasNext) {
- await this._communicator.send(
- BinaryUtils.OPERATION.RESOURCE_CLOSE,
- async (payload) => {
- await this._write(payload);
- });
- }
- }
-
- /** Private methods */
-
- /**
- * @ignore
- */
- constructor(communicator, operation, buffer, keyType = null, valueType = null) {
- this._communicator = communicator;
- this._operation = operation;
- this._buffer = buffer;
- this._keyType = keyType;
- this._valueType = valueType;
- this._id = null;
- this._hasNext = false;
- this._values = null;
- this._valueIndex = 0;
- }
-
- /**
- * @ignore
- */
- async _getNext() {
- this._hasNext = false;
- this._values = null;
- this._buffer = null;
- await this._communicator.send(
- this._operation,
- async (payload) => {
- await this._write(payload);
- },
- async (payload) => {
- this._buffer = payload;
- });
- }
-
- /**
- * @ignore
- */
- async _getValues() {
- if (!this._buffer && this._hasNext) {
- await this._getNext();
- }
- await this._read(this._buffer)
- this._buffer = null;
- return this._values;
- }
-
- /**
- * @ignore
- */
- async _write(buffer) {
- buffer.writeLong(this._id);
- }
-
- /**
- * @ignore
- */
- _readId(buffer) {
- this._id = buffer.readLong();
- }
-
- /**
- * @ignore
- */
- async _readRow(buffer) {
- const CacheEntry = require('./CacheClient').CacheEntry;
- return new CacheEntry(
- await this._communicator.readObject(buffer, this._keyType),
- await this._communicator.readObject(buffer, this._valueType));
- }
-
- /**
- * @ignore
- */
- async _read(buffer) {
- const rowCount = buffer.readInteger();
- this._values = new Array(rowCount);
- for (let i = 0; i < rowCount; i++) {
- this._values[i] = await this._readRow(buffer);
- }
- this._hasNext = buffer.readBoolean();
- }
-}
-
-/**
- * Class representing a cursor to obtain results of SQL Fields query operation.
- *
- * The class has no public constructor. An instance of this class is obtained
- * via query() method of {@link CacheClient} objects.
- * One instance of this class returns results of one SQL Fields query operation.
- *
- * @hideconstructor
- * @extends Cursor
- */
-class SqlFieldsCursor extends Cursor {
-
- /**
- * Returns one element (array with values of the fields) from the query results.
- *
- * Every new call returns the next element from the query results.
- * If the method returns null, no more elements are available.
- *
- * @async
- *
- * @return {Promise<Array<*>>} - array with values of the fields requested by the query.
- *
- */
- async getValue() {
- return await super.getValue();
- }
-
- /**
- * Returns all elements (arrays with values of the fields) from the query results.
- *
- * May be used instead of getValue() method if the number of returned elements
- * is relatively small and will not cause memory utilization issues.
- *
- * @async
- *
- * @return {Promise<Array<Array<*>>>} - all results returned by SQL Fields query.
- * Every element of the array is an array with values of the fields requested by the query.
- *
- */
- async getAll() {
- return await super.getAll();
- }
-
- /**
- * Returns names of the fields which were requested in the SQL Fields query.
- *
- * Empty array is returned if "include field names" flag was false in the query.
- *
- * @return {Array<string>} - field names.
- * The order of names corresponds to the order of field values returned in the results of the query.
- */
- getFieldNames() {
- return this._fieldNames;
- }
-
- /**
- * Specifies types of the fields returned by the SQL Fields query.
- *
- * By default, a type of every field is not specified that means during operations the Ignite client
- * will try to make automatic mapping between JavaScript types and Ignite object types -
- * according to the mapping table defined in the description of the {@link ObjectType} class.
- *
- * @param {...ObjectType.PRIMITIVE_TYPE | CompositeType} fieldTypes - types of the returned fields.
- * The order of types must correspond the order of field values returned in the results of the query.
- * A type of every field can be:
- * - either a type code of primitive (simple) type
- * - or an instance of class representing non-primitive (composite) type
- * - or null (means the type is not specified)
- *
- * @return {SqlFieldsCursor} - the same instance of the SqlFieldsCursor.
- */
- setFieldTypes(...fieldTypes) {
- this._fieldTypes = fieldTypes;
- return this;
- }
-
- /** Private methods */
-
- /**
- * @ignore
- */
- constructor(communicator, buffer) {
- super(communicator, BinaryUtils.OPERATION.QUERY_SQL_FIELDS_CURSOR_GET_PAGE, buffer);
- this._fieldNames = [];
- }
-
- /**
- * @ignore
- */
- async _readFieldNames(buffer, includeFieldNames) {
- this._id = buffer.readLong();
- this._fieldCount = buffer.readInteger();
- if (includeFieldNames) {
- for (let i = 0; i < this._fieldCount; i++) {
- this._fieldNames[i] = await this._communicator.readObject(buffer);
- }
- }
- }
-
- /**
- * @ignore
- */
- async _readRow(buffer) {
- let values = new Array(this._fieldCount);
- let fieldType;
- for (let i = 0; i < this._fieldCount; i++) {
- fieldType = this._fieldTypes && i < this._fieldTypes.length ? this._fieldTypes[i] : null;
- values[i] = await this._communicator.readObject(buffer, fieldType);
- }
- return values;
- }
-}
-
-module.exports.Cursor = Cursor;
-module.exports.SqlFieldsCursor = SqlFieldsCursor;
diff --git a/modules/platforms/nodejs/lib/EnumItem.js b/modules/platforms/nodejs/lib/EnumItem.js
deleted file mode 100644
index 5e80da9..0000000
--- a/modules/platforms/nodejs/lib/EnumItem.js
+++ /dev/null
@@ -1,212 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-'use strict';
-
-const Util = require('util');
-const ArgumentChecker = require('./internal/ArgumentChecker');
-const Errors = require('./Errors');
-
-/**
- * Class representing an item of Ignite enum type.
- *
- * The item is defined by:
- * - type Id (mandatory) - Id of the Ignite enum type.
- * - ordinal (optional) - ordinal of the item in the Ignite enum type.
- * - name (optional) - name of the item (field name in the Ignite enum type).
- * - value (optional) - value of the item.
- * Usually, at least one from the optional ordinal, name or value must be specified
- * in order to use an instance of this class in Ignite operations.
- *
- * To distinguish one item from another, the Ignite client analyzes the optional fields in the following order:
- * ordinal, name, value.
- */
-class EnumItem {
-
- /**
- * Public constructor.
- *
- * @param {number} typeId - Id of the Ignite enum type.
- *
- * @return {EnumItem} - new EnumItem instance
- *
- * @throws {IgniteClientError} if error.
- */
- constructor(typeId) {
- this.setTypeId(typeId);
- this._ordinal = null;
- this._name = null;
- this._value = null;
- }
-
- /**
- * Returns Id of the Ignite enum type.
- *
- * @return {number} - Id of the enum type.
- */
- getTypeId() {
- return this._typeId;
- }
-
- /**
- * Updates Id of the Ignite enum type.
- *
- * @param {number} typeId - new Id of the Ignite enum type.
- *
- * @return {EnumItem} - the same instance of EnumItem
- *
- * @throws {IgniteClientError} if error.
- */
- setTypeId(typeId) {
- ArgumentChecker.isInteger(typeId, 'typeId');
- this._typeId = typeId;
- return this;
- }
-
- /**
- * Returns ordinal of the item in the Ignite enum type
- * or null if ordinal is not set.
- *
- * @return {number} - ordinal of the item in the Ignite enum type.
- */
- getOrdinal() {
- return this._ordinal;
- }
-
- /**
- * Sets or updates ordinal of the item in the Ignite enum type.
- *
- * @param {number} ordinal - ordinal of the item in the Ignite enum type.
- *
- * @return {EnumItem} - the same instance of EnumItem
- *
- * @throws {IgniteClientError} if error.
- */
- setOrdinal(ordinal) {
- ArgumentChecker.isInteger(ordinal, 'ordinal');
- this._ordinal = ordinal;
- return this;
- }
-
- /**
- * Returns name of the item
- * or null if name is not set.
- *
- * @return {string} - name of the item.
- */
- getName() {
- return this._name;
- }
-
- /**
- * Sets or updates name of the item.
- *
- * @param {string} name - name of the item.
- *
- * @return {EnumItem} - the same instance of EnumItem
- *
- * @throws {IgniteClientError} if error.
- */
- setName(name) {
- ArgumentChecker.notEmpty(name, 'name');
- this._name = name;
- return this;
- }
-
- /**
- * Returns value of the item
- * or null if value is not set.
- *
- * @return {number} - value of the item.
- */
- getValue() {
- return this._value;
- }
-
- /**
- * Sets or updates value of the item.
- *
- * @param {number} value - value of the item.
- *
- * @return {EnumItem} - the same instance of EnumItem
- *
- * @throws {IgniteClientError} if error.
- */
- setValue(value) {
- ArgumentChecker.isInteger(value, 'value');
- this._value = value;
- return this;
- }
-
- /** Private methods */
-
- /**
- * @ignore
- */
- async _write(communicator, buffer) {
- const type = await this._getType(communicator, this._typeId);
- if (!type || !type._isEnum) {
- throw Errors.IgniteClientError.enumSerializationError(
- true, Util.format('enum type id "%d" is not registered', this._typeId));
- }
- buffer.writeInteger(this._typeId);
- if (this._ordinal !== null) {
- buffer.writeInteger(this._ordinal);
- return;
- }
- else if (this._name !== null || this._value !== null) {
- if (type._enumValues) {
- for (let i = 0; i < type._enumValues.length; i++) {
- if (this._name === type._enumValues[i][0] ||
- this._value === type._enumValues[i][1]) {
- buffer.writeInteger(i);
- return;
- }
- }
- }
- }
- throw Errors.IgniteClientError.illegalArgumentError(
- 'Proper ordinal, name or value must be specified for EnumItem');
- }
-
- /**
- * @ignore
- */
- async _read(communicator, buffer) {
- this._typeId = buffer.readInteger();
- this._ordinal = buffer.readInteger();
- const type = await this._getType(communicator, this._typeId);
- if (!type || !type._isEnum) {
- throw Errors.IgniteClientError.enumSerializationError(
- false, Util.format('enum type id "%d" is not registered', this._typeId));
- }
- else if (!type._enumValues || type._enumValues.length <= this._ordinal) {
- throw Errors.IgniteClientError.enumSerializationError(false, 'type mismatch');
- }
- this._name = type._enumValues[this._ordinal][0];
- this._value = type._enumValues[this._ordinal][1];
- }
-
- /**
- * @ignore
- */
- async _getType(communicator, typeId) {
- return await communicator.typeStorage.getType(typeId);
- }
-}
-
-module.exports = EnumItem;
diff --git a/modules/platforms/nodejs/lib/Errors.js b/modules/platforms/nodejs/lib/Errors.js
deleted file mode 100644
index 89baf38..0000000
--- a/modules/platforms/nodejs/lib/Errors.js
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-'use strict';
-
-const Util = require('util');
-
-/**
- * Base Ignite client error class.
- */
-class IgniteClientError extends Error {
- constructor(message) {
- super(message);
- }
-
- /**
- * Ignite client does not support one of the specified or received data types.
- * @ignore
- */
- static unsupportedTypeError(type) {
- const BinaryUtils = require('./internal/BinaryUtils');
- return new IgniteClientError(Util.format('Type %s is not supported', BinaryUtils.getTypeName(type)));
- }
-
- /**
- * The real type of data is not equal to the specified one.
- * @ignore
- */
- static typeCastError(fromType, toType) {
- const BinaryUtils = require('./internal/BinaryUtils');
- return new IgniteClientError(Util.format('Type "%s" can not be cast to %s',
- BinaryUtils.getTypeName(fromType), BinaryUtils.getTypeName(toType)));
- }
-
- /**
- * The real value can not be cast to the specified type.
- * @ignore
- */
- static valueCastError(value, toType) {
- const BinaryUtils = require('./internal/BinaryUtils');
- return new IgniteClientError(Util.format('Value "%s" can not be cast to %s',
- value, BinaryUtils.getTypeName(toType)));
- }
-
- /**
- * An illegal or inappropriate argument has been passed to the API method.
- * @ignore
- */
- static illegalArgumentError(message) {
- return new IgniteClientError(message);
- }
-
- /**
- * Ignite client internal error.
- * @ignore
- */
- static internalError(message = null) {
- return new IgniteClientError(message || 'Internal library error');
- }
-
- /**
- * Serialization/deserialization errors.
- * @ignore
- */
- static serializationError(serialize, message = null) {
- let msg = serialize ? 'Complex object can not be serialized' : 'Complex object can not be deserialized';
- if (message) {
- msg = msg + ': ' + message;
- }
- return new IgniteClientError(msg);
- }
-
- /**
- * EnumItem serialization/deserialization errors.
- * @ignore
- */
- static enumSerializationError(serialize, message = null) {
- let msg = serialize ? 'Enum item can not be serialized' : 'Enum item can not be deserialized';
- if (message) {
- msg = msg + ': ' + message;
- }
- return new IgniteClientError(msg);
- }
-}
-
-/**
- * Ignite server returns error for the requested operation.
- * @extends IgniteClientError
- */
-class OperationError extends IgniteClientError {
- constructor(message) {
- super(message);
- }
-}
-
-/**
- * Ignite client is not in an appropriate state for the requested operation.
- * @extends IgniteClientError
- */
-class IllegalStateError extends IgniteClientError {
- constructor(message = null) {
- super(message || 'Ignite client is not in an appropriate state for the requested operation');
- }
-}
-
-/**
- * The requested operation is not completed due to the connection lost.
- * @extends IgniteClientError
- */
-class LostConnectionError extends IgniteClientError {
- constructor(message = null) {
- super(message || 'Request is not completed due to the connection lost');
- }
-}
-
-module.exports.IgniteClientError = IgniteClientError;
-module.exports.OperationError = OperationError;
-module.exports.IllegalStateError = IllegalStateError;
-module.exports.LostConnectionError = LostConnectionError;
diff --git a/modules/platforms/nodejs/lib/IgniteClient.js b/modules/platforms/nodejs/lib/IgniteClient.js
deleted file mode 100644
index 1974352..0000000
--- a/modules/platforms/nodejs/lib/IgniteClient.js
+++ /dev/null
@@ -1,290 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-'use strict';
-
-const CacheClient = require('./CacheClient');
-const IgniteClientConfiguration = require('./IgniteClientConfiguration');
-const CacheConfiguration = require('./CacheConfiguration');
-const BinaryUtils = require('./internal/BinaryUtils');
-const BinaryCommunicator = require('./internal/BinaryCommunicator');
-const ArgumentChecker = require('./internal/ArgumentChecker');
-const Logger = require('./internal/Logger');
-
-/**
- * State of Ignite client.
- *
- * @typedef IgniteClient.STATE
- * @enum
- * @readonly
- * @property DISCONNECTED The client is not connected to any Ignite node,
- * operations with the Ignite server are not allowed.
- * This is initial state after a client instance creation.
- * If connect() method is called, the client moves to CONNECTING state.
- * @property CONNECTING The client tries to connect to an Ignite node,
- * operations with the Ignite server are not allowed.
- * If disconnect() method is called, the client moves to DISCONNECTED state.
- * If not possible to connect to any Ignite node, the client moves to DISCONNECTED state.
- * If connection to an Ignite node is successful, the client moves to CONNECTED state.
- * @property CONNECTED The client is connected to an Ignite node,
- * all operations with the Ignite server are allowed.
- * If connection with the Ignite node is lost, the client moves to CONNECTING state.
- * If disconnect() method is called, the client moves to DISCONNECTED state.
- */
-const STATE = Object.freeze({
- DISCONNECTED : 0,
- CONNECTING : 1,
- CONNECTED : 2
-});
-
-/**
- * Class representing Ignite client.
- *
- */
-class IgniteClient {
-
- /**
- * Public constructor.
- *
- * @param {IgniteClient.onStateChanged} [onStateChanged] -
- * callback called everytime when the client has moved to a new state {@link IgniteClient.STATE}.
- *
- * @return {IgniteClient} - new IgniteClient instance.
- */
- constructor(onStateChanged = null) {
- const ClientFailoverSocket = require('./internal/ClientFailoverSocket');
- this._socket = new ClientFailoverSocket(onStateChanged);
- this._communicator = new BinaryCommunicator(this._socket);
- }
-
- static get STATE() {
- return STATE;
- }
-
- /**
- * onStateChanged callback.
- * @callback IgniteClient.onStateChanged
- * @param {IgniteClient.STATE} state - the new state of the client.
- * @param {string} reason - the reason why the state has been changed.
- */
-
- /**
- * Connects the client.
- *
- * Should be called from DISCONNECTED state only.
- * Moves the client to CONNECTING state.
- *
- * @async
- *
- * @param {IgniteClientConfiguration} config - the client configuration.
- *
- * @throws {IllegalStateError} if the client is not in DISCONNECTED {@link IgniteClient.STATE}.
- * @throws {IgniteClientError} if other error.
- */
- async connect(config) {
- ArgumentChecker.notEmpty(config, 'config');
- ArgumentChecker.hasType(config, 'config', false, IgniteClientConfiguration);
- await this._socket.connect(config);
- }
-
- /**
- * Disconnects the client.
- *
- * Moves the client to DISCONNECTED state from any other state.
- * Does nothing if the client already disconnected.
- */
- disconnect() {
- if (this._socket) {
- this._socket.disconnect();
- }
- }
-
- /**
- * Creates new cache with the provided name and optional configuration.
- *
- * @async
- *
- * @param {string} name - cache name.
- * @param {CacheConfiguration} [cacheConfig] - cache configuration.
- *
- * @return {Promise<CacheClient>} - new cache client instance for the created cache.
- *
- * @throws {IllegalStateError} if the client is not in CONNECTED {@link IgniteClient.STATE}.
- * @throws {OperationError} if cache with the provided name already exists.
- * @throws {IgniteClientError} if other error.
- */
- async createCache(name, cacheConfig = null) {
- ArgumentChecker.notEmpty(name, 'name');
- ArgumentChecker.hasType(cacheConfig, 'cacheConfig', false, CacheConfiguration);
-
- await this._communicator.send(
- cacheConfig ?
- BinaryUtils.OPERATION.CACHE_CREATE_WITH_CONFIGURATION :
- BinaryUtils.OPERATION.CACHE_CREATE_WITH_NAME,
- async (payload) => {
- await this._writeCacheNameOrConfig(payload, name, cacheConfig);
- });
- return this._getCache(name, cacheConfig);
- }
-
- /**
- * Gets existing cache with the provided name
- * or creates new one with the provided name and optional configuration.
- *
- * @async
- *
- * @param {string} name - cache name.
- * @param {CacheConfiguration} [cacheConfig] - cache configuration (ignored if cache
- * with the provided name already exists).
- *
- * @return {Promise<CacheClient>} - new cache client instance for the existing or created cache.
- *
- * @throws {IllegalStateError} if the client is not in CONNECTED {@link IgniteClient.STATE}.
- * @throws {IgniteClientError} if other error.
- */
- async getOrCreateCache(name, cacheConfig = null) {
- ArgumentChecker.notEmpty(name, 'name');
- ArgumentChecker.hasType(cacheConfig, 'cacheConfig', false, CacheConfiguration);
- await this._communicator.send(
- cacheConfig ?
- BinaryUtils.OPERATION.CACHE_GET_OR_CREATE_WITH_CONFIGURATION :
- BinaryUtils.OPERATION.CACHE_GET_OR_CREATE_WITH_NAME,
- async (payload) => {
- await this._writeCacheNameOrConfig(payload, name, cacheConfig);
- });
- return this._getCache(name, cacheConfig);
- }
-
- /**
- * Gets cache client instance of cache with the provided name.
- * The method does not check if the cache with the provided name exists.
- *
- * @param {string} name - cache name.
- *
- * @return {CacheClient} - new cache client instance.
- *
- * @throws {IgniteClientError} if error.
- */
- getCache(name) {
- ArgumentChecker.notEmpty(name, 'name');
- return this._getCache(name);
- }
-
- /**
- * Destroys cache with the provided name.
- *
- * @async
- *
- * @param {string} name - cache name.
- *
- * @throws {IllegalStateError} if the client is not in CONNECTED {@link IgniteClient.STATE}.
- * @throws {OperationError} if cache with the provided name does not exist.
- * @throws {IgniteClientError} if other error.
- */
- async destroyCache(name) {
- ArgumentChecker.notEmpty(name, 'name');
- await this._communicator.send(
- BinaryUtils.OPERATION.CACHE_DESTROY,
- async (payload) => {
- payload.writeInteger(CacheClient._calculateId(name));
- });
- }
-
- /**
- * Returns configuration of cache with the provided name.
- *
- * @async
- *
- * @param {string} name - cache name.
- *
- * @return {Promise<CacheConfiguration>} - cache configuration
- *
- * @throws {IllegalStateError} if the client is not in CONNECTED {@link IgniteClient.STATE}.
- * @throws {OperationError} if cache with the provided name does not exist.
- * @throws {IgniteClientError} if other error.
- */
- async getCacheConfiguration(name) {
- ArgumentChecker.notEmpty(name, 'name');
- let config;
- await this._communicator.send(
- BinaryUtils.OPERATION.CACHE_GET_CONFIGURATION,
- async (payload) => {
- payload.writeInteger(CacheClient._calculateId(name));
- payload.writeByte(0);
- },
- async (payload) => {
- config = new CacheConfiguration();
- await config._read(this._communicator, payload);
- });
- return config;
- }
-
- /**
- * Gets existing cache names.
- *
- * @async
- *
- * @return {Promise<Array<string>>} - array with the existing cache names.
- * The array is empty if no caches exist.
- *
- * @throws {IllegalStateError} if the client is not in CONNECTED {@link IgniteClient.STATE}.
- * @throws {IgniteClientError} if other error.
- */
- async cacheNames() {
- let names;
- await this._communicator.send(
- BinaryUtils.OPERATION.CACHE_GET_NAMES,
- null,
- async (payload) => {
- names = await this._communicator.readStringArray(payload);
- });
- return names;
- }
-
- /**
- * Enables/disables the library debug output (including errors logging).
- * Disabled by default.
- *
- * @param {boolean} value - true to enable, false to disable
- */
- setDebug(value) {
- Logger.debug = value;
- }
-
- /** Private methods */
-
- /**
- * @ignore
- */
- _getCache(name, cacheConfig = null) {
- return new CacheClient(name, cacheConfig, this._communicator);
- }
-
- /**
- * @ignore
- */
- async _writeCacheNameOrConfig(buffer, name, cacheConfig) {
- if (cacheConfig) {
- await cacheConfig._write(this._communicator, buffer, name);
- }
- else {
- BinaryCommunicator.writeString(buffer, name);
- }
- }
-}
-
-module.exports = IgniteClient;
diff --git a/modules/platforms/nodejs/lib/IgniteClientConfiguration.js b/modules/platforms/nodejs/lib/IgniteClientConfiguration.js
deleted file mode 100644
index 5dab92a..0000000
--- a/modules/platforms/nodejs/lib/IgniteClientConfiguration.js
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-'use strict';
-
-const FS = require('fs');
-const Util = require('util');
-const Errors = require('./Errors');
-const ArgumentChecker = require('./internal/ArgumentChecker');
-
-/**
- * Class representing Ignite client configuration.
- *
- * The configuration includes:
- * - (mandatory) Ignite node endpoint(s)
- * - (optional) user credentials for authentication
- * - (optional) TLS enabling
- * - (optional) connection options
- */
-class IgniteClientConfiguration {
-
- /**
- * Creates an instance of Ignite client configuration
- * with the provided mandatory settings and default optional settings.
- *
- * By default, the client does not use authentication and secure connection.
- *
- * @param {...string} endpoints - Ignite node endpoint(s).
- * The client randomly connects/reconnects to one of the specified node.
- *
- * @return {IgniteClientConfiguration} - new client configuration instance.
- *
- * @throws {IgniteClientError} if error.
- */
- constructor(...endpoints) {
- ArgumentChecker.notEmpty(endpoints, 'endpoints');
- this._endpoints = endpoints;
- this._userName = null;
- this._password = null;
- this._useTLS = false;
- this._options = null;
- }
-
-
- /**
- * Sets username which will be used for authentication during the client's connection.
- *
- * If username is not set, the client does not use authentication during connection.
- *
- * @param {string} userName - username. If null, authentication is disabled.
- *
- * @return {IgniteClientConfiguration} - the same instance of the IgniteClientConfiguration.
- *
- * @throws {IgniteClientError} if error.
- */
- setUserName(userName) {
- this._userName = userName;
- return this;
- }
-
- /**
- * Sets password which will be used for authentication during the client's connection.
- *
- * Password is ignored, if username is not set.
- * If password is not set, it is considered empty.
- *
- * @param {string} password - password. If null, password is empty.
- *
- * @return {IgniteClientConfiguration} - the same instance of the IgniteClientConfiguration.
- *
- * @throws {IgniteClientError} if error.
- */
- setPassword(password) {
- this._password = password;
- return this;
- }
-
- /**
- * Sets connection options.
- *
- * By default the client establishes a non-secure connection with default connection options defined by nodejs.
- *
- * @param {boolean} useTLS - if true, secure connection will be established;
- * if false, non-secure connection will be established.
- * @param {object} [connectionOptions=null] - connection options.
- * - For non-secure connection options defined here {@link https://nodejs.org/api/net.html#net_net_createconnection_options_connectlistener}
- * - For secure connection options defined here {@link https://nodejs.org/api/tls.html#tls_tls_connect_options_callback}
- *
- * @return {IgniteClientConfiguration} - the same instance of the IgniteClientConfiguration.
- */
- setConnectionOptions(useTLS, connectionOptions = null) {
- this._useTLS = useTLS;
- this._options = connectionOptions;
- return this;
- }
-}
-
-module.exports = IgniteClientConfiguration;
diff --git a/modules/platforms/nodejs/lib/ObjectType.js b/modules/platforms/nodejs/lib/ObjectType.js
deleted file mode 100644
index 00c4d56..0000000
--- a/modules/platforms/nodejs/lib/ObjectType.js
+++ /dev/null
@@ -1,600 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-'use strict';
-
-const Util = require('util');
-const Errors = require('./Errors');
-const ArgumentChecker = require('./internal/ArgumentChecker');
-
-/**
- * Supported Ignite type codes for primitive (simple) types.
- * @typedef ObjectType.PRIMITIVE_TYPE
- * @enum
- * @readonly
- * @property BYTE 1
- * @property SHORT 2
- * @property INTEGER 3
- * @property LONG 4
- * @property FLOAT 5
- * @property DOUBLE 6
- * @property CHAR 7
- * @property BOOLEAN 8
- * @property STRING 9
- * @property UUID 10
- * @property DATE 11
- * @property BYTE_ARRAY 12
- * @property SHORT_ARRAY 13
- * @property INTEGER_ARRAY 14
- * @property LONG_ARRAY 15
- * @property FLOAT_ARRAY 16
- * @property DOUBLE_ARRAY 17
- * @property CHAR_ARRAY 18
- * @property BOOLEAN_ARRAY 19
- * @property STRING_ARRAY 20
- * @property UUID_ARRAY 21
- * @property DATE_ARRAY 22
- * @property ENUM 28
- * @property ENUM_ARRAY 29
- * @property DECIMAL 30
- * @property DECIMAL_ARRAY 31
- * @property TIMESTAMP 33
- * @property TIMESTAMP_ARRAY 34
- * @property TIME 36
- * @property TIME_ARRAY 37
- */
-const PRIMITIVE_TYPE = Object.freeze({
- BYTE : 1,
- SHORT : 2,
- INTEGER : 3,
- LONG : 4,
- FLOAT : 5,
- DOUBLE : 6,
- CHAR : 7,
- BOOLEAN : 8,
- STRING : 9,
- UUID : 10,
- DATE : 11,
- BYTE_ARRAY : 12,
- SHORT_ARRAY : 13,
- INTEGER_ARRAY : 14,
- LONG_ARRAY : 15,
- FLOAT_ARRAY : 16,
- DOUBLE_ARRAY : 17,
- CHAR_ARRAY : 18,
- BOOLEAN_ARRAY : 19,
- STRING_ARRAY : 20,
- UUID_ARRAY : 21,
- DATE_ARRAY : 22,
- ENUM : 28,
- ENUM_ARRAY : 29,
- DECIMAL : 30,
- DECIMAL_ARRAY : 31,
- TIMESTAMP : 33,
- TIMESTAMP_ARRAY : 34,
- TIME : 36,
- TIME_ARRAY : 37
-});
-
-/**
- * Supported Ignite type codes for non-primitive (composite) types.
- * @typedef ObjectType.COMPOSITE_TYPE
- * @enum
- * @readonly
- * @property OBJECT_ARRAY 23
- * @property COLLECTION 24
- * @property MAP 25
- * @property NULL 101
- * @property COMPLEX_OBJECT 103
- */
-const COMPOSITE_TYPE = Object.freeze({
- OBJECT_ARRAY : 23,
- COLLECTION : 24,
- MAP : 25,
- NULL : 101,
- COMPLEX_OBJECT : 103
-});
-
-/**
- * Base class representing a type of Ignite object.
- *
- * The class has no public constructor. Only subclasses may be instantiated.
- *
- * There are two groups of Ignite object types:
- *
- * - Primitive (simple) types. To fully describe such a type it is enough to specify
- * Ignite type code {@link ObjectType.PRIMITIVE_TYPE} only.
- *
- * - Non-primitive (composite) types. To fully describe such a type
- * Ignite type code {@link ObjectType.COMPOSITE_TYPE} with additional information should be specified.
- * Eg. a kind of map or a kind of collection.
- *
- * This class helps the Ignite client to make a mapping between JavaScript types
- * and types used by Ignite.
- *
- * In many methods the Ignite client does not require to directly specify a type of Ignite object.
- * In this case the Ignite client tries to make automatic mapping between JavaScript types
- * and Ignite object types according to the following mapping tables:
- *
- * ----------------------------------------------------------------------------
- *
- * DEFAULT MAPPING FROM JavaScript type TO Ignite type code.
- *
- * This mapping is used when an application does not explicitly specify an Ignite type
- * for a field and is writing data to that field.
- *
- * <pre>
- * | JavaScript type | Ignite type code |
- * | ------------------------- | ----------------------|
- * | number | DOUBLE |
- * | boolean | BOOLEAN |
- * | string | STRING |
- * | Date | DATE |
- * | Timestamp* | TIMESTAMP |
- * | EnumItem* | ENUM |
- * | Decimal** | DECIMAL |
- * | BinaryObject* | COMPLEX_OBJECT |
- * | Array of number | DOUBLE_ARRAY |
- * | Array of boolean | BOOLEAN_ARRAY |
- * | Array of string | STRING_ARRAY |
- * | Array of Date | DATE_ARRAY |
- * | Array of Timestamp* | TIMESTAMP_ARRAY |
- * | Array of EnumItem* | ENUM_ARRAY |
- * | Array of Decimal** | DECIMAL_ARRAY |
- * | Array of BinaryObject* | OBJECT_ARRAY |
- * | Array of any other Object | OBJECT_ARRAY |
- * | Set | COLLECTION (HASH_SET) |
- * | Map | MAP (HASH_MAP) |
- * | any other Object | COMPLEX_OBJECT |
- * </pre>
- *
- * Type of an array content is determined by the type of the first element of the array.
- * Empty array has no default mapping.
- *
- * All other JavaScript types have no default mapping.
- *
- * ----------------------------------------------------------------------------
- *
- * DEFAULT MAPPING FROM Ignite type code TO JavaScript type.
- *
- * This mapping is used when an application does not explicitly specify an Ignite type
- * for a field and is reading data from that field.
- *
- * <pre>
- * | Ignite type code | JavaScript type |
- * | ---------------------------- | --------------------------------------|
- * | BYTE | number |
- * | SHORT | number |
- * | INTEGER | number |
- * | LONG | number |
- * | FLOAT | number |
- * | DOUBLE | number |
- * | DECIMAL | Decimal** |
- * | BOOLEAN | boolean |
- * | STRING | string |
- * | CHAR | string (one character) |
- * | UUID | Array of number (16 numbers) |
- * | DATE | Date |
- * | TIME | Date |
- * | TIMESTAMP | Timestamp* |
- * | ENUM | EnumItem* |
- * | COMPLEX_OBJECT | BinaryObject* |
- * | BYTE_ARRAY | Array of number |
- * | SHORT_ARRAY | Array of number |
- * | INTEGER_ARRAY | Array of number |
- * | LONG_ARRAY | Array of number |
- * | FLOAT_ARRAY | Array of number |
- * | DOUBLE_ARRAY | Array of number |
- * | DECIMAL_ARRAY | Array of Decimal** |
- * | BOOLEAN_ARRAY | Array of boolean |
- * | STRING_ARRAY | Array of string |
- * | CHAR_ARRAY | Array of string (one character) |
- * | UUID_ARRAY | Array of Array of number (16 numbers) |
- * | DATE_ARRAY | Array of Date |
- * | TIME_ARRAY | Array of Date |
- * | TIMESTAMP_ARRAY | Array of Timestamp* |
- * | ENUM_ARRAY | Array of EnumItem* |
- * | OBJECT_ARRAY | Array |
- * | COLLECTION (USER_COL) | Array |
- * | COLLECTION (ARR_LIST) | Array |
- * | COLLECTION (LINKED_LIST) | Array |
- * | COLLECTION (SINGLETON_LIST) | Array |
- * | COLLECTION (HASH_SET) | Set |
- * | COLLECTION (LINKED_HASH_SET) | Set |
- * | COLLECTION (USER_SET) | Set |
- * | MAP (HASH_MAP) | Map |
- * | MAP (LINKED_HASH_MAP) | Map |
- * | NULL | null |
- * </pre>
- *
- * ----------------------------------------------------------------------------
- *
- * RETURNED JavaScript types WHEN READING DATA OF THE SPECIFIED Ignite type code.
- *
- * When an application explicitly specifies an Ignite type for a field
- * and is reading data from that field - the following JavaScript types
- * are returned for every concrete Ignite type code -
- *
- * SEE THE PREVIOUS TABLE with the following additional comments:
- *
- * - for COMPLEX_OBJECT the Ignite Client returns a JavaScript Object
- * which is defined by the specified {@link ComplexObjectType}.
- *
- * - the returned Map for MAP is defined by the specified {@link MapObjectType}.
- *
- * - the returned Set or Array for COLLECTION is defined by the specified {@link CollectionObjectType}.
- *
- * - the returned Array for OBJECT_ARRAY is defined by the specified {@link ObjectArrayType}.
- *
- * - NULL cannot be specified as a type of a field but JavaScript null may be returned
- * as a value of a field.
- *
- * ----------------------------------------------------------------------------
- *
- * ALLOWED JavaScript types WHEN WRITING DATA OF THE SPECIFIED Ignite type code.
- *
- * When an application explicitly specifies an Ignite type for a field
- * and is writing data to that field - the following JavaScript types
- * are allowed for every concrete Ignite type code -
- *
- * SEE THE PREVIOUS TABLE with the following additional comments:
- *
- * - for COMPLEX_OBJECT the Ignite Client allows a JavaScript Object
- * which is defined by the specified {@link ComplexObjectType}.
- *
- * - the allowed Map for MAP is defined by the specified {@link MapObjectType}.
- *
- * - the allowed Set or Array for COLLECTION is defined by the specified {@link CollectionObjectType}.
- *
- * - the allowed Array for OBJECT_ARRAY is defined by the specified {@link ObjectArrayType}.
- *
- * - NULL cannot be specified as a type of a field but JavaScript null is allowed
- * as value of a field (but not as a key/value in a cache) or as a value of Array/Set/Map element
- * for all Ignite types, except BYTE, SHORT, INTEGER, LONG, FLOAT, DOUBLE, CHAR, BOOLEAN.
- *
- * - for all *_ARRAY Ignite types an empty JavaScript Array is allowed.
- *
- * ----------------------------------------------------------------------------
- *
- * COMMENTS TO ALL TABLES
- *
- * JavaScript type - is a JavaScript primitive or a JavaScript Object
- * ({@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures})
- *
- * (*) Timestamp, EnumItem and BinaryObject - are JavaScript Objects introduced by the Ignite client.
- *
- * (**) Decimal - is an external JavaScript Object exported into the Ignite client
- * ({@link https://github.com/MikeMcl/decimal.js})
- *
- * Ignite type code - is the type code of an Ignite primitive type ({@link ObjectType.PRIMITIVE_TYPE})
- * or an Ignite composite type ({@link ObjectType.COMPOSITE_TYPE}).
- *
- * ----------------------------------------------------------------------------
- *
- * @hideconstructor
- */
-
-class ObjectType {
- static get PRIMITIVE_TYPE() {
- return PRIMITIVE_TYPE;
- }
-
- static get COMPOSITE_TYPE() {
- return COMPOSITE_TYPE;
- }
-
- /** Private methods */
-
- constructor(typeCode) {
- this._typeCode = typeCode;
- }
-}
-
-/**
- * Base class representing a non-primitive (composite) type of Ignite object.
- *
- * The class has no public constructor. Only subclasses may be instantiated.
- *
- * @hideconstructor
- * @extends ObjectType
- */
-class CompositeType extends ObjectType {
-}
-
-/**
- * Supported kinds of map.
- * @typedef MapObjectType.MAP_SUBTYPE
- * @enum
- * @readonly
- * @property HASH_MAP 1
- * @property LINKED_HASH_MAP 2
- */
-const MAP_SUBTYPE = Object.freeze({
- HASH_MAP : 1,
- LINKED_HASH_MAP : 2
-});
-
-/**
- * Class representing a map type of Ignite object.
- *
- * It is described by COMPOSITE_TYPE.MAP {@link ObjectType.COMPOSITE_TYPE}
- * and one of {@link MapObjectType.MAP_SUBTYPE}.
- *
- * @extends CompositeType
- */
-class MapObjectType extends CompositeType {
- static get MAP_SUBTYPE() {
- return MAP_SUBTYPE;
- }
-
- /**
- * Public constructor.
- *
- * Optionally specifies a kind of map and types of keys and values in the map.
- *
- * If a kind of map is not specified, MAP_SUBTYPE.HASH_MAP is assumed.
- *
- * If key and/or value type is not specified then during operations the Ignite client
- * will try to make automatic mapping between JavaScript types and Ignite object types -
- * according to the mapping table defined in the description of the {@link ObjectType} class.
- *
- * @param {MapObjectType.MAP_SUBTYPE} [mapSubType=MAP_SUBTYPE.HASH_MAP] - map subtype, one of the
- * {@link MapObjectType.MAP_SUBTYPE} constants.
- * @param {ObjectType.PRIMITIVE_TYPE | CompositeType} [keyType=null] - type of the keys in the map:
- * - either a type code of primitive (simple) type
- * - or an instance of class representing non-primitive (composite) type
- * - or null (or not specified) that means the type is not specified
- * @param {ObjectType.PRIMITIVE_TYPE | CompositeType} [valueType=null] - type of the values in the map:
- * - either a type code of primitive (simple) type
- * - or an instance of class representing non-primitive (composite) type
- * - or null (or not specified) that means the type is not specified
- *
- * @return {MapObjectType} - new MapObjectType instance
- *
- * @throws {IgniteClientError} if error.
- */
- constructor(mapSubType = MapObjectType.MAP_SUBTYPE.HASH_MAP, keyType = null, valueType = null) {
- super(COMPOSITE_TYPE.MAP);
- const BinaryUtils = require('./internal/BinaryUtils');
- ArgumentChecker.hasValueFrom(mapSubType, 'mapSubType', false, MapObjectType.MAP_SUBTYPE);
- this._subType = mapSubType;
- BinaryUtils.checkObjectType(keyType, 'keyType');
- BinaryUtils.checkObjectType(valueType, 'valueType');
- this._keyType = keyType;
- this._valueType = valueType;
- }
-}
-
-/**
- * Supported kinds of collections.
- * @typedef CollectionObjectType.COLLECTION_SUBTYPE
- * @enum
- * @readonly
- * @property USER_SET -1
- * @property USER_COL 0
- * @property ARRAY_LIST 1
- * @property LINKED_LIST 2
- * @property HASH_SET 3
- * @property LINKED_HASH_SET 4
- * @property SINGLETON_LIST 5
- */
-const COLLECTION_SUBTYPE = Object.freeze({
- USER_SET : -1,
- USER_COL : 0,
- ARRAY_LIST : 1,
- LINKED_LIST : 2,
- HASH_SET : 3,
- LINKED_HASH_SET : 4,
- SINGLETON_LIST : 5
-});
-
-/**
- * Class representing a collection type of Ignite object.
- *
- * It is described by COMPOSITE_TYPE.COLLECTION {@link ObjectType.COMPOSITE_TYPE}
- * and one of {@link CollectionObjectType.COLLECTION_SUBTYPE}.
- *
- * @extends CompositeType
- */
-class CollectionObjectType extends CompositeType {
- static get COLLECTION_SUBTYPE() {
- return COLLECTION_SUBTYPE;
- }
-
- /**
- * Public constructor.
- *
- * Specifies a kind of collection
- * and optionally specifies a type of elements in the collection.
- *
- * If the type of elements is not specified then during operations the Ignite client
- * will try to make automatic mapping between JavaScript types and Ignite object types -
- * according to the mapping table defined in the description of the {@link ObjectType} class.
- *
- * @param {CollectionObjectType.COLLECTION_SUBTYPE} collectionSubType - collection subtype, one of the
- * {@link CollectionObjectType.COLLECTION_SUBTYPE} constants.
- * @param {ObjectType.PRIMITIVE_TYPE | CompositeType} [elementType=null] - type of elements in the collection:
- * - either a type code of primitive (simple) type
- * - or an instance of class representing non-primitive (composite) type
- * - or null (or not specified) that means the type is not specified
- *
- * @return {CollectionObjectType} - new CollectionObjectType instance
- *
- * @throws {IgniteClientError} if error.
- */
- constructor(collectionSubType, elementType = null) {
- super(COMPOSITE_TYPE.COLLECTION);
- const BinaryUtils = require('./internal/BinaryUtils');
- ArgumentChecker.hasValueFrom(
- collectionSubType, 'collectionSubType', false, CollectionObjectType.COLLECTION_SUBTYPE);
- this._subType = collectionSubType;
- BinaryUtils.checkObjectType(elementType, 'elementType');
- this._elementType = elementType;
- }
-
- /** Private methods */
-
- /**
- * @ignore
- */
- static _isSet(subType) {
- return subType === CollectionObjectType.COLLECTION_SUBTYPE.USER_SET ||
- subType === CollectionObjectType.COLLECTION_SUBTYPE.HASH_SET ||
- subType === CollectionObjectType.COLLECTION_SUBTYPE.LINKED_HASH_SET;
- }
-
- /**
- * @ignore
- */
- _isSet() {
- return CollectionObjectType._isSet(this._subType);
- }
-}
-
-/**
- * Class representing an array type of Ignite objects.
- *
- * It is described by COMPOSITE_TYPE.OBJECT_ARRAY {@link ObjectType.COMPOSITE_TYPE}.
- *
- * @extends CompositeType
- */
-class ObjectArrayType extends CompositeType {
-
- /**
- * Public constructor.
- *
- * Optionally specifies a type of elements in the array.
- *
- * If the type of elements is not specified then during operations the Ignite client
- * will try to make automatic mapping between JavaScript types and Ignite object types -
- * according to the mapping table defined in the description of the {@link ObjectType} class.
- *
- * @param {ObjectType.PRIMITIVE_TYPE | CompositeType} [elementType=null] - type of the array element:
- * - either a type code of primitive (simple) type
- * - or an instance of class representing non-primitive (composite) type
- * - or null (or not specified) that means the type is not specified
- *
- * @return {ObjectArrayType} - new ObjectArrayType instance
- *
- * @throws {IgniteClientError} if error.
- */
- constructor(elementType = null) {
- super(COMPOSITE_TYPE.OBJECT_ARRAY);
- const BinaryUtils = require('./internal/BinaryUtils');
- BinaryUtils.checkObjectType(elementType, 'elementType');
- this._elementType = elementType;
- }
-}
-
-/**
- * Class representing a complex type of Ignite object.
- *
- * It is described by COMPOSITE_TYPE.COMPLEX_OBJECT {@link ObjectType.COMPOSITE_TYPE},
- * by a name of the complex type and by a JavaScript Object which is mapped to/from the Ignite complex type.
- *
- * @extends CompositeType
- */
-class ComplexObjectType extends CompositeType {
-
- /**
- * Public constructor.
- *
- * Specifies a JavaScript Object type which will be mapped to/from the complex type.
- * This specification is done using an instance of the JavaScript Object.
- *
- * If an object of the complex type is going to be received (deserialized),
- * the JavaScript Object must have a constructor without parameters or with optional parameters only.
- *
- * The JavaScript Object defines a set of fields of the complex type.
- *
- * By default, the fields have no types specified. It means during operations the Ignite client
- * will try to make automatic mapping between JavaScript types and Ignite object types -
- * according to the mapping table defined in the description of the {@link ObjectType} class.
- *
- * A type of any field may be specified later by setFieldType() method.
- *
- * By default, the name of the complex type is the name of the JavaScript Object.
- * The name may be explicitely specified using optional typeName parameter in the constructor.
- *
- * @param {object} jsObject - instance of JavaScript Object which will be mapped to/from this complex type.
- * @param {string} [typeName] - name of the complex type.
- *
- * @return {ComplexObjectType} - new ComplexObjectType instance
- *
- * @throws {IgniteClientError} if error.
- */
- constructor(jsObject, typeName = null) {
- super(COMPOSITE_TYPE.COMPLEX_OBJECT);
- ArgumentChecker.notEmpty(jsObject, 'jsObject');
- this._template = jsObject;
- this._objectConstructor = jsObject && jsObject.constructor ?
- jsObject.constructor : Object;
- if (!typeName) {
- typeName = this._objectConstructor.name;
- }
- this._typeName = typeName;
- this._fields = new Map();
- const BinaryUtils = require('./internal/BinaryUtils');
- for (let fieldName of BinaryUtils.getJsObjectFieldNames(this._template)) {
- this._fields.set(fieldName, null);
- }
- }
-
- /**
- * Specifies a type of the field in the complex type.
- *
- * If the type is not specified then during operations the Ignite client
- * will try to make automatic mapping between JavaScript types and Ignite object types -
- * according to the mapping table defined in the description of the {@link ObjectType} class.
- *
- * @param {string} fieldName - name of the field.
- * @param {ObjectType.PRIMITIVE_TYPE | CompositeType} fieldType - type of the field:
- * - either a type code of primitive (simple) type
- * - or an instance of class representing non-primitive (composite) type
- * - or null (means the type is not specified).
- *
- * @return {ComplexObjectType} - the same instance of the ComplexObjectType.
- *
- * @throws {IgniteClientError} if error.
- */
- setFieldType(fieldName, fieldType) {
- if (!this._fields.has(fieldName)) {
- throw Errors.IgniteClientError.illegalArgumentError(
- Util.format('Field "%s" is absent in the complex object type', fieldName));
- }
- const BinaryUtils = require('./internal/BinaryUtils');
- BinaryUtils.checkObjectType(fieldType, 'fieldType');
- this._fields.set(fieldName, fieldType);
- return this;
- }
-
- /** Private methods */
-
- /**
- * @ignore
- */
- _getFieldType(fieldName) {
- return this._fields.get(fieldName);
- }
-}
-
-module.exports.ObjectType = ObjectType;
-module.exports.CompositeType = CompositeType;
-module.exports.MapObjectType = MapObjectType;
-module.exports.CollectionObjectType = CollectionObjectType;
-module.exports.ComplexObjectType = ComplexObjectType;
-module.exports.ObjectArrayType = ObjectArrayType;
diff --git a/modules/platforms/nodejs/lib/Query.js b/modules/platforms/nodejs/lib/Query.js
deleted file mode 100644
index d3f6f87..0000000
--- a/modules/platforms/nodejs/lib/Query.js
+++ /dev/null
@@ -1,508 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-'use strict';
-
-const Cursor = require('./Cursor').Cursor;
-const SqlFieldsCursor = require('./Cursor').SqlFieldsCursor;
-const ArgumentChecker = require('./internal/ArgumentChecker');
-const BinaryCommunicator = require('./internal/BinaryCommunicator');
-const BinaryUtils = require('./internal/BinaryUtils');
-
-const PAGE_SIZE_DEFAULT = 1024;
-
-/**
- * Base class representing an Ignite SQL or Scan query.
- *
- * The class has no public constructor. Only subclasses may be instantiated.
- *
- * @hideconstructor
- */
-class Query {
-
- /**
- * Set local query flag.
- *
- * @param {boolean} local - local query flag: true or false.
- *
- * @return {Query} - the same instance of the Query.
- */
- setLocal(local) {
- this._local = local;
- return this;
- }
-
- /**
- * Set {@link Cursor} page size.
- *
- * @param {number} pageSize - cursor page size.
- *
- * @return {Query} - the same instance of the Query.
- */
- setPageSize(pageSize) {
- this._pageSize = pageSize;
- return this;
- }
-
- /** Private methods */
-
- /**
- * @ignore
- */
- constructor(operation) {
- this._operation = operation;
- this._local = false;
- this._pageSize = PAGE_SIZE_DEFAULT;
- }
-}
-
-/**
- * Class representing an SQL query which returns the whole cache entries (key-value pairs).
- * @extends Query
- */
-class SqlQuery extends Query {
-
- /**
- * Public constructor.
- *
- * Requires name of a type (or SQL table) and SQL query string to be specified.
- * Other SQL query settings have the following defaults:
- * <pre>
- * SQL Query setting : Default value
- * Local query flag : false
- * Cursor page size : 1024
- * Query arguments : not specified
- * Distributed joins flag : false
- * Replicated only flag : false
- * Timeout : 0 (disabled)
- * </pre>
- * Every setting may be changed using set methods.
- *
- * @param {string} type - name of a type or SQL table.
- * @param {string} sql - SQL query string.
- *
- * @return {SqlQuery} - new SqlQuery instance.
- */
- constructor(type, sql) {
- super(BinaryUtils.OPERATION.QUERY_SQL);
- this.setType(type);
- this.setSql(sql);
- this._args = null;
- this._argTypes = null;
- this._distributedJoins = false;
- this._replicatedOnly = false;
- this._timeout = 0;
- }
-
- /**
- * Set name of a type or SQL table.
- *
- * @param {string} type - name of a type or SQL table.
- *
- * @return {SqlQuery} - the same instance of the SqlQuery.
- */
- setType(type) {
- if (this instanceof SqlFieldsQuery) {
- ArgumentChecker.invalidArgument(type, 'type', SqlFieldsQuery);
- }
- else {
- ArgumentChecker.notNull(type, 'type');
- }
- this._type = type;
- return this;
- }
-
- /**
- * Set SQL query string.
- *
- * @param {string} sql - SQL query string.
- *
- * @return {SqlQuery} - the same instance of the SqlQuery.
- */
- setSql(sql) {
- ArgumentChecker.notNull(sql, 'sql');
- this._sql = sql;
- return this;
- }
-
- /**
- * Set query arguments.
- *
- * Type of any argument may be specified using setArgTypes() method.
- * If type of an argument is not specified then during operations the Ignite client
- * will try to make automatic mapping between JavaScript types and Ignite object types -
- * according to the mapping table defined in the description of the {@link ObjectType} class.
- *
- * @param {...*} args - Query arguments.
- *
- * @return {SqlQuery} - the same instance of the SqlQuery.
- */
- setArgs(...args) {
- this._args = args;
- return this;
- }
-
- /**
- * Specifies types of query arguments.
- *
- * Query arguments itself are set using setArgs() method.
- * By default, a type of every argument is not specified that means during operations the Ignite client
- * will try to make automatic mapping between JavaScript types and Ignite object types -
- * according to the mapping table defined in the description of the {@link ObjectType} class.
- *
- * @param {...ObjectType.PRIMITIVE_TYPE | CompositeType} argTypes - types of Query arguments.
- * The order of types must follow the order of arguments in the setArgs() method.
- * A type of every argument can be:
- * - either a type code of primitive (simple) type
- * - or an instance of class representing non-primitive (composite) type
- * - or null (means the type is not specified)
- *
- * @return {SqlQuery} - the same instance of the SqlQuery.
- */
- setArgTypes(...argTypes) {
- this._argTypes = argTypes;
- return this;
- }
-
- /**
- * Set distributed joins flag.
- *
- * @param {boolean} distributedJoins - distributed joins flag: true or false.
- *
- * @return {SqlQuery} - the same instance of the SqlQuery.
- */
- setDistributedJoins(distributedJoins) {
- this._distributedJoins = distributedJoins;
- return this;
- }
-
- /**
- * Set replicated only flag.
- *
- * @param {boolean} replicatedOnly - replicated only flag: true or false.
- *
- * @return {SqlQuery} - the same instance of the SqlQuery.
- */
- setReplicatedOnly(replicatedOnly) {
- this._replicatedOnly = replicatedOnly;
- return this;
- }
-
- /**
- * Set timeout.
- *
- * @param {number} timeout - timeout value in milliseconds.
- * Must be non-negative. Zero value disables timeout.
- *
- * @return {SqlQuery} - the same instance of the SqlQuery.
- */
- setTimeout(timeout) {
- this._timeout = timeout;
- return this;
- }
-
- /** Private methods */
-
- /**
- * @ignore
- */
- async _write(communicator, buffer) {
- BinaryCommunicator.writeString(buffer, this._type);
- BinaryCommunicator.writeString(buffer, this._sql);
- await this._writeArgs(communicator, buffer);
- buffer.writeBoolean(this._distributedJoins);
- buffer.writeBoolean(this._local);
- buffer.writeBoolean(this._replicatedOnly);
- buffer.writeInteger(this._pageSize);
- buffer.writeLong(this._timeout);
- }
-
- /**
- * @ignore
- */
- async _writeArgs(communicator, buffer) {
- const argsLength = this._args ? this._args.length : 0;
- buffer.writeInteger(argsLength);
- if (argsLength > 0) {
- let argType;
- for (let i = 0; i < argsLength; i++) {
- argType = this._argTypes && i < this._argTypes.length ? this._argTypes[i] : null;
- await communicator.writeObject(buffer, this._args[i], argType);
- }
- }
- }
-
- /**
- * @ignore
- */
- async _getCursor(communicator, payload, keyType = null, valueType = null) {
- const cursor = new Cursor(communicator, BinaryUtils.OPERATION.QUERY_SQL_CURSOR_GET_PAGE, payload, keyType, valueType);
- cursor._readId(payload);
- return cursor;
- }
-}
-
-/**
- * Statement type of SQL Fields query.
- * @typedef SqlFieldsQuery.STATEMENT_TYPE
- * @enum
- * @readonly
- * @property ANY 0
- * @property SELECT 1
- * @property UPDATE 2
- */
-const STATEMENT_TYPE = Object.freeze({
- ANY : 0,
- SELECT : 1,
- UPDATE : 2
-});
-
-
-/**
- * Class representing an SQL Fields query.
- * @extends SqlQuery
- */
-class SqlFieldsQuery extends SqlQuery {
-
- /**
- * Public constructor.
- *
- * Requires SQL query string to be specified.
- * Other SQL Fields query settings have the following defaults:
- * <pre>
- * SQL Fields Query setting : Default value
- * Local query flag : false
- * Cursor page size : 1024
- * Query arguments : not specified
- * Distributed joins flag : false
- * Replicated only flag : false
- * Timeout : 0 (disabled)
- * Schema for the query : not specified
- * Max rows : -1
- * Statement type : STATEMENT_TYPE.ANY
- * Enforce join order flag : false
- * Collocated flag : false
- * Lazy query execution flag : false
- * Include field names flag : false
- * </pre>
- * Every setting may be changed using set methods.
- *
- * @param {string} sql - SQL query string.
- *
- * @return {SqlFieldsQuery} - new SqlFieldsQuery instance.
- */
- constructor(sql) {
- super(null, sql);
- this._operation = BinaryUtils.OPERATION.QUERY_SQL_FIELDS;
- this._schema = null;
- this._maxRows = -1;
- this._statementType = SqlFieldsQuery.STATEMENT_TYPE.ANY;
- this._enforceJoinOrder = false;
- this._collocated = false;
- this._lazy = false;
- this._includeFieldNames = false;
- }
-
- static get STATEMENT_TYPE() {
- return STATEMENT_TYPE;
- }
-
- /**
- * Set schema for the query.
- *
- * @param {string} schema - schema for the query.
- *
- * @return {SqlFieldsQuery} - the same instance of the SqlFieldsQuery.
- */
- setSchema(schema) {
- this._schema = schema;
- return this;
- }
-
- /**
- * Set max rows.
- *
- * @param {number} maxRows - max rows.
- *
- * @return {SqlFieldsQuery} - the same instance of the SqlFieldsQuery.
- */
- setMaxRows(maxRows) {
- this._maxRows = maxRows;
- return this;
- }
-
- /**
- * Set statement type.
- *
- * @param {SqlFieldsQuery.STATEMENT_TYPE} type - statement type.
- *
- * @return {SqlFieldsQuery} - the same instance of the SqlFieldsQuery.
- */
- setStatementType(type) {
- this._statementType = type;
- return this;
- }
-
- /**
- * Set enforce join order flag.
- *
- * @param {boolean} enforceJoinOrder - enforce join order flag: true or false.
- *
- * @return {SqlFieldsQuery} - the same instance of the SqlFieldsQuery.
- */
- setEnforceJoinOrder(enforceJoinOrder) {
- this._enforceJoinOrder = enforceJoinOrder;
- return this;
- }
-
- /**
- * Set collocated flag.
- *
- * @param {boolean} collocated - collocated flag: true or false.
- *
- * @return {SqlFieldsQuery} - the same instance of the SqlFieldsQuery.
- */
- setCollocated(collocated) {
- this._collocated = collocated;
- return this;
- }
-
- /**
- * Set lazy query execution flag.
- *
- * @param {boolean} lazy - lazy query execution flag: true or false.
- *
- * @return {SqlFieldsQuery} - the same instance of the SqlFieldsQuery.
- */
- setLazy(lazy) {
- this._lazy = lazy;
- return this;
- }
-
- /**
- * Set include field names flag.
- *
- * @param {boolean} includeFieldNames - include field names flag: true or false.
- *
- * @return {SqlFieldsQuery} - the same instance of the SqlFieldsQuery.
- */
- setIncludeFieldNames(includeFieldNames) {
- this._includeFieldNames = includeFieldNames;
- return this;
- }
-
- /** Private methods */
-
- /**
- * @ignore
- */
- async _write(communicator, buffer) {
- BinaryCommunicator.writeString(buffer, this._schema);
- buffer.writeInteger(this._pageSize);
- buffer.writeInteger(this._maxRows);
- BinaryCommunicator.writeString(buffer, this._sql);
- await this._writeArgs(communicator, buffer)
- buffer.writeByte(this._statementType);
- buffer.writeBoolean(this._distributedJoins);
- buffer.writeBoolean(this._local);
- buffer.writeBoolean(this._replicatedOnly);
- buffer.writeBoolean(this._enforceJoinOrder);
- buffer.writeBoolean(this._collocated);
- buffer.writeBoolean(this._lazy);
- buffer.writeLong(this._timeout);
- buffer.writeBoolean(this._includeFieldNames);
- }
-
- /**
- * @ignore
- */
- async _getCursor(communicator, payload, keyType = null, valueType = null) {
- const cursor = new SqlFieldsCursor(communicator, payload);
- await cursor._readFieldNames(payload, this._includeFieldNames);
- return cursor;
- }
-}
-
-/**
- * Class representing a Scan query which returns the whole cache entries (key-value pairs).
- *
- * This version of the class does not support a possibility to specify a Filter object for the query.
- * The query returns all entries from the entire cache or from the specified partition.
- * @extends Query
- */
-class ScanQuery extends Query {
-
- /**
- * Public constructor.
- *
- * Scan query settings have the following defaults:
- * <pre>
- * Scan Query setting : Default value
- * Local query flag : false
- * Cursor page size : 1024
- * Partition number : -1 (entire cache)
- * Filter object : null (not supported)
- * </pre>
- * Every setting (except Filter object) may be changed using set methods.
- *
- * @return {ScanQuery} - new ScanQuery instance.
- */
- constructor() {
- super(BinaryUtils.OPERATION.QUERY_SCAN);
- this._partitionNumber = -1;
- }
-
- /**
- * Sets a partition number over which this query should iterate.
- *
- * If negative, the query will iterate over all partitions in the cache.
- *
- * @param {number} partitionNumber - partition number over which this query should iterate.
- *
- * @return {ScanQuery} - the same instance of the ScanQuery.
- */
- setPartitionNumber(partitionNumber) {
- this._partitionNumber = partitionNumber;
- return this;
- }
-
- /** Private methods */
-
- /**
- * @ignore
- */
- async _write(communicator, buffer) {
- // filter
- await communicator.writeObject(buffer, null);
- buffer.writeInteger(this._pageSize);
- buffer.writeInteger(this._partitionNumber);
- buffer.writeBoolean(this._local);
- }
-
- /**
- * @ignore
- */
- async _getCursor(communicator, payload, keyType = null, valueType = null) {
- const cursor = new Cursor(communicator, BinaryUtils.OPERATION.QUERY_SCAN_CURSOR_GET_PAGE, payload, keyType, valueType);
- cursor._readId(payload);
- return cursor;
- }
-}
-
-module.exports.SqlQuery = SqlQuery;
-module.exports.SqlFieldsQuery = SqlFieldsQuery;
-module.exports.ScanQuery = ScanQuery;
diff --git a/modules/platforms/nodejs/lib/Timestamp.js b/modules/platforms/nodejs/lib/Timestamp.js
deleted file mode 100644
index 04d750c..0000000
--- a/modules/platforms/nodejs/lib/Timestamp.js
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-'use strict';
-
-const ArgumentChecker = require('./internal/ArgumentChecker');
-
-/**
- * Class representing an Ignite timestamp type.
- *
- * The timestamp extends the standard JavaScript {@link Date} Object and consists of:
- * - time - the number of milliseconds since January 1, 1970, 00:00:00 UTC,
- * methods of the JavaScript {@link Date} Object can be used to operate with the time.
- * - nanoseconds - fraction of the last millisecond in the range from 0 to 999999 nanoseconds,
- * this class specifies additional methods to operate with the nanoseconds.
- * @extends Date
- */
-class Timestamp extends Date {
-
- /**
- * Public constructor.
- *
- * @param {number} time - integer value representing the number of milliseconds since January 1, 1970, 00:00:00 UTC.
- * @param {number} nanos - integer value representing the nanoseconds of the last millisecond,
- * should be in the range from 0 to 999999.
- *
- * @return {Timestamp} - new Timestamp instance
- *
- * @throws {IgniteClientError} if error.
- */
- constructor(time, nanos) {
- super(time);
- this.setNanos(nanos);
- }
-
- /**
- * Returns the nanoseconds of the last millisecond from the timestamp.
- *
- * @return {number} - nanoseconds of the last millisecond.
- */
- getNanos() {
- return this._nanos;
- }
-
- /**
- * Updates the nanoseconds of the last millisecond in the timestamp.
- *
- * @param {number} nanos - new value for the nanoseconds of the last millisecond,
- * should be in the range from 0 to 999999.
- *
- * @return {Timestamp} - the same instance of Timestamp
- *
- * @throws {IgniteClientError} if error.
- */
- setNanos(nanos) {
- ArgumentChecker.isInteger(nanos, 'nanos');
- this._nanos = nanos;
- return this;
- }
-}
-
-module.exports = Timestamp;
diff --git a/modules/platforms/nodejs/lib/internal/ArgumentChecker.js b/modules/platforms/nodejs/lib/internal/ArgumentChecker.js
deleted file mode 100644
index 9e60ad6..0000000
--- a/modules/platforms/nodejs/lib/internal/ArgumentChecker.js
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-'use strict';
-
-const Util = require('util');
-const Errors = require('../Errors');
-
-/** Helper class for the library methods arguments check. */
-class ArgumentChecker {
- static notEmpty(arg, argName) {
- if (!arg || arg instanceof Array && arg.length === 0) {
- throw Errors.IgniteClientError.illegalArgumentError(Util.format('"%s" argument should not be empty', argName));
- }
- }
-
- static notNull(arg, argName) {
- if (arg === null || arg === undefined) {
- throw Errors.IgniteClientError.illegalArgumentError(Util.format('"%s" argument should not be null', argName));
- }
- }
-
- static hasType(arg, argName, isArray, ...types) {
- if (arg === null) {
- return;
- }
- if (isArray && arg instanceof Array) {
- for (let a of arg) {
- ArgumentChecker.hasType(a, argName, false, ...types);
- }
- }
- else {
- for (let type of types) {
- if (arg instanceof type) {
- return;
- }
- }
- throw Errors.IgniteClientError.illegalArgumentError(Util.format('"%s" argument has incorrect type', argName));
- }
- }
-
- static hasValueFrom(arg, argName, isArray, values) {
- if (isArray && arg instanceof Array) {
- for (let a of arg) {
- ArgumentChecker.hasValueFrom(a, argName, false, values);
- }
- }
- else {
- if (!Object.values(values).includes(arg)) {
- throw Errors.IgniteClientError.illegalArgumentError(Util.format('"%s" argument has incorrect value', argName));
- }
- }
- }
-
- static isInteger(arg, argName) {
- if (arg === null || arg === undefined || !Number.isInteger(arg)) {
- throw Errors.IgniteClientError.illegalArgumentError(Util.format('"%s" argument should be integer', argName));
- }
- }
-
- static invalidArgument(arg, argName, type) {
- if (arg !== null && arg !== undefined) {
- throw Errors.IgniteClientError.illegalArgumentError(
- Util.format('"%s" argument is invalid for %s', argName, type.constructor.name));
- }
- }
-}
-
-module.exports = ArgumentChecker;
diff --git a/modules/platforms/nodejs/lib/internal/BinaryCommunicator.js b/modules/platforms/nodejs/lib/internal/BinaryCommunicator.js
deleted file mode 100644
index 20ddcff..0000000
--- a/modules/platforms/nodejs/lib/internal/BinaryCommunicator.js
+++ /dev/null
@@ -1,409 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-'use strict';
-
-const Decimal = require('decimal.js');
-const CollectionObjectType = require('../ObjectType').CollectionObjectType;
-const ComplexObjectType = require('../ObjectType').ComplexObjectType;
-const Errors = require('../Errors');
-const Timestamp = require('../Timestamp');
-const EnumItem = require('../EnumItem');
-const BinaryUtils = require('./BinaryUtils');
-const BinaryTypeStorage = require('./BinaryTypeStorage');
-
-class BinaryCommunicator {
-
- constructor(socket) {
- this._socket = socket;
- this._typeStorage = new BinaryTypeStorage(this);
- }
-
- static readString(buffer) {
- const typeCode = buffer.readByte();
- BinaryUtils.checkTypesComatibility(BinaryUtils.TYPE_CODE.STRING, typeCode);
- if (typeCode === BinaryUtils.TYPE_CODE.NULL) {
- return null;
- }
- return buffer.readString();
- }
-
- static writeString(buffer, value) {
- if (value === null) {
- buffer.writeByte(BinaryUtils.TYPE_CODE.NULL);
- }
- else {
- buffer.writeByte(BinaryUtils.TYPE_CODE.STRING);
- buffer.writeString(value);
- }
- }
-
- async send(opCode, payloadWriter, payloadReader = null) {
- await this._socket.send(opCode, payloadWriter, payloadReader);
- }
-
- get typeStorage() {
- return this._typeStorage;
- }
-
- async readObject(buffer, expectedType = null) {
- const typeCode = buffer.readByte();
- BinaryUtils.checkTypesComatibility(expectedType, typeCode);
- return await this._readTypedObject(buffer, typeCode, expectedType);
- }
-
- async readStringArray(buffer) {
- return await this._readTypedObject(buffer, BinaryUtils.TYPE_CODE.STRING_ARRAY);
- }
-
- async writeObject(buffer, object, objectType = null, writeObjectType = true) {
- BinaryUtils.checkCompatibility(object, objectType);
- if (object === null) {
- buffer.writeByte(BinaryUtils.TYPE_CODE.NULL);
- return;
- }
-
- objectType = objectType ? objectType : BinaryUtils.calcObjectType(object);
- const objectTypeCode = BinaryUtils.getTypeCode(objectType);
-
- if (writeObjectType) {
- buffer.writeByte(objectTypeCode);
- }
- switch (objectTypeCode) {
- case BinaryUtils.TYPE_CODE.BYTE:
- case BinaryUtils.TYPE_CODE.SHORT:
- case BinaryUtils.TYPE_CODE.INTEGER:
- case BinaryUtils.TYPE_CODE.FLOAT:
- case BinaryUtils.TYPE_CODE.DOUBLE:
- buffer.writeNumber(object, objectTypeCode);
- break;
- case BinaryUtils.TYPE_CODE.LONG:
- buffer.writeLong(object);
- break;
- case BinaryUtils.TYPE_CODE.CHAR:
- buffer.writeChar(object);
- break;
- case BinaryUtils.TYPE_CODE.BOOLEAN:
- buffer.writeBoolean(object);
- break;
- case BinaryUtils.TYPE_CODE.STRING:
- buffer.writeString(object);
- break;
- case BinaryUtils.TYPE_CODE.UUID:
- this._writeUUID(buffer, object);
- break;
- case BinaryUtils.TYPE_CODE.DATE:
- buffer.writeDate(object);
- break;
- case BinaryUtils.TYPE_CODE.ENUM:
- await this._writeEnum(buffer, object);
- break;
- case BinaryUtils.TYPE_CODE.DECIMAL:
- this._writeDecimal(buffer, object);
- break;
- case BinaryUtils.TYPE_CODE.TIMESTAMP:
- this._writeTimestamp(buffer, object);
- break;
- case BinaryUtils.TYPE_CODE.TIME:
- this._writeTime(buffer, object);
- break;
- case BinaryUtils.TYPE_CODE.BYTE_ARRAY:
- case BinaryUtils.TYPE_CODE.SHORT_ARRAY:
- case BinaryUtils.TYPE_CODE.INTEGER_ARRAY:
- case BinaryUtils.TYPE_CODE.LONG_ARRAY:
- case BinaryUtils.TYPE_CODE.FLOAT_ARRAY:
- case BinaryUtils.TYPE_CODE.DOUBLE_ARRAY:
- case BinaryUtils.TYPE_CODE.CHAR_ARRAY:
- case BinaryUtils.TYPE_CODE.BOOLEAN_ARRAY:
- case BinaryUtils.TYPE_CODE.STRING_ARRAY:
- case BinaryUtils.TYPE_CODE.UUID_ARRAY:
- case BinaryUtils.TYPE_CODE.DATE_ARRAY:
- case BinaryUtils.TYPE_CODE.OBJECT_ARRAY:
- case BinaryUtils.TYPE_CODE.ENUM_ARRAY:
- case BinaryUtils.TYPE_CODE.DECIMAL_ARRAY:
- case BinaryUtils.TYPE_CODE.TIMESTAMP_ARRAY:
- case BinaryUtils.TYPE_CODE.TIME_ARRAY:
- await this._writeArray(buffer, object, objectType, objectTypeCode);
- break;
- case BinaryUtils.TYPE_CODE.COLLECTION:
- await this._writeCollection(buffer, object, objectType);
- break;
- case BinaryUtils.TYPE_CODE.MAP:
- await this._writeMap(buffer, object, objectType);
- break;
- case BinaryUtils.TYPE_CODE.BINARY_OBJECT:
- await this._writeBinaryObject(buffer, object, objectType);
- break;
- case BinaryUtils.TYPE_CODE.COMPLEX_OBJECT:
- await this._writeComplexObject(buffer, object, objectType);
- break;
- default:
- throw Errors.IgniteClientError.unsupportedTypeError(objectType);
- }
- }
-
- async _readTypedObject(buffer, objectTypeCode, expectedType = null) {
- switch (objectTypeCode) {
- case BinaryUtils.TYPE_CODE.BYTE:
- case BinaryUtils.TYPE_CODE.SHORT:
- case BinaryUtils.TYPE_CODE.INTEGER:
- case BinaryUtils.TYPE_CODE.FLOAT:
- case BinaryUtils.TYPE_CODE.DOUBLE:
- return buffer.readNumber(objectTypeCode);
- case BinaryUtils.TYPE_CODE.LONG:
- return buffer.readLong().toNumber();
- case BinaryUtils.TYPE_CODE.CHAR:
- return buffer.readChar();
- case BinaryUtils.TYPE_CODE.BOOLEAN:
- return buffer.readBoolean();
- case BinaryUtils.TYPE_CODE.STRING:
- return buffer.readString();
- case BinaryUtils.TYPE_CODE.UUID:
- return this._readUUID(buffer);
- case BinaryUtils.TYPE_CODE.DATE:
- return buffer.readDate();
- case BinaryUtils.TYPE_CODE.ENUM:
- case BinaryUtils.TYPE_CODE.BINARY_ENUM:
- return await this._readEnum(buffer);
- case BinaryUtils.TYPE_CODE.DECIMAL:
- return this._readDecimal(buffer);
- case BinaryUtils.TYPE_CODE.TIMESTAMP:
- return this._readTimestamp(buffer);
- case BinaryUtils.TYPE_CODE.TIME:
- return buffer.readDate();
- case BinaryUtils.TYPE_CODE.BYTE_ARRAY:
- case BinaryUtils.TYPE_CODE.SHORT_ARRAY:
- case BinaryUtils.TYPE_CODE.INTEGER_ARRAY:
- case BinaryUtils.TYPE_CODE.LONG_ARRAY:
- case BinaryUtils.TYPE_CODE.FLOAT_ARRAY:
- case BinaryUtils.TYPE_CODE.DOUBLE_ARRAY:
- case BinaryUtils.TYPE_CODE.CHAR_ARRAY:
- case BinaryUtils.TYPE_CODE.BOOLEAN_ARRAY:
- case BinaryUtils.TYPE_CODE.STRING_ARRAY:
- case BinaryUtils.TYPE_CODE.UUID_ARRAY:
- case BinaryUtils.TYPE_CODE.DATE_ARRAY:
- case BinaryUtils.TYPE_CODE.OBJECT_ARRAY:
- case BinaryUtils.TYPE_CODE.ENUM_ARRAY:
- case BinaryUtils.TYPE_CODE.DECIMAL_ARRAY:
- case BinaryUtils.TYPE_CODE.TIMESTAMP_ARRAY:
- case BinaryUtils.TYPE_CODE.TIME_ARRAY:
- return await this._readArray(buffer, objectTypeCode, expectedType);
- case BinaryUtils.TYPE_CODE.COLLECTION:
- return await this._readCollection(buffer, expectedType);
- case BinaryUtils.TYPE_CODE.MAP:
- return await this._readMap(buffer, expectedType);
- case BinaryUtils.TYPE_CODE.BINARY_OBJECT:
- return await this._readBinaryObject(buffer, expectedType);
- case BinaryUtils.TYPE_CODE.NULL:
- return null;
- case BinaryUtils.TYPE_CODE.COMPLEX_OBJECT:
- return await this._readComplexObject(buffer, expectedType);
- default:
- throw Errors.IgniteClientError.unsupportedTypeError(objectTypeCode);
- }
- }
-
- _readUUID(buffer) {
- return [...buffer.readBuffer(BinaryUtils.getSize(BinaryUtils.TYPE_CODE.UUID)).swap64()];
- }
-
- async _readEnum(buffer) {
- const enumItem = new EnumItem(0);
- await enumItem._read(this, buffer);
- return enumItem;
- }
-
- _readDecimal(buffer) {
- const scale = buffer.readInteger();
- const dataLength = buffer.readInteger();
- const data = buffer.readBuffer(dataLength);
- const isNegative = (data[0] & 0x80) !== 0;
- if (isNegative) {
- data[0] &= 0x7F;
- }
- let result = new Decimal('0x' + data.toString('hex'));
- if (isNegative) {
- result = result.negated();
- }
- return result.mul(Decimal.pow(10, -scale));
- }
-
- _readTimestamp(buffer) {
- return new Timestamp(buffer.readLong().toNumber(), buffer.readInteger());
- }
-
- async _readArray(buffer, arrayTypeCode, arrayType) {
- if (arrayTypeCode === BinaryUtils.TYPE_CODE.OBJECT_ARRAY) {
- buffer.readInteger();
- }
- const length = buffer.readInteger();
- const elementType = BinaryUtils.getArrayElementType(arrayType ? arrayType : arrayTypeCode);
- const keepElementType = elementType === null ? true : BinaryUtils.keepArrayElementType(arrayTypeCode);
- const result = new Array(length);
- for (let i = 0; i < length; i++) {
- result[i] = keepElementType ?
- await this.readObject(buffer, elementType) :
- await this._readTypedObject(buffer, elementType);
- }
- return result;
- }
-
- async _readMap(buffer, expectedMapType) {
- const result = new Map();
- const size = buffer.readInteger();
- const subType = buffer.readByte();
- let key, value;
- for (let i = 0; i < size; i++) {
- key = await this.readObject(buffer, expectedMapType ? expectedMapType._keyType : null);
- value = await this.readObject(buffer, expectedMapType ? expectedMapType._valueType : null);
- result.set(key, value);
- }
- return result;
- }
-
- async _readCollection(buffer, expectedColType) {
- const size = buffer.readInteger();
- const subType = buffer.readByte();
- const isSet = CollectionObjectType._isSet(subType);
- const result = isSet ? new Set() : new Array(size);
- let element;
- for (let i = 0; i < size; i++) {
- element = await this.readObject(buffer, expectedColType ? expectedColType._elementType : null);
- if (isSet) {
- result.add(element);
- }
- else {
- result[i] = element;
- }
- }
- return result;
- }
-
- async _readBinaryObject(buffer, expectedType) {
- const size = buffer.readInteger();
- const startPos = buffer.position;
- buffer.position = startPos + size;
- const offset = buffer.readInteger();
- const endPos = buffer.position;
- buffer.position = startPos + offset;
- const result = await this.readObject(buffer, expectedType);
- buffer.position = endPos;
- return result;
- }
-
- async _readComplexObject(buffer, expectedType) {
- buffer.position = buffer.position - 1;
- const BinaryObject = require('../BinaryObject');
- const binaryObject = await BinaryObject._fromBuffer(this, buffer);
- return expectedType ?
- await binaryObject.toObject(expectedType) : binaryObject;
- }
-
- _writeUUID(buffer, value) {
- buffer.writeBuffer(Buffer.from(value).swap64());
- }
-
- async _writeEnum(buffer, enumValue) {
- await enumValue._write(this, buffer);
- }
-
- _writeDecimal(buffer, decimal) {
- let strValue = decimal.toExponential();
- let expIndex = strValue.indexOf('e');
- if (expIndex < 0) {
- expIndex = strValue.indexOf('E');
- }
- let scale = 0;
- if (expIndex >= 0) {
- scale = parseInt(strValue.substring(expIndex + 1));
- strValue = strValue.substring(0, expIndex);
- }
- const isNegative = strValue.startsWith('-');
- if (isNegative) {
- strValue = strValue.substring(1);
- }
- const dotIndex = strValue.indexOf('.');
- if (dotIndex >= 0) {
- scale -= strValue.length - dotIndex - 1;
- strValue = strValue.substring(0, dotIndex) + strValue.substring(dotIndex + 1);
- }
- scale = -scale;
- let hexValue = new Decimal(strValue).toHexadecimal().substring(2);
- hexValue = ((hexValue.length % 2 !== 0) ? '000' : '00') + hexValue;
- const valueBuffer = Buffer.from(hexValue, 'hex');
- if (isNegative) {
- valueBuffer[0] |= 0x80;
- }
- buffer.writeInteger(scale);
- buffer.writeInteger(valueBuffer.length);
- buffer.writeBuffer(valueBuffer);
- }
-
- _writeTimestamp(buffer, timestamp) {
- buffer.writeDate(timestamp);
- buffer.writeInteger(timestamp.getNanos());
- }
-
- _writeTime(buffer, time) {
- const midnight = new Date(time);
- midnight.setHours(0, 0, 0, 0);
- buffer.writeLong(time.getTime() - midnight.getTime());
- }
-
- async _writeArray(buffer, array, arrayType, arrayTypeCode) {
- const BinaryType = require('./BinaryType');
- const elementType = BinaryUtils.getArrayElementType(arrayType);
- const keepElementType = BinaryUtils.keepArrayElementType(arrayTypeCode);
- if (arrayTypeCode === BinaryUtils.TYPE_CODE.OBJECT_ARRAY) {
- buffer.writeInteger(elementType instanceof ComplexObjectType ?
- BinaryType._calculateId(elementType._typeName) : -1);
- }
- buffer.writeInteger(array.length);
- for (let elem of array) {
- await this.writeObject(buffer, elem, elementType, keepElementType);
- }
- }
-
- async _writeCollection(buffer, collection, collectionType) {
- buffer.writeInteger(collection instanceof Set ? collection.size : collection.length);
- buffer.writeByte(collectionType._subType);
- for (let element of collection) {
- await this.writeObject(buffer, element, collectionType._elementType);
- }
- }
-
- async _writeMap(buffer, map, mapType) {
- buffer.writeInteger(map.size);
- buffer.writeByte(mapType._subType);
- for (let [key, value] of map.entries()) {
- await this.writeObject(buffer, key, mapType._keyType);
- await this.writeObject(buffer, value, mapType._valueType);
- }
- }
-
- async _writeBinaryObject(buffer, binaryObject) {
- buffer.position = buffer.position - 1;
- await binaryObject._write(this, buffer);
- }
-
- async _writeComplexObject(buffer, object, objectType) {
- const BinaryObject = require('../BinaryObject');
- await this._writeBinaryObject(buffer, await BinaryObject.fromObject(object, objectType));
- }
-}
-
-module.exports = BinaryCommunicator;
diff --git a/modules/platforms/nodejs/lib/internal/BinaryType.js b/modules/platforms/nodejs/lib/internal/BinaryType.js
deleted file mode 100644
index 4a36426..0000000
--- a/modules/platforms/nodejs/lib/internal/BinaryType.js
+++ /dev/null
@@ -1,483 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-'use strict';
-
-const Util = require('util');
-const Long = require('long');
-const ComplexObjectType = require('../ObjectType').ComplexObjectType;
-const BinaryTypeStorage = require('./BinaryTypeStorage');
-const BinaryUtils = require('./BinaryUtils');
-const BinaryCommunicator = require('./BinaryCommunicator');
-const Errors = require('../Errors');
-
-class BinaryType {
- constructor(name) {
- this._name = name;
- this._id = BinaryType._calculateId(name);
- this._fields = new Map();
- this._schemas = new Map();
- this._isEnum = false;
- this._enumValues = null;
- }
-
- get id() {
- return this._id;
- }
-
- get name() {
- return this._name;
- }
-
- get fields() {
- return [...this._fields.values()];
- }
-
- getField(fieldId) {
- return this._fields.get(fieldId);
- }
-
- hasField(fieldId) {
- return this._fields.has(fieldId);
- }
-
- removeField(fieldId) {
- return this._fields.delete(fieldId);
- }
-
- setField(field) {
- this._fields.set(field.id, field);
- }
-
- hasSchema(schemaId) {
- return this._schemas.has(schemaId);
- }
-
- addSchema(schema) {
- if (!this.hasSchema(schema.id)) {
- this._schemas.set(schema.id, schema);
- }
- }
-
- getSchema(schemaId) {
- return this._schemas.get(schemaId);
- }
-
- merge(binaryType, binarySchema) {
- let fieldId;
- for (let field of binaryType.fields) {
- fieldId = field.id;
- if (this.hasField(fieldId)) {
- if (this.getField(fieldId).typeCode !== field.typeCode) {
- throw Errors.IgniteClientError.serializationError(
- true, Util.format('type conflict for field "%s" of complex object type "%s"'),
- field.name, this._name);
- }
- }
- else {
- this.setField(field);
- }
- }
- this.addSchema(binarySchema);
- }
-
- clone() {
- const result = new BinaryType();
- result._name = this._name;
- result._id = this._id;
- result._fields = new Map(this._fields.entries());
- result._schemas = new Map(this._schemas.entries());
- result._isEnum = this._isEnum;
- return result;
- }
-
- isValid() {
- for (let field of this._fields.values()) {
- if (!field.isValid()) {
- return false;
- }
- }
- return this._name !== null;
- }
-
- static _calculateId(name) {
- return BinaryUtils.hashCodeLowerCase(name);
- }
-
- async _write(buffer) {
- // type id
- buffer.writeInteger(this._id);
- // type name
- BinaryCommunicator.writeString(buffer, this._name);
- // affinity key field name
- BinaryCommunicator.writeString(buffer, null);
- // fields count
- buffer.writeInteger(this._fields.size);
- // fields
- for (let field of this._fields.values()) {
- await field._write(buffer);
- }
- await this._writeEnum(buffer);
- // schemas count
- buffer.writeInteger(this._schemas.size);
- for (let schema of this._schemas.values()) {
- await schema._write(buffer);
- }
- }
-
- async _writeEnum(buffer) {
- buffer.writeBoolean(this._isEnum);
- if (this._isEnum) {
- const length = this._enumValues ? this._enumValues.length : 0;
- buffer.writeInteger(length);
- if (length > 0) {
- for (let [key, value] of this._enumValues) {
- BinaryCommunicator.writeString(buffer, key);
- buffer.writeInteger(value);
- }
- }
- }
- }
-
- async _read(buffer) {
- // type id
- this._id = buffer.readInteger();
- // type name
- this._name = BinaryCommunicator.readString(buffer);
- // affinity key field name
- BinaryCommunicator.readString(buffer);
- // fields count
- const fieldsCount = buffer.readInteger();
- // fields
- let field;
- for (let i = 0; i < fieldsCount; i++) {
- field = new BinaryField(null, null);
- await field._read(buffer);
- this.setField(field);
- }
- await this._readEnum(buffer);
- // schemas count
- const schemasCount = buffer.readInteger();
- // schemas
- let schema;
- for (let i = 0; i < schemasCount; i++) {
- schema = new BinarySchema();
- await schema._read(buffer);
- this.addSchema(schema);
- }
- }
-
- async _readEnum(buffer) {
- this._isEnum = buffer.readBoolean();
- if (this._isEnum) {
- const valuesCount = buffer.readInteger();
- this._enumValues = new Array(valuesCount);
- for (let i = 0; i < valuesCount; i++) {
- this._enumValues[i] = [BinaryCommunicator.readString(buffer), buffer.readInteger()];
- }
- }
- }
-}
-
-/** FNV1 hash offset basis. */
-const FNV1_OFFSET_BASIS = 0x811C9DC5;
-/** FNV1 hash prime. */
-const FNV1_PRIME = 0x01000193;
-
-class BinarySchema {
- constructor() {
- this._id = BinarySchema._schemaInitialId();
- this._fieldIds = new Set();
- this._isValid = true;
- }
-
- get id() {
- return this._id;
- }
-
- get fieldIds() {
- return [...this._fieldIds];
- }
-
- finalize() {
- if (!this._isValid) {
- this._id = BinarySchema._schemaInitialId();
- for (let fieldId of this._fieldIds) {
- this._id = BinarySchema._updateSchemaId(this._id, fieldId);
- }
- this._isValid = true;
- }
- }
-
- clone() {
- const result = new BinarySchema();
- result._id = this._id;
- result._fieldIds = new Set(this._fieldIds);
- result._isValid = this._isValid;
- return result;
- }
-
- addField(fieldId) {
- if (!this.hasField(fieldId)) {
- this._fieldIds.add(fieldId);
- if (this._isValid) {
- this._id = BinarySchema._updateSchemaId(this._id, fieldId);
- }
- }
- }
-
- removeField(fieldId) {
- if (this._fieldIds.delete(fieldId)) {
- this._isValid = false;
- }
- }
-
- hasField(fieldId) {
- return this._fieldIds.has(fieldId);
- }
-
- static _schemaInitialId() {
- return FNV1_OFFSET_BASIS | 0;
- }
-
- static _updateSchemaId(schemaId, fieldId) {
- schemaId = BinarySchema._updateSchemaIdPart(schemaId, fieldId & 0xFF);
- schemaId = BinarySchema._updateSchemaIdPart(schemaId, (fieldId >> 8) & 0xFF);
- schemaId = BinarySchema._updateSchemaIdPart(schemaId, (fieldId >> 16) & 0xFF);
- schemaId = BinarySchema._updateSchemaIdPart(schemaId, (fieldId >> 24) & 0xFF);
- return schemaId;
- }
-
- static _updateSchemaIdPart(schemaId, fieldIdPart) {
- schemaId = schemaId ^ fieldIdPart;
- schemaId = Long.fromValue(schemaId).multiply(FNV1_PRIME).getLowBits();
- return schemaId;
- }
-
- async _write(buffer) {
- this.finalize();
- // schema id
- buffer.writeInteger(this._id);
- // fields count
- buffer.writeInteger(this._fieldIds.size);
- // field ids
- for (let fieldId of this._fieldIds) {
- buffer.writeInteger(fieldId);
- }
- }
-
- async _read(buffer) {
- // schema id
- this._id = buffer.readInteger();
- // fields count
- const fieldsCount = buffer.readInteger();
- // field ids
- for (let i = 0; i < fieldsCount; i++) {
- this._fieldIds.add(buffer.readInteger());
- }
- }
-}
-
-class BinaryField {
- constructor(name, typeCode) {
- this._name = name;
- this._id = BinaryField._calculateId(name);
- this._typeCode = typeCode;
- }
-
- get id() {
- return this._id;
- }
-
- get name() {
- return this._name;
- }
-
- get typeCode() {
- return this._typeCode;
- }
-
- isValid() {
- return this._name !== null;
- }
-
- static _calculateId(name) {
- return BinaryUtils.hashCodeLowerCase(name);
- }
-
- async _write(buffer) {
- // field name
- BinaryCommunicator.writeString(buffer, this._name);
- // type code
- buffer.writeInteger(this._typeCode);
- // field id
- buffer.writeInteger(this._id);
- }
-
- async _read(buffer) {
- // field name
- this._name = BinaryCommunicator.readString(buffer);
- // type code
- this._typeCode = buffer.readInteger();
- // field id
- this._id = buffer.readInteger();
- }
-}
-
-class BinaryTypeBuilder {
-
- static fromTypeName(typeName) {
- let result = new BinaryTypeBuilder();
- result._init(typeName);
- return result;
- }
-
- static async fromTypeId(communicator, typeId, schemaId) {
- let result = new BinaryTypeBuilder();
- let type = await communicator.typeStorage.getType(typeId, schemaId);
- if (type) {
- result._type = type;
- if (schemaId !== null) {
- result._schema = type.getSchema(schemaId);
- if (!result._schema) {
- throw Errors.IgniteClientError.serializationError(
- false, Util.format('schema id "%d" specified for complex object of type "%s" not found',
- schemaId, type.name));
- }
- result._fromStorage = true;
- }
- else {
- result._schema = new BinarySchema();
- }
- return result;
- }
- result._init(null);
- result._type._id = typeId;
- return result;
- }
-
- static fromObject(jsObject, complexObjectType = null) {
- if (complexObjectType) {
- return BinaryTypeBuilder.fromComplexObjectType(complexObjectType, jsObject);
- }
- else {
- const result = new BinaryTypeBuilder();
- result._fromComplexObjectType(new ComplexObjectType(jsObject), jsObject);
- return result;
- }
- }
-
- static fromComplexObjectType(complexObjectType, jsObject) {
- let result = new BinaryTypeBuilder();
- const typeInfo = BinaryTypeStorage.getByComplexObjectType(complexObjectType);
- if (typeInfo) {
- result._type = typeInfo[0];
- result._schema = typeInfo[1];
- result._fromStorage = true;
- }
- else {
- result._fromComplexObjectType(complexObjectType, jsObject);
- BinaryTypeStorage.setByComplexObjectType(complexObjectType, result._type, result._schema);
- }
- return result;
- }
-
- getTypeId() {
- return this._type.id;
- }
-
- getTypeName() {
- return this._type.name;
- }
-
- getSchemaId() {
- return this._schema.id;
- }
-
- getFields() {
- return this._type.fields;
- }
-
- getField(fieldId) {
- return this._type._fields.get(fieldId);
- }
-
- setField(fieldName, fieldTypeCode = null) {
- const fieldId = BinaryField._calculateId(fieldName);
- if (!this._type.hasField(fieldId) || !this._schema.hasField(fieldId) ||
- this._type.getField(fieldId).typeCode !== fieldTypeCode) {
- this._beforeModify();
- this._type.setField(new BinaryField(fieldName, fieldTypeCode));
- this._schema.addField(fieldId);
- }
- }
-
- removeField(fieldName) {
- const fieldId = BinaryField._calculateId(fieldName);
- if (this._type.hasField(fieldId)) {
- this._beforeModify();
- this._type.removeField(fieldId);
- this._schema.removeField(fieldId);
- }
- }
-
- async finalize(communicator) {
- this._schema.finalize();
- await communicator.typeStorage.addType(this._type, this._schema);
- }
-
- constructor() {
- this._type = null;
- this._schema = null;
- this._fromStorage = false;
- }
-
- _fromComplexObjectType(complexObjectType, jsObject) {
- this._init(complexObjectType._typeName);
- if (complexObjectType._template) {
- this._setFields(complexObjectType, complexObjectType._template, jsObject);
- }
- }
-
- _init(typeName) {
- this._type = new BinaryType(typeName);
- this._schema = new BinarySchema();
- }
-
- _beforeModify() {
- if (this._fromStorage) {
- this._type = this._type.clone();
- this._schema = this._schema.clone();
- this._fromStorage = false;
- }
- }
-
- _setFields(complexObjectType, objectTemplate, jsObject) {
- let fieldType;
- for (let fieldName of BinaryUtils.getJsObjectFieldNames(objectTemplate)) {
- fieldType = complexObjectType._getFieldType(fieldName);
- if (!fieldType && jsObject[fieldName]) {
- fieldType = BinaryUtils.calcObjectType(jsObject[fieldName]);
- }
- this.setField(fieldName, BinaryUtils.getTypeCode(fieldType));
- }
- }
-}
-
-module.exports = BinaryType;
-module.exports.BinaryField = BinaryField;
-module.exports.BinaryTypeBuilder = BinaryTypeBuilder;
diff --git a/modules/platforms/nodejs/lib/internal/BinaryTypeStorage.js b/modules/platforms/nodejs/lib/internal/BinaryTypeStorage.js
deleted file mode 100644
index 2248eb5..0000000
--- a/modules/platforms/nodejs/lib/internal/BinaryTypeStorage.js
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-'use strict';
-
-const Errors = require('../Errors');
-const BinaryUtils = require('./BinaryUtils');
-const Util = require('util');
-
-class BinaryTypeStorage {
-
- constructor(communicator) {
- this._communicator = communicator;
- this._types = new Map();
- }
-
- static getByComplexObjectType(complexObjectType) {
- return BinaryTypeStorage.complexObjectTypes.get(complexObjectType);
- }
-
- static setByComplexObjectType(complexObjectType, type, schema) {
- if (!BinaryTypeStorage.complexObjectTypes.has(complexObjectType)) {
- BinaryTypeStorage.complexObjectTypes.set(complexObjectType, [type, schema]);
- }
- }
-
- static get complexObjectTypes() {
- if (!BinaryTypeStorage._complexObjectTypes) {
- BinaryTypeStorage._complexObjectTypes = new Map();
- }
- return BinaryTypeStorage._complexObjectTypes;
- }
-
- async addType(binaryType, binarySchema) {
- const typeId = binaryType.id;
- const schemaId = binarySchema.id;
- let storageType = this._types.get(typeId);
- if (!storageType || !storageType.hasSchema(schemaId)) {
- binaryType.addSchema(binarySchema);
- if (!storageType) {
- this._types.set(typeId, binaryType);
- storageType = binaryType;
- }
- else {
- storageType.merge(binaryType, binarySchema);
- }
- await this._putBinaryType(binaryType);
- }
- }
-
- async getType(typeId, schemaId = null) {
- let storageType = this._types.get(typeId);
- if (!storageType || schemaId && !storageType.hasSchema(schemaId)) {
- storageType = await this._getBinaryType(typeId);
- if (storageType) {
- this._types.set(storageType.id, storageType);
- }
- }
- return storageType;
- }
-
- /** Private methods */
-
- async _getBinaryType(typeId) {
- const BinaryType = require('./BinaryType');
- let binaryType = new BinaryType(null);
- binaryType._id = typeId;
- await this._communicator.send(
- BinaryUtils.OPERATION.GET_BINARY_TYPE,
- async (payload) => {
- payload.writeInteger(typeId);
- },
- async (payload) => {
- const exist = payload.readBoolean();
- if (exist) {
- await binaryType._read(payload);
- }
- else {
- binaryType = null;
- }
- });
- return binaryType;
- }
-
- async _putBinaryType(binaryType) {
- if (!binaryType.isValid()) {
- throw Errors.IgniteClientError.serializationError(
- true, Util.format('type "%d" can not be registered', binaryType.id));
- }
- await this._communicator.send(
- BinaryUtils.OPERATION.PUT_BINARY_TYPE,
- async (payload) => {
- await binaryType._write(payload);
- });
- }
-}
-
-module.exports = BinaryTypeStorage;
diff --git a/modules/platforms/nodejs/lib/internal/BinaryUtils.js b/modules/platforms/nodejs/lib/internal/BinaryUtils.js
deleted file mode 100644
index fe1e403..0000000
--- a/modules/platforms/nodejs/lib/internal/BinaryUtils.js
+++ /dev/null
@@ -1,602 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-'use strict';
-
-const Decimal = require('decimal.js');
-const ObjectType = require('../ObjectType').ObjectType;
-const CompositeType = require('../ObjectType').CompositeType;
-const MapObjectType = require('../ObjectType').MapObjectType;
-const CollectionObjectType = require('../ObjectType').CollectionObjectType;
-const ComplexObjectType = require('../ObjectType').ComplexObjectType;
-const ObjectArrayType = require('../ObjectType').ObjectArrayType;
-const Timestamp = require('../Timestamp');
-const EnumItem = require('../EnumItem');
-const Errors = require('../Errors');
-const ArgumentChecker = require('./ArgumentChecker');
-
-// Operation codes
-const OPERATION = Object.freeze({
- // Key-Value Queries
- CACHE_GET : 1000,
- CACHE_PUT : 1001,
- CACHE_PUT_IF_ABSENT : 1002,
- CACHE_GET_ALL : 1003,
- CACHE_PUT_ALL : 1004,
- CACHE_GET_AND_PUT : 1005,
- CACHE_GET_AND_REPLACE : 1006,
- CACHE_GET_AND_REMOVE : 1007,
- CACHE_GET_AND_PUT_IF_ABSENT : 1008,
- CACHE_REPLACE : 1009,
- CACHE_REPLACE_IF_EQUALS : 1010,
- CACHE_CONTAINS_KEY : 1011,
- CACHE_CONTAINS_KEYS : 1012,
- CACHE_CLEAR : 1013,
- CACHE_CLEAR_KEY : 1014,
- CACHE_CLEAR_KEYS : 1015,
- CACHE_REMOVE_KEY : 1016,
- CACHE_REMOVE_IF_EQUALS : 1017,
- CACHE_REMOVE_KEYS : 1018,
- CACHE_REMOVE_ALL : 1019,
- CACHE_GET_SIZE : 1020,
- // Cache Configuration
- CACHE_GET_NAMES : 1050,
- CACHE_CREATE_WITH_NAME : 1051,
- CACHE_GET_OR_CREATE_WITH_NAME : 1052,
- CACHE_CREATE_WITH_CONFIGURATION : 1053,
- CACHE_GET_OR_CREATE_WITH_CONFIGURATION : 1054,
- CACHE_GET_CONFIGURATION : 1055,
- CACHE_DESTROY : 1056,
- // SQL and Scan Queries
- QUERY_SCAN : 2000,
- QUERY_SCAN_CURSOR_GET_PAGE : 2001,
- QUERY_SQL : 2002,
- QUERY_SQL_CURSOR_GET_PAGE : 2003,
- QUERY_SQL_FIELDS : 2004,
- QUERY_SQL_FIELDS_CURSOR_GET_PAGE : 2005,
- RESOURCE_CLOSE : 0,
- // Binary Types
- GET_BINARY_TYPE : 3002,
- PUT_BINARY_TYPE : 3003
-});
-
-const TYPE_CODE = Object.assign({
- BINARY_OBJECT : 27,
- BINARY_ENUM : 38
- },
- ObjectType.PRIMITIVE_TYPE,
- ObjectType.COMPOSITE_TYPE);
-
-
-const TYPE_INFO = Object.freeze({
- [TYPE_CODE.BYTE] : {
- NAME : 'byte',
- SIZE : 1
- },
- [TYPE_CODE.SHORT] : {
- NAME : 'short',
- SIZE : 2
- },
- [TYPE_CODE.INTEGER] : {
- NAME : 'integer',
- SIZE : 4
- },
- [TYPE_CODE.LONG] : {
- NAME : 'long',
- SIZE : 8
- },
- [TYPE_CODE.FLOAT] : {
- NAME : 'float',
- SIZE : 4
- },
- [TYPE_CODE.DOUBLE] : {
- NAME : 'double',
- SIZE : 8
- },
- [TYPE_CODE.CHAR] : {
- NAME : 'char',
- SIZE : 2
- },
- [TYPE_CODE.BOOLEAN] : {
- NAME : 'boolean',
- SIZE : 1
- },
- [TYPE_CODE.STRING] : {
- NAME : 'string',
- NULLABLE : true
- },
- [TYPE_CODE.UUID] : {
- NAME : 'UUID',
- SIZE : 16,
- NULLABLE : true
- },
- [TYPE_CODE.DATE] : {
- NAME : 'date',
- SIZE : 8,
- NULLABLE : true
- },
- [TYPE_CODE.BYTE_ARRAY] : {
- NAME : 'byte array',
- ELEMENT_TYPE : TYPE_CODE.BYTE,
- NULLABLE : true
- },
- [TYPE_CODE.SHORT_ARRAY] : {
- NAME : 'short array',
- ELEMENT_TYPE : TYPE_CODE.SHORT,
- NULLABLE : true
- },
- [TYPE_CODE.INTEGER_ARRAY] : {
- NAME : 'integer array',
- ELEMENT_TYPE : TYPE_CODE.INTEGER,
- NULLABLE : true
- },
- [TYPE_CODE.LONG_ARRAY] : {
- NAME : 'long array',
- ELEMENT_TYPE : TYPE_CODE.LONG,
- NULLABLE : true
- },
- [TYPE_CODE.FLOAT_ARRAY] : {
- NAME : 'float array',
- ELEMENT_TYPE : TYPE_CODE.FLOAT,
- NULLABLE : true
- },
- [TYPE_CODE.DOUBLE_ARRAY] : {
- NAME : 'double array',
- ELEMENT_TYPE : TYPE_CODE.DOUBLE,
- NULLABLE : true
- },
- [TYPE_CODE.CHAR_ARRAY] : {
- NAME : 'char array',
- ELEMENT_TYPE : TYPE_CODE.CHAR,
- NULLABLE : true
- },
- [TYPE_CODE.BOOLEAN_ARRAY] : {
- NAME : 'boolean array',
- ELEMENT_TYPE : TYPE_CODE.BOOLEAN,
- NULLABLE : true
- },
- [TYPE_CODE.STRING_ARRAY] : {
- NAME : 'string array',
- ELEMENT_TYPE : TYPE_CODE.STRING,
- KEEP_ELEMENT_TYPE : true,
- NULLABLE : true
- },
- [TYPE_CODE.DATE_ARRAY] : {
- NAME : 'date array',
- ELEMENT_TYPE : TYPE_CODE.DATE,
- KEEP_ELEMENT_TYPE : true,
- NULLABLE : true
- },
- [TYPE_CODE.UUID_ARRAY] : {
- NAME : 'UUID array',
- ELEMENT_TYPE : TYPE_CODE.UUID,
- KEEP_ELEMENT_TYPE : true,
- NULLABLE : true
- },
- [TYPE_CODE.OBJECT_ARRAY] : {
- NAME : 'object array',
- ELEMENT_TYPE : TYPE_CODE.COMPLEX_OBJECT,
- KEEP_ELEMENT_TYPE : true,
- NULLABLE : true
- },
- [TYPE_CODE.COLLECTION] : {
- NAME : 'collection',
- NULLABLE : true
- },
- [TYPE_CODE.MAP] : {
- NAME : 'map',
- NULLABLE : true
- },
- [TYPE_CODE.BINARY_OBJECT] : {
- NAME : 'BinaryObject',
- NULLABLE : true
- },
- [TYPE_CODE.ENUM] : {
- NAME : 'enum',
- NULLABLE : true
- },
- [TYPE_CODE.ENUM_ARRAY] : {
- NAME : 'enum array',
- ELEMENT_TYPE : TYPE_CODE.ENUM,
- KEEP_ELEMENT_TYPE : true,
- NULLABLE : true
- },
- [TYPE_CODE.DECIMAL] : {
- NAME : 'decimal',
- NULLABLE : true
- },
- [TYPE_CODE.DECIMAL_ARRAY] : {
- NAME : 'decimal array',
- ELEMENT_TYPE : TYPE_CODE.DECIMAL,
- KEEP_ELEMENT_TYPE : true,
- NULLABLE : true
- },
- [TYPE_CODE.TIMESTAMP] : {
- NAME : 'timestamp',
- NULLABLE : true
- },
- [TYPE_CODE.TIMESTAMP_ARRAY] : {
- NAME : 'timestamp array',
- ELEMENT_TYPE : TYPE_CODE.TIMESTAMP,
- KEEP_ELEMENT_TYPE : true,
- NULLABLE : true
- },
- [TYPE_CODE.TIME] : {
- NAME : 'time',
- NULLABLE : true
- },
- [TYPE_CODE.TIME_ARRAY] : {
- NAME : 'time array',
- ELEMENT_TYPE : TYPE_CODE.TIME,
- KEEP_ELEMENT_TYPE : true,
- NULLABLE : true
- },
- [TYPE_CODE.NULL] : {
- NAME : 'null',
- NULLABLE : true
- },
- [TYPE_CODE.COMPLEX_OBJECT] : {
- NAME : 'complex object',
- NULLABLE : true
- }
-});
-
-const UTF8_ENCODING = 'utf8';
-
-class BinaryUtils {
- static get OPERATION() {
- return OPERATION;
- }
-
- static get TYPE_CODE() {
- return TYPE_CODE;
- }
-
- static get TYPE_INFO() {
- return TYPE_INFO;
- }
-
- static getSize(typeCode) {
- const size = TYPE_INFO[typeCode].SIZE;
- return size ? size : 0;
- }
-
- static get ENCODING() {
- return UTF8_ENCODING;
- }
-
- static getTypeName(type) {
- if (typeof type === 'string') {
- return type;
- }
- const typeCode = BinaryUtils.getTypeCode(type);
- return TYPE_INFO[typeCode] ? TYPE_INFO[typeCode].NAME : 'type code ' + typeCode;
- }
-
- static isNullable(type) {
- return TYPE_INFO[BinaryUtils.getTypeCode(type)].NULLABLE === true;
- }
-
- static getTypeCode(type) {
- return type instanceof CompositeType ? type._typeCode : type;
- }
-
- static checkObjectType(type, argName) {
- if (type === null || type instanceof CompositeType) {
- return;
- }
- ArgumentChecker.hasValueFrom(type, argName, false, ObjectType.PRIMITIVE_TYPE);
- }
-
- static calcObjectType(object) {
- const BinaryObject = require('../BinaryObject');
- const objectType = typeof object;
- if (object === null) {
- throw Errors.IgniteClientError.unsupportedTypeError(BinaryUtils.TYPE_CODE.NULL);
- }
- else if (objectType === 'number') {
- return BinaryUtils.TYPE_CODE.DOUBLE;
- }
- else if (objectType === 'string') {
- return BinaryUtils.TYPE_CODE.STRING;
- }
- else if (objectType === 'boolean') {
- return BinaryUtils.TYPE_CODE.BOOLEAN;
- }
- else if (object instanceof Timestamp) {
- return BinaryUtils.TYPE_CODE.TIMESTAMP;
- }
- else if (object instanceof Date) {
- return BinaryUtils.TYPE_CODE.DATE;
- }
- else if (object instanceof EnumItem) {
- return BinaryUtils.TYPE_CODE.ENUM;
- }
- else if (object instanceof Decimal) {
- return BinaryUtils.TYPE_CODE.DECIMAL;
- }
- else if (object instanceof Array) {
- if (object.length > 0 && object[0] !== null) {
- return BinaryUtils.getArrayType(BinaryUtils.calcObjectType(object[0]));
- }
- }
- else if (object instanceof Set) {
- return new CollectionObjectType(CollectionObjectType.COLLECTION_SUBTYPE.HASH_SET);
- }
- else if (object instanceof Map) {
- return new MapObjectType();
- }
- else if (object instanceof BinaryObject) {
- return BinaryUtils.TYPE_CODE.BINARY_OBJECT;
- }
- else if (objectType === 'object') {
- return new ComplexObjectType(object);
- }
- throw Errors.IgniteClientError.unsupportedTypeError(objectType);
- }
-
- static checkCompatibility(value, type) {
- if (!type) {
- return;
- }
- const typeCode = BinaryUtils.getTypeCode(type);
- if (value === null) {
- if (!BinaryUtils.isNullable(typeCode)) {
- throw Errors.IgniteClientError.typeCastError(BinaryUtils.TYPE_CODE.NULL, typeCode);
- }
- return;
- }
- else if (BinaryUtils.isStandardType(typeCode)) {
- BinaryUtils.checkStandardTypeCompatibility(value, typeCode, type);
- return;
- }
- const valueTypeCode = BinaryUtils.getTypeCode(BinaryUtils.calcObjectType(value));
- if (typeCode !== valueTypeCode) {
- throw Errors.IgniteClientError.typeCastError(valueTypeCode, typeCode);
- }
- }
-
- static isStandardType(typeCode) {
- return typeCode !== BinaryUtils.TYPE_CODE.BINARY_OBJECT &&
- typeCode !== BinaryUtils.TYPE_CODE.COMPLEX_OBJECT;
- }
-
- static checkStandardTypeCompatibility(value, typeCode, type = null) {
- const valueType = typeof value;
- switch (typeCode) {
- case BinaryUtils.TYPE_CODE.BYTE:
- case BinaryUtils.TYPE_CODE.SHORT:
- case BinaryUtils.TYPE_CODE.INTEGER:
- case BinaryUtils.TYPE_CODE.LONG:
- if (!Number.isInteger(value)) {
- throw Errors.IgniteClientError.valueCastError(value, typeCode);
- }
- return;
- case BinaryUtils.TYPE_CODE.FLOAT:
- case BinaryUtils.TYPE_CODE.DOUBLE:
- if (valueType !== 'number') {
- throw Errors.IgniteClientError.valueCastError(value, typeCode);
- }
- return;
- case BinaryUtils.TYPE_CODE.CHAR:
- if (valueType !== 'string' || value.length !== 1) {
- throw Errors.IgniteClientError.valueCastError(value, typeCode);
- }
- return;
- case BinaryUtils.TYPE_CODE.BOOLEAN:
- if (valueType !== 'boolean') {
- throw Errors.IgniteClientError.valueCastError(value, typeCode);
- }
- return;
- case BinaryUtils.TYPE_CODE.STRING:
- if (valueType !== 'string') {
- throw Errors.IgniteClientError.valueCastError(value, typeCode);
- }
- return;
- case BinaryUtils.TYPE_CODE.UUID:
- if (!value instanceof Array ||
- value.length !== BinaryUtils.getSize(BinaryUtils.TYPE_CODE.UUID)) {
- throw Errors.IgniteClientError.valueCastError(value, typeCode);
- }
- value.forEach(element =>
- BinaryUtils.checkStandardTypeCompatibility(element, BinaryUtils.TYPE_CODE.BYTE));
- return;
- case BinaryUtils.TYPE_CODE.DATE:
- if (!value instanceof Date) {
- throw Errors.IgniteClientError.valueCastError(value, typeCode);
- }
- return;
- case BinaryUtils.TYPE_CODE.ENUM:
- if (!value instanceof EnumItem) {
- throw Errors.IgniteClientError.valueCastError(value, typeCode);
- }
- return;
- case BinaryUtils.TYPE_CODE.DECIMAL:
- if (!value instanceof Decimal) {
- throw Errors.IgniteClientError.valueCastError(value, typeCode);
- }
- return;
- case BinaryUtils.TYPE_CODE.TIMESTAMP:
- if (!value instanceof Timestamp) {
- throw Errors.IgniteClientError.valueCastError(value, typeCode);
- }
- return;
- case BinaryUtils.TYPE_CODE.TIME:
- if (!value instanceof Date) {
- throw Errors.IgniteClientError.valueCastError(value, typeCode);
- }
- return;
- case BinaryUtils.TYPE_CODE.BYTE_ARRAY:
- case BinaryUtils.TYPE_CODE.SHORT_ARRAY:
- case BinaryUtils.TYPE_CODE.INTEGER_ARRAY:
- case BinaryUtils.TYPE_CODE.LONG_ARRAY:
- case BinaryUtils.TYPE_CODE.FLOAT_ARRAY:
- case BinaryUtils.TYPE_CODE.DOUBLE_ARRAY:
- case BinaryUtils.TYPE_CODE.CHAR_ARRAY:
- case BinaryUtils.TYPE_CODE.BOOLEAN_ARRAY:
- case BinaryUtils.TYPE_CODE.STRING_ARRAY:
- case BinaryUtils.TYPE_CODE.UUID_ARRAY:
- case BinaryUtils.TYPE_CODE.DATE_ARRAY:
- case BinaryUtils.TYPE_CODE.OBJECT_ARRAY:
- case BinaryUtils.TYPE_CODE.ENUM_ARRAY:
- case BinaryUtils.TYPE_CODE.DECIMAL_ARRAY:
- case BinaryUtils.TYPE_CODE.TIMESTAMP_ARRAY:
- case BinaryUtils.TYPE_CODE.TIME_ARRAY:
- if (!value instanceof Array) {
- throw Errors.IgniteClientError.typeCastError(valueType, typeCode);
- }
- return;
- case BinaryUtils.TYPE_CODE.MAP:
- if (!value instanceof Map) {
- throw Errors.IgniteClientError.typeCastError(valueType, typeCode);
- }
- return;
- case BinaryUtils.TYPE_CODE.COLLECTION:
- if (!(type && type._isSet() && value instanceof Set || value instanceof Array)) {
- throw Errors.IgniteClientError.typeCastError(valueType, type && type._isSet() ? 'set' : typeCode);
- }
- return;
- case BinaryUtils.TYPE_CODE.NULL:
- if (value !== null) {
- throw Errors.IgniteClientError.typeCastError('not null', typeCode);
- }
- return;
- default:
- const valueTypeCode = BinaryUtils.getTypeCode(BinaryUtils.calcObjectType(value));
- if (valueTypeCode === BinaryUtils.TYPE_CODE.BINARY_OBJECT) {
- throw Errors.IgniteClientError.typeCastError(valueTypeCode, typeCode);
- }
- return;
- }
- }
-
- static checkTypesComatibility(expectedType, actualTypeCode) {
- if (expectedType === null) {
- return;
- }
- const expectedTypeCode = BinaryUtils.getTypeCode(expectedType);
- if (actualTypeCode === BinaryUtils.TYPE_CODE.NULL) {
- return;
- }
- else if (expectedTypeCode === BinaryUtils.TYPE_CODE.BINARY_OBJECT ||
- actualTypeCode === BinaryUtils.TYPE_CODE.BINARY_OBJECT &&
- expectedTypeCode === BinaryUtils.TYPE_CODE.COMPLEX_OBJECT) {
- return;
- }
- else if (expectedTypeCode === BinaryUtils.TYPE_CODE.ENUM &&
- actualTypeCode === BinaryUtils.TYPE_CODE.BINARY_ENUM) {
- return;
- }
- else if (actualTypeCode !== expectedTypeCode) {
- throw Errors.IgniteClientError.typeCastError(actualTypeCode, expectedTypeCode);
- }
- }
-
- static getArrayElementType(arrayType) {
- if (arrayType instanceof ObjectArrayType) {
- return arrayType._elementType;
- }
- else if (arrayType === BinaryUtils.TYPE_CODE.OBJECT_ARRAY) {
- return null;
- }
- const elementTypeCode = TYPE_INFO[arrayType].ELEMENT_TYPE;
- if (!elementTypeCode) {
- throw Errors.IgniteClientError.internalError();
- }
- return elementTypeCode;
- }
-
- static getArrayType(elementType) {
- switch (BinaryUtils.getTypeCode(elementType)) {
- case BinaryUtils.TYPE_CODE.BYTE:
- return BinaryUtils.TYPE_CODE.BYTE_ARRAY;
- case BinaryUtils.TYPE_CODE.SHORT:
- return BinaryUtils.TYPE_CODE.SHORT_ARRAY;
- case BinaryUtils.TYPE_CODE.INTEGER:
- return BinaryUtils.TYPE_CODE.INTEGER_ARRAY;
- case BinaryUtils.TYPE_CODE.LONG:
- return BinaryUtils.TYPE_CODE.LONG_ARRAY;
- case BinaryUtils.TYPE_CODE.FLOAT:
- return BinaryUtils.TYPE_CODE.FLOAT_ARRAY;
- case BinaryUtils.TYPE_CODE.DOUBLE:
- return BinaryUtils.TYPE_CODE.DOUBLE_ARRAY;
- case BinaryUtils.TYPE_CODE.CHAR:
- return BinaryUtils.TYPE_CODE.CHAR_ARRAY;
- case BinaryUtils.TYPE_CODE.BOOLEAN:
- return BinaryUtils.TYPE_CODE.BOOLEAN_ARRAY;
- case BinaryUtils.TYPE_CODE.STRING:
- return BinaryUtils.TYPE_CODE.STRING_ARRAY;
- case BinaryUtils.TYPE_CODE.UUID:
- return BinaryUtils.TYPE_CODE.UUID_ARRAY;
- case BinaryUtils.TYPE_CODE.DATE:
- return BinaryUtils.TYPE_CODE.DATE_ARRAY;
- case BinaryUtils.TYPE_CODE.ENUM:
- return BinaryUtils.TYPE_CODE.ENUM_ARRAY;
- case BinaryUtils.TYPE_CODE.DECIMAL:
- return BinaryUtils.TYPE_CODE.DECIMAL_ARRAY;
- case BinaryUtils.TYPE_CODE.TIMESTAMP:
- return BinaryUtils.TYPE_CODE.TIMESTAMP_ARRAY;
- case BinaryUtils.TYPE_CODE.TIME:
- return BinaryUtils.TYPE_CODE.TIME_ARRAY;
- case BinaryUtils.TYPE_CODE.BINARY_OBJECT:
- return new ObjectArrayType();
- default:
- return new ObjectArrayType(elementType);
- }
- }
-
- static keepArrayElementType(arrayTypeCode) {
- return TYPE_INFO[arrayTypeCode].KEEP_ELEMENT_TYPE === true;
- }
-
- static getJsObjectFieldNames(jsObject) {
- var fields = new Array();
- for (let field in jsObject) {
- if (typeof jsObject[field] !== 'function') {
- fields.push(field);
- }
- }
- return fields;
- }
-
- static hashCode(str) {
- let hash = 0, char;
- if (str && str.length > 0) {
- for (let i = 0; i < str.length; i++) {
- char = str.charCodeAt(i);
- hash = ((hash << 5) - hash) + char;
- hash |= 0; // Convert to 32bit integer
- }
- }
- return hash;
- }
-
- static hashCodeLowerCase(str) {
- return BinaryUtils.hashCode(str ? str.toLowerCase() : str);
- }
-
- static contentHashCode(buffer, startPos, endPos) {
- let hash = 1;
- for (let i = startPos; i <= endPos; i++) {
- hash = 31 * hash + buffer._buffer[i];
- hash |= 0; // Convert to 32bit integer
- }
- return hash;
- }
-}
-
-module.exports = BinaryUtils;
diff --git a/modules/platforms/nodejs/lib/internal/ClientFailoverSocket.js b/modules/platforms/nodejs/lib/internal/ClientFailoverSocket.js
deleted file mode 100644
index 770c5c6..0000000
--- a/modules/platforms/nodejs/lib/internal/ClientFailoverSocket.js
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-'use strict';
-
-const Util = require('util');
-const Errors = require('../Errors');
-const IgniteClient = require('../IgniteClient');
-const ClientSocket = require('./ClientSocket');
-const Logger = require('./Logger');
-
-/** Socket wrapper with failover functionality: reconnects on failure. */
-class ClientFailoverSocket {
-
- constructor(onStateChanged) {
- this._socket = null;
- this._state = IgniteClient.STATE.DISCONNECTED;
- this._onStateChanged = onStateChanged;
- }
-
- async connect(config) {
- if (this._state !== IgniteClient.STATE.DISCONNECTED) {
- throw new Errors.IllegalStateError();
- }
- this._config = config;
- this._endpointsNumber = this._config._endpoints.length;
- this._endpointIndex = this._getRandomInt(this._endpointsNumber - 1);
- await this._connect();
- }
-
- async send(opCode, payloadWriter, payloadReader = null) {
- if (this._state !== IgniteClient.STATE.CONNECTED) {
- throw new Errors.IllegalStateError();
- }
- await this._socket.sendRequest(opCode, payloadWriter, payloadReader);
- }
-
- disconnect() {
- if (this._state !== IgniteClient.STATE.DISCONNECTED) {
- this._changeState(IgniteClient.STATE.DISCONNECTED);
- if (this._socket) {
- this._socket.disconnect();
- this._socket = null;
- }
- }
- }
-
- async _onSocketDisconnect(error = null) {
- this._changeState(IgniteClient.STATE.CONNECTING, null, error);
- this._socket = null;
- this._endpointIndex++;
- try {
- await this._connect();
- }
- catch (err) {
- }
- }
-
- async _connect() {
- const errors = new Array();
- let index, endpoint;
- for (let i = 0; i < this._endpointsNumber; i++) {
- index = (this._endpointIndex + i) % this._endpointsNumber;
- endpoint = this._config._endpoints[index];
- try {
- this._changeState(IgniteClient.STATE.CONNECTING, endpoint);
- this._socket = new ClientSocket(
- endpoint, this._config, this._onSocketDisconnect.bind(this));
- await this._socket.connect();
- this._changeState(IgniteClient.STATE.CONNECTED, endpoint);
- return;
- }
- catch (err) {
- errors.push(Util.format('[%s] %s', endpoint, err.message));
- }
- }
- const error = errors.join('; ');
- this._changeState(IgniteClient.STATE.DISCONNECTED, endpoint, error);
- this._socket = null;
- throw new Errors.IgniteClientError(error);
- }
-
- _changeState(state, endpoint = null, reason = null) {
- if (Logger.debug) {
- Logger.logDebug(Util.format('Socket %s: %s -> %s'),
- endpoint ? endpoint : this._socket ? this._socket._endpoint : '',
- this._getState(this._state),
- this._getState(state));
- }
- if (this._state !== state) {
- this._state = state;
- if (this._onStateChanged) {
- this._onStateChanged(state, reason);
- }
- }
- }
-
- _getState(state) {
- switch (state) {
- case IgniteClient.STATE.DISCONNECTED:
- return 'DISCONNECTED';
- case IgniteClient.STATE.CONNECTING:
- return 'CONNECTING';
- case IgniteClient.STATE.CONNECTED:
- return 'CONNECTED';
- default:
- return 'UNKNOWN';
- }
- }
-
- // returns a random integer between 0 and max
- _getRandomInt(max) {
- if (max === 0) {
- return 0;
- }
- return Math.floor(Math.random() * (max + 1));
- }
-}
-
-module.exports = ClientFailoverSocket;
diff --git a/modules/platforms/nodejs/lib/internal/ClientSocket.js b/modules/platforms/nodejs/lib/internal/ClientSocket.js
deleted file mode 100644
index 73e11f0..0000000
--- a/modules/platforms/nodejs/lib/internal/ClientSocket.js
+++ /dev/null
@@ -1,454 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-'use strict';
-
-const net = require('net');
-const tls = require('tls');
-const URL = require('url');
-const Long = require('long');
-const Util = require('util');
-const Errors = require('../Errors');
-const IgniteClientConfiguration = require('../IgniteClientConfiguration');
-const MessageBuffer = require('./MessageBuffer');
-const BinaryUtils = require('./BinaryUtils');
-const BinaryCommunicator = require('./BinaryCommunicator');
-const ArgumentChecker = require('./ArgumentChecker');
-const Logger = require('./Logger');
-
-const HANDSHAKE_SUCCESS_STATUS_CODE = 1;
-const REQUEST_SUCCESS_STATUS_CODE = 0;
-const PORT_DEFAULT = 10800;
-
-class ProtocolVersion {
-
- constructor(major = null, minor = null, patch = null) {
- this._major = major;
- this._minor = minor;
- this._patch = patch;
- }
-
- compareTo(other) {
- let diff = this._major - other._major;
- if (diff !== 0) {
- return diff;
- }
- diff = this._minor - other._minor;
- if (diff !== 0) {
- return diff;
- }
- return this._patch - other._patch;
- }
-
- equals(other) {
- return this.compareTo(other) === 0;
- }
-
- toString() {
- return Util.format('%d.%d.%d', this._major, this._minor, this._patch);
- }
-
- read(buffer) {
- this._major = buffer.readShort();
- this._minor = buffer.readShort();
- this._patch = buffer.readShort();
- }
-
- write(buffer) {
- buffer.writeShort(this._major);
- buffer.writeShort(this._minor);
- buffer.writeShort(this._patch);
- }
-}
-
-const PROTOCOL_VERSION_1_0_0 = new ProtocolVersion(1, 0, 0);
-const PROTOCOL_VERSION_1_1_0 = new ProtocolVersion(1, 1, 0);
-const PROTOCOL_VERSION_1_2_0 = new ProtocolVersion(1, 2, 0);
-
-const SUPPORTED_VERSIONS = [
- // PROTOCOL_VERSION_1_0_0, // Support for QueryField precision/scale fields breaks 1.0.0 compatibility
- PROTOCOL_VERSION_1_1_0,
- PROTOCOL_VERSION_1_2_0
-];
-
-const CURRENT_VERSION = PROTOCOL_VERSION_1_2_0;
-
-const STATE = Object.freeze({
- INITIAL : 0,
- HANDSHAKE : 1,
- CONNECTED : 2,
- DISCONNECTED : 3
-});
-
-class ClientSocket {
-
- constructor(endpoint, config, onSocketDisconnect) {
- ArgumentChecker.notEmpty(endpoint, 'endpoints');
- this._endpoint = endpoint;
- this._parseEndpoint(endpoint);
- this._config = config;
- this._state = STATE.INITIAL;
- this._socket = null;
- this._requestId = Long.ZERO;
- this._handshakeRequestId = null;
- this._protocolVersion = null;
- this._requests = new Map();
- this._onSocketDisconnect = onSocketDisconnect;
- this._error = null;
- this._wasConnected = false;
- this._buffer = null;
- this._offset = 0;
- }
-
- async connect() {
- return new Promise((resolve, reject) => {
- this._connectSocket(
- this._getHandshake(CURRENT_VERSION, resolve, reject));
- });
- }
-
- disconnect() {
- this._disconnect(true, false);
- }
-
- get requestId() {
- const id = this._requestId;
- this._requestId = this._requestId.add(1);
- return id;
- }
-
- async sendRequest(opCode, payloadWriter, payloadReader = null) {
- if (this._state === STATE.CONNECTED) {
- return new Promise(async (resolve, reject) => {
- const request = new Request(this.requestId, opCode, payloadWriter, payloadReader, resolve, reject);
- this._addRequest(request);
- await this._sendRequest(request);
- });
- }
- else {
- throw new Errors.IllegalStateError();
- }
- }
-
- _connectSocket(handshakeRequest) {
- const onConnected = async () => {
- this._state = STATE.HANDSHAKE;
- // send handshake
- await this._sendRequest(handshakeRequest);
- };
-
- const options = Object.assign({},
- this._config._options,
- { host : this._host, port : this._port, version : this._version });
- if (this._config._useTLS) {
- this._socket = tls.connect(options, onConnected);
- }
- else {
- this._socket = net.createConnection(options, onConnected);
- }
-
- this._socket.on('data', async (data) => {
- try {
- await this._processResponse(data);
- }
- catch (err) {
- this._error = err.message;
- this._disconnect();
- }
- });
- this._socket.on('close', () => {
- this._disconnect(false);
- });
- this._socket.on('error', (error) => {
- this._error = this._state === STATE.INITIAL ?
- 'Connection failed: ' + error : error;
- this._disconnect();
- });
- }
-
- _addRequest(request) {
- this._requests.set(request.id.toString(), request);
- }
-
- async _sendRequest(request) {
- try {
- const message = await request.getMessage();
- this._logMessage(request.id.toString(), true, message);
- this._socket.write(message);
- }
- catch (err) {
- this._requests.delete(request.id);
- request.reject(err);
- }
- }
-
- async _processResponse(message) {
- if (this._state === STATE.DISCONNECTED) {
- return;
- }
- if (this._buffer) {
- this._buffer.concat(message);
- this._buffer.position = this._offset;
- }
- else {
- this._buffer = MessageBuffer.from(message, 0);
- }
- while (this._buffer && this._offset < this._buffer.length) {
- // Response length
- const length = this._buffer.readInteger() + BinaryUtils.getSize(BinaryUtils.TYPE_CODE.INTEGER);
- if (this._buffer.length < this._offset + length) {
- break;
- }
- this._offset += length;
-
- let requestId, isSuccess;
- const isHandshake = this._state === STATE.HANDSHAKE;
-
- if (isHandshake) {
- // Handshake status
- isSuccess = (this._buffer.readByte() === HANDSHAKE_SUCCESS_STATUS_CODE);
- requestId = this._handshakeRequestId.toString();
- }
- else {
- // Request id
- requestId = this._buffer.readLong().toString();
- // Status code
- isSuccess = (this._buffer.readInteger() === REQUEST_SUCCESS_STATUS_CODE);
- }
-
- this._logMessage(requestId, false, this._buffer.data);
-
- const buffer = this._buffer;
- if (this._offset === this._buffer.length) {
- this._buffer = null;
- this._offset = 0;
- }
-
- if (this._requests.has(requestId)) {
- const request = this._requests.get(requestId);
- this._requests.delete(requestId);
- if (isHandshake) {
- await this._finalizeHandshake(buffer, request, isSuccess);
- }
- else {
- await this._finalizeResponse(buffer, request, isSuccess);
- }
- }
- else {
- throw Errors.IgniteClientError.internalError('Invalid response id: ' + requestId);
- }
- }
- }
-
- async _finalizeHandshake(buffer, request, isSuccess) {
- if (!isSuccess) {
- // Server protocol version
- const serverVersion = new ProtocolVersion();
- serverVersion.read(buffer);
- // Error message
- const errMessage = BinaryCommunicator.readString(buffer);
-
- if (!this._protocolVersion.equals(serverVersion)) {
- if (!this._isSupportedVersion(serverVersion) ||
- serverVersion.compareTo(PROTOCOL_VERSION_1_1_0) < 0 && this._config._userName) {
- request.reject(new Errors.OperationError(
- Util.format('Protocol version mismatch: client %s / server %s. Server details: %s',
- this._protocolVersion.toString(), serverVersion.toString(), errMessage)));
- this._disconnect();
- }
- else {
- // retry handshake with server version
- const handshakeRequest = this._getHandshake(serverVersion, request.resolve, request.reject);
- await this._sendRequest(handshakeRequest);
- }
- }
- else {
- request.reject(new Errors.OperationError(errMessage));
- this._disconnect();
- }
- }
- else {
- this._state = STATE.CONNECTED;
- this._wasConnected = true;
- request.resolve();
- }
- }
-
- async _finalizeResponse(buffer, request, isSuccess) {
- if (!isSuccess) {
- // Error message
- const errMessage = BinaryCommunicator.readString(buffer);
- request.reject(new Errors.OperationError(errMessage));
- }
- else {
- try {
- if (request.payloadReader) {
- await request.payloadReader(buffer);
- }
- request.resolve();
- }
- catch (err) {
- request.reject(err);
- }
- }
- }
-
- async _handshakePayloadWriter(payload) {
- // Handshake code
- payload.writeByte(1);
- // Protocol version
- this._protocolVersion.write(payload);
- // Client code
- payload.writeByte(2);
- if (this._config._userName) {
- BinaryCommunicator.writeString(payload, this._config._userName);
- BinaryCommunicator.writeString(payload, this._config._password);
- }
- }
-
- _getHandshake(version, resolve, reject) {
- this._protocolVersion = version;
- const handshakeRequest = new Request(
- this.requestId, null, this._handshakePayloadWriter.bind(this), null, resolve, reject);
- this._addRequest(handshakeRequest);
- this._handshakeRequestId = handshakeRequest.id;
- return handshakeRequest;
- }
-
- _isSupportedVersion(protocolVersion) {
- for (let version of SUPPORTED_VERSIONS) {
- if (version.equals(protocolVersion)) {
- return true;
- }
- }
- return false;
- }
-
- _disconnect(close = true, callOnDisconnect = true) {
- this._state = STATE.DISCONNECTED;
- this._requests.forEach((request, id) => {
- request.reject(new Errors.LostConnectionError(this._error));
- this._requests.delete(id);
- });
- if (this._wasConnected && callOnDisconnect && this._onSocketDisconnect) {
- this._onSocketDisconnect(this._error);
- }
- if (close) {
- this._onSocketDisconnect = null;
- this._socket.end();
- }
- }
-
- _parseEndpoint(endpoint) {
- endpoint = endpoint.trim();
- this._host = endpoint;
- this._port = null;
- const colonCnt = endpoint.split(':').length - 1;
- if (colonCnt > 1) {
- // IPv6 address
- this._version = 6;
- const index = endpoint.lastIndexOf(']:');
- if (index >= 0) {
- this._host = endpoint.substring(0, index + 1);
- this._port = endpoint.substring(index + 2);
- }
- if (this._host.startsWith('[') || this._host.endsWith(']')) {
- if (this._host.startsWith('[') && this._host.endsWith(']')) {
- this._host = this._host.substring(1, this._host.length - 1);
- }
- else {
- throw Errors.IgniteClientError.illegalArgumentError('Incorrect endpoint format: ' + endpoint);
- }
- }
- }
- else {
- // IPv4 address
- this._version = 4;
- const index = endpoint.lastIndexOf(':');
- if (index >= 0) {
- this._host = endpoint.substring(0, index);
- this._port = endpoint.substring(index + 1);
- }
- }
- if (!this._port) {
- this._port = PORT_DEFAULT;
- }
- else {
- this._port = parseInt(this._port);
- if (isNaN(this._port)) {
- throw Errors.IgniteClientError.illegalArgumentError('Incorrect endpoint format: ' + endpoint);
- }
- }
- }
-
- _logMessage(requestId, isRequest, message) {
- if (Logger.debug) {
- Logger.logDebug((isRequest ? 'Request: ' : 'Response: ') + requestId);
- Logger.logDebug('[' + [...message] + ']');
- }
- }
-}
-
-class Request {
- constructor(id, opCode, payloadWriter, payloadReader, resolve, reject) {
- this._id = id;
- this._opCode = opCode;
- this._payloadWriter = payloadWriter;
- this._payloadReader = payloadReader;
- this._resolve = resolve;
- this._reject = reject;
- }
-
- get id() {
- return this._id;
- }
-
- get payloadReader() {
- return this._payloadReader;
- }
-
- get resolve() {
- return this._resolve;
- }
-
- get reject() {
- return this._reject;
- }
-
- async getMessage() {
- const message = new MessageBuffer();
- // Skip message length
- const messageStartPos = BinaryUtils.getSize(BinaryUtils.TYPE_CODE.INTEGER);
- message.position = messageStartPos;
- if (this._opCode !== null) {
- // Op code
- message.writeShort(this._opCode);
- // Request id
- message.writeLong(this._id);
- }
- if (this._payloadWriter) {
- // Payload
- await this._payloadWriter(message);
- }
- // Message length
- message.position = 0;
- message.writeInteger(message.length - messageStartPos);
- return message.data;
- }
-}
-
-module.exports = ClientSocket;
diff --git a/modules/platforms/nodejs/lib/internal/Logger.js b/modules/platforms/nodejs/lib/internal/Logger.js
deleted file mode 100644
index 628c70e..0000000
--- a/modules/platforms/nodejs/lib/internal/Logger.js
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-'use strict';
-
-/** Utility class for logging errors and debug messages. */
-class Logger {
- static get debug() {
- return Logger._debug;
- }
-
- static set debug(value) {
- Logger._debug = value;
- }
-
- static logDebug(data, ...args) {
- if (Logger._debug) {
- console.log(data, ...args);
- }
- }
-
- static logError(data, ...args) {
- if (Logger._debug) {
- console.log('ERROR: ' + data, ...args);
- }
- }
-}
-
-Logger._debug = false;
-
-module.exports = Logger;
diff --git a/modules/platforms/nodejs/lib/internal/MessageBuffer.js b/modules/platforms/nodejs/lib/internal/MessageBuffer.js
deleted file mode 100644
index e282967..0000000
--- a/modules/platforms/nodejs/lib/internal/MessageBuffer.js
+++ /dev/null
@@ -1,293 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-'use strict';
-
-const Long = require('long');
-const BinaryUtils = require('./BinaryUtils');
-const Errors = require('../Errors');
-
-const BUFFER_CAPACITY_DEFAULT = 256;
-const BYTE_ZERO = 0;
-const BYTE_ONE = 1;
-
-class MessageBuffer {
- constructor(capacity = BUFFER_CAPACITY_DEFAULT) {
- this._buffer = Buffer.allocUnsafe(capacity);
- this._capacity = capacity;
- this._length = 0;
- this._position = 0;
- }
-
- static from(source, position) {
- const buf = new MessageBuffer();
- buf._buffer = Buffer.from(source);
- buf._position = position;
- buf._length = buf._buffer.length;
- buf._capacity = buf._length;
- return buf;
- }
-
- concat(source) {
- this._buffer = Buffer.concat([this._buffer, source]);
- this._length = this._buffer.length;
- this._capacity = this._length;
- }
-
- get position() {
- return this._position;
- }
-
- set position(position) {
- this._position = position;
- }
-
- get length() {
- return this._length;
- }
-
- get data() {
- return this.getSlice(0, this.length);
- }
-
- get buffer() {
- return this._buffer;
- }
-
- getSlice(start, end) {
- return this._buffer.slice(start, end);
- }
-
- writeByte(value) {
- this.writeNumber(value, BinaryUtils.TYPE_CODE.BYTE);
- }
-
- writeShort(value) {
- this.writeNumber(value, BinaryUtils.TYPE_CODE.SHORT);
- }
-
- writeInteger(value) {
- this.writeNumber(value, BinaryUtils.TYPE_CODE.INTEGER);
- }
-
- writeLong(value) {
- try {
- if (!Long.isLong(value)) {
- value = Long.fromValue(value);
- }
- }
- catch (err) {
- throw Errors.IgniteClientError.valueCastError(value, BinaryUtils.TYPE_CODE.LONG);
- }
- const buffer = Buffer.from(value.toBytesLE());
- this.writeBuffer(buffer);
- }
-
- writeFloat(value) {
- this.writeNumber(value, BinaryUtils.TYPE_CODE.FLOAT);
- }
-
- writeDouble(value) {
- this.writeNumber(value, BinaryUtils.TYPE_CODE.DOUBLE);
- }
-
- writeNumber(value, type, signed = true) {
- const size = BinaryUtils.getSize(type);
- this._ensureCapacity(size);
- try {
- switch (type) {
- case BinaryUtils.TYPE_CODE.BYTE:
- if (signed) {
- this._buffer.writeInt8(value, this._position);
- }
- else {
- this._buffer.writeUInt8(value, this._position);
- }
- break;
- case BinaryUtils.TYPE_CODE.SHORT:
- if (signed) {
- this._buffer.writeInt16LE(value, this._position);
- }
- else {
- this._buffer.writeUInt16LE(value, this._position);
- }
- break;
- case BinaryUtils.TYPE_CODE.INTEGER:
- if (signed) {
- this._buffer.writeInt32LE(value, this._position);
- }
- else {
- this._buffer.writeUInt32LE(value, this._position);
- }
- break;
- case BinaryUtils.TYPE_CODE.FLOAT:
- this._buffer.writeFloatLE(value, this._position);
- break;
- case BinaryUtils.TYPE_CODE.DOUBLE:
- this._buffer.writeDoubleLE(value, this._position);
- break;
- default:
- throw Errors.IgniteClientError.internalError();
- }
- }
- catch (err) {
- throw Errors.IgniteClientError.valueCastError(value, type);
- }
- this._position += size;
- }
-
- writeBoolean(value) {
- this.writeByte(value ? BYTE_ONE : BYTE_ZERO);
- }
-
- writeChar(value) {
- this.writeShort(value.charCodeAt(0));
- }
-
- writeString(value) {
- const buffer = Buffer.from(value, BinaryUtils.ENCODING);
- const length = buffer.length;
- this.writeInteger(length);
- if (length > 0) {
- this.writeBuffer(buffer);
- }
- }
-
- writeDate(value) {
- this.writeLong(value.getTime());
- }
-
- readByte() {
- return this.readNumber(BinaryUtils.TYPE_CODE.BYTE);
- }
-
- readShort() {
- return this.readNumber(BinaryUtils.TYPE_CODE.SHORT);
- }
-
- readInteger() {
- return this.readNumber(BinaryUtils.TYPE_CODE.INTEGER);
- }
-
- readLong() {
- const size = BinaryUtils.getSize(BinaryUtils.TYPE_CODE.LONG)
- this._ensureSize(size);
- const value = Long.fromBytesLE([...this._buffer.slice(this._position, this._position + size)]);
- this._position += size;
- return value;
- }
-
- readFloat() {
- return this.readNumber(BinaryUtils.TYPE_CODE.FLOAT);
- }
-
- readDouble() {
- return this.readNumber(BinaryUtils.TYPE_CODE.DOUBLE);
- }
-
- readNumber(type, signed = true) {
- const size = BinaryUtils.getSize(type);
- this._ensureSize(size);
- let value;
- switch (type) {
- case BinaryUtils.TYPE_CODE.BYTE:
- value = signed ? this._buffer.readInt8(this._position) : this._buffer.readUInt8(this._position);
- break;
- case BinaryUtils.TYPE_CODE.SHORT:
- value = signed ? this._buffer.readInt16LE(this._position) : this._buffer.readUInt16LE(this._position);
- break;
- case BinaryUtils.TYPE_CODE.INTEGER:
- value = signed ? this._buffer.readInt32LE(this._position) : this._buffer.readUInt32LE(this._position);
- break;
- case BinaryUtils.TYPE_CODE.FLOAT:
- value = this._buffer.readFloatLE(this._position);
- break;
- case BinaryUtils.TYPE_CODE.DOUBLE:
- value = this._buffer.readDoubleLE(this._position);
- break;
- default:
- throw Errors.IgniteClientError.internalError();
- }
- this._position += size;
- return value;
- }
-
- readBoolean() {
- return this.readByte() === BYTE_ONE;
- }
-
- readChar() {
- return String.fromCharCode(this.readShort());
- }
-
- readString() {
- const bytesCount = this.readInteger();
- this._ensureSize(bytesCount);
- const result = this._buffer.toString(BinaryUtils.ENCODING, this._position, this._position + bytesCount);
- this._position += bytesCount;
- return result;
- }
-
- readBuffer(length) {
- this._ensureSize(length);
- const result = this._buffer.slice(this._position, this._position + length);
- this._position += length;
- return result;
- }
-
- readDate() {
- return new Date(this.readLong().toNumber());
- }
-
- writeBuffer(buffer, start = undefined, end = undefined) {
- if (start === undefined) {
- start = 0;
- }
- if (end === undefined) {
- end = buffer.length;
- }
- const size = end - start;
- this._ensureCapacity(size);
- buffer.copy(this._buffer, this._position, start, end);
- this._position += size;
- }
-
- _ensureSize(size) {
- if (this._position + size > this._length) {
- throw Errors.IgniteClientError.internalError('Unexpected format of response');
- }
- }
-
- _ensureCapacity(valueSize) {
- if (valueSize <= 0) {
- throw Errors.IgniteClientError.internalError();
- }
- let newCapacity = this._capacity;
- while (this._position + valueSize > newCapacity) {
- newCapacity = newCapacity * 2;
- }
- if (this._capacity < newCapacity) {
- this._buffer = Buffer.concat([this._buffer, Buffer.allocUnsafe(newCapacity - this._capacity)], newCapacity);
- this._capacity = newCapacity;
- }
- if (this._position + valueSize > this._length) {
- this._length = this._position + valueSize;
- }
- }
-}
-
-module.exports = MessageBuffer;
diff --git a/modules/platforms/nodejs/package.json b/modules/platforms/nodejs/package.json
deleted file mode 100644
index dc6898c..0000000
--- a/modules/platforms/nodejs/package.json
+++ /dev/null
@@ -1,40 +0,0 @@
-{
- "name": "apache-ignite-client",
- "version": "1.0.1",
- "description": "NodeJS Client for Apache Ignite",
- "main": "index.js",
- "files": [
- "/examples",
- "/lib",
- "index.js"
- ],
- "repository": {
- "type": "git",
- "url": "https://github.com/apache/ignite/tree/master/modules/platforms/nodejs"
- },
- "keywords": [
- "apache",
- "ignite",
- "client"
- ],
- "author": "",
- "license": "Apache-2.0",
- "engines": {
- "node": ">=8.0.0"
- },
- "dependencies": {
- "long": "latest",
- "decimal.js": "latest"
- },
- "scripts": {
- "test": "jasmine",
- "test:examples": "node ./spec/ExamplesExecutor.js Examples",
- "test:auth_example": "node ./spec/ExamplesExecutor.js AuthExample"
- },
- "devDependencies": {
- "jasmine": "3.6.1",
- "jasmine-expect": "4.0.0",
- "jasmine-reporters": "2.1.1"
- }
-}
-
diff --git a/modules/platforms/nodejs/spec/ExamplesExecutor.js b/modules/platforms/nodejs/spec/ExamplesExecutor.js
deleted file mode 100644
index c02cf66..0000000
--- a/modules/platforms/nodejs/spec/ExamplesExecutor.js
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-const Jasmine = require('jasmine');
-
-const jasmine = new Jasmine();
-jasmine.loadConfig({
- 'spec_dir': 'spec',
- 'spec_files': [
- `examples/${process.argv[2]}.spec.js`
- ],
- "random": false
-});
-jasmine.execute();
\ No newline at end of file
diff --git a/modules/platforms/nodejs/spec/TestingHelper.js b/modules/platforms/nodejs/spec/TestingHelper.js
deleted file mode 100644
index 25465bb..0000000
--- a/modules/platforms/nodejs/spec/TestingHelper.js
+++ /dev/null
@@ -1,391 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-'use strict';
-
-require('jasmine-expect');
-const JasmineReporters = require('jasmine-reporters');
-
-const Util = require('util');
-const exec = require('child_process').exec;
-const config = require('./config');
-const IgniteClient = require('apache-ignite-client');
-const IgniteClientConfiguration = IgniteClient.IgniteClientConfiguration;
-const Errors = IgniteClient.Errors;
-const EnumItem = IgniteClient.EnumItem;
-const Timestamp = IgniteClient.Timestamp;
-const Decimal = IgniteClient.Decimal;
-const BinaryObject = IgniteClient.BinaryObject;
-const ObjectType = IgniteClient.ObjectType;
-
-const TIMEOUT_MS = 60000;
-
-jasmine.getEnv().addReporter(new JasmineReporters.TeamCityReporter());
-
-const dateComparator = (date1, date2) => { return !date1 && !date2 || date1.value === date2.value; };
-const floatComparator = (date1, date2) => { return Math.abs(date1 - date2) < 0.00001; };
-const defaultComparator = (value1, value2) => { return value1 === value2; };
-const enumComparator = (value1, value2) => {
- return value1.getTypeId() === value2.getTypeId() &&
- value1.getOrdinal() === value2.getOrdinal(); };
-const decimalComparator = (value1, value2) => {
- return value1 === null && value2 === null ||
- value1.equals(value2);
-};
-const timestampComparator = (value1, value2) => {
- return value1 === null && value2 === null ||
- dateComparator(value1.getTime(), value2.getTime()) &&
- value1.getNanos() === value2.getNanos(); };
-
-const numericValueModificator = (data) => { return data > 0 ? data - 10 : data + 10; };
-const charValueModificator = (data) => { return String.fromCharCode(data.charCodeAt(0) + 5); };
-const booleanValueModificator = (data) => { return !data; };
-const stringValueModificator = (data) => { return data + 'xxx'; };
-const dateValueModificator = (data) => { return new Date(data.getTime() + 12345); };
-const UUIDValueModificator = (data) => { return data.reverse(); };
-const enumValueModificator = (data) => { return new EnumItem(data.getTypeId(), data.getOrdinal() + 1); };
-const decimalValueModificator = (data) => { return data.add(12345); };
-const timestampValueModificator = (data) => { return new Timestamp(new Date(data.getTime() + 12345), data.getNanos() + 123); };
-
-const primitiveValues = {
- [ObjectType.PRIMITIVE_TYPE.BYTE] : {
- values : [-128, 0, 127],
- isMapKey : true,
- modificator : numericValueModificator
- },
- [ObjectType.PRIMITIVE_TYPE.SHORT] : {
- values : [-32768, 0, 32767],
- isMapKey : true,
- modificator : numericValueModificator
- },
- [ObjectType.PRIMITIVE_TYPE.INTEGER] : {
- values : [12345, 0, -54321],
- isMapKey : true,
- modificator : numericValueModificator
- },
- [ObjectType.PRIMITIVE_TYPE.LONG] : {
- values : [12345678912345, 0, -98765432112345],
- isMapKey : true,
- modificator : numericValueModificator
- },
- [ObjectType.PRIMITIVE_TYPE.FLOAT] : {
- values : [-1.155, 0, 123e-5],
- isMapKey : false,
- modificator : numericValueModificator
- },
- [ObjectType.PRIMITIVE_TYPE.DOUBLE] : {
- values : [-123e5, 0, 0.0001],
- typeOptional : true,
- isMapKey : false,
- modificator : numericValueModificator
- },
- [ObjectType.PRIMITIVE_TYPE.CHAR] : {
- values : ['a', String.fromCharCode(0x1234)],
- isMapKey : true,
- modificator : charValueModificator
- },
- [ObjectType.PRIMITIVE_TYPE.BOOLEAN] : {
- values : [true, false],
- isMapKey : true,
- typeOptional : true,
- modificator : booleanValueModificator
- },
- [ObjectType.PRIMITIVE_TYPE.STRING] : {
- values : ['abc', ''],
- isMapKey : true,
- typeOptional : true,
- modificator : stringValueModificator
- },
- [ObjectType.PRIMITIVE_TYPE.UUID] : {
- values : [
- [ 18, 70, 2, 119, 154, 254, 198, 254, 195, 146, 33, 60, 116, 230, 0, 146 ],
- [ 141, 77, 31, 194, 127, 36, 184, 255, 192, 4, 118, 57, 253, 209, 111, 147 ]
- ],
- isMapKey : false,
- modificator : UUIDValueModificator
- },
- [ObjectType.PRIMITIVE_TYPE.DATE] : {
- values : [new Date(), new Date('1995-12-17T03:24:00'), new Date(0)],
- typeOptional : true,
- isMapKey : false,
- modificator : dateValueModificator
- },
- // [ObjectType.PRIMITIVE_TYPE.ENUM] : {
- // values : [new EnumItem(12345, 7), new EnumItem(0, 0)],
- // typeOptional : true,
- // isMapKey : false,
- // modificator : enumValueModificator
- // },
- [ObjectType.PRIMITIVE_TYPE.DECIMAL] : {
- values : [new Decimal('123456789.6789345'), new Decimal(0), new Decimal('-98765.4321e15')],
- typeOptional : true,
- isMapKey : false,
- modificator : decimalValueModificator
- },
- [ObjectType.PRIMITIVE_TYPE.TIMESTAMP] : {
- values : [new Timestamp(new Date().getTime(), 12345), new Timestamp(new Date('1995-12-17T03:24:00').getTime(), 543), new Timestamp(0, 0)],
- typeOptional : true,
- isMapKey : false,
- modificator : timestampValueModificator
- },
- [ObjectType.PRIMITIVE_TYPE.TIME] : {
- values : [new Date(), new Date('1995-12-17T03:24:00'), new Date(123)],
- isMapKey : false,
- modificator : dateValueModificator
- }
-};
-
-const arrayValues = {
- [ObjectType.PRIMITIVE_TYPE.BYTE_ARRAY] : { elemType : ObjectType.PRIMITIVE_TYPE.BYTE },
- [ObjectType.PRIMITIVE_TYPE.SHORT_ARRAY] : { elemType : ObjectType.PRIMITIVE_TYPE.SHORT },
- [ObjectType.PRIMITIVE_TYPE.INTEGER_ARRAY] : { elemType : ObjectType.PRIMITIVE_TYPE.INTEGER },
- [ObjectType.PRIMITIVE_TYPE.LONG_ARRAY] : { elemType : ObjectType.PRIMITIVE_TYPE.LONG },
- [ObjectType.PRIMITIVE_TYPE.FLOAT_ARRAY] : { elemType : ObjectType.PRIMITIVE_TYPE.FLOAT },
- [ObjectType.PRIMITIVE_TYPE.DOUBLE_ARRAY] : { elemType : ObjectType.PRIMITIVE_TYPE.DOUBLE, typeOptional : true },
- [ObjectType.PRIMITIVE_TYPE.CHAR_ARRAY] : { elemType : ObjectType.PRIMITIVE_TYPE.CHAR },
- [ObjectType.PRIMITIVE_TYPE.BOOLEAN_ARRAY] : { elemType : ObjectType.PRIMITIVE_TYPE.BOOLEAN, typeOptional : true },
- [ObjectType.PRIMITIVE_TYPE.STRING_ARRAY] : { elemType : ObjectType.PRIMITIVE_TYPE.STRING, typeOptional : true },
- [ObjectType.PRIMITIVE_TYPE.UUID_ARRAY] : { elemType : ObjectType.PRIMITIVE_TYPE.UUID },
- [ObjectType.PRIMITIVE_TYPE.DATE_ARRAY] : { elemType : ObjectType.PRIMITIVE_TYPE.DATE, typeOptional : true },
- //[ObjectType.PRIMITIVE_TYPE.ENUM_ARRAY] : { elemType : ObjectType.PRIMITIVE_TYPE.ENUM, typeOptional : true },
- [ObjectType.PRIMITIVE_TYPE.DECIMAL_ARRAY] : { elemType : ObjectType.PRIMITIVE_TYPE.DECIMAL, typeOptional : true },
- [ObjectType.PRIMITIVE_TYPE.TIMESTAMP_ARRAY] : { elemType : ObjectType.PRIMITIVE_TYPE.TIMESTAMP, typeOptional : true },
- [ObjectType.PRIMITIVE_TYPE.TIME_ARRAY] : { elemType : ObjectType.PRIMITIVE_TYPE.TIME }
-};
-
-// Helper class for testing apache-ignite-client library.
-// Contains common methods for testing environment initialization and cleanup.
-class TestingHelper {
- static get TIMEOUT() {
- return TIMEOUT_MS;
- }
-
- static get primitiveValues() {
- return primitiveValues;
- }
-
- static get arrayValues() {
- return arrayValues;
- }
-
- // Initializes testing environment: creates and starts the library client, sets default jasmine test timeout.
- // Should be called from any test suite beforeAll method.
- static async init() {
- jasmine.DEFAULT_TIMEOUT_INTERVAL = TIMEOUT_MS;
-
- TestingHelper._igniteClient = new IgniteClient();
- TestingHelper._igniteClient.setDebug(config.debug);
- await TestingHelper._igniteClient.connect(new IgniteClientConfiguration(...config.endpoints));
- }
-
- // Cleans up testing environment.
- // Should be called from any test suite afterAll method.
- static async cleanUp() {
- await TestingHelper.igniteClient.disconnect();
- }
-
- static get igniteClient() {
- return TestingHelper._igniteClient;
- }
-
- static async destroyCache(cacheName, done) {
- try {
- await TestingHelper.igniteClient.destroyCache(cacheName);
- }
- catch (err) {
- TestingHelper.checkOperationError(err, done);
- }
- }
-
- static executeExample(name, outputChecker) {
- return new Promise((resolve, reject) => {
- exec('node ' + name, (error, stdout, stderr) => {
- TestingHelper.logDebug(stdout);
- resolve(stdout);
- })
- }).
- then(output => {
- expect(output).not.toMatch('ERROR:');
- expect(output).toMatch('Client is started');
- });
- }
-
- static checkOperationError(error, done) {
- TestingHelper.checkError(error, Errors.OperationError, done)
- }
-
- static checkIllegalArgumentError(error, done) {
- TestingHelper.checkError(error, Errors.IgniteClientError, done)
- }
-
- static checkEnumItemSerializationError(error, done) {
- if (!(error instanceof Errors.IgniteClientError) ||
- error.message.indexOf('Enum item can not be serialized') < 0) {
- done.fail('unexpected error: ' + error);
- }
- }
-
- static checkError(error, errorType, done) {
- if (!(error instanceof errorType)) {
- done.fail('unexpected error: ' + error);
- }
- }
-
- static logDebug(message) {
- if (config.debug) {
- console.log(message);
- }
- }
-
- static printValue(value) {
- const val = Util.inspect(value, false, null);
- const length = 500;
- return val.length > length ? val.substr(0, length) + '...' : val;
- }
-
- static async compare(value1, value2) {
- TestingHelper.logDebug(Util.format('compare: %s and %s', TestingHelper.printValue(value1), TestingHelper.printValue(value2)));
- if (value1 === undefined || value2 === undefined) {
- TestingHelper.logDebug(Util.format('compare: unexpected "undefined" value'));
- return false;
- }
- if (value1 === null && value2 === null) {
- return true;
- }
- if (value1 === null && value2 !== null || value1 !== null && value2 === null) {
- return false;
- }
- if (typeof value1 !== typeof value2) {
- TestingHelper.logDebug(Util.format('compare: value types are different: %s and %s',
- typeof value1, typeof value2));
- return false;
- }
- if (typeof value1 === 'number') {
- return floatComparator(value1, value2);
- }
- else if (typeof value1 !== 'object') {
- return defaultComparator(value1, value2);
- }
- else if (value1.constructor.name !== value2.constructor.name && !value2 instanceof BinaryObject) {
- TestingHelper.logDebug(Util.format('compare: value types are different: %s and %s',
- value1.constructor.name, value2.constructor.name));
- return false;
- }
- else if (value1 instanceof Date && value2 instanceof Date) {
- return dateComparator(value1, value2);
- }
- else if (value1 instanceof EnumItem && value2 instanceof EnumItem) {
- return enumComparator(value1, value2);
- }
- else if (value1 instanceof Decimal && value2 instanceof Decimal) {
- return decimalComparator(value1, value2);
- }
- else if (value1 instanceof Timestamp && value2 instanceof Timestamp) {
- return timestampComparator(value1, value2);
- }
- else if (value1 instanceof Array && value2 instanceof Array) {
- if (value1.length !== value2.length) {
- TestingHelper.logDebug(Util.format('compare: array lengths are different'));
- return false;
- }
- for (var i = 0; i < value1.length; i++) {
- if (!await TestingHelper.compare(value1[i], value2[i])) {
- TestingHelper.logDebug(Util.format('compare: array elements are different: %s, %s',
- TestingHelper.printValue(value1[i]), TestingHelper.printValue(value2[i])));
- return false;
- }
- }
- return true;
- }
- else if (value1 instanceof Map && value2 instanceof Map) {
- if (value1.size !== value2.size) {
- TestingHelper.logDebug(Util.format('compare: map sizes are different'));
- return false;
- }
- for (var [key, val] of value1) {
- if (!value2.has(key)) {
- TestingHelper.logDebug(Util.format('compare: maps are different: %s key is absent', TestingHelper.printValue(key)));
- return false;
- }
- if (!(await TestingHelper.compare(val, value2.get(key)))) {
- TestingHelper.logDebug(Util.format('compare: map values are different: %s, %s',
- TestingHelper.printValue(val), TestingHelper.printValue(value2.get(key))));
- return false;
- }
- }
- return true;
- }
- else if (value1 instanceof Set && value2 instanceof Set) {
- if (value1.size !== value2.size) {
- TestingHelper.logDebug(Util.format('compare: set sizes are different'));
- return false;
- }
- const value1Arr = [...value1].sort();
- const value2Arr = [...value2].sort();
- if (!await TestingHelper.compare(value1Arr, value2Arr)) {
- TestingHelper.logDebug(Util.format('compare: sets are different: %s and %s',
- TestingHelper.printValue(value1Arr), TestingHelper.printValue(value2Arr)));
- return false;
- }
- return true;
- }
- else if (value2 instanceof BinaryObject) {
- if (value1 instanceof BinaryObject) {
- if (value1.getTypeName() !== value2.getTypeName()) {
- TestingHelper.logDebug(Util.format('compare: binary object type names are different'));
- return false;
- }
- if (!await TestingHelper.compare(value1.getFieldNames(), value2.getFieldNames())) {
- TestingHelper.logDebug(Util.format('compare: binary object field names are different'));
- return false;
- }
- for (let fieldName of value1.getFieldNames()) {
- if (!value1.hasField(fieldName) || !value2.hasField(fieldName) ||
- !await TestingHelper.compare(await value1.getField(fieldName), await value1.getField(fieldName))) {
- TestingHelper.logDebug(Util.format('compare: binary objects field "%s" values are different', fieldName));
- return false;
- }
- }
- return true;
- }
- else {
- let value;
... 33935 lines suppressed ...