From 5605ce6d633fa9dd7d8314f2f496a91621f7abfb Mon Sep 17 00:00:00 2001 From: stepan <stepan.sindelar@oracle.com> Date: Wed, 29 Mar 2017 13:43:17 +0200 Subject: [PATCH] readBin supports 2-byte size --- .../truffle/r/nodes/builtin/base/ConnectionFunctions.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ConnectionFunctions.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ConnectionFunctions.java index 24a803191f..efa1508a88 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ConnectionFunctions.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ConnectionFunctions.java @@ -54,6 +54,7 @@ import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.DoubleBuffer; import java.nio.IntBuffer; +import java.nio.ShortBuffer; import java.nio.channels.ByteChannel; import java.nio.charset.Charset; import java.nio.charset.IllegalCharsetNameException; @@ -860,7 +861,7 @@ public abstract class ConnectionFunctions { if (size == RRuntime.INT_NA) { size = 4; } - if (size == 1 || size == 4) { + if (size == 1 || size == 4 || size == 2) { result = readInteger(connection, n, size, swap, signed); } else { throw RError.nyi(RError.SHOW_CALLER, "readBin \"int\" size not implemented"); @@ -917,6 +918,11 @@ public abstract class ConnectionFunctions { int d = signed ? b : b & 0xFF; data[i] = d; } + } else if (size == 2) { + ShortBuffer shortBuffer = buffer.asShortBuffer(); + for (int i = 0; i < nInts; i++) { + data[i] = shortBuffer.get(); + } } return RDataFactory.createIntVector(data, complete); } -- GitLab