|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectit.unipi.di.rs.SparseSelect
public class SparseSelect
An index implementing the select
function over binary files with a
small number of 1s.
The index uses the SDarrays method and creates two vectors from the source: H and L; it
can performs select operations in constant time and rank operations as binary search.
This index is not suitable for source files having an amount of 1s greater than the 15% of their size.
Being a self-index, after the first build the source will be no longer necessary to perform rank
and select operations. If the two support vectors are already stored on disk it is possible
to create this index without source using constructor SparseSelect(String, String)
and then create the data structures using createOnlyIndex methods or load it with load()
.
Field Summary | |
---|---|
static double |
DENSITY_LIMIT
|
Fields inherited from interface it.unipi.di.rs.IRankSelect |
---|
DISK, MEMORY |
Constructor Summary | |
---|---|
SparseSelect(String source)
Creates an object and initializes basic data structures; it will be necessary to use a specific method to create data structures or load them. |
|
SparseSelect(String source,
Directory tdb)
Creates an object from a source contained in a Directory and initializes basic data structures; it will be necessary to use a specific method to create data structures or load them. |
|
SparseSelect(String HFileName,
String LFileName)
Create an index that will work without the source; H and L are required. |
|
SparseSelect(String HFileName,
String LFileName,
Directory tdb)
Create an index that will work without the source; H and L are required inside the Directory. |
Method Summary | |
---|---|
long |
count1(long start,
long end)
Returns the number of 1s in the selected range of the source |
void |
createIndex(int mode)
Creates the index in memory or on disk. |
void |
createIndex(int mode,
float iPerc)
Creates the index in memory or on disk using the specified amount of space |
void |
createOnlyIndex(int mode)
Creates the Index to perform rank operations without creating files that contains H and L vectors. |
void |
createOnlyIndex(int mode,
float iPerc)
Creates the Index to perform select operations without creating files that contains H and L. |
long |
DenseVectorSize()
Returns the size of the dense vector |
boolean |
get(long index)
Returns the value at the specified position |
static String |
getIndexFileName(String baseName)
Generates the names of the file that will contain the index in case of store() operations |
static String[] |
getVectorsFileNames(String baseName)
Generates the names of the two files that will contain the two vectors generated by this index. |
long |
ISize()
Returns the size in bits of the index |
void |
load()
Loads the data structures from the default file(s) |
void |
load(Directory directory)
This methods acts as IRankSelect.load() , but load data structures from a Directory |
long |
rank0(long pos)
Returns the rank0 at the pos-th bit (starting from 0) |
long |
rank1(long pos)
Returns the rank1 at the pos-th bit (starting from 0) |
long |
Scard()
Returns the number of 1s in the source |
long |
select1(long rank)
Returns the position of the rank-th 1 (starting from 0) |
long |
Ssize()
Returns the size in bits of the source file. |
void |
store()
Stores data structures in the default file(s). |
void |
store(Directory directory)
This methods acts as IRankSelect.store() , but store data structures inside a Directory |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final double DENSITY_LIMIT
Constructor Detail |
---|
public SparseSelect(String source) throws IOException
source
- the name of the source file
IOException
public SparseSelect(String source, Directory tdb) throws IOException
source
- the name of the source file
IOException
public SparseSelect(String HFileName, String LFileName) throws IOException
HFileName
- the file inside tdb containing the vector HLFileName
- the file inside tdb containing the vector L
IOException
public SparseSelect(String HFileName, String LFileName, Directory tdb) throws IOException
HFileName
- the file inside tdb containing the vector HLFileName
- the file inside tdb containing the vector Ltdb
- the Directory
used to store information to disk
IOException
Method Detail |
---|
public static String[] getVectorsFileNames(String baseName)
baseName
- is the name from which generate the new names; tipically the name of the source of the index
public static String getIndexFileName(String baseName)
store()
operations
baseName
- is the name from which generate the new names; tipically the name of the source of the index
public long Scard() throws IOException
IRankSelect
Scard
in interface IRankSelect
IOException
public long Ssize()
IRankSelect
Ssize
in interface IRankSelect
public long DenseVectorSize()
IOException
public long ISize() throws IOException
IRankSelect
ISize
in interface IRankSelect
IOException
public void createIndex(int mode) throws IOException
IRankSelect
createIndex
in interface IRankSelect
mode
- the mode of creation (IRankSelect.MEMORY
or IRankSelect.DISK
)
IOException
public void createIndex(int mode, float iPerc) throws IOException
IRankSelect
createIndex
in interface IRankSelect
mode
- the mode of creation (IRankSelect.MEMORY
or IRankSelect.DISK
)iPerc
- is the space occupancy in terms of % of the source dimension that the index must achieve
IOException
public void createOnlyIndex(int mode) throws IOException
mode
- the mode of creation
YQLException
IOException
public void createOnlyIndex(int mode, float iPerc) throws IOException
mode
- the mode of creationiPerc
- is the % of the dense vector to use to save index information
YQLException
IOException
public long rank0(long pos) throws IOException
IRankSelect
rank0
in interface IRankSelect
pos
- is the position to analyze
IOException
public long rank1(long pos) throws IOException
IRankSelect
rank1
in interface IRankSelect
pos
- is the position to analyze
IOException
public long select1(long rank) throws IOException
IRankSelect
select1
in interface IRankSelect
rank
- is the rank to find
IOException
public void load() throws IOException
IRankSelect
load
in interface IRankSelect
IOException
public void load(Directory directory) throws IOException
IRankSelect
IRankSelect.load()
, but load data structures from a Directory
load
in interface IRankSelect
directory
- the source Directory; must be opened in READ_MODE
IOException
public void store() throws IOException, IOException
IRankSelect
store
in interface IRankSelect
IOException
public void store(Directory directory) throws IOException
IRankSelect
IRankSelect.store()
, but store data structures inside a Directory
store
in interface IRankSelect
directory
- the destination Directory; must be opened in WRITE_MODE
IOException
public long count1(long start, long end) throws IOException
IRankSelect
count1
in interface IRankSelect
IOException
public boolean get(long index) throws IOException
IRankSelect
get
in interface IRankSelect
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |