iterator
Class TupleUtils

java.lang.Object
  extended byiterator.TupleUtils

public class TupleUtils
extends java.lang.Object

some useful method when processing Tuple


Constructor Summary
TupleUtils()
           
 
Method Summary
static int CompareTupleWithTuple(AttrType fldType, Tuple t1, int t1_fld_no, Tuple t2, int t2_fld_no)
          This function compares a tuple with another tuple in respective field, and returns: 0 if the two are equal, 1 if the tuple is greater, -1 if the tuple is smaller,
static int CompareTupleWithValue(AttrType fldType, Tuple t1, int t1_fld_no, Tuple value)
          This function compares tuple1 with another tuple2 whose field number is same as the tuple1
static boolean Equal(Tuple t1, Tuple t2, AttrType[] types, int len)
          This function Compares two Tuple inn all fields
static short[] setup_op_tuple(Tuple Jtuple, AttrType[] res_attrs, AttrType[] in1, int len_in1, AttrType[] in2, int len_in2, short[] t1_str_sizes, short[] t2_str_sizes, FldSpec[] proj_list, int nOutFlds)
          set up the Jtuple's attrtype, string size,field number for using join
static short[] setup_op_tuple(Tuple Jtuple, AttrType[] res_attrs, AttrType[] in1, int len_in1, short[] t1_str_sizes, FldSpec[] proj_list, int nOutFlds)
          set up the Jtuple's attrtype, string size,field number for using project
static void SetValue(Tuple value, Tuple tuple, int fld_no, AttrType fldType)
          set up a tuple in specified field from a tuple
static java.lang.String Value(Tuple tuple, int fldno)
          get the string specified by the field number
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TupleUtils

public TupleUtils()
Method Detail

CompareTupleWithTuple

public static int CompareTupleWithTuple(AttrType fldType,
                                        Tuple t1,
                                        int t1_fld_no,
                                        Tuple t2,
                                        int t2_fld_no)
                                 throws java.io.IOException,
                                        UnknowAttrType,
                                        TupleUtilsException
This function compares a tuple with another tuple in respective field, and returns: 0 if the two are equal, 1 if the tuple is greater, -1 if the tuple is smaller,

Parameters:
fldType - the type of the field being compared.
t1 - one tuple.
t2 - another tuple.
t1_fld_no - the field numbers in the tuples to be compared.
t2_fld_no - the field numbers in the tuples to be compared.
Returns:
0 if the two are equal, 1 if the tuple is greater, -1 if the tuple is smaller,
Throws:
UnknowAttrType - don't know the attribute type
java.io.IOException - some I/O fault
TupleUtilsException - exception from this class

CompareTupleWithValue

public static int CompareTupleWithValue(AttrType fldType,
                                        Tuple t1,
                                        int t1_fld_no,
                                        Tuple value)
                                 throws java.io.IOException,
                                        UnknowAttrType,
                                        TupleUtilsException
This function compares tuple1 with another tuple2 whose field number is same as the tuple1

Parameters:
fldType - the type of the field being compared.
t1 - one tuple
value - another tuple.
t1_fld_no - the field numbers in the tuples to be compared.
Returns:
0 if the two are equal, 1 if the tuple is greater, -1 if the tuple is smaller,
Throws:
UnknowAttrType - don't know the attribute type
java.io.IOException - some I/O fault
TupleUtilsException - exception from this class

Equal

public static boolean Equal(Tuple t1,
                            Tuple t2,
                            AttrType[] types,
                            int len)
                     throws java.io.IOException,
                            UnknowAttrType,
                            TupleUtilsException
This function Compares two Tuple inn all fields

Parameters:
t1 - the first tuple
t2 - the secocnd tuple
len - the field numbers
Returns:
0 if the two are not equal, 1 if the two are equal,
Throws:
UnknowAttrType - don't know the attribute type
java.io.IOException - some I/O fault
TupleUtilsException - exception from this class

Value

public static java.lang.String Value(Tuple tuple,
                                     int fldno)
                              throws java.io.IOException,
                                     TupleUtilsException
get the string specified by the field number

Parameters:
tuple - the tuple
Returns:
the content of the field number
Throws:
java.io.IOException - some I/O fault
TupleUtilsException - exception from this class

SetValue

public static void SetValue(Tuple value,
                            Tuple tuple,
                            int fld_no,
                            AttrType fldType)
                     throws java.io.IOException,
                            UnknowAttrType,
                            TupleUtilsException
set up a tuple in specified field from a tuple

Parameters:
value - the tuple to be set
tuple - the given tuple
fld_no - the field number
fldType - the tuple attr type
Throws:
UnknowAttrType - don't know the attribute type
java.io.IOException - some I/O fault
TupleUtilsException - exception from this class

setup_op_tuple

public static short[] setup_op_tuple(Tuple Jtuple,
                                     AttrType[] res_attrs,
                                     AttrType[] in1,
                                     int len_in1,
                                     AttrType[] in2,
                                     int len_in2,
                                     short[] t1_str_sizes,
                                     short[] t2_str_sizes,
                                     FldSpec[] proj_list,
                                     int nOutFlds)
                              throws java.io.IOException,
                                     TupleUtilsException
set up the Jtuple's attrtype, string size,field number for using join

Parameters:
Jtuple - reference to an actual tuple - no memory has been malloced
res_attrs - attributes type of result tuple
in1 - array of the attributes of the tuple (ok)
len_in1 - num of attributes of in1
in2 - array of the attributes of the tuple (ok)
len_in2 - num of attributes of in2
t1_str_sizes - shows the length of the string fields in S
t2_str_sizes - shows the length of the string fields in R
proj_list - shows what input fields go where in the output tuple
nOutFlds - number of outer relation fileds
Throws:
java.io.IOException - some I/O fault
TupleUtilsException - exception from this class

setup_op_tuple

public static short[] setup_op_tuple(Tuple Jtuple,
                                     AttrType[] res_attrs,
                                     AttrType[] in1,
                                     int len_in1,
                                     short[] t1_str_sizes,
                                     FldSpec[] proj_list,
                                     int nOutFlds)
                              throws java.io.IOException,
                                     TupleUtilsException,
                                     InvalidRelation
set up the Jtuple's attrtype, string size,field number for using project

Parameters:
Jtuple - reference to an actual tuple - no memory has been malloced
res_attrs - attributes type of result tuple
in1 - array of the attributes of the tuple (ok)
len_in1 - num of attributes of in1
t1_str_sizes - shows the length of the string fields in S
proj_list - shows what input fields go where in the output tuple
nOutFlds - number of outer relation fileds
Throws:
java.io.IOException - some I/O fault
TupleUtilsException - exception from this class
InvalidRelation - invalid relation