Package com.nickrobison.tuple
Class HeapTupleSchema
- java.lang.Object
-
- com.nickrobison.tuple.TupleSchema
-
- com.nickrobison.tuple.HeapTupleSchema
-
public class HeapTupleSchema extends TupleSchema
Created by cliff on 5/9/14.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
HeapTupleSchema.Builder
-
Field Summary
-
Fields inherited from class com.nickrobison.tuple.TupleSchema
clazz, fieldNames, fieldTypes, iface, pool
-
-
Constructor Summary
Constructors Constructor Description HeapTupleSchema(HeapTupleSchema.Builder builder)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FastTuple
createTuple()
Allocates a new tuple, completely separate from any pooling.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
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.protected void
generateClass()
-
Methods inherited from class com.nickrobison.tuple.TupleSchema
builder, createArray, destroyArray, equals, getClassLoader, getFieldNames, getFieldTypes, hashCode, pool, toString, tupleClass
-
-
-
-
Constructor Detail
-
HeapTupleSchema
public HeapTupleSchema(HeapTupleSchema.Builder builder) throws java.lang.Exception
- Throws:
java.lang.Exception
-
-
Method Detail
-
generateClass
protected void generateClass() throws java.lang.Exception
- Specified by:
generateClass
in classTupleSchema
- Throws:
java.lang.Exception
-
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
-
-