Package com.nickrobison.tuple
Class DirectTupleSchema
- java.lang.Object
-
- com.nickrobison.tuple.TupleSchema
-
- com.nickrobison.tuple.DirectTupleSchema
-
public class DirectTupleSchema extends TupleSchema
Created by cliff on 5/9/14.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DirectTupleSchema.Builder
-
Field Summary
Fields Modifier and Type Field Description protected long
addressOffset
protected TupleAllocatorGenerator.TupleAllocator
allocator
protected int
byteSize
protected int[]
layout
protected int[]
widths
protected int
wordSize
-
Fields inherited from class com.nickrobison.tuple.TupleSchema
clazz, fieldNames, fieldTypes, iface, pool
-
-
Constructor Summary
Constructors Constructor Description DirectTupleSchema(DirectTupleSchema.Builder builder)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
createRecord()
long
createRecordArray(long size)
FastTuple
createTuple()
Allocates a new tuple, completely separate from any pooling.FastTuple
createTuple(long address)
FastTuple[]
createTupleArray(int size)
Allocates an array of tuples.<T> T
createTypedTuple(java.lang.Class<T> clazz)
Allocates a new typed tuple, completely separate from any pooling.<T> T[]
createTypedTupleArray(java.lang.Class<T> clazz, int size)
* Allocates an array of tuples.void
destroy(long address)
void
destroy(FastTuple tuple)
void
destroyTuple(FastTuple tuple)
Deallocates memory for a tuple.void
destroyTupleArray(FastTuple[] ary)
Deallocates memory for an array of tuples.<T> void
destroyTypedTuple(T tuple)
Deallocates memory for a typed tuple.<T> void
destroyTypedTupleArray(T[] ary)
Deallocates memory for an array of typed tuples.boolean
equals(java.lang.Object o)
protected void
generateClass()
protected void
generateLayout()
byte
getByte(long address, int index)
int
getByteSize()
char
getChar(long address, int index)
double
getDouble(long address, int index)
float
getFloat(long address, int index)
int
getInt(long address, int index)
int[]
getLayout()
long
getLong(long address, int index)
short
getShort(long address, int index)
int
hashCode()
void
setByte(long address, int index, byte value)
void
setChar(long address, int index, char value)
void
setDouble(long address, int index, double value)
void
setFloat(long address, int index, float value)
void
setInt(long address, int index, int value)
void
setLong(long address, int index, long value)
void
setShort(long address, int index, short value)
-
Methods inherited from class com.nickrobison.tuple.TupleSchema
builder, createArray, destroyArray, getClassLoader, getFieldNames, getFieldTypes, pool, toString, tupleClass
-
-
-
-
Field Detail
-
layout
protected final int[] layout
-
widths
protected final int[] widths
-
byteSize
protected int byteSize
-
addressOffset
protected long addressOffset
-
wordSize
protected final int wordSize
-
allocator
protected TupleAllocatorGenerator.TupleAllocator allocator
-
-
Constructor Detail
-
DirectTupleSchema
public DirectTupleSchema(DirectTupleSchema.Builder builder) throws java.lang.Exception
- Throws:
java.lang.Exception
-
-
Method Detail
-
getLong
public long getLong(long address, int index)
-
getInt
public int getInt(long address, int index)
-
getShort
public short getShort(long address, int index)
-
getChar
public char getChar(long address, int index)
-
getByte
public byte getByte(long address, int index)
-
getDouble
public double getDouble(long address, int index)
-
getFloat
public float getFloat(long address, int index)
-
setLong
public void setLong(long address, int index, long value)
-
setInt
public void setInt(long address, int index, int value)
-
setShort
public void setShort(long address, int index, short value)
-
setChar
public void setChar(long address, int index, char value)
-
setByte
public void setByte(long address, int index, byte value)
-
setFloat
public void setFloat(long address, int index, float value)
-
setDouble
public void setDouble(long address, int index, double value)
-
getLayout
public int[] getLayout()
-
getByteSize
public int getByteSize()
-
createTuple
public FastTuple createTuple(long address)
-
createRecord
public long createRecord()
-
createRecordArray
public long createRecordArray(long size)
-
createTuple
public FastTuple createTuple() throws java.lang.Exception
Description copied from class:TupleSchema
Allocates a new tuple, completely separate from any pooling.- Specified by:
createTuple
in classTupleSchema
- Returns:
- -
FastTuple
- Throws:
java.lang.Exception
- - Throws an exception if unable to allocate tuple
-
createTypedTuple
public <T> T createTypedTuple(java.lang.Class<T> clazz) throws java.lang.Exception
Description copied from class:TupleSchema
Allocates a new typed tuple, completely separate from any pooling. Use care to callTupleSchema.Builder.implementInterface(Class)
before using this method- Specified by:
createTypedTuple
in classTupleSchema
- Type Parameters:
T
- -TupleSchema
type parameter- Parameters:
clazz
- -Class
implemented by the Tuple- Returns:
- -
FastTuple
case to typeTupleSchema
- Throws:
java.lang.Exception
- - Throws an exception if unable to allocate tuple or cast to the specified type
-
createTupleArray
public FastTuple[] createTupleArray(int size) throws java.lang.Exception
Description copied from class:TupleSchema
Allocates an array of tuples. This method will try to ensure that tuples get allocated in adjacent memory, however with the heap based allocation this is not guaranteed.- Specified by:
createTupleArray
in classTupleSchema
- Parameters:
size
- the number of tuples in the array.- Returns:
- - Array of
FastTuple
- Throws:
java.lang.Exception
- - Throws if unable to allocate tuple array
-
createTypedTupleArray
public <T> T[] createTypedTupleArray(java.lang.Class<T> clazz, int size) throws java.lang.Exception
Description copied from class:TupleSchema
* Allocates an array of tuples. This method will try to ensure that tuples get allocated in adjacent memory, however with the heap based allocation this is not guaranteed.- Specified by:
createTypedTupleArray
in classTupleSchema
- Type Parameters:
T
- -TupleSchema
type parameter- Parameters:
clazz
- -Class
implemented by the Tuplesize
- - the number of tuples in the array- Returns:
- - Array of
FastTuple
cast to typeTupleSchema
- Throws:
java.lang.Exception
- - Throws is unable to allocate tuple array or cast to the specified type
-
destroyTuple
public void destroyTuple(FastTuple tuple)
Description copied from class:TupleSchema
Deallocates memory for a tuple.- Specified by:
destroyTuple
in classTupleSchema
- Parameters:
tuple
- -FastTuple
to deallocate
-
destroyTypedTuple
public <T> void destroyTypedTuple(T tuple)
Description copied from class:TupleSchema
Deallocates memory for a typed tuple.- Specified by:
destroyTypedTuple
in classTupleSchema
- Type Parameters:
T
- -TupleSchema
underlying class implemented by tuples- Parameters:
tuple
- -FastTuple
cast to typeTupleSchema
-
destroyTupleArray
public void destroyTupleArray(FastTuple[] ary)
Description copied from class:TupleSchema
Deallocates memory for an array of tuples. Assumes that they were allocated as an array.- Specified by:
destroyTupleArray
in classTupleSchema
- Parameters:
ary
- - Array ofFastTuple
to deallocate
-
destroyTypedTupleArray
public <T> void destroyTypedTupleArray(T[] ary)
Description copied from class:TupleSchema
Deallocates memory for an array of typed tuples. Assumes that they were allocated as an array.- Specified by:
destroyTypedTupleArray
in classTupleSchema
- Type Parameters:
T
- -TupleSchema
underlying class implemented by tuples- Parameters:
ary
- - Array of typedFastTuple
to deallocate
-
destroy
public void destroy(FastTuple tuple)
-
destroy
public void destroy(long address)
-
generateClass
protected void generateClass() throws java.lang.Exception
- Specified by:
generateClass
in classTupleSchema
- Throws:
java.lang.Exception
-
generateLayout
protected void generateLayout()
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classTupleSchema
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classTupleSchema
-
-