public static class SequenceFile.Writer extends Object implements Closeable, Syncable
Modifier and Type | Class and Description |
---|---|
static interface |
SequenceFile.Writer.Option |
Modifier and Type | Field and Description |
---|---|
protected org.apache.hadoop.io.serializer.Serializer |
compressedValSerializer |
protected org.apache.hadoop.io.serializer.Serializer |
keySerializer |
protected org.apache.hadoop.io.serializer.Serializer |
uncompressedValSerializer |
Constructor and Description |
---|
SequenceFile.Writer(FileSystem fs,
Configuration conf,
Path name,
Class keyClass,
Class valClass)
Deprecated.
|
SequenceFile.Writer(FileSystem fs,
Configuration conf,
Path name,
Class keyClass,
Class valClass,
int bufferSize,
short replication,
long blockSize,
Progressable progress,
SequenceFile.Metadata metadata)
Deprecated.
|
SequenceFile.Writer(FileSystem fs,
Configuration conf,
Path name,
Class keyClass,
Class valClass,
Progressable progress,
SequenceFile.Metadata metadata)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
void |
append(Object key,
Object val)
Append a key/value pair.
|
void |
append(Writable key,
Writable val)
Append a key/value pair.
|
static SequenceFile.Writer.Option |
appendIfExists(boolean value) |
void |
appendRaw(byte[] keyData,
int keyOffset,
int keyLength,
SequenceFile.ValueBytes val) |
static SequenceFile.Writer.Option |
blockSize(long value) |
static SequenceFile.Writer.Option |
bufferSize(int value) |
void |
close()
Close the file.
|
static SequenceFile.Writer.Option |
compression(SequenceFile.CompressionType value) |
static SequenceFile.Writer.Option |
compression(SequenceFile.CompressionType value,
CompressionCodec codec) |
static SequenceFile.Writer.Option |
file(Path value) |
CompressionCodec |
getCompressionCodec()
Returns the compression codec of data in this file.
|
Class |
getKeyClass()
Returns the class of keys in this file.
|
long |
getLength()
Returns the current length of the output file.
|
Class |
getValueClass()
Returns the class of values in this file.
|
void |
hflush()
Flush out the data in client's user buffer.
|
void |
hsync()
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.Option |
keyClass(Class<?> value) |
static SequenceFile.Writer.Option |
metadata(SequenceFile.Metadata value) |
static SequenceFile.Writer.Option |
progressable(Progressable value) |
static SequenceFile.Writer.Option |
replication(short value) |
static SequenceFile.Writer.Option |
stream(FSDataOutputStream value) |
void |
sync()
create a sync point
|
void |
syncFs()
|
static SequenceFile.Writer.Option |
valueClass(Class<?> value) |
protected org.apache.hadoop.io.serializer.Serializer keySerializer
protected org.apache.hadoop.io.serializer.Serializer uncompressedValSerializer
protected org.apache.hadoop.io.serializer.Serializer compressedValSerializer
@Deprecated public SequenceFile.Writer(FileSystem fs, Configuration conf, Path name, Class keyClass, Class valClass) throws IOException
SequenceFile.createWriter(Configuration, Writer.Option...)
instead.IOException
@Deprecated public SequenceFile.Writer(FileSystem fs, Configuration conf, Path name, Class keyClass, Class valClass, Progressable progress, SequenceFile.Metadata metadata) throws IOException
SequenceFile.createWriter(Configuration, Writer.Option...)
instead.IOException
@Deprecated public SequenceFile.Writer(FileSystem fs, Configuration conf, Path name, Class keyClass, Class valClass, int bufferSize, short replication, long blockSize, Progressable progress, SequenceFile.Metadata metadata) throws IOException
SequenceFile.createWriter(Configuration, Writer.Option...)
instead.IOException
public static SequenceFile.Writer.Option file(Path value)
public static SequenceFile.Writer.Option bufferSize(int value)
public static SequenceFile.Writer.Option stream(FSDataOutputStream value)
public static SequenceFile.Writer.Option replication(short value)
public static SequenceFile.Writer.Option appendIfExists(boolean value)
public static SequenceFile.Writer.Option blockSize(long value)
public static SequenceFile.Writer.Option progressable(Progressable value)
public static SequenceFile.Writer.Option keyClass(Class<?> value)
public static SequenceFile.Writer.Option valueClass(Class<?> value)
public static SequenceFile.Writer.Option metadata(SequenceFile.Metadata value)
public static SequenceFile.Writer.Option compression(SequenceFile.CompressionType value)
public static SequenceFile.Writer.Option compression(SequenceFile.CompressionType value, CompressionCodec codec)
public Class getKeyClass()
public Class getValueClass()
public CompressionCodec getCompressionCodec()
public void sync() throws IOException
sync
in interface Syncable
IOException
Syncable.hflush()
@Deprecated public void syncFs() throws IOException
IOException
public void hsync() throws IOException
Syncable
hsync
in interface Syncable
IOException
- if error occurspublic void hflush() throws IOException
Syncable
hflush
in interface Syncable
IOException
- if any error occurspublic void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public void append(Writable key, Writable val) throws IOException
IOException
public void append(Object key, Object val) throws IOException
IOException
public void appendRaw(byte[] keyData, int keyOffset, int keyLength, SequenceFile.ValueBytes val) throws IOException
IOException
public long getLength() throws IOException
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).
IOException
Copyright © 2017 Apache Software Foundation. All Rights Reserved.