You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When attempting to read an int array (and possibly all other types) from a yaml wire, it throws the following error/warning and will fill the array with 0's.
Unable to read *number* as a long.
Test application:
importnet.openhft.chronicle.bytes.Bytes;
importnet.openhft.chronicle.wire.YamlWire;
importjava.util.Arrays;
publicclassMain {
publicstaticvoidmain(String[] args) {
varbuffer = Bytes.allocateElasticDirect(10 * 4);
int[] one = {1, 2, 3, 4, 5};
int[] two = {101, 102, 103, 104, 105};
// Create wire for saving two int arraysvarwire = newYamlWire(buffer);
wire.write("one").array(one, 5);
wire.write("two").array(two, 5);
System.out.println("Write wire:");
System.out.println(wire);
System.out.println();
buffer.readPosition(0);
// Copy buffer into a new wire for reading (mocks saving/loading)varcopyWire = newYamlWire(buffer);
System.out.println("Read wire:");
System.out.println(copyWire);
System.out.println();
int[] readBuffer = newint[5];
intamtRead = copyWire.read("one").array(readBuffer);
System.out.println("Read: " + amtRead + ", " + Arrays.toString(readBuffer));
}
}
As you can see, it reads the correct amount of elements (5 in this case), but does not fill the array with the appropriate values due to the following code in YamlWire -> TextValueIn public long int64()
if (yt.current() != YamlToken.TEXT) {
Jvm.warn().on(getClass(), "Unable to read " + valueIn.object() + " as a long.");
return0;
}
The text was updated successfully, but these errors were encountered:
jonatino
added a commit
to jonatino/Chronicle-Wire
that referenced
this issue
Apr 14, 2021
The fix for this specific use case is consuming SEQUENCE_START with padding, but that breaks the usecase when saving arrays with .object instead of .array.
When attempting to read an int array (and possibly all other types) from a yaml wire, it throws the following error/warning and will fill the array with 0's.
Unable to read *number* as a long.
Test application:
Output from above:
As you can see, it reads the correct amount of elements (5 in this case), but does not fill the array with the appropriate values due to the following code in YamlWire -> TextValueIn
public long int64()
The text was updated successfully, but these errors were encountered: