public class ArrayKVWriter extends Object implements Closeable
ArrayKVStore
index, key, and value data, given a sorted sequence of key/value pairs.
Key and value data must not exceed 2GB (each separately).
Constructor and Description |
---|
ArrayKVWriter(OutputStream indxOutput,
OutputStream keysOutput,
OutputStream valsOutput)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close all three outputs.
|
void |
flush()
Flush all three outputs.
|
int |
getIndxLength()
Get the number of bytes written so far to the index file.
|
int |
getKeysLength()
Get the number of bytes written so far to the key data file.
|
int |
getValsLength()
Get the number of bytes written so far to the value data file.
|
void |
writeKV(byte[] key,
byte[] val)
Write out the next key/value pair.
|
void |
writeMerged(KVStore kvstore,
Iterator<KVPair> kvIterator,
Mutations mutations)
Merge the given key/value pair iteration with the specified mutations and write out the merged combination.
|
public ArrayKVWriter(OutputStream indxOutput, OutputStream keysOutput, OutputStream valsOutput)
indxOutput
- index file outputkeysOutput
- key data file outputvalsOutput
- value data file outputpublic int getIndxLength()
public int getKeysLength()
public int getValsLength()
public void writeKV(byte[] key, byte[] val) throws IOException
key
- keyval
- valueIllegalArgumentException
- if key
is out of order (i.e., not strictly greater then the previous key)IllegalArgumentException
- if key
or val
is nullIllegalStateException
- if either the key or data file would grow larger than 231-1 bytesIOException
- if an I/O error occurrspublic void writeMerged(KVStore kvstore, Iterator<KVPair> kvIterator, Mutations mutations) throws IOException
The KVStore
parameter will only be used to invoke KVStore.encodeCounter()
and KVStore.decodeCounter()
in order to handle counter adjustments.
kvstore
- callback for encoding and decoding counter valueskvIterator
- key/value pairs - must be sorted in ordermutations
- mutations to applyIllegalArgumentException
- if any parameter is nullIllegalArgumentException
- if kvs
iterates out of orderIllegalStateException
- if either the key or data file would grow larger than 231-1 bytesIOException
- if an I/O error occurrspublic void flush() throws IOException
IOException
- if an I/O error occurrspublic void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
- if an I/O error occurrsCopyright © 2022. All rights reserved.