public class TupleIOManager
extends java.lang.Object
Constructor and Description |
---|
TupleIOManager(Relation relation,
java.lang.String filename)
Construct a new manager given a relation schema.
|
Modifier and Type | Method and Description |
---|---|
static int |
byteSize(Relation rel,
Tuple t)
Calculates the byte size of a tuple given its relation.
|
int |
byteSize(Tuple t)
Calculates the byte size of a tuple of this IO manager.
|
protected int |
dumpSlot(java.lang.Class<? extends java.lang.Comparable> type,
Tuple t,
int s,
byte[] bytes,
int start)
Low-level method to dump a tuple slot to a byte array.
|
protected Pair<? extends java.lang.Comparable,java.lang.Integer> |
fetch(java.lang.Class<? extends java.lang.Comparable> type,
byte[] bytes,
int start)
Low-level method to read a slot from a byte array.
|
Pair<Tuple,java.lang.Integer> |
readTuple(byte[] bytes,
int start)
Reads a tuple from a byte array -- should be used when there is
page buffering.
|
int |
writeTuple(Tuple tuple,
byte[] bytes,
int start)
Writes a tuple to a byte array -- should be used when there is
page buffering.
|
public TupleIOManager(Relation relation, java.lang.String filename)
relation
- the relation schema.filename
- the name of the relation's file.public int writeTuple(Tuple tuple, byte[] bytes, int start) throws StorageManagerException
tuple
- the tuple to be written.bytes
- the byte array the tuple should be written to.start
- the starting offset into the byte array.StorageManagerException
- thrown whenever there is an I/O
error.public Pair<Tuple,java.lang.Integer> readTuple(byte[] bytes, int start) throws StorageManagerException
bytes
- the byte array.start
- the starting offset into the byte array.StorageManagerException
- thrown whenever there is an I/O
error.protected int dumpSlot(java.lang.Class<? extends java.lang.Comparable> type, Tuple t, int s, byte[] bytes, int start) throws StorageManagerException
type
- the type of the slot.t
- the tuple.s
- the slot of the tuple to be dumped.bytes
- the byte array where the slot will be dumped.start
- the starting offset.StorageManagerException
- thrown whenever there is an I/O
error.protected Pair<? extends java.lang.Comparable,java.lang.Integer> fetch(java.lang.Class<? extends java.lang.Comparable> type, byte[] bytes, int start) throws StorageManagerException
type
- the type of the slot to be read.bytes
- the input byte array.start
- the starting offset in the byte array.StorageManagerException
- thrown whenever there is an I/O
error.public int byteSize(Tuple t)
t
- the tuple.public static int byteSize(Relation rel, Tuple t)
rel
- the relation.t
- the tuple.