simpledb
Class Utility

java.lang.Object
  extended by simpledb.Utility

public class Utility
extends java.lang.Object

Helper methods used for testing and implementing random features.


Constructor Summary
Utility()
           
 
Method Summary
static HeapFile createEmptyHeapFile(java.lang.String path, int cols)
          A utility method to create a new HeapFile with a single empty page, assuming the path does not already exist.
static Tuple getHeapTuple(int n)
           
static Tuple getHeapTuple(int[] tupdata)
           
static Tuple getHeapTuple(int n, int width)
           
static java.lang.String[] getStrings(int len, java.lang.String val)
           
static Tuple getTuple(int[] tupledata, int width)
           
static TupleDesc getTupleDesc(int n)
           
static TupleDesc getTupleDesc(int n, java.lang.String name)
           
static Type[] getTypes(int len)
           
static java.lang.String listToString(java.util.ArrayList<java.lang.Integer> list)
           
static HeapFile openHeapFile(int cols, java.io.File f)
          Opens a HeapFile and adds it to the catalog.
static HeapFile openHeapFile(int cols, java.lang.String colPrefix, java.io.File f)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Utility

public Utility()
Method Detail

getTypes

public static Type[] getTypes(int len)
Returns:
a Type array of length len populated with Type.INT_TYPE

getStrings

public static java.lang.String[] getStrings(int len,
                                            java.lang.String val)
Returns:
a String array of length len populated with the (possibly null) strings in val, and an appended increasing integer at the end (val1, val2, etc.).

getTupleDesc

public static TupleDesc getTupleDesc(int n,
                                     java.lang.String name)
Returns:
a TupleDesc with n fields of type Type.INT_TYPE, each named name + n (name1, name2, etc.).

getTupleDesc

public static TupleDesc getTupleDesc(int n)
Returns:
a TupleDesc with n fields of type Type.INT_TYPE

getHeapTuple

public static Tuple getHeapTuple(int n)
Returns:
a Tuple with a single IntField with value n and with RecordId(HeapPageId(1,2), 3)

getHeapTuple

public static Tuple getHeapTuple(int[] tupdata)
Returns:
a Tuple with an IntField for every element of tupdata and RecordId(HeapPageId(1, 2), 3)

getHeapTuple

public static Tuple getHeapTuple(int n,
                                 int width)
Returns:
a Tuple with a 'width' IntFields each with value n and with RecordId(HeapPageId(1, 2), 3)

getTuple

public static Tuple getTuple(int[] tupledata,
                             int width)
Returns:
a Tuple with a 'width' IntFields with the value tupledata[i] in each field. do not set it's RecordId, hence do not distinguish which sort of file it belongs to.

createEmptyHeapFile

public static HeapFile createEmptyHeapFile(java.lang.String path,
                                           int cols)
                                    throws java.io.IOException
A utility method to create a new HeapFile with a single empty page, assuming the path does not already exist. If the path exists, the file will be overwritten. The new table will be added to the Catalog with the specified number of columns as IntFields.

Throws:
java.io.IOException

openHeapFile

public static HeapFile openHeapFile(int cols,
                                    java.io.File f)
Opens a HeapFile and adds it to the catalog.

Parameters:
cols - number of columns in the table.
f - location of the file storing the table.
Returns:
the opened table.

openHeapFile

public static HeapFile openHeapFile(int cols,
                                    java.lang.String colPrefix,
                                    java.io.File f)

listToString

public static java.lang.String listToString(java.util.ArrayList<java.lang.Integer> list)