ptupitsyn commented on a change in pull request #284:
URL: https://github.com/apache/ignite-3/pull/284#discussion_r700038879
##########
File path:
modules/client-common/src/main/java/org/apache/ignite/client/proto/ClientMessageUnpacker.java
##########
@@ -584,6 +606,92 @@ public Object unpackObject(int dataType) {
throw new IgniteException("Unknown client data type: " + dataType);
}
+ /**
+ * Packs an object.
+ *
+ * @return Object array.
+ * @throws IllegalStateException in case of unexpected value type.
+ */
+ public Object[] unpackObjectArray() {
+ assert refCnt > 0 : "Unpacker is closed";
+
+ if (tryUnpackNil())
+ return null;
+
+ int size = unpackArrayHeader();
+
+ if (size == 0)
+ return ArrayUtils.OBJECT_EMPTY_ARRAY;
+
+ Object[] args = new Object[size];
+
+ for (int i = 0; i < size; i++) {
+ MessageFormat format = getNextFormat();
+
+ switch (format) {
+ case NIL:
+ unpackNil();
+
+ break;
+ case BOOLEAN:
+ args[i] = unpackBoolean();
+
+ break;
+ case FLOAT32:
+ args[i] = unpackFloat();
+
+ break;
+ case FLOAT64:
+ args[i] = unpackDouble();
+
+ break;
+ case POSFIXINT:
+ args[i] = extractExtendedValue(unpackInt());
Review comment:
@AMashenkov `extractExtendedValue` solves that problem. `POSFIXINT`
means that there is a type code before the actual value.
##########
File path:
modules/client-common/src/main/java/org/apache/ignite/client/proto/ClientMessageUnpacker.java
##########
@@ -584,6 +606,92 @@ public Object unpackObject(int dataType) {
throw new IgniteException("Unknown client data type: " + dataType);
}
+ /**
+ * Packs an object.
+ *
+ * @return Object array.
+ * @throws IllegalStateException in case of unexpected value type.
+ */
+ public Object[] unpackObjectArray() {
+ assert refCnt > 0 : "Unpacker is closed";
+
+ if (tryUnpackNil())
+ return null;
+
+ int size = unpackArrayHeader();
+
+ if (size == 0)
+ return ArrayUtils.OBJECT_EMPTY_ARRAY;
+
+ Object[] args = new Object[size];
+
+ for (int i = 0; i < size; i++) {
+ MessageFormat format = getNextFormat();
+
+ switch (format) {
+ case NIL:
+ unpackNil();
+
+ break;
+ case BOOLEAN:
+ args[i] = unpackBoolean();
+
+ break;
+ case FLOAT32:
+ args[i] = unpackFloat();
+
+ break;
+ case FLOAT64:
+ args[i] = unpackDouble();
+
+ break;
+ case POSFIXINT:
+ args[i] = extractExtendedValue(unpackInt());
Review comment:
@vladErmakov07 what is a bit confusing though is that we write type code
only for some of the types. I understand that some Ignite types map 1-to-1 to
MsgPack types, but maybe it'll be cleaner and more future-proof if we always
have a type code.
##########
File path:
modules/client-common/src/main/java/org/apache/ignite/client/proto/ClientMessageUnpacker.java
##########
@@ -584,6 +606,92 @@ public Object unpackObject(int dataType) {
throw new IgniteException("Unknown client data type: " + dataType);
}
+ /**
+ * Packs an object.
+ *
+ * @return Object array.
+ * @throws IllegalStateException in case of unexpected value type.
+ */
+ public Object[] unpackObjectArray() {
+ assert refCnt > 0 : "Unpacker is closed";
+
+ if (tryUnpackNil())
+ return null;
+
+ int size = unpackArrayHeader();
+
+ if (size == 0)
+ return ArrayUtils.OBJECT_EMPTY_ARRAY;
+
+ Object[] args = new Object[size];
+
+ for (int i = 0; i < size; i++) {
+ MessageFormat format = getNextFormat();
+
+ switch (format) {
+ case NIL:
+ unpackNil();
+
+ break;
+ case BOOLEAN:
+ args[i] = unpackBoolean();
+
+ break;
+ case FLOAT32:
+ args[i] = unpackFloat();
+
+ break;
+ case FLOAT64:
+ args[i] = unpackDouble();
+
+ break;
+ case POSFIXINT:
+ args[i] = extractExtendedValue(unpackInt());
Review comment:
@vladErmakov07 what is a bit confusing though is that we write type code
only for some of the types. I understand that some Ignite types map 1-to-1 to
MsgPack types, but maybe it'll be cleaner and more future-proof if we always
have a type code. For query args the overhead should be insignificant.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]