Package org.apache.avro.file
Class DataFileStream<D>
java.lang.Object
org.apache.avro.file.DataFileStream<D>
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Iterable<D>
,Iterator<D>
- Direct Known Subclasses:
DataFileReader
Streaming access to files written by
DataFileWriter
. Use
DataFileReader
for file-based input.- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
A handle that can be used to reopen a DataFile without re-reading the header of the stream. -
Constructor Summary
ModifierConstructorDescriptionDataFileStream
(InputStream in, DatumReader<D> reader) Construct a reader for an input stream.protected
DataFileStream
(DatumReader<D> reader) create an uninitialized DataFileStream -
Method Summary
Modifier and TypeMethodDescriptionprotected void
void
close()
Close this reader.long
Expert: Return the count of items in the current block.long
Expert: Return the size in bytes (uncompressed) of the current block.A handle that can be used to reopen this stream without rereading the head.byte[]
Return the value of a metadata property.Return the list of keys in the metadatalong
getMetaLong
(String key) Return the value of a metadata property.getMetaString
(String key) Return the value of a metadata property.Return the schema used in this file.boolean
hasNext()
True if more entries remain in this file.iterator()
Returns an iterator over entries in this file.next()
Read the next datum in the file.Read the next datum from the file.Expert: Return the next block in the file, as binary-encoded data.void
remove()
Not supported.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface java.util.Iterator
forEachRemaining
-
Constructor Details
-
DataFileStream
Construct a reader for an input stream. For file-based input, useDataFileReader
. This will buffer, wrapping with aBufferedInputStream
is not necessary.- Throws:
IOException
-
DataFileStream
create an uninitialized DataFileStream- Throws:
IOException
-
-
Method Details
-
getHeader
A handle that can be used to reopen this stream without rereading the head. -
getSchema
Return the schema used in this file. -
getMetaKeys
Return the list of keys in the metadata -
getMeta
Return the value of a metadata property. -
getMetaString
Return the value of a metadata property. -
getMetaLong
Return the value of a metadata property. -
iterator
Returns an iterator over entries in this file. Note that this iterator is shared with other users of the file: it does not contain a separate pointer into the file. -
hasNext
public boolean hasNext()True if more entries remain in this file. -
next
Read the next datum in the file.- Specified by:
next
in interfaceIterator<D>
- Throws:
NoSuchElementException
- if no more remain in the file.
-
next
Read the next datum from the file.- Parameters:
reuse
- an instance to reuse.- Throws:
NoSuchElementException
- if no more remain in the file.IOException
-
nextBlock
Expert: Return the next block in the file, as binary-encoded data.- Throws:
IOException
-
getBlockCount
public long getBlockCount()Expert: Return the count of items in the current block. -
getBlockSize
public long getBlockSize()Expert: Return the size in bytes (uncompressed) of the current block. -
blockFinished
- Throws:
IOException
-
remove
public void remove()Not supported. -
close
Close this reader.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-