@Test public void testReadDouble() throws IOException { ByteBuffer bb = ByteBuffer.allocate(Double.BYTES); bb.putDouble(.42); bb.position(0); final ByteArrayInputStream bais = new ByteArrayInputStream(bb.array()); final double d = Decoder.readDouble(new byte[Double.BYTES], bb, bais); assertThat(d).isEqualTo(.42); }
public static double readDouble(byte[] dest, ByteBuffer bb, InputStream is) throws IOException { readNumberOfBytes(dest, bb, is); int upper = (((dest[0] & 0xff) << 24) + ((dest[1] & 0xff) << 16) + ((dest[2] & 0xff) << 8) + ((dest[3] & 0xff) << 0)); int lower = (((dest[4] & 0xff) << 24) + ((dest[5] & 0xff) << 16) + ((dest[6] & 0xff) << 8) + ((dest[7] & 0xff) << 0)); return Double.longBitsToDouble((((long) upper) << 32) + (lower & 0xffffffffl)); }
Decoder { public static double readDouble(byte[] dest, ByteBuffer bb, InputStream is) throws IOException { readNumberOfBytes(dest, bb, is); int upper = (((dest[0] & 0xff) << 24) + ((dest[1] & 0xff) << 16) + ((dest[2] & 0xff) << 8) + ((dest[3] & 0xff) << 0)); int lower = (((dest[4] & 0xff) << 24) + ((dest[5] & 0xff) << 16) + ((dest[6] & 0xff) << 8) + ((dest[7] & 0xff) << 0)); return Double.longBitsToDouble((((long) upper) << 32) + (lower & 0xffffffffl)); } }
Decoder { public static double readDouble(byte[] dest, ByteBuffer bb, InputStream is) throws IOException { readNumberOfBytes(dest, bb, is); int upper = (((dest[0] & 0xff) << 24) + ((dest[1] & 0xff) << 16) + ((dest[2] & 0xff) << 8) + ((dest[3] & 0xff) << 0)); int lower = (((dest[4] & 0xff) << 24) + ((dest[5] & 0xff) << 16) + ((dest[6] & 0xff) << 8) + ((dest[7] & 0xff) << 0)); return Double.longBitsToDouble((((long) upper) << 32) + (lower & 0xffffffffl)); }  }
Decoder { public static double readDouble(byte[] dest, ByteBuffer bb, InputStream is) throws IOException { readNumberOfBytes(dest, bb, is); int upper = (((dest[0] & 0xff) << 24) + ((dest[1] & 0xff) << 16) + ((dest[2] & 0xff) << 8) + ((dest[3] & 0xff) << 0)); int lower = (((dest[4] & 0xff) << 24) + ((dest[5] & 0xff) << 16) + ((dest[6] & 0xff) << 8) + ((dest[7] & 0xff) << 0)); return Double.longBitsToDouble((((long) upper) << 32) + (lower & 0xffffffffl)); }  static Pair<List<String>, List<double[]>> decodeBinaryEmbeddingVectors(InputStream is); static Pair<List<String>, List<double[]>> decodeBinaryEmbeddingVectors(InputStream is, int bufferSize); static void mergeEmbeddingFiles(List<InputStream> inputStreams, OutputStream os, boolean groupByText); static double readDouble(byte[] dest, ByteBuffer bb, InputStream is); static int readInt(byte[] dest, ByteBuffer bb, InputStream is); static void readNumberOfBytes(byte[] dest, ByteBuffer bb, InputStream is); }
Decoder { public static double readDouble(byte[] dest, ByteBuffer bb, InputStream is) throws IOException { readNumberOfBytes(dest, bb, is); int upper = (((dest[0] & 0xff) << 24) + ((dest[1] & 0xff) << 16) + ((dest[2] & 0xff) << 8) + ((dest[3] & 0xff) << 0)); int lower = (((dest[4] & 0xff) << 24) + ((dest[5] & 0xff) << 16) + ((dest[6] & 0xff) << 8) + ((dest[7] & 0xff) << 0)); return Double.longBitsToDouble((((long) upper) << 32) + (lower & 0xffffffffl)); }  static Pair<List<String>, List<double[]>> decodeBinaryEmbeddingVectors(InputStream is); static Pair<List<String>, List<double[]>> decodeBinaryEmbeddingVectors(InputStream is, int bufferSize); static void mergeEmbeddingFiles(List<InputStream> inputStreams, OutputStream os, boolean groupByText); static double readDouble(byte[] dest, ByteBuffer bb, InputStream is); static int readInt(byte[] dest, ByteBuffer bb, InputStream is); static void readNumberOfBytes(byte[] dest, ByteBuffer bb, InputStream is);  }