K
- Type of the keysV
- Type of the valuespublic class FSOrderedMapFile<K extends org.apache.hadoop.io.WritableComparable,V extends org.apache.hadoop.io.Writable> extends ReadOnlyMap<K,V> implements OrderedMap<K,V>, Closeable, SortedMap<K,V>
Modifier and Type | Class and Description |
---|---|
static class |
FSOrderedMapFile.EntryIterator<IK extends org.apache.hadoop.io.Writable,IV extends org.apache.hadoop.io.Writable>
an iterator for entries.
|
static interface |
FSOrderedMapFile.FSOMapFileBSearchShortcut<KEY>
interface FSOMapFileBSearchShortcut
|
static class |
FSOrderedMapFile.MapFileInMemory<IK extends org.apache.hadoop.io.Writable,IV extends org.apache.hadoop.io.Writable>
MapFileInMemory class
|
static interface |
FSOrderedMapFile.MapFileWriter
Interface for writing a FSOMapFile
|
static class |
FSOrderedMapFile.MultiFSOMapWriter
Writes out a FSOMapFile, but assumes that input data need not be sorted by key.
|
Modifier and Type | Field and Description |
---|---|
protected RandomDataInput |
dataFile
actual underlying data file
|
protected String |
dataFilename
filename of the underlying file
|
protected int |
entrySize
total size of one key,value pair
|
protected FixedSizeWriteableFactory<K> |
keyFactory |
protected static org.slf4j.Logger |
logger
The logger used for this class
|
protected int |
numberOfEntries
The number of entries in the file.
|
protected FSOrderedMapFile.FSOMapFileBSearchShortcut<K> |
shortcut |
static String |
USUAL_EXTENSION
USUAL_EXTENSION
|
protected FixedSizeWriteableFactory<V> |
valueFactory |
Constructor and Description |
---|
FSOrderedMapFile(IndexOnDisk index,
String structureName)
constructor
|
FSOrderedMapFile(RandomDataInput file,
String filename,
FixedSizeWriteableFactory<K> _keyFactory,
FixedSizeWriteableFactory<V> _valueFactory)
constructor
|
FSOrderedMapFile(String filename,
boolean updateable,
FixedSizeWriteableFactory<K> _keyFactory,
FixedSizeWriteableFactory<V> _valueFactory)
Construct a new object to access the underlying file data structure
|
Modifier and Type | Method and Description |
---|---|
protected void |
_clear() |
void |
clear()
Remove all entries from this map
|
void |
close() |
Comparator<? super K> |
comparator()
Always returns null, as keys for FSOMapFile are
always Comparable, and their Comparable implementation are
used.
|
boolean |
containsKey(Object o) |
boolean |
containsValue(Object o) |
Set<Map.Entry<K,V>> |
entrySet() |
K |
firstKey() |
Map.Entry<K,V> |
get(int entryNumber)
Return the entry at the specified index
|
V |
get(Object _key) |
protected org.terrier.structures.collections.FSOrderedMapFile.MapFileEntry<K,V> |
getEntry(K key)
this method is the one which does the actual disk lookup of entries.
|
WriteableFactory<K> |
getKeyFactory()
Get the key factory
|
WriteableFactory<V> |
getValueFactory()
Get the value factory
|
SortedMap<K,V> |
headMap(K to) |
boolean |
isEmpty() |
Set<K> |
keySet() |
K |
lastKey() |
static FSOrderedMapFile.MapFileWriter |
mapFileWrite(String filename)
returns a utility class which can be used to write a FSOrderedMapFile.
|
static void |
mapFileWrite(String filename,
Iterable<Map.Entry<org.apache.hadoop.io.WritableComparable,org.apache.hadoop.io.Writable>> t)
writes an entire map FSOrderedMapFile at once, to the specified filename,
and using the data contained in the specified iterator
|
static void |
mapFileWrite(String filename,
Iterator<Map.Entry<org.apache.hadoop.io.WritableComparable,org.apache.hadoop.io.Writable>> ti)
writes an entire map FSOrderedMapFile at once, to the specified filename,
and using the data contained in the specified iterator
|
static int |
numberOfEntries(String filename,
FixedSizeWriteableFactory<?> _keyFactory,
FixedSizeWriteableFactory<?> _valueFactory)
Return number of entries
|
void |
putAll(Map<? extends K,? extends V> m) |
void |
setBSearchShortcut(FSOrderedMapFile.FSOMapFileBSearchShortcut<K> _shortcut)
Set the FSOMapFileBSearchShortcut
|
int |
size()
Returns the number of entries in this map
|
SortedMap<K,V> |
subMap(K from,
K to) |
SortedMap<K,V> |
tailMap(K from) |
Collection<V> |
values() |
protected RandomDataOutput |
write() |
put, remove
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, put, putIfAbsent, remove, remove, replace, replace, replaceAll
public static final String USUAL_EXTENSION
protected static final org.slf4j.Logger logger
protected RandomDataInput dataFile
protected String dataFilename
protected int numberOfEntries
protected int entrySize
protected FSOrderedMapFile.FSOMapFileBSearchShortcut<K extends org.apache.hadoop.io.WritableComparable> shortcut
protected FixedSizeWriteableFactory<K extends org.apache.hadoop.io.WritableComparable> keyFactory
protected FixedSizeWriteableFactory<V extends org.apache.hadoop.io.Writable> valueFactory
public FSOrderedMapFile(IndexOnDisk index, String structureName) throws IOException
index
- structureName
- IOException
public FSOrderedMapFile(String filename, boolean updateable, FixedSizeWriteableFactory<K> _keyFactory, FixedSizeWriteableFactory<V> _valueFactory) throws IOException
filename
- Filename of the file containing the structureupdateable
- Whether the file can be updated in this JVM_keyFactory
- factory object for keys_valueFactory
- factory object for valuesIOException
- thrown if an IO problem occurspublic FSOrderedMapFile(RandomDataInput file, String filename, FixedSizeWriteableFactory<K> _keyFactory, FixedSizeWriteableFactory<V> _valueFactory) throws IOException
file
- filename
- _keyFactory
- _valueFactory
- IOException
protected RandomDataOutput write()
public static int numberOfEntries(String filename, FixedSizeWriteableFactory<?> _keyFactory, FixedSizeWriteableFactory<?> _valueFactory)
filename
- _keyFactory
- _valueFactory
- public WriteableFactory<K> getKeyFactory()
public WriteableFactory<V> getValueFactory()
public void clear()
protected void _clear()
public Collection<V> values()
public int size()
public boolean containsValue(Object o)
containsValue
in interface Map<K extends org.apache.hadoop.io.WritableComparable,V extends org.apache.hadoop.io.Writable>
public boolean containsKey(Object o)
containsKey
in interface Map<K extends org.apache.hadoop.io.WritableComparable,V extends org.apache.hadoop.io.Writable>
public boolean isEmpty()
public void setBSearchShortcut(FSOrderedMapFile.FSOMapFileBSearchShortcut<K> _shortcut)
protected org.terrier.structures.collections.FSOrderedMapFile.MapFileEntry<K,V> getEntry(K key)
public K firstKey()
public K lastKey()
public final Comparator<? super K> comparator()
comparator
in interface SortedMap<K extends org.apache.hadoop.io.WritableComparable,V extends org.apache.hadoop.io.Writable>
public Map.Entry<K,V> get(int entryNumber)
get
in interface OrderedMap<K extends org.apache.hadoop.io.WritableComparable,V extends org.apache.hadoop.io.Writable>
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public static void mapFileWrite(String filename, Iterable<Map.Entry<org.apache.hadoop.io.WritableComparable,org.apache.hadoop.io.Writable>> t) throws IOException
IOException
public static void mapFileWrite(String filename, Iterator<Map.Entry<org.apache.hadoop.io.WritableComparable,org.apache.hadoop.io.Writable>> ti) throws IOException
IOException
public static FSOrderedMapFile.MapFileWriter mapFileWrite(String filename) throws IOException
IOException
Terrier Information Retrieval Platform 5.1. Copyright © 2004-2019, University of Glasgow