All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class heap.Tuple

java.lang.Object
   |
   +----heap.Tuple

public class Tuple
extends Object
implements GlobalConst

Variable Index

 o max_size
Maximum size of any tuple

Constructor Index

 o Tuple()
Class constructor Creat a new tuple with length = max_size,tuple offset = 0.
 o Tuple(byte[], int, int)
Constructor
 o Tuple(int)
Class constructor Creat a new tuple with length = size,tuple offset = 0.
 o Tuple(Tuple)
Constructor(used as tuple copy)

Method Index

 o copyFldOffset()
Makes a copy of the fldOffset array
 o getCharFld(int)
Convert this field into a character
 o getFloFld(int)
Convert this field in to float
 o getIntFld(int)
Convert this field into integer
 o getLength()
get the length of a tuple, call this method if you did not call setHdr () before
 o getOffset()
get the offset of a tuple
 o getStrFld(int)
Convert this field into String
 o getTupleByteArray()
Copy the tuple byte array out
 o noOfFlds()
Returns number of fields in this tuple
 o print(AttrType[])
Print out the tuple
 o returnTupleByteArray()
return the data byte array
 o setFloFld(int, float)
Set this field to float value
 o setHdr(short, AttrType[], short[])
setHdr will set the header of this tuple.
 o setIntFld(int, int)
Set this field to integer value
 o setStrFld(int, String)
Set this field to String value
 o size()
get the length of a tuple, call this method if you did call setHdr () before
 o tupleCopy(Tuple)
Copy a tuple to the current tuple position you must make sure the tuple lengths must be equal
 o tupleInit(byte[], int, int)
This is used when you don't want to use the constructor
 o tupleSet(byte[], int, int)
Set a tuple with the given tuple length and offset

Variables

 o max_size
 public static final int max_size
Maximum size of any tuple

Constructors

 o Tuple
 public Tuple()
Class constructor Creat a new tuple with length = max_size,tuple offset = 0.

 o Tuple
 public Tuple(byte atuple[],
              int offset,
              int length)
Constructor

Parameters:
atuple - a byte array which contains the tuple
offset - the offset of the tuple in the byte array
length - the length of the tuple
 o Tuple
 public Tuple(Tuple fromTuple)
Constructor(used as tuple copy)

Parameters:
fromTuple - a byte array which contains the tuple
 o Tuple
 public Tuple(int size)
Class constructor Creat a new tuple with length = size,tuple offset = 0.

Methods

 o tupleCopy
 public void tupleCopy(Tuple fromTuple)
Copy a tuple to the current tuple position you must make sure the tuple lengths must be equal

Parameters:
fromTuple - the tuple being copied
 o tupleInit
 public void tupleInit(byte atuple[],
                       int offset,
                       int length)
This is used when you don't want to use the constructor

Parameters:
atuple - a byte array which contains the tuple
offset - the offset of the tuple in the byte array
length - the length of the tuple
 o tupleSet
 public void tupleSet(byte record[],
                      int offset,
                      int length)
Set a tuple with the given tuple length and offset

Parameters:
record - a byte array contains the tuple
offset - the offset of the tuple ( =0 by default)
length - the length of the tuple
 o getLength
 public int getLength()
get the length of a tuple, call this method if you did not call setHdr () before

Returns:
length of this tuple in bytes
 o size
 public short size()
get the length of a tuple, call this method if you did call setHdr () before

Returns:
size of this tuple in bytes
 o getOffset
 public int getOffset()
get the offset of a tuple

Returns:
offset of the tuple in byte array
 o getTupleByteArray
 public byte[] getTupleByteArray()
Copy the tuple byte array out

Returns:
byte[], a byte array contains the tuple the length of byte[] = length of the tuple
 o returnTupleByteArray
 public byte[] returnTupleByteArray()
return the data byte array

Returns:
data byte array
 o getIntFld
 public int getIntFld(int fldNo) throws IOException, FieldNumberOutOfBoundException
Convert this field into integer

Parameters:
fldNo - the field number
Returns:
the converted integer if success
Throws: IOException
I/O errors
Throws: FieldNumberOutOfBoundException
Tuple field number out of bound
 o getFloFld
 public float getFloFld(int fldNo) throws IOException, FieldNumberOutOfBoundException
Convert this field in to float

Parameters:
fldNo - the field number
Returns:
the converted float number if success
Throws: IOException
I/O errors
Throws: FieldNumberOutOfBoundException
Tuple field number out of bound
 o getStrFld
 public String getStrFld(int fldNo) throws IOException, FieldNumberOutOfBoundException
Convert this field into String

Parameters:
fldNo - the field number
Returns:
the converted string if success
Throws: IOException
I/O errors
Throws: FieldNumberOutOfBoundException
Tuple field number out of bound
 o getCharFld
 public char getCharFld(int fldNo) throws IOException, FieldNumberOutOfBoundException
Convert this field into a character

Parameters:
fldNo - the field number
Returns:
the character if success
Throws: IOException
I/O errors
Throws: FieldNumberOutOfBoundException
Tuple field number out of bound
 o setIntFld
 public Tuple setIntFld(int fldNo,
                        int val) throws IOException, FieldNumberOutOfBoundException
Set this field to integer value

Parameters:
fldNo - the field number
val - the integer value
Throws: IOException
I/O errors
Throws: FieldNumberOutOfBoundException
Tuple field number out of bound
 o setFloFld
 public Tuple setFloFld(int fldNo,
                        float val) throws IOException, FieldNumberOutOfBoundException
Set this field to float value

Parameters:
fldNo - the field number
val - the float value
Throws: IOException
I/O errors
Throws: FieldNumberOutOfBoundException
Tuple field number out of bound
 o setStrFld
 public Tuple setStrFld(int fldNo,
                        String val) throws IOException, FieldNumberOutOfBoundException
Set this field to String value

Parameters:
fldNo - the field number
val - the string value
Throws: IOException
I/O errors
Throws: FieldNumberOutOfBoundException
Tuple field number out of bound
 o setHdr
 public void setHdr(short numFlds,
                    AttrType types[],
                    short strSizes[]) throws IOException, InvalidTypeException, InvalidTupleSizeException
setHdr will set the header of this tuple.

Parameters:
numFlds - number of fields
types[] - contains the types that will be in this tuple
strSizes[] - contains the sizes of the string
Throws: IOException
I/O errors
Throws: InvalidTypeException
Invalid tupe type
Throws: InvalidTupleSizeException
Tuple size too big
 o noOfFlds
 public short noOfFlds()
Returns number of fields in this tuple

Returns:
the number of fields in this tuple
 o copyFldOffset
 public short[] copyFldOffset()
Makes a copy of the fldOffset array

Returns:
a copy of the fldOffset arrray
 o print
 public void print(AttrType type[]) throws IOException
Print out the tuple

Parameters:
type - the types in the tuple

All Packages  Class Hierarchy  This Package  Previous  Next  Index