ReferenceType
- public final class ReferenceContainerCache<ReferenceType extends Reference> extends AbstractIndex<ReferenceType> implements Index<ReferenceType>, IndexReader<ReferenceType>, java.lang.Iterable<ReferenceContainer<ReferenceType>>
Modifier and Type | Class and Description |
---|---|
static class |
ReferenceContainerCache.ContainerOrder<ReferenceType extends Reference> |
class |
ReferenceContainerCache.ReferenceContainerIterator
cache iterator: iterates objects within the heap cache.
|
class |
ReferenceContainerCache.ReferenceCountIterator
cache iterator: iterates objects within the heap cache.
|
Modifier and Type | Field and Description |
---|---|
private java.util.concurrent.ConcurrentHashMap<ByteArray,ReferenceContainer<ReferenceType>> |
cache |
private ReferenceContainerCache.ContainerOrder<ReferenceType> |
containerOrder |
private static ConcurrentLog |
log |
private ByteOrder |
termOrder |
private int |
termSize |
factory
Constructor and Description |
---|
ReferenceContainerCache(ReferenceFactory<ReferenceType> factory,
ByteOrder termOrder,
int termSize)
open an existing heap file in undefined mode
after this a initialization should be made to use the heap:
either a read-only or read/write mode initialization
|
Modifier and Type | Method and Description |
---|---|
void |
add(byte[] termHash,
ReferenceType newEntry)
add a single reference to the reverse index
if no references to the word are stored, the a new entry is added,
if there are already references to the word hash stored,
then the old and the new references are merged
|
void |
add(ReferenceContainer<ReferenceType> container)
add references to the reverse index
if no references to the word are stored, the new Entries are added,
if there are already references to the word that is denoted with the
reference to be stored, then the old and the new references are merged
|
void |
clear()
delete all references entries
|
void |
close()
close the reverse index
|
int |
count(byte[] key)
return the size of the container with corresponding key
|
void |
delete(byte[] termHash)
delete all references for a word
the difference to 'remove' is, that the removed element is not returned
|
void |
dump(java.io.File heapFile,
int writeBuffer,
boolean destructive)
dump the cache to a file.
|
ReferenceContainer<ReferenceType> |
get(byte[] key,
HandleSet urlselection)
get a indexContainer from a heap
|
boolean |
has(byte[] key)
test if a given key is in the heap
this works with heaps in write- and read-mode
|
boolean |
isEmpty() |
java.util.Iterator<ReferenceContainer<ReferenceType>> |
iterator() |
java.util.Iterator<ByteArray> |
keys() |
int |
maxReferences() |
int |
minMem()
calculate needed memory
|
private java.util.List<Rating<ByteArray>> |
ratingList() |
CloneableIterator<ReferenceContainer<ReferenceType>> |
referenceContainerIterator(byte[] startWordHash,
boolean rot,
boolean excludePrivate)
return an iterator object that creates top-level-clones of the indexContainers
in the cache, so that manipulations of the iterated objects do not change
objects in the cache.
|
CloneableIterator<Rating<byte[]>> |
referenceCountIterator(byte[] startHash,
boolean rot,
boolean excludePrivate)
iterate all references from the beginning of a specific word hash
|
ReferenceContainer<ReferenceType> |
remove(byte[] termHash)
delete a indexContainer from the heap cache.
|
boolean |
remove(byte[] termHash,
byte[] urlHashBytes)
remove a specific reference entry
|
int |
remove(byte[] termHash,
HandleSet urlHashes)
remove a set of reference entries for a given word
|
void |
removeDelayed() |
void |
removeDelayed(byte[] termHash,
byte[] urlHashBytes) |
Row |
rowdef() |
int |
size()
the number of all references
|
private java.util.List<ReferenceContainer<ReferenceType>> |
sortedClone()
create a clone of the cache content that is sorted using the this.containerOrder
|
int |
termKeyLength()
every index entry is made for a term which has a fixed size
|
ByteOrder |
termKeyOrdering()
return the order that is used for the storage of the word hashes
|
java.lang.String |
toString()
return a string with the key as a list
|
long |
usedMemory() |
merge, query, referenceRow, remove, searchConjunction
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
merge, referenceRow, remove, searchConjunction
private static final ConcurrentLog log
private final int termSize
private final ByteOrder termOrder
private final ReferenceContainerCache.ContainerOrder<ReferenceType extends Reference> containerOrder
private java.util.concurrent.ConcurrentHashMap<ByteArray,ReferenceContainer<ReferenceType extends Reference>> cache
public ReferenceContainerCache(ReferenceFactory<ReferenceType> factory, ByteOrder termOrder, int termSize)
factory
- the factory for payload reference objectstermOrder
- the order on search terms for the cachetermSize
- the fixed size of search termspublic Row rowdef()
public int termKeyLength()
termKeyLength
in interface Index<ReferenceType extends Reference>
public void clear()
Index
clear
in interface Index<ReferenceType extends Reference>
public void close()
Index
close
in interface Index<ReferenceType extends Reference>
close
in interface IndexReader<ReferenceType extends Reference>
public java.util.Iterator<ByteArray> keys()
public void dump(java.io.File heapFile, int writeBuffer, boolean destructive)
heapFile
- writeBuffer
- destructive
- - if true then the cache is cleaned during the dump causing to free memoryprivate java.util.List<ReferenceContainer<ReferenceType>> sortedClone()
public int size()
Index
size
in interface Index<ReferenceType extends Reference>
size
in interface IndexReader<ReferenceType extends Reference>
public long usedMemory()
public boolean isEmpty()
public int maxReferences()
public java.util.Iterator<ReferenceContainer<ReferenceType>> iterator()
iterator
in interface java.lang.Iterable<ReferenceContainer<ReferenceType extends Reference>>
public CloneableIterator<ReferenceContainer<ReferenceType>> referenceContainerIterator(byte[] startWordHash, boolean rot, boolean excludePrivate)
referenceContainerIterator
in interface Index<ReferenceType extends Reference>
referenceContainerIterator
in interface IndexReader<ReferenceType extends Reference>
rot
- if true, then rotate at the end to the beginningpublic CloneableIterator<Rating<byte[]>> referenceCountIterator(byte[] startHash, boolean rot, boolean excludePrivate)
Index
referenceCountIterator
in interface Index<ReferenceType extends Reference>
rot
- if true, then rotate at the end to the beginningpublic boolean has(byte[] key)
has
in interface Index<ReferenceType extends Reference>
has
in interface IndexReader<ReferenceType extends Reference>
key
- public ReferenceContainer<ReferenceType> get(byte[] key, HandleSet urlselection)
get
in interface Index<ReferenceType extends Reference>
get
in interface IndexReader<ReferenceType extends Reference>
key
-
public int count(byte[] key)
count
in interface Index<ReferenceType extends Reference>
key
- public ReferenceContainer<ReferenceType> remove(byte[] termHash)
remove
in interface Index<ReferenceType extends Reference>
wordHash
- public void delete(byte[] termHash)
Index
delete
in interface Index<ReferenceType extends Reference>
public void removeDelayed(byte[] termHash, byte[] urlHashBytes)
removeDelayed
in interface Index<ReferenceType extends Reference>
public boolean remove(byte[] termHash, byte[] urlHashBytes)
Index
remove
in interface Index<ReferenceType extends Reference>
urlHashBytes
- the key for the reference entry to be removedpublic int remove(byte[] termHash, HandleSet urlHashes)
Index
remove
in interface Index<ReferenceType extends Reference>
termHash
- the key for the referencespublic void removeDelayed()
removeDelayed
in interface Index<ReferenceType extends Reference>
public void add(ReferenceContainer<ReferenceType> container) throws SpaceExceededException
Index
add
in interface Index<ReferenceType extends Reference>
container
- the References to be merged with existing referencesSpaceExceededException
public void add(byte[] termHash, ReferenceType newEntry) throws SpaceExceededException
Index
add
in interface Index<ReferenceType extends Reference>
SpaceExceededException
public int minMem()
Index
minMem
in interface Index<ReferenceType extends Reference>
public ByteOrder termKeyOrdering()
Index
termKeyOrdering
in interface Index<ReferenceType extends Reference>
public java.lang.String toString()
toString
in class java.lang.Object