|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.sun.labs.minion.indexer.partition.DelMap
public class DelMap
A class that holds the two components of a deletion map: the number of documents deleted and the bitmap of the deleted documents.
Field Summary | |
---|---|
protected java.io.File |
delFile
The file that contains the deletion map we're managing. |
protected Buffer |
delMap
The bitmap of deleted documents. |
protected boolean |
dirty
Whether the bitmap has been modified since it was read. |
protected FileLock |
lock
A lock for the file. |
protected static java.lang.String |
logTag
The log tag. |
protected int |
nDeleted
The number of deleted documents. |
Constructor Summary | |
---|---|
DelMap()
Creates an empty deletion bitmap. |
|
DelMap(java.io.File delFile,
FileLock lock)
Instantiates a DelMap from the given file, which is
locked with the given lock. |
Method Summary | |
---|---|
void |
clear()
Clears out the map. |
java.lang.Object |
clone()
Clones this map. |
boolean |
delete(int id)
Sets the bit indicating tha the given ID has been deleted. |
ReadableBuffer |
getDelMap()
Gets the current deletion map. |
int |
getNDeleted()
Gets the number of deleted documents. |
boolean |
isDeleted(int id)
Tells us whether a document has been deleted. |
static void |
main(java.lang.String[] args)
A main program that prints out a deletion map. |
protected void |
read()
Reads the deletion bitmap from the file, and computes the number of deleted documents. |
protected Buffer |
readBuffer()
Reads the deletion bitmap from the file, locking if necessary. |
void |
setPartition(Partition part)
|
protected void |
sync()
Synchronizes the map in memory with the map on disk. |
protected ReadableBuffer |
syncGetMap()
A helper that atomically syncs the deletion map and returns the buffer. |
java.lang.String |
toString()
|
void |
write()
Writes this map to a file. |
void |
write(java.io.File delFile)
Writes this map to a file. |
static void |
write(java.io.File f,
WriteableBuffer m)
|
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected java.io.File delFile
protected FileLock lock
protected int nDeleted
protected Buffer delMap
protected boolean dirty
protected static java.lang.String logTag
Constructor Detail |
---|
public DelMap()
public DelMap(java.io.File delFile, FileLock lock)
DelMap
from the given file, which is
locked with the given lock.
delFile
- The file that the deletion map is read from.lock
- The lock for that file.Method Detail |
---|
public void setPartition(Partition part)
protected Buffer readBuffer()
protected void read()
public static void write(java.io.File f, WriteableBuffer m) throws java.io.IOException
java.io.IOException
public void write()
public void write(java.io.File delFile)
delFile
- the file to which we'll write the deletion mapprotected void sync()
protected ReadableBuffer syncGetMap()
public boolean delete(int id)
id
- the ID of the document to delete
true
if the document was deleted successfully, false
otherwise. Note that we will return false
if this ID has
already been deleted in this map. That is, this method will only return
true the first time that a document is deleted.public boolean isDeleted(int id)
id
- the ID of the document that we want to check
true
if the document has been deleted, false
otherwise.public void clear()
public java.lang.Object clone()
clone
in class java.lang.Object
public int getNDeleted()
public ReadableBuffer getDelMap()
syncGetMap()
public java.lang.String toString()
toString
in class java.lang.Object
public static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |