Class VectorReader.Buffering
java.lang.Object
uk.co.parnmatt.vector.reader.VectorReader.Buffering
- Enclosing class:
VectorReader
The choice of how bytes are buffered as records are read.
- Since:
- 0.4.0
-
Method Summary
Modifier and TypeMethodDescriptionBuffer into a fixed-capacity buffer shared across records, reading ahead.Buffer each record exactly into a buffer that grows as records require.
-
Method Details
-
fixed
Buffer into a fixed-capacity buffer shared across records, reading ahead.
Reads ahead into one buffer, so it suits an unbuffered
Sourcesuch as a raw file or channel; the capacity must be at least the largest record.- Parameters:
buffers- the specification of the buffer to allocate- Returns:
- the choice of element type
-
growable
Buffer each record exactly into a buffer that grows as records require.
Allocates no read-ahead buffer, so it suits records whose size is large or unknown up front, or an already-buffered
Sourcewhere a second buffer would be redundant.// GZIPInputStream is already buffered, so growable avoids a second buffer try (InputStream input = new GZIPInputStream(source); CloseableIterator<float[]> vectors = VectorReader.from(Source.stream(input)) .growable(ByteOrder.LITTLE_ENDIAN) .as(ElementType.FLOAT32)) { while (vectors.hasNext()) { float[] vector = vectors.next(); } }- Parameters:
order- the byte order in which to interpret the buffered data- Returns:
- the choice of element type
-