DatumWriter. Data is grouped into
blocks. A synchronization marker is written between blocks, so that
files may be split. Blocks may be compressed. Extensible metadata is stored
at the end of the file. Files may be appended to.
DataFileReader
| Modifier and Type | Class and Description |
|---|---|
| public static class | DataFileWriter.AppendWriteException
Thrown by |
| private class |
| Modifier and Type | Field and Description |
|---|---|
| private long | |
| private NonCopyingByteArrayOutputStream | |
| private BinaryEncoder | |
| private Codec | |
| private DatumWriter | |
| private boolean | |
| private boolean | |
| private final Map | |
| private DataFileWriter | |
| private Schema | |
| private byte[] | |
| private int | |
| private OutputStream | |
| private BinaryEncoder |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void | |
| public void | |
| public DataFileWriter | |
| public DataFileWriter | appendTo(SeekableInput
reading the existing file. in, OutputStream positioned at the end of the existing file. out)Open a writer appending to an existing file. |
| private void | |
| private void | |
| private int | |
| public void | |
| public DataFileWriter | |
| public DataFileWriter | create(Schema schema, OutputStream outs)
Open a new file for data matching a schema with a random sync. |
| public DataFileWriter | create(Schema schema, OutputStream outs, byte[] sync)
Open a new file for data matching a schema with an explicit sync. |
| public void | flush()
Implements java. |
| public void | |
| private static byte[] | |
| private void | |
| public boolean | Returns: - true if this writer flushes the block to the stream every time a sync marker is written. Else returns false.
|
| public static boolean | |
| private void | |
| public DataFileWriter | |
| public void | setFlushOnEveryBlock(boolean
- If set to false, this writer will not flush the
block to the stream until flush() is
explicitly called. flushOnEveryBlock)Set whether this writer should flush the block to the stream every time a sync marker is written. |
| public DataFileWriter | |
| public DataFileWriter | |
| public DataFileWriter | |
| private DataFileWriter | |
| private DataFileWriter | |
| public DataFileWriter | Returns: this DataFileWriterthe approximate number of uncompressed bytes to write in
each block syncInterval)Set the synchronization interval for this file, in bytes. |
| public long | |
| private void | |
| private void |
| blockCount | back to summary |
|---|---|
| private long blockCount | |
| buffer | back to summary |
|---|---|
| private NonCopyingByteArrayOutputStream buffer | |
| bufOut | back to summary |
|---|---|
| private BinaryEncoder bufOut | |
| codec | back to summary |
|---|---|
| private Codec codec | |
| dout | back to summary |
|---|---|
| private DatumWriter<D> dout | |
| flushOnEveryBlock | back to summary |
|---|---|
| private boolean flushOnEveryBlock | |
| isOpen | back to summary |
|---|---|
| private boolean isOpen | |
| meta | back to summary |
|---|---|
| private final Map<String, byte[]> meta | |
| out | back to summary |
|---|---|
| private DataFileWriter<D>. | |
| schema | back to summary |
|---|---|
| private Schema schema | |
| sync | back to summary |
|---|---|
| private byte[] sync | |
| syncInterval | back to summary |
|---|---|
| private int syncInterval | |
| underlyingStream | back to summary |
|---|---|
| private OutputStream underlyingStream | |
| vout | back to summary |
|---|---|
| private BinaryEncoder vout | |
| DataFileWriter | back to summary |
|---|---|
| public DataFileWriter(DatumWriter<D> dout) Construct a writer, not yet open. | |
| append | back to summary |
|---|---|
| public void append(D datum) throws IOException Append a datum to the file.
| |
| appendAllFrom | back to summary |
|---|---|
| public void appendAllFrom(DataFileStream<D> otherFile, boolean recompress) throws IOException Appends data from another file. otherFile must have the same schema. Data blocks will be copied without de-serializing data. If the codecs of the two files are compatible, data blocks are copied directly without decompression. If the codecs are not compatible, blocks from otherFile are uncompressed and then compressed using this file's codec. If the recompress flag is set all blocks are decompressed and then compressed using this file's codec. This is useful when the two files have compatible compression codecs but different codec options. For example, one might append a file compressed with deflate at compression level 1 to a file with deflate at compression level 7. If recompress is false, blocks will be copied without changing the compression level. If true, they will be converted to the new compression level. | |
| appendEncoded | back to summary |
|---|---|
| public void appendEncoded(ByteBuffer datum) throws IOException Expert: Append a pre-encoded datum to the file. No validation is performed to check that the encoding conforms to the file's schema. Appending non-conforming data may result in an unreadable file. | |
| appendTo | back to summary |
|---|---|
| public DataFileWriter Open a writer appending to an existing file. | |
| appendTo | back to summary |
|---|---|
| public DataFileWriter Open a writer appending to an existing file. Since 1.9.0 this method does not close in.
| |
| assertNotOpen | back to summary |
|---|---|
| private void assertNotOpen() | |
| assertOpen | back to summary |
|---|---|
| private void assertOpen() | |
| bufferInUse | back to summary |
|---|---|
| private int bufferInUse() | |
| close | back to summary |
|---|---|
| public void close() throws IOException Implements java. Flush and close the file.
| |
| create | back to summary |
|---|---|
| public DataFileWriter Open a new file for data matching a schema with a random sync. | |
| create | back to summary |
|---|---|
| public DataFileWriter Open a new file for data matching a schema with a random sync. | |
| create | back to summary |
|---|---|
| public DataFileWriter Open a new file for data matching a schema with an explicit sync. | |
| flush | back to summary |
|---|---|
| public void flush() throws IOException Implements java. Calls sync() and then flushes the current state of the file.
| |
| fSync | back to summary |
|---|---|
| public void fSync() throws IOException If this writer was instantiated using a File or using an Syncable instance, this method flushes all buffers for this writer to disk. In other cases, this method behaves exactly like flush(). | |
| generateSync | back to summary |
|---|---|
| private static byte[] generateSync() | |
| init | back to summary |
|---|---|
| private void init(OutputStream outs) throws IOException | |
| isFlushOnEveryBlock | back to summary |
|---|---|
public boolean isFlushOnEveryBlock()
| |
| isReservedMeta | back to summary |
|---|---|
| public static boolean isReservedMeta(String key) | |
| resetBufferTo | back to summary |
|---|---|
| private void resetBufferTo(int size) throws IOException | |
| setCodec | back to summary |
|---|---|
| public DataFileWriter Configures this writer to use the given codec. May not be reset after writes have begun. | |
| setFlushOnEveryBlock | back to summary |
|---|---|
| public void setFlushOnEveryBlock(boolean flushOnEveryBlock) Set whether this writer should flush the block to the stream every time a sync marker is written. By default, the writer will flush the buffer each time a sync marker is written (if the block size limit is reached or the sync() is called.
| |
| setMeta | back to summary |
|---|---|
| public DataFileWriter Set a metadata property. | |
| setMeta | back to summary |
|---|---|
| public DataFileWriter Set a metadata property. | |
| setMeta | back to summary |
|---|---|
| public DataFileWriter Set a metadata property. | |
| setMetaInternal | back to summary |
|---|---|
| private DataFileWriter | |
| setMetaInternal | back to summary |
|---|---|
| private DataFileWriter | |
| setSyncInterval | back to summary |
|---|---|
| public DataFileWriter Set the synchronization interval for this file, in bytes. Valid values range from 32 to 2^30 Suggested values are between 2K and 2M The stream is flushed by default at the end of each synchronization interval. If setFlushOnEveryBlock(boolean) is called with param set to false, then the block may not be flushed to the stream after the sync marker is written. In this case, the flush() must be called to flush the stream. Invalid values throw IllegalArgumentException
| |
| sync | back to summary |
|---|---|
| public long sync() throws IOException Return the current position as a value that may be passed to
| |
| writeBlock | back to summary |
|---|---|
| private void writeBlock() throws IOException | |
| writeIfBlockFull | back to summary |
|---|---|
| private void writeIfBlockFull() throws IOException | |
append(Object) when an exception occurs while writing a
datum to the buffer. When this is thrown, the file is unaltered and may
continue to be appended to.
| Access | Constructor and Description |
|---|---|
| public |
| AppendWriteException | back to summary |
|---|---|
| public AppendWriteException(Exception e) | |
| Modifier and Type | Class and Description |
|---|---|
| private class |
| Modifier and Type | Field and Description |
|---|---|
| private long |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public synchronized void | flush()
Overrides java. Implements java. |
| public long |
| position | back to summary |
|---|---|
| private long position | |
| BufferedFileOutputStream | back to summary |
|---|---|
| public BufferedFileOutputStream(OutputStream out) throws IOException | |
| flush | back to summary |
|---|---|
| public synchronized void flush() throws IOException Overrides java. Implements java. Doc from java. Flushes this buffered output stream. This forces any buffered output bytes to be written out to the underlying output stream.
| |
| tell | back to summary |
|---|---|
| public long tell() | |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | write(byte[]
the data. b, int the start offset in the data. off, int the number of bytes to write. len)Overrides java. len bytes from the specified
byte array starting at offset off to
this output stream.
|
| PositionFilter | back to summary |
|---|---|
| public PositionFilter(OutputStream out) throws IOException | |
| write | back to summary |
|---|---|
| public void write(byte[] b, int off, int len) throws IOException Overrides java. Doc from java. Writes
| |