common
Class Record

java.lang.Object
  extended by common.Record
All Implemented Interfaces:
org.apache.hadoop.io.Writable

public class Record
extends java.lang.Object
implements org.apache.hadoop.io.Writable

Definition of a record used by the application.

Each record has a fixed size that can be changed via blocksize.

Each record also has a fixed number of fields.

Note: for convenient experiments, a generated record contains twice the number of countable fields defined in the parameter file, i.e. if the number of countable fields is m, the actual number of fields defined in each record is 2m, where an even-indexed 2k-th field contains the encrypted value of the k-th field, while an odd-indexed (2k+1)-th field contains the plain-text value of the k-th field.

Author:
vohuudtr

Field Summary
static int blocksize
          Specifies a fixed size in bytes for each record.
 
Constructor Summary
Record()
          Initializes the record with zero fields.
Record(int numFields)
          Initializes the record with a given number of fields.
 
Method Summary
 BigIntegerWritable getField(int i)
          Return values of the specified field.
 int getNumFields()
          Returns the number of fields in the record (not considering random bytes of the rest).
 int getSize()
          Returns total size in bytes of all fields in the record, not including the rest of random bytes.
 void readFields(java.io.DataInput in)
          Re-initializes the record by reading from the input stream.
 void setField(int i, BigIntegerWritable value)
          Set value of the specified field.
 void write(java.io.DataOutput out)
          Writes the record to the given output stream using the format specified in readFields(DataInput).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

blocksize

public static int blocksize
Specifies a fixed size in bytes for each record.

Constructor Detail

Record

public Record()
Initializes the record with zero fields.


Record

public Record(int numFields)
Initializes the record with a given number of fields.

Parameters:
numFields - number of fields.
Method Detail

readFields

public void readFields(java.io.DataInput in)
                throws java.io.IOException
Re-initializes the record by reading from the input stream.

Format of record in the input is as follows:

All fields are in BigIntegerWritable format.

Specified by:
readFields in interface org.apache.hadoop.io.Writable
Throws:
java.io.IOException

write

public void write(java.io.DataOutput out)
           throws java.io.IOException
Writes the record to the given output stream using the format specified in readFields(DataInput).

Specified by:
write in interface org.apache.hadoop.io.Writable
Throws:
java.io.IOException

getSize

public int getSize()
Returns total size in bytes of all fields in the record, not including the rest of random bytes.

Returns:
total size.

getField

public BigIntegerWritable getField(int i)
Return values of the specified field.

Parameters:
i - index of the field.
Returns:
value of the field.

setField

public void setField(int i,
                     BigIntegerWritable value)
Set value of the specified field.

Parameters:
i - index of the field.
value - value of the field.

getNumFields

public int getNumFields()
Returns the number of fields in the record (not considering random bytes of the rest).

Returns:
number of fields.