simpledb
Class Utility
java.lang.Object
simpledb.Utility
public class Utility
- extends java.lang.Object
Helper methods used for testing and implementing random features.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Utility
public Utility()
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.
listToString
public static java.lang.String listToString(java.util.ArrayList<java.lang.Integer> list)