K
- The key type.V
- The value type.public static class SortedKeyValueFile.Reader<K,V> extends Object implements Closeable, Iterable<AvroKeyValue<K,V>>
When doing a lookup, this reader finds the correct block in the data file using the key index. It performs a single disk seek to the block and loads the entire block into memory. The block is scanned until the key is found or is determined not to exist.
Modifier and Type | Class and Description |
---|---|
static class |
SortedKeyValueFile.Reader.Options
A class to encapsulate the options of a Reader.
|
Constructor and Description |
---|
SortedKeyValueFile.Reader(SortedKeyValueFile.Reader.Options options)
Constructs a reader.
|
public SortedKeyValueFile.Reader(SortedKeyValueFile.Reader.Options options) throws IOException
options
- The options.IOException
- If there is an error.public V get(K key) throws IOException
This method will move the current position in the file to the record immediately following the requested key.
key
- The key to look up.IOException
- If there is an error.public Iterator<AvroKeyValue<K,V>> iterator()
Use the get() method to move the current position.
Note that this iterator is shared with other clients of the file; it does not contain a separate pointer into the file.
iterator
in interface Iterable<AvroKeyValue<K,V>>
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
Copyright © 2009–2017 The Apache Software Foundation. All rights reserved.