Interface IWritableBuffer
-
- All Superinterfaces:
IArrayReader,IArrayWriter
- All Known Subinterfaces:
ICompositeColumnCursor,IInternalCompositeColumnCursor
- All Known Implementing Classes:
CompositeColumnCursor
public interface IWritableBuffer extends IArrayReader, IArrayWriter
An array with the interface to write elements into it.It also allow to create new vector without having to decide if there must be on heap or or not.
- Author:
- ActiveViam
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description IVectorallocateVector(int position, int size)Allocates a vector with the given size at the specified position of the buffer and returns it.booleanisVectorWritable(int position)Checks if the vector stored at the given position can be modified.default IVectorreadVector(int position)Reads anIVectorvalue from the array.default IVectorreadWritableVector(int position)Returns theIVectorat the given position.voidwrite(int position, IVector vector)Writes a vector at the given position.voidwrite(int position, Object value)Writes a piece of data at a position in the array.-
Methods inherited from interface com.qfs.chunk.IArrayReader
isNull, read, readBoolean, readDouble, readFloat, readInt, readLong
-
Methods inherited from interface com.qfs.chunk.IArrayWriter
addDouble, addFloat, addInt, addLong, writeBoolean, writeDouble, writeFloat, writeInt, writeLong
-
-
-
-
Method Detail
-
allocateVector
IVector allocateVector(int position, int size)
Allocates a vector with the given size at the specified position of the buffer and returns it.Warning: The vector will be uninitialized. The caller has the responsibility to initialize it.
The content at the specified position will be replaced by the returned vector.
This method should be used instead of
IVector.cloneOnHeap()as it may decide to allocate the vector off-heap.- Parameters:
position- position 0-based index in an arraysize- the size of the vector- Returns:
- a new uninitialized vector
-
isVectorWritable
boolean isVectorWritable(int position)
Checks if the vector stored at the given position can be modified.Vectors that are shared by several components should not be modified in general as it can cause concurrency issues.
- Parameters:
position- position 0-based index in an array- Returns:
trueif the vector can be edited,falseotherwise
-
readVector
default IVector readVector(int position)
Reads anIVectorvalue from the array.An exception is thrown if the value is not of the right type.
Warning:
readWritableVector(int)must be called instead of this method when one needs to modify the returned vector.- Specified by:
readVectorin interfaceIArrayReader- Parameters:
position- 0-based index in an array- Returns:
- vector instance
- See Also:
readWritableVector(int)
-
readWritableVector
default IVector readWritableVector(int position)
Returns theIVectorat the given position.This method returns a vector that can be safely edited. If the vector stored at the given position in the buffer is not
writable, it will be replaced with a copy.This is useful to implement lazy cloning.
- Parameters:
position- position 0-based index in an array- Returns:
- a safely modifiable vector
-
write
void write(int position, IVector vector)Writes a vector at the given position.- Parameters:
position- the position at which to write the vectorvector- the vector to write
-
write
void write(int position, Object value)Writes a piece of data at a position in the array.For better performance, use the primitive type operations.
Warning: This method does not accept an
IVectoras value. Usewrite(int, IVector)instead.- Specified by:
writein interfaceIArrayWriter- Parameters:
position- 0-based index in the arrayvalue- the value to write- See Also:
write(int, IVector)
-
-