net.sf.farrago.fennel.tuple
Class FennelAttributeAccessor

java.lang.Object
  extended by net.sf.farrago.fennel.tuple.FennelAttributeAccessor
Direct Known Subclasses:
FennelAttributeAccessor.FennelBitAccessor, FennelAttributeAccessor.FennelByteAccessor, FennelAttributeAccessor.FennelFixedWidthAccessor, FennelAttributeAccessor.FennelIntAccessor, FennelAttributeAccessor.FennelLongAccessor, FennelAttributeAccessor.FennelShortAccessor, FennelAttributeAccessor.FennelVarWidthAccessor

public abstract class FennelAttributeAccessor
extends Object

FennelAttributeAccessor defines how to efficiently unmarshal the value of an attribute from a stored tuple. Derived classes implement various strategies depending on the storage type.

All data members are defined at this level rather than in derived classes, which only provide method implementations. This makes it possible to write non-polymorphic access code in cases where the entire tuple is being processed, but polymorphic access code in cases where only a small subset of the attributes are being processed. In theory, this hybrid should yield the highest efficiency, but it needs to be benchmarked and tuned. This class is JDK 1.4 compatible.


Nested Class Summary
static class FennelAttributeAccessor.FennelBitAccessor
          marshalls a numeric bit
static class FennelAttributeAccessor.FennelByteAccessor
          marshalls a numeric byte (signed or unsigned)
static class FennelAttributeAccessor.FennelFixedWidthAccessor
          marshalls fixed-width byte arrays.
static class FennelAttributeAccessor.FennelIntAccessor
          marshalls a numeric int (signed or unsigned)
static class FennelAttributeAccessor.FennelLongAccessor
          marshalls a numeric long (signed or unsigned)
static class FennelAttributeAccessor.FennelShortAccessor
          marshalls a numeric short (signed or unsigned)
static class FennelAttributeAccessor.FennelVarWidthAccessor
          marshalls any variable width accessor, either first or subsequent.
 
Field Summary
 int capacity
          Copied from FennelTupleAttributeDescriptor.storageSize.
 int endIndirectOffset
          Indirect offset of the end of this attribute within a stored tuple image, or Integer.MAX_VALUE if the end is fixed.
 int fixedOffset
          Byte offset of this attribute within a stored tuple image, or Integer.MAX_VALUE if the start is variable.
protected  byte nullableBitMask
          pre-computed offsets and masks for testing bit fields.
protected  int nullableBitOffset
          pre-computed offsets and masks for testing bit fields.
 int nullBitNdx
          Index of this attribute's null indicator bit in the tuple's bit array, or Integer.MAX_VALUE for a NOT NULL attribute.
protected  byte valueBitMask
          pre-computed offsets and masks for testing bit fields.
 int valueBitNdx
          Index of this attribute's value in the tuple's bit array, or Integer.MAX_VALUE for a non-bit attribute.
protected  int valueBitOffset
          pre-computed offsets and masks for testing bit fields.
 
Constructor Summary
protected FennelAttributeAccessor()
           
 
Method Summary
 void computeBitAccessors(int bitfieldOffset)
          computes bit accessors.
 boolean isPresent(ByteBuffer buf)
          tests if a field is present in a tuple buffer.
abstract  void marshalValueData(ByteBuffer pDestData, FennelTupleDatum value)
          Marshalls value data for the attribute.
 void setPresent(ByteBuffer buf, boolean isPresent)
          sets the presence of a field in a tuple buffer.
abstract  void unmarshalValue(FennelTupleAccessor tupleAccessor, FennelTupleDatum value)
          Unmarshalls the attribute's value into a tupledatum holder.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nullBitNdx

public int nullBitNdx
Index of this attribute's null indicator bit in the tuple's bit array, or Integer.MAX_VALUE for a NOT NULL attribute.


fixedOffset

public int fixedOffset
Byte offset of this attribute within a stored tuple image, or Integer.MAX_VALUE if the start is variable.


endIndirectOffset

public int endIndirectOffset
Indirect offset of the end of this attribute within a stored tuple image, or Integer.MAX_VALUE if the end is fixed.


valueBitNdx

public int valueBitNdx
Index of this attribute's value in the tuple's bit array, or Integer.MAX_VALUE for a non-bit attribute. NOTE: this is only used for booleans


capacity

public int capacity
Copied from FennelTupleAttributeDescriptor.storageSize. This is not used for anything except assertions.


valueBitOffset

protected int valueBitOffset
pre-computed offsets and masks for testing bit fields.


valueBitMask

protected byte valueBitMask
pre-computed offsets and masks for testing bit fields.


nullableBitOffset

protected int nullableBitOffset
pre-computed offsets and masks for testing bit fields.


nullableBitMask

protected byte nullableBitMask
pre-computed offsets and masks for testing bit fields.

Constructor Detail

FennelAttributeAccessor

protected FennelAttributeAccessor()
Method Detail

computeBitAccessors

public void computeBitAccessors(int bitfieldOffset)
computes bit accessors.


isPresent

public boolean isPresent(ByteBuffer buf)
tests if a field is present in a tuple buffer.


setPresent

public void setPresent(ByteBuffer buf,
                       boolean isPresent)
sets the presence of a field in a tuple buffer.


unmarshalValue

public abstract void unmarshalValue(FennelTupleAccessor tupleAccessor,
                                    FennelTupleDatum value)
Unmarshalls the attribute's value into a tupledatum holder. Unlike the C++ version, this *does* actually copy data.

Parameters:
tupleAccessor - containing FennelTupleAccessor set up with the current tuple image to be accessed
value - receives the reference to the unmarshalled value

marshalValueData

public abstract void marshalValueData(ByteBuffer pDestData,
                                      FennelTupleDatum value)
Marshalls value data for the attribute. Only deals with the data bytes, not length and null indicators.

Parameters:
pDestData - the target address where the data should be marshalled
value - the value to be marshalled