|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.farrago.fennel.tuple.FennelTupleAccessor
public final class FennelTupleAccessor
FennelTupleAccessor defines how to efficiently marshall and unmarshall values in a stored tuple. The same logical tuple definition can have multiple storage formats. See the design docs for more details. This class is JDK 1.4 compatible.
Field Summary | |
---|---|
private List |
attrAccessors
Precomputed accessors for attributes, in logical tuple order. |
private int |
bitFieldOffset
Precomputed byte offset for bit array. |
private ByteBuffer |
currTupleBuf
current ByteBuffer used for unmarshalling; set by setCurrentTupleBuf(). |
private int |
firstVarEndIndirectOffset
Precomputed offset for indirect offset of end of first variable-width attribute, or Integer.MAX_VALUE if there are no variable-width attributes. |
private int |
firstVarOffset
Precomputed offset for fixed start of first variable-width attribute, or Integer.MAX_VALUE if there are no variable-width attributes. |
private int |
format
actual format of this accessor. |
private boolean |
hasAlignedVar
Whether any variable-width attributes with alignment requirements (currently restricted to 2-byte alignment for UNICODE strings) are present. |
private int |
lastVarEndIndirectOffset
Precomputed offset for indirect offset of end of last variable-width attribute, or Integer.MAX_VALUE if there are no variable-length attributes. |
private List |
marshalOrder
Permutation in which attributes should be marshalled; null when !hasAlignedVar, in which case attributes should be marshalled in logical order. |
private int |
maxStorage
maximum marshalled size of this tuple |
private int |
minStorage
minimum marshalled size of this tuple |
private int |
nBitFields
Precomputed size of bit field array (in bits). |
private boolean |
setNativeOrder
if true, set the ByteBuffer to native order after slicing, when doing unmarshals |
(package private) static int |
STOREDVALUEOFFSETSIZE
|
static int |
TUPLE_ALIGN_JVM
Specifies alignment matching the data model of this JVM; fallback is to assume 4-byte if relevant system property is undefined. |
static int |
TUPLE_ALIGN4
Specifies 4-byte alignment. |
static int |
TUPLE_ALIGN8
Specifies 8-byte alignment. |
static int |
TUPLE_FORMAT_ALL_NOT_NULL_AND_FIXED
|
static int |
TUPLE_FORMAT_NETWORK
|
static int |
TUPLE_FORMAT_STANDARD
format of the constructed buffer. |
private int |
tupleAlignment
tuple byte alignment. |
private int |
tupleAlignmentMask
mask derived from tupleAlignment |
private List |
varWidthAccessors
Array of 0-based indices of variable-width attributes. |
Constructor Summary | |
---|---|
FennelTupleAccessor()
default construction. |
|
FennelTupleAccessor(boolean setNativeOrder)
Creates tuple accessor with the default byte alignmnent and a flag indicating whether byte ordering should be set to native order after slicing. |
|
FennelTupleAccessor(int alignment)
Creates tuple accessor with specified byte alignmnent. |
|
FennelTupleAccessor(int alignment,
boolean setNativeOrder)
Creates tuple accessor with specified byte alignmnent and a flag indicating whether byte ordering should be set to native order after slicing. |
Method Summary | |
---|---|
int |
alignRoundUp(int val)
rounds up a value to the next multiple of tupleAlignment . |
private void |
clear()
reset this accessor. |
void |
compute(FennelTupleDescriptor tuple)
Precomputes access for a particular tuple format. |
void |
compute(FennelTupleDescriptor tuple,
int format)
Precomputes access for a particular tuple format. |
FennelAttributeAccessor |
getAccessor(int i)
gets an accessor by its numeric position. |
FennelAttributeAccessor |
getAttributeAccessor(int iAttribute)
Gets an accessor for an individual attribute. |
int |
getBitFieldOffset()
gets the offset of the first byte of bit fields, or Integer.MAX_VALUE if no bit fields are present. |
int |
getBufferByteCount(ByteBuffer pBuf)
Determines the number of bytes stored in a tuple buffer without actually preparing to unmarshal it. |
int |
getByteCount(FennelTupleData tuple)
Determines the number of bytes required to store a tuple without actually marshalling it. |
int |
getCurrentByteCount()
Determines the number of bytes stored in the current tuple buffer. |
ByteBuffer |
getCurrentTupleBuf()
Accesses the ByteBuffer storing the current tuple image. |
int |
getMaxByteCount()
returns the maximum possible tuple storage size in bytes |
int |
getMinByteCount()
returns the minimum possible tuple storage size in bytes |
private void |
initBitFieldAccessors(FennelTupleDescriptor tuple,
List list)
Initialize all the bit accessors in a tuple. |
private void |
initFixedAccessors(FennelTupleDescriptor tuple,
List list)
Initialize all the fixed width accessors in a tuple. |
private void |
initVarWidthAccessors(FennelTupleDescriptor tuple,
List list)
Initialize all the variable width accessors in a tuple. |
boolean |
isBufferSufficient(FennelTupleData tuple,
int bufSize)
Determines whether a buffer is big enough to fit marshalled tuple data. |
boolean |
isFixedWidth()
Indicates whether all tuples will have the same fixed size. |
void |
marshal(FennelTupleData tuple,
ByteBuffer tupleBuf)
Marshalls a tuple's values into a buffer. |
static int |
readUnsignedShort(ByteBuffer buffer,
int position)
gets an unsigned short value. |
void |
resetCurrentTupleBuf()
Forgets the current tuple buffer. |
void |
setCurrentTupleBuf(ByteBuffer currTupleBuf)
Sets the buffer storing the current tuple image. |
int |
size()
gets the number of attributes contained in this accessor. |
void |
unmarshal(FennelTupleData tuple)
Unmarshals the current tuple buffer, setting a tuple's values to reference the contents. |
void |
unmarshal(FennelTupleData tuple,
int iFirstDatum)
Unmarshals the current tuple buffer, setting a tuple's values to reference the contents. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int TUPLE_FORMAT_STANDARD
public static final int TUPLE_FORMAT_ALL_NOT_NULL_AND_FIXED
public static final int TUPLE_FORMAT_NETWORK
static final int STOREDVALUEOFFSETSIZE
public static final int TUPLE_ALIGN4
public static final int TUPLE_ALIGN8
public static final int TUPLE_ALIGN_JVM
private final List attrAccessors
private final List varWidthAccessors
private int maxStorage
private int minStorage
private int nBitFields
private int bitFieldOffset
private int firstVarEndIndirectOffset
private int lastVarEndIndirectOffset
private int firstVarOffset
private ByteBuffer currTupleBuf
private int format
private int tupleAlignment
private int tupleAlignmentMask
private final boolean setNativeOrder
private List marshalOrder
private boolean hasAlignedVar
Constructor Detail |
---|
public FennelTupleAccessor()
public FennelTupleAccessor(int alignment)
alignment
- must be multiple of 4public FennelTupleAccessor(boolean setNativeOrder)
setNativeOrder
- if true, set byte ordering to native order after
slicingpublic FennelTupleAccessor(int alignment, boolean setNativeOrder)
alignment
- must be multiple of 4setNativeOrder
- if true, set byte ordering to native order after
slicingMethod Detail |
---|
public int alignRoundUp(int val)
tupleAlignment
.
public int size()
public static int readUnsignedShort(ByteBuffer buffer, int position)
private void initFixedAccessors(FennelTupleDescriptor tuple, List list)
private void initVarWidthAccessors(FennelTupleDescriptor tuple, List list)
private void initBitFieldAccessors(FennelTupleDescriptor tuple, List list)
private void clear()
public FennelAttributeAccessor getAccessor(int i)
public void compute(FennelTupleDescriptor tuple, int format)
tuple
- the tuple to be accessedformat
- how to store tuplepublic void compute(FennelTupleDescriptor tuple)
tuple
- the tuple to be accessedpublic int getMaxByteCount()
public int getMinByteCount()
public boolean isFixedWidth()
NOTE: this is copied from fennel, but what about isNullable fields?
public int getBitFieldOffset()
public ByteBuffer getCurrentTupleBuf()
public void setCurrentTupleBuf(ByteBuffer currTupleBuf)
currTupleBuf
- address of tuple imagepublic void resetCurrentTupleBuf()
public int getCurrentByteCount()
public int getBufferByteCount(ByteBuffer pBuf)
pBuf
- tuple buffer
public int getByteCount(FennelTupleData tuple)
tuple
- the tuple data
public boolean isBufferSufficient(FennelTupleData tuple, int bufSize)
tuple
- the tuple to be marshalledbufSize
- the size of the candidate buffer
public void unmarshal(FennelTupleData tuple, int iFirstDatum)
tuple
- the tuple which will be modified to reference the
unmarshalled valuesiFirstDatum
- 0-based index of FennelTupleDatum at which to start
writing to tuple (defaults to first FennelTupleDatum); note that
unmarshalling always starts with the first attributepublic void unmarshal(FennelTupleData tuple)
tuple
- the tuple which will be modified to reference the
unmarshalled values, starting with the first datumpublic FennelAttributeAccessor getAttributeAccessor(int iAttribute)
iAttribute
- 0-based index of the attribute within the tuplepublic void marshal(FennelTupleData tuple, ByteBuffer tupleBuf)
tuple
- the tuple to be marshalledtupleBuf
- the buffer into which to marshal (note that this
accessor's own current tuple buffer remains unchanged)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |