Decoder { public static Pair<List<String>, List<double[]>> decodeBinaryEmbeddingVectors(InputStream is) throws IOException { return decodeBinaryEmbeddingVectors(is, 8192); }  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);  }
@Test public void decodeEmbeddings() throws IOException { final Pair<List<String>, List<double[]>> embeddings = Decoder.decodeBinaryEmbeddingVectors(new FileInputStream("src/test/resources/testembeddings.dat")); assertThat(embeddings.getLeft()).containsExactly("t1", "t2", "t3"); assertThat(embeddings.getRight()).containsExactly(new double[]{3, 12}, new double[]{7, 5}, new double[]{45, 13}); }
@Test public void decodeEmbeddingsSmallerBufferThanData() throws IOException { final Pair<List<String>, List<double[]>> embeddings = Decoder.decodeBinaryEmbeddingVectors(new FileInputStream("src/test/resources/testembeddings.dat"), 2); assertThat(embeddings.getLeft()).containsExactly("t1", "t2", "t3"); assertThat(embeddings.getRight()).containsExactly(new double[]{3, 12}, new double[]{7, 5}, new double[]{45, 13}); }