simpledb
Class HeapFileEncoder

java.lang.Object
  extended by simpledb.HeapFileEncoder

public class HeapFileEncoder
extends java.lang.Object

HeapFileEncoder reads a comma delimited text file or accepts an array of tuples and converts it to pages of binary data in the appropriate format for simpledb heap pages Pages are padded out to a specified length, and written consecutive in a data file.


Constructor Summary
HeapFileEncoder()
           
 
Method Summary
static void convert(java.util.ArrayList<java.util.ArrayList<java.lang.Integer>> tuples, java.io.File outFile, int npagebytes, int numFields)
          Convert the specified tuple list (with only integer fields) into a binary page file.
static void convert(java.io.File inFile, java.io.File outFile, int npagebytes, int numFields)
           
static void convert(java.io.File inFile, java.io.File outFile, int npagebytes, int numFields, Type[] typeAr)
          Convert the specified input text file into a binary page file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HeapFileEncoder

public HeapFileEncoder()
Method Detail

convert

public static void convert(java.util.ArrayList<java.util.ArrayList<java.lang.Integer>> tuples,
                           java.io.File outFile,
                           int npagebytes,
                           int numFields)
                    throws java.io.IOException
Convert the specified tuple list (with only integer fields) into a binary page file.
The format of the output file will be as specified in HeapPage and HeapFile.

Parameters:
tuples - the tuples - a list of tuples, each represented by a list of integers that are the field values for that tuple.
outFile - The output file to write data to
npagebytes - The number of bytes per page in the output file
numFields - the number of fields in each input tuple
Throws:
java.io.IOException - if the temporary/output file can't be opened
See Also:
HeapPage, HeapFile

convert

public static void convert(java.io.File inFile,
                           java.io.File outFile,
                           int npagebytes,
                           int numFields)
                    throws java.io.IOException
Throws:
java.io.IOException

convert

public static void convert(java.io.File inFile,
                           java.io.File outFile,
                           int npagebytes,
                           int numFields,
                           Type[] typeAr)
                    throws java.io.IOException
Convert the specified input text file into a binary page file.
Assume format of the input file is (note that only integer fields are supported):
int,...,int\n
int,...,int\n
...
where each row represents a tuple.

The format of the output file will be as specified in HeapPage and HeapFile.

Parameters:
inFile - The input file to read data from
outFile - The output file to write data to
npagebytes - The number of bytes per page in the output file
numFields - the number of fields in each input line/output tuple
Throws:
java.io.IOException - if the input/output file can't be opened or a malformed input line is encountered
See Also:
HeapPage, HeapFile