Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@pilshchikov
Created November 21, 2018 08:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pilshchikov/7ba7a7a2568c758b7b8680ba9a4215f5 to your computer and use it in GitHub Desktop.
Save pilshchikov/7ba7a7a2568c758b7b8680ba9a4215f5 to your computer and use it in GitHub Desktop.
Put get collections
from pyignite import Client
from datetime import datetime
from pyignite.datatypes import *
client = Client()
client.connect('127.0.0.1', 10800)
cache = client.get_or_create_cache("ARRAY_LIST_INTEGER_PY")
cache.put(1, (0, [-2147483647, 0, 2147483647]), key_hint=IntObject, value_hint=CollectionObject)
## successful
## JS Thin CLient code
IgniteClient = require('apache-ignite-client');
IgniteClientConfiguration = IgniteClient.IgniteClientConfiguration;
const ObjectType = IgniteClient.ObjectType;
const CollectionObjectType = IgniteClient.CollectionObjectType;
ENDPOINT = '127.0.0.1:10800';
igniteClient = new IgniteClient();
async function start() {
await igniteClient.connect(new IgniteClientConfiguration(ENDPOINT));
try {
cache = (await igniteClient.getOrCreateCache("ARRAY_LIST_INTEGER_PY"))
.setKeyType(ObjectType.PRIMITIVE_TYPE.INTEGER)
.setValueType(new CollectionObjectType(CollectionObjectType.COLLECTION_SUBTYPE.ARRAY_LIST,
ObjectType.PRIMITIVE_TYPE.INTEGER));
result = (await cache.get(1));
console.log(result);
} finally {
igniteClient.disconnect();
}
}
start();
## Output
(node:17805) UnhandledPromiseRejectionWarning: Error: Type "long" can not be cast to integer
at Function.typeCastError (..platforms/nodejs/lib/Errors.js:45:16)
at Function.checkTypesComatibility (..platforms/nodejs/lib/internal/BinaryUtils.js:501:44)
at BinaryCommunicator.readObject (..platforms/nodejs/lib/internal/BinaryCommunicator.js:65:21)
at BinaryCommunicator._readCollection (..platforms/nodejs/lib/internal/BinaryCommunicator.js:285:34)
at BinaryCommunicator._readTypedObject (..platforms/nodejs/lib/internal/BinaryCommunicator.js:206:35)
at BinaryCommunicator.readObject (..platforms/nodejs/lib/internal/BinaryCommunicator.js:66:27)
at Request._writeKeyOp [as _payloadReader] (..platforms/nodejs/lib/CacheClient.js:674:50)
at ClientSocket._finalizeResponse (..platforms/nodejs/lib/internal/ClientSocket.js:300:35)
at ClientSocket._processResponse (..platforms/nodejs/lib/internal/ClientSocket.js:248:32)
at Socket._socket.on (..platforms/nodejs/lib/internal/ClientSocket.js:166:28)
(node:17805) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:17805) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
## PHP Thin Client
<?php
require_once 'vendor/autoload.php';
use Apache\Ignite\Client;
use Apache\Ignite\ClientConfiguration;
use Apache\Ignite\Type\ObjectType;
use Apache\Ignite\Type\CollectionObjectType;
$client = new Client();
$ENDPOINT = '127.0.0.1:10800';
$client->connect(new ClientConfiguration($ENDPOINT));
try {
$cache = $client->getOrCreateCache("ARRAY_LIST_INTEGER_PY")
->setKeyType(ObjectType::INTEGER)
->setValueType(new CollectionObjectType(CollectionObjectType::ARRAY_LIST, ObjectType::INTEGER));
$result = $cache->get(1);
echo(var_export($result));
echo(PHP_EOL);
} finally {
$client->disconnect();
}
## Output
PHP Fatal error: Uncaught Apache\Ignite\Exception\ClientException: Type "long" can not be cast to integer in platforms/php/src/Apache/Ignite/Internal/Binary/BinaryUtils.php:424
Stack trace:
#0 platforms/php/src/Apache/Ignite/Internal/Binary/BinaryUtils.php(207): Apache\Ignite\Internal\Binary\BinaryUtils::typeCastError(4, 3)
#1 platforms/php/src/Apache/Ignite/Internal/Binary/BinaryCommunicator.php(82): Apache\Ignite\Internal\Binary\BinaryUtils::checkTypesCompatibility(3, 4)
#2 platforms/php/src/Apache/Ignite/Internal/Binary/BinaryCommunicator.php(329): Apache\Ignite\Internal\Binary\BinaryCommunicator->readObject(Object(Apache\Ignite\Internal\Binary\MessageBuffer), 3)
#3 platforms/php/src/Apache/Ignite/Internal/Binary/BinaryUtils.php on line 424
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment