Package org.apache.hadoop.io
Class SequenceFile.Writer
java.lang.Object
org.apache.hadoop.io.SequenceFile.Writer
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable,StreamCapabilities,Syncable
- Enclosing class:
- SequenceFile
public static class SequenceFile.Writer
extends Object
implements Closeable, Syncable, Flushable, StreamCapabilities
Write key/value pairs to a sequence-format file.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface org.apache.hadoop.fs.StreamCapabilities
StreamCapabilities.StreamCapability -
Field Summary
FieldsFields inherited from interface org.apache.hadoop.fs.StreamCapabilities
ABORTABLE_STREAM, DROPBEHIND, HFLUSH, HSYNC, IOSTATISTICS, IOSTATISTICS_CONTEXT, PREADBYTEBUFFER, READAHEAD, READBYTEBUFFER, UNBUFFER, VECTOREDIO, VECTOREDIO_BUFFERS_SLICED -
Constructor Summary
ConstructorsConstructorDescriptionWriter(FileSystem fs, Configuration conf, Path name, Class keyClass, Class valClass) Deprecated.Writer(FileSystem fs, Configuration conf, Path name, Class keyClass, Class valClass, int bufferSize, short replication, long blockSize, Progressable progress, SequenceFile.Metadata metadata) Deprecated.Writer(FileSystem fs, Configuration conf, Path name, Class keyClass, Class valClass, Progressable progress, SequenceFile.Metadata metadata) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionvoidAppend a key/value pair.voidAppend a key/value pair.static SequenceFile.Writer.OptionappendIfExists(boolean value) voidappendRaw(byte[] keyData, int keyOffset, int keyLength, SequenceFile.ValueBytes val) static SequenceFile.Writer.OptionblockSize(long value) static SequenceFile.Writer.OptionbufferSize(int value) voidclose()Close the file.static SequenceFile.Writer.Optionstatic SequenceFile.Writer.Optioncompression(SequenceFile.CompressionType value, CompressionCodec codec) static SequenceFile.Writer.Optionvoidflush()longbooleanhasCapability(String capability) Query the stream for a specific capability.voidhflush()Flush out the data in client's user buffer.voidhsync()Similar to posix fsync, flush out the data in client's user buffer all the way to the disk device (but the disk may have it in its cache).static SequenceFile.Writer.Optionstatic SequenceFile.Writer.Optionmetadata(SequenceFile.Metadata value) static SequenceFile.Writer.Optionprogressable(Progressable value) static SequenceFile.Writer.Optionreplication(short value) static SequenceFile.Writer.Optionstream(FSDataOutputStream value) voidsync()create a sync point.voidsyncFs()static SequenceFile.Writer.OptionsyncInterval(int value) static SequenceFile.Writer.OptionvalueClass(Class<?> value)
-
Field Details
-
keySerializer
-
uncompressedValSerializer
-
compressedValSerializer
-
-
Constructor Details
-
Writer
@Deprecated public Writer(FileSystem fs, Configuration conf, Path name, Class keyClass, Class valClass) throws IOException Deprecated.Create the named file.- Parameters:
fs- input filesystem.conf- input configuration.name- input name.keyClass- input keyClass.valClass- input valClass.- Throws:
IOException- raised on errors performing I/O.
-
Writer
@Deprecated public Writer(FileSystem fs, Configuration conf, Path name, Class keyClass, Class valClass, Progressable progress, SequenceFile.Metadata metadata) throws IOException Deprecated.Create the named file with write-progress reporter.- Parameters:
fs- input filesystem.conf- input configuration.name- input name.keyClass- input keyClass.valClass- input valClass.progress- input progress.metadata- input metadata.- Throws:
IOException- raised on errors performing I/O.
-
Writer
@Deprecated public Writer(FileSystem fs, Configuration conf, Path name, Class keyClass, Class valClass, int bufferSize, short replication, long blockSize, Progressable progress, SequenceFile.Metadata metadata) throws IOException Deprecated.Create the named file with write-progress reporter.- Parameters:
fs- input filesystem.conf- input configuration.name- input name.keyClass- input keyClass.valClass- input valClass.bufferSize- input bufferSize.replication- input replication.blockSize- input blockSize.progress- input progress.metadata- input metadata.- Throws:
IOException- raised on errors performing I/O.
-
-
Method Details
-
file
-
bufferSize
-
stream
-
replication
-
appendIfExists
-
blockSize
-
progressable
-
keyClass
-
valueClass
-
metadata
-
compression
-
compression
public static SequenceFile.Writer.Option compression(SequenceFile.CompressionType value, CompressionCodec codec) -
syncInterval
-
getKeyClass
- Returns:
- Returns the class of keys in this file.
-
getValueClass
- Returns:
- Returns the class of values in this file.
-
getCompressionCodec
- Returns:
- Returns the compression codec of data in this file.
-
sync
create a sync point.- Throws:
IOException- raised on errors performing I/O.
-
syncFs
flush all currently written data to the file system.- Throws:
IOException- raised on errors performing I/O.
-
hsync
Description copied from interface:SyncableSimilar to posix fsync, flush out the data in client's user buffer all the way to the disk device (but the disk may have it in its cache).- Specified by:
hsyncin interfaceSyncable- Throws:
IOException- if error occurs
-
hflush
Description copied from interface:SyncableFlush out the data in client's user buffer. After the return of this call, new readers will see the data.- Specified by:
hflushin interfaceSyncable- Throws:
IOException- if any error occurs
-
flush
- Specified by:
flushin interfaceFlushable- Throws:
IOException
-
hasCapability
Description copied from interface:StreamCapabilitiesQuery the stream for a specific capability.- Specified by:
hasCapabilityin interfaceStreamCapabilities- Parameters:
capability- string to query the stream support for.- Returns:
- True if the stream supports capability.
-
close
Close the file.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
append
Append a key/value pair.- Parameters:
key- input Writable key.val- input Writable val.- Throws:
IOException- raised on errors performing I/O.
-
append
Append a key/value pair.- Parameters:
key- input Object key.val- input Object val.- Throws:
IOException- raised on errors performing I/O.
-
appendRaw
public void appendRaw(byte[] keyData, int keyOffset, int keyLength, SequenceFile.ValueBytes val) throws IOException - Throws:
IOException
-
getLength
- Returns:
- Returns the current length of the output file.
This always returns a synchronized position. In other words, immediately after calling
SequenceFile.Reader.seek(long)with a position returned by this method,SequenceFile.Reader.next(Writable)may be called. However the key may be earlier in the file than key last written when this method was called (e.g., with block-compression, it may be the first key in the block that was being written when this method was called). - Throws:
IOException- raised on errors performing I/O.
-
SequenceFile.createWriter(Configuration, Writer.Option...)instead.