|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.terrier.structures.collections.ReadOnlyMap<K,V>
org.terrier.structures.collections.FSOrderedMapFile<K,V>
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>
An implementation of java.util.Map that can be accessed from disk. Key and value types are assumed to have a fixed size. Their factories must be passed to the constructor. In the name, FSOrderedMapFile, FS stands for Fixed Size.
| Nested Class Summary | |
|---|---|
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. |
| Nested classes/interfaces inherited from interface java.util.Map |
|---|
Map.Entry<K,V> |
| Field Summary | |
|---|---|
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.apache.log4j.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 Summary | |
|---|---|
FSOrderedMapFile(Index 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 |
|
| Method Summary | |
|---|---|
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()
|
| Methods inherited from class org.terrier.structures.collections.ReadOnlyMap |
|---|
put, remove |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface java.util.Map |
|---|
equals, hashCode, put, remove |
| Field Detail |
|---|
public static final String USUAL_EXTENSION
protected static final org.apache.log4j.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
| Constructor Detail |
|---|
public FSOrderedMapFile(Index 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 values
IOException - thrown if an IO problem occurs
public FSOrderedMapFile(RandomDataInput file,
String filename,
FixedSizeWriteableFactory<K> _keyFactory,
FixedSizeWriteableFactory<V> _valueFactory)
throws IOException
file - filename - _keyFactory - _valueFactory -
IOException| Method Detail |
|---|
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()
clear in interface Map<K extends org.apache.hadoop.io.WritableComparable,V extends org.apache.hadoop.io.Writable>clear in class ReadOnlyMap<K extends org.apache.hadoop.io.WritableComparable,V extends org.apache.hadoop.io.Writable>public void putAll(Map<? extends K,? extends V> m)
putAll in interface Map<K extends org.apache.hadoop.io.WritableComparable,V extends org.apache.hadoop.io.Writable>protected void _clear()
public Set<Map.Entry<K,V>> entrySet()
entrySet in interface Map<K extends org.apache.hadoop.io.WritableComparable,V extends org.apache.hadoop.io.Writable>entrySet in interface SortedMap<K extends org.apache.hadoop.io.WritableComparable,V extends org.apache.hadoop.io.Writable>public Set<K> keySet()
keySet in interface Map<K extends org.apache.hadoop.io.WritableComparable,V extends org.apache.hadoop.io.Writable>keySet in interface SortedMap<K extends org.apache.hadoop.io.WritableComparable,V extends org.apache.hadoop.io.Writable>public Collection<V> values()
values in interface Map<K extends org.apache.hadoop.io.WritableComparable,V extends org.apache.hadoop.io.Writable>values in interface SortedMap<K extends org.apache.hadoop.io.WritableComparable,V extends org.apache.hadoop.io.Writable>public int size()
size in interface Map<K extends org.apache.hadoop.io.WritableComparable,V extends org.apache.hadoop.io.Writable>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()
isEmpty in interface Map<K extends org.apache.hadoop.io.WritableComparable,V extends org.apache.hadoop.io.Writable>public void setBSearchShortcut(FSOrderedMapFile.FSOMapFileBSearchShortcut<K> _shortcut)
protected org.terrier.structures.collections.FSOrderedMapFile.MapFileEntry<K,V> getEntry(K key)
public K firstKey()
firstKey in interface SortedMap<K extends org.apache.hadoop.io.WritableComparable,V extends org.apache.hadoop.io.Writable>public K lastKey()
lastKey in interface SortedMap<K extends org.apache.hadoop.io.WritableComparable,V extends org.apache.hadoop.io.Writable>public SortedMap<K,V> headMap(K to)
headMap in interface SortedMap<K extends org.apache.hadoop.io.WritableComparable,V extends org.apache.hadoop.io.Writable>
public SortedMap<K,V> subMap(K from,
K to)
subMap in interface SortedMap<K extends org.apache.hadoop.io.WritableComparable,V extends org.apache.hadoop.io.Writable>public SortedMap<K,V> tailMap(K from)
tailMap in interface SortedMap<K extends org.apache.hadoop.io.WritableComparable,V extends org.apache.hadoop.io.Writable>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 V get(Object _key)
get in interface Map<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 CloseableIOException
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
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||