korat.utils.cv
Class CVFinder

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

public class CVFinder
extends Object
implements ICVFinder

Author:
Aleksandar Milicevic

Field Summary
private  long bodyStart
           
private  BitRandomAccessFile cvFile
           
(package private)  String cvFileName
           
private  int cvSizeInBits
           
private  int numBitsPerElem
           
(package private)  long numCVs
           
private  int numElemsPerCV
           
private  boolean predicateOK
           
 
Constructor Summary
protected CVFinder(String cvFileName)
           
 
Method Summary
 void close()
          Closes underlying files, streams, etc.
 long find(int[] cv)
          Finds the index for the given candidate vector.
 long[] find(int[][] cvs)
          Finds indexes for the given candidate vectors
 long getNumCVs()
          Gets number of candidate vectors in a file
 int getNumElemsPerCV()
          Gets number of elements per candidate vector
 boolean isPredicateOK()
          Call this method immediately after calling readCV to find out if the read vector passes predicate check or not
static void main(String[] args)
           
 int[] readCV(long idx)
          Reads idx-th candidate vector from file
private  void readHeader()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

numCVs

long numCVs

numElemsPerCV

private int numElemsPerCV

numBitsPerElem

private int numBitsPerElem

bodyStart

private long bodyStart

cvSizeInBits

private int cvSizeInBits

predicateOK

private boolean predicateOK

cvFileName

String cvFileName

cvFile

private BitRandomAccessFile cvFile
Constructor Detail

CVFinder

protected CVFinder(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

find

public long find(int[] cv)
          throws IOException
Description copied from interface: ICVFinder
Finds the index for the given candidate vector.

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
Description copied from interface: ICVFinder
Finds indexes for the given candidate vectors

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

close

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

Specified by:
close in interface ICVFinder
Throws:
IOException

main

public static void main(String[] args)