|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectrelop.Tuple
public class Tuple
Each tuple in a relation is a collection of bytes that must fit within a single page. The Tuple class provides a logical view of fields, allowing get and set operations while automatically handling offsets and type conversions.
Field Summary | |
---|---|
protected byte[] |
data
Page buffer containing this tuple. |
protected Schema |
schema
Schema information for the fields. |
Constructor Summary | |
---|---|
Tuple(Schema schema)
Creates a new empty tuple, given its schema. |
|
Tuple(Schema schema,
byte[] data)
Creates a new tuple, given existing values to wrap. |
|
Tuple(Schema schema,
java.lang.Object... values)
Creates a new tuple, given its schema and values. |
Method Summary | |
---|---|
java.lang.Object[] |
getAllFields()
Returns generic values for all fields. |
byte[] |
getData()
Gets the underlying data buffer. |
java.lang.Object |
getField(int fldno)
Gets a field's value generically. |
java.lang.Object |
getField(java.lang.String fldName)
Gets a field's value generically, by column name. |
float |
getFloatFld(int fldno)
Gets a float field. |
int |
getIntFld(int fldno)
Gets an integer field. |
java.lang.String |
getStringFld(int fldno)
Gets a string field. |
RID |
insertIntoFile(HeapFile file)
Inserts the tuple into the given heap file. |
static Tuple |
join(Tuple t1,
Tuple t2,
Schema schema)
Builds and returns a new tuple resulting from joining two tuples. |
protected void |
padOutput(int fieldLen,
int outputLen)
Pads the current output to make columns line up. |
void |
print()
Prints the tuple in a human-readable format. |
void |
setAllFields(java.lang.Object... values)
Sets all fields, given generic values. |
void |
setField(int fldno,
java.lang.Object val)
Sets a field's value generically. |
void |
setField(java.lang.String fldName,
java.lang.Object val)
Sets a field's value generically, by column name. |
void |
setFloatFld(int fldno,
float val)
Sets a float field. |
void |
setIntFld(int fldno,
int val)
Sets an integer field. |
void |
setStringFld(int fldno,
java.lang.String val)
Sets a string field (automatically truncates, if necessary). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected byte[] data
protected Schema schema
Constructor Detail |
---|
public Tuple(Schema schema)
schema
- logical information for the fieldspublic Tuple(Schema schema, java.lang.Object... values)
schema
- logical information for the fieldsvalues
- individual data values of the fieldspublic Tuple(Schema schema, byte[] data)
schema
- logical information for the fieldsdata
- record buffer containing the tupleMethod Detail |
---|
public static Tuple join(Tuple t1, Tuple t2, Schema schema)
t1
- the left tuplet2
- the right tupleschema
- of the resultpublic byte[] getData()
public RID insertIntoFile(HeapFile file)
public java.lang.Object getField(int fldno)
public java.lang.Object getField(java.lang.String fldName)
public void setField(int fldno, java.lang.Object val)
public void setField(java.lang.String fldName, java.lang.Object val)
public java.lang.Object[] getAllFields()
public void setAllFields(java.lang.Object... values)
public int getIntFld(int fldno)
public void setIntFld(int fldno, int val)
public float getFloatFld(int fldno)
public void setFloatFld(int fldno, float val)
public java.lang.String getStringFld(int fldno)
public void setStringFld(int fldno, java.lang.String val)
public void print()
protected void padOutput(int fieldLen, int outputLen)
fieldLen
- minimum length of the current fieldoutputLen
- length of the current output so far
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |