Class ContextWithChunk<ATTR extends Attributes.Any,CONTEXT extends Context>
java.lang.Object
com.illumon.iris.db.v2.sources.chunk.ContextWithChunk<ATTR,CONTEXT>
- All Implemented Interfaces:
Context,SafeCloseable,AutoCloseable
- Direct Known Subclasses:
DefaultGetContext
public class ContextWithChunk<ATTR extends Attributes.Any,CONTEXT extends Context>
extends Object
implements Context
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Release any resources associated with this context.voidensureLength(int length) Makes sure that the internal array (and hence the writableChunk) is at least specified size.static <CONTEXT extends Context>
CONTEXTgetContext(Context context) static <ATTR extends Attributes.Any,RESETTABLE_WRITABLE_CHUNK extends ResettableWritableChunk<ATTR>>
RESETTABLE_WRITABLE_CHUNKgetResettableChunk(Context context) static <ATTR extends Attributes.Any,WRITABLE_CHUNK extends WritableChunk<ATTR>>
WRITABLE_CHUNKgetWritableChunk(Context context) static <ATTR extends Attributes.Any>
booleanisMyResettableChunk(Context context, Chunk<ATTR> chunk) Checks if this chunk is the result of a call togetResettableChunk()orgetResettableChunk(Context)with this context, followed by a some reset call, including the result of a call toresetChunkFromArray(Context, Object, int, int).static <ATTR extends Attributes.Any>
booleanisMyWritableChunk(Context context, Chunk<ATTR> chunk) Checks if this chunk is the result of a call togetWritableChunk()orgetWritableChunk(Context)with this context.static <ATTR extends Attributes.Any,CHUNK extends Chunk<ATTR>>
CHUNKresetChunkFromArray(Context context, Object array, int offset, int length)
-
Method Details
-
close
public void close()Description copied from interface:ContextRelease any resources associated with this context. The context should not be used afterwards.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceContext- Specified by:
closein interfaceSafeCloseable
-
getWritableChunk
- Returns:
- a
WritableChunkwhich you can use for results - ApiNote:
- the chunk is valid until the next call to this function,
getResettableChunk(),getWritableChunk(Context),getResettableChunk(Context), orresetChunkFromArray(Context, Object, int, int)for this context.
-
getResettableChunk
- Returns:
- a
ResettableChunkchunk which you can use for results by calling one of its various reset methods. - ApiNote:
- the chunk is valid until the next call to this function,
getWritableChunk(),getWritableChunk(Context),getResettableChunk(Context), orresetChunkFromArray(Context, Object, int, int)for this context.
-
getContext
- Returns:
- The context held in this Context
-
getContext
- Returns:
- The context held in this Context
-
ensureLength
public void ensureLength(int length) Makes sure that the internal array (and hence the writableChunk) is at least specified size. -
getWritableChunk
public static <ATTR extends Attributes.Any,WRITABLE_CHUNK extends WritableChunk<ATTR>> WRITABLE_CHUNK getWritableChunk(@NotNull Context context) - Parameters:
context- The context that owns the reusable chunk- Returns:
- a
WritableChunkwhich you can use for results. The size will be set to 0. - ApiNote:
- the chunk is valid until the next call to this function,
getWritableChunk(),getResettableChunk(),getResettableChunk(Context), orresetChunkFromArray(Context, Object, int, int)for this context.
-
getResettableChunk
public static <ATTR extends Attributes.Any,RESETTABLE_WRITABLE_CHUNK extends ResettableWritableChunk<ATTR>> RESETTABLE_WRITABLE_CHUNK getResettableChunk(@NotNull Context context) - Parameters:
context- The context that owns the reusable chunk- Returns:
- a
ResettableWritableChunk, which you can use for results by using one of its various reset methods. - ApiNote:
- the chunk is valid until the next call to this function,
getWritableChunk(),getResettableChunk(),getWritableChunk(Context),resetChunkFromArray(Context, Object, int, int)for this context.
-
resetChunkFromArray
public static <ATTR extends Attributes.Any,CHUNK extends Chunk<ATTR>> CHUNK resetChunkFromArray(@NotNull Context context, Object array, int offset, int length) - Parameters:
context- The context that owns the reusable chunkarray- The array to alias. If this is null, returns a null-value filled chunk.offset- The offset in the array for the beginning of the chunklength- The length of the chunk- Returns:
- A chunk which aliases the region of the array which can be used for results.
- ApiNote:
- the chunk is valid until the next call to this function,
getWritableChunk(),getResettableChunk(),getWritableChunk(Context), orgetResettableChunk(Context)for this context.
-
isMyWritableChunk
public static <ATTR extends Attributes.Any> boolean isMyWritableChunk(@NotNull Context context, Chunk<ATTR> chunk) Checks if this chunk is the result of a call togetWritableChunk()orgetWritableChunk(Context)with this context. This is primarily intended for testing and verification code. -
isMyResettableChunk
public static <ATTR extends Attributes.Any> boolean isMyResettableChunk(@NotNull Context context, Chunk<ATTR> chunk) Checks if this chunk is the result of a call togetResettableChunk()orgetResettableChunk(Context)with this context, followed by a some reset call, including the result of a call toresetChunkFromArray(Context, Object, int, int). This is primarily intended for testing and verification code.
-