korat.utils.cv
Class CVWriter

java.lang.Object
  extended by korat.utils.cv.CVWriter
All Implemented Interfaces:
ICVWriter

public class CVWriter
extends Object
implements ICVWriter

Utility for writing candidate vectors in a binary file.

Format of the file that this utility produces is: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | TOTAL NUMBER OF CANDIDADE VECTORS IN A FILE (high word) | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | TOTAL NUMBER OF CANDIDADE VECTORS IN A FILE (low word) | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | NUMBER OF ELEMENTS PER CANDIDATE VECTOR | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | NUMBER OF BITS PER CANDIDATE VECTOR ELEMENT | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | CVs[0,0] (variable size) | CVs[0,1] (variable size) |.... | CVs[0,m] (variable size) |ok| +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | CVs[1,0] (variable size) | CVs[1,1] (variable size) |.... | CVs[1,m] (variable size) |ok| +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | .... | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | CVs[n,0] (variable size) | CVs[n,1] (variable size) |.... | CVs[n,m] (variable size) |ok| +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+

Author:
Aleksandar Milicevic

Field Summary
private  BitOutputStream bos
           
private  String fileName
           
private  int numBitsPerElem
           
private  long numCVs
           
private  int numElemsPerCV
           
 
Constructor Summary
protected CVWriter(String fileName, int numElemsPerCV, int maxElem)
           
 
Method Summary
 void close()
          Closes underlying files, streams, etc.
 void writeCV(int[] cv, boolean predicateOK)
          Writes given candidate vector and its predicateOK flag to file.
private  void writeHeader()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

numElemsPerCV

private int numElemsPerCV

numBitsPerElem

private int numBitsPerElem

fileName

private String fileName

numCVs

private long numCVs

bos

private BitOutputStream bos
Constructor Detail

CVWriter

protected CVWriter(String fileName,
                   int numElemsPerCV,
                   int maxElem)
            throws IOException
Throws:
IOException
Method Detail

writeHeader

private void writeHeader()
                  throws IOException
Throws:
IOException

writeCV

public void writeCV(int[] cv,
                    boolean predicateOK)
             throws IOException
Description copied from interface: ICVWriter
Writes given candidate vector and its predicateOK flag to file.

Specified by:
writeCV in interface ICVWriter
Parameters:
cv - candidate vector to be written to file
predicateOK - if the given candidate vector passes predicate check or not
Throws:
IOException - if an I/O error occurs

close

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

Specified by:
close in interface ICVWriter
Throws:
IOException - if an I/O error occurs