Package org.terrier.structures
Class SimpleBitIndexPointer
- java.lang.Object
-
- org.terrier.structures.SimpleBitIndexPointer
-
- All Implemented Interfaces:
org.apache.hadoop.io.Writable,BitFilePosition,BitIndexPointer,Pointer
public class SimpleBitIndexPointer extends java.lang.Object implements BitIndexPointer, org.apache.hadoop.io.Writable
An implementation of a BitIndexPointer. Records a pointer in a BitIndex structure - i.e. a file number (0-31), a byte offset (long), a bit offset (0-8), and a number of entries (positive int).- Since:
- 3.0
- Author:
- Craig Macdonald
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSimpleBitIndexPointer.FactoryFactory class forSimpleBitIndexPointer.
-
Field Summary
-
Fields inherited from interface org.terrier.structures.BitIndexPointer
BIT_MASK, FILE_SHIFT, MAX_FILE_ID
-
-
Constructor Summary
Constructors Constructor Description SimpleBitIndexPointer()Construct an instance of the class.SimpleBitIndexPointer(byte fileId, long byteOffset, byte bitOffset, int numEntries)Construct an instance of the class withSimpleBitIndexPointer(long byteOffset, byte bitOffset, int numEntries)Construct an instance of the class with
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description bytegetFileNumber()Returns the file number (byte value in the 0-31 range)intgetNumberOfEntries()Return the number of "things" that this pointer refers to.longgetOffset()Return the number of bytes offset.bytegetOffsetBits()Return the number of bits offset.java.lang.StringpointerToString()Returns a textual representation of the pointer alonevoidreadFields(java.io.DataInput arg0)Populate this pointer from DataInput sourcevoidsetBitIndexPointer(BitIndexPointer pointer)Update this pointer to reflect the same values as the specified pointervoidsetFileNumber(byte fileId)Set the file number.voidsetNumberOfEntries(int count)Set the number of "things" that the pointer refers to.voidsetOffset(long _bytes, byte _bits)Set the offset in number of bytes and number of bits.voidsetOffset(BitFilePosition pos)Sets the bit file position within this object to that represented by the specified bit file position.voidsetPointer(Pointer p)Sets the pointer within this object to that represented by the specified pointer.java.lang.StringtoString()Debug friendly output of this pointervoidwrite(java.io.DataOutput arg0)Write this pointer to DataOutput
-
-
-
Constructor Detail
-
SimpleBitIndexPointer
public SimpleBitIndexPointer()
Construct an instance of the class.
-
SimpleBitIndexPointer
public SimpleBitIndexPointer(byte fileId, long byteOffset, byte bitOffset, int numEntries)Construct an instance of the class with- Parameters:
fileId-byteOffset-bitOffset-numEntries-
-
SimpleBitIndexPointer
public SimpleBitIndexPointer(long byteOffset, byte bitOffset, int numEntries)Construct an instance of the class with- Parameters:
byteOffset-bitOffset-numEntries-
-
-
Method Detail
-
getNumberOfEntries
public int getNumberOfEntries()
Return the number of "things" that this pointer refers to.- Specified by:
getNumberOfEntriesin interfacePointer- Returns:
- the number of "things" that this pointer refers to.
-
setNumberOfEntries
public void setNumberOfEntries(int count)
Set the number of "things" that the pointer refers to.- Specified by:
setNumberOfEntriesin interfacePointer- Parameters:
count- the number of "things" that the pointer refers to.
-
getOffsetBits
public byte getOffsetBits()
Return the number of bits offset.- Specified by:
getOffsetBitsin interfaceBitFilePosition- Returns:
- the number of bits offset.
-
getFileNumber
public byte getFileNumber()
Returns the file number (byte value in the 0-31 range)- Specified by:
getFileNumberin interfaceBitIndexPointer- Returns:
- the file number (byte value in the 0-31 range)
-
setFileNumber
public void setFileNumber(byte fileId)
Set the file number.- Specified by:
setFileNumberin interfaceBitIndexPointer- Parameters:
fileId- the file number.
-
getOffset
public long getOffset()
Return the number of bytes offset.- Specified by:
getOffsetin interfaceBitFilePosition- Returns:
- the number of bytes offset.
-
setOffset
public void setOffset(long _bytes, byte _bits)Set the offset in number of bytes and number of bits.- Specified by:
setOffsetin interfaceBitFilePosition- Parameters:
_bytes- the number of bytes to set._bits- the number of bits to set.
-
setBitIndexPointer
public void setBitIndexPointer(BitIndexPointer pointer)
Update this pointer to reflect the same values as the specified pointer- Specified by:
setBitIndexPointerin interfaceBitIndexPointer- Parameters:
pointer- the pointer to use to set the byte offset, bit offset and file number parameters.
-
setOffset
public void setOffset(BitFilePosition pos)
Sets the bit file position within this object to that represented by the specified bit file position.- Specified by:
setOffsetin interfaceBitFilePosition- Parameters:
pos- other bit file position to update the bit file position in this object.
-
readFields
public void readFields(java.io.DataInput arg0) throws java.io.IOExceptionPopulate this pointer from DataInput source- Specified by:
readFieldsin interfaceorg.apache.hadoop.io.Writable- Throws:
java.io.IOException
-
write
public void write(java.io.DataOutput arg0) throws java.io.IOExceptionWrite this pointer to DataOutput- Specified by:
writein interfaceorg.apache.hadoop.io.Writable- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
Debug friendly output of this pointer- Overrides:
toStringin classjava.lang.Object
-
pointerToString
public java.lang.String pointerToString()
Returns a textual representation of the pointer alone- Specified by:
pointerToStringin interfacePointer
-
setPointer
public void setPointer(Pointer p)
Sets the pointer within this object to that represented by the specified pointer.- Specified by:
setPointerin interfacePointer- Parameters:
p- other pointer to update the pointer in this object.
-
-