Class VectorFileIterators

java.lang.Object
uk.co.parnmatt.vector.reader.VectorFileIterators

public final class VectorFileIterators extends Object

Reads binary encoded vectors from files with default buffering.

try (CloseableIterator<float[]> vectors = VectorFileIterators.floats(path)) {
    while (vectors.hasNext()) {
        float[] vector = vectors.next();
        // process vector
    }
}

For control over the source, buffering strategy, and byte order, compose a reader with VectorReader.

Since:
0.1.0
  • Method Details

    • bytes

      @MustBeClosed public static CloseableIterator<byte[]> bytes(Path path) throws IOException
      Reads byte vectors from a file
      Parameters:
      path - the path to the file which to read
      Returns:
      a closeable iterator over the file's byte vectors
      Throws:
      IOException
      Since:
      0.4.0
      See Also:
    • shorts

      @MustBeClosed public static CloseableIterator<short[]> shorts(Path path) throws IOException
      Reads short vectors from a file
      Parameters:
      path - the path to the file which to read
      Returns:
      a closeable iterator over the file's short vectors
      Throws:
      IOException
      Since:
      0.4.0
      See Also:
    • ints

      @MustBeClosed public static CloseableIterator<int[]> ints(Path path) throws IOException
      Reads int vectors from a file
      Parameters:
      path - the path to the file which to read
      Returns:
      a closeable iterator over the file's int vectors
      Throws:
      IOException
      Since:
      0.4.0
      See Also:
    • longs

      @MustBeClosed public static CloseableIterator<long[]> longs(Path path) throws IOException
      Reads long vectors from a file
      Parameters:
      path - the path to the file which to read
      Returns:
      a closeable iterator over the file's long vectors
      Throws:
      IOException
      Since:
      0.4.0
      See Also:
    • floats

      @MustBeClosed public static CloseableIterator<float[]> floats(Path path) throws IOException
      Reads float vectors from a file
      Parameters:
      path - the path to the file which to read
      Returns:
      a closeable iterator over the file's float vectors
      Throws:
      IOException
      Since:
      0.4.0
      See Also:
    • doubles

      @MustBeClosed public static CloseableIterator<double[]> doubles(Path path) throws IOException
      Reads double vectors from a file
      Parameters:
      path - the path to the file which to read
      Returns:
      a closeable iterator over the file's double vectors
      Throws:
      IOException
      Since:
      0.4.0
      See Also: