korat.utils.cv
Class CVFinderDelta

java.lang.Object
  extended by korat.utils.cv.CVFinderDelta
All Implemented Interfaces:
ICVFinder

public class CVFinderDelta
extends Object
implements ICVFinder

Author:
Aleksandar Milicevic

Nested Class Summary
static class CVFinderDelta.FinderResult
           
 
Field Summary
(package private)  boolean binSearchFound
           
(package private)  int binSearchIdx
           
private  long bodyStart
           
private  int[][] buffer
           
private  BitRandomAccessFile cvDeltaFile
           
private  String cvDeltaFileName
           
private  BitRandomAccessFile cvFile
           
private  String cvFileName
           
private  int dataSizeInBits
           
private  int fullFormatRatio
           
private  int numBitsPerCVIndex
           
private  int numBitsPerElem
           
private  long numCVs
           
private  int numElemsPerCV
           
private  int numFullFormatVectors
           
private  long[] offsets
           
private  boolean predicateOK
           
 
Constructor Summary
protected CVFinderDelta(String cvFileName)
           
 
Method Summary
private  void binSearch(int[] cvToFind, IIntList fieldAccessList)
           
 void close()
          Closes underlying files, streams, etc.
 long find(int[] cv)
          sequential search
 long[] find(int[][] cvs)
          sequential search
 CVFinderDelta.FinderResult find(int[] cv, IIntList fieldAccessList)
           
 long getNumCVs()
          Gets number of candidate vectors in a file
 int getNumElemsPerCV()
          Gets number of elements per candidate vector
private  void initBuffer()
           
 boolean isPredicateOK()
          Call this method immediately after calling readCV to find out if the read vector passes predicate check or not
 int[] readCV(long idx)
          Reads idx-th candidate vector from file
private  void readHeader()
           
private  long readOffset(long idx, int[] cv)
           
private  CVFinderDelta.FinderResult seqSearch(int[] cvToFind, int[] lastCV, IIntList fieldAccessList)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

numCVs

private long numCVs

numElemsPerCV

private int numElemsPerCV

numBitsPerElem

private int numBitsPerElem

fullFormatRatio

private int fullFormatRatio

numFullFormatVectors

private int numFullFormatVectors

bodyStart

private long bodyStart

predicateOK

private boolean predicateOK

cvFileName

private String cvFileName

cvDeltaFileName

private String cvDeltaFileName

cvFile

private BitRandomAccessFile cvFile

cvDeltaFile

private BitRandomAccessFile cvDeltaFile

dataSizeInBits

private int dataSizeInBits

numBitsPerCVIndex

private int numBitsPerCVIndex

buffer

private int[][] buffer

offsets

private long[] offsets

binSearchIdx

int binSearchIdx

binSearchFound

boolean binSearchFound
Constructor Detail

CVFinderDelta

protected CVFinderDelta(String cvFileName)
                 throws IOException
Throws:
IOException
Method Detail

readHeader

private void readHeader()
                 throws IOException
Throws:
IOException

getNumCVs

public long getNumCVs()
Description copied from interface: ICVFinder
Gets number of candidate vectors in a file

Specified by:
getNumCVs in interface ICVFinder
Returns:
number of candidate vectors

getNumElemsPerCV

public int getNumElemsPerCV()
Description copied from interface: ICVFinder
Gets number of elements per candidate vector

Specified by:
getNumElemsPerCV in interface ICVFinder
Returns:
number of elements per candidate vector

isPredicateOK

public boolean isPredicateOK()
Description copied from interface: ICVFinder
Call this method immediately after calling readCV to find out if the read vector passes predicate check or not

Specified by:
isPredicateOK in interface ICVFinder
Returns:
is predicate ok or not for the last read candidate vector

readCV

public int[] readCV(long idx)
             throws IOException
Description copied from interface: ICVFinder
Reads idx-th candidate vector from file

Specified by:
readCV in interface ICVFinder
Parameters:
idx - index of candidate vector in the file
Returns:
candidate vector on the idx-th position in the file
Throws:
IOException - if an I/O error occurs

readOffset

private long readOffset(long idx,
                        int[] cv)
                 throws IOException
Throws:
IOException

find

public long find(int[] cv)
          throws IOException
sequential search

Specified by:
find in interface ICVFinder
Parameters:
cv - candidate vector to search for
Returns:
index of the given candidate vector in the file if vector exists of -1 otherwise
Throws:
IOException - if an I/O error occurs

find

public long[] find(int[][] cvs)
            throws IOException
sequential search

Specified by:
find in interface ICVFinder
Parameters:
cvs - candidate vectors to search for
Returns:
indices of the given candidate vectors in the file
Throws:
IOException - if an I/O error occurs

initBuffer

private void initBuffer()
                 throws IOException
Throws:
IOException

find

public CVFinderDelta.FinderResult find(int[] cv,
                                       IIntList fieldAccessList)
                                throws IOException
Throws:
IOException

seqSearch

private CVFinderDelta.FinderResult seqSearch(int[] cvToFind,
                                             int[] lastCV,
                                             IIntList fieldAccessList)
                                      throws IOException
Throws:
IOException

binSearch

private void binSearch(int[] cvToFind,
                       IIntList fieldAccessList)

close

public void close()
           throws IOException
Description copied from interface: ICVFinder
Closes underlying files, streams, etc.

Specified by:
close in interface ICVFinder
Throws:
IOException