Chunks¶
Description¶
Chunk
is the abstract base class representing a simple typed data buffer.
These buffers are used to pass data to and from the library, e.g. as arguments to
FillChunk
or
FillFromChunk
.
The concrete implementing classes are defined by the templated class
GenericChunk
.
For convenience we provide typedefs which instantiate
GenericChunk
on all the Deephaven types:
Int8Chunk
,
Int16Chunk
,
Int32Chunk
,
Int64Chunk
,
FloatChunk
,
DoubleChunk
,
BooleanChunk
,
StringChunk
, and
DateTimeChunk
.
GenericChunk
also supports the methods
Take
and
Drop
to take slices of the
GenericChunk
.
AnyChunk¶
The
AnyChunk
class is a variant value type that can hold one of the concrete Chunk types described above.
AnyChunk
is useful in certain limited cases
where a factory method needs to create a
Chunk
having a dynamically-determined type, not known at compile time. Of course this could also be
accomplished by returning a heap-allocated pointer to a
Chunk
.
The rationale for using the variant approach rather than the
heap-allocated object approach is for the sake of simplicity and efficiency when using these
small objects. One example method that returns an
AnyChunk
is
CreateChunkFor
,
which creates a
Chunk
with a type appropriate to the passed-in
ColumnSource
,
and wraps that dynamicaly-determined Chunk in an
AnyChunk
value.
Chunk Declarations¶
-
class Chunk¶
Abstract base class for Deephaven chunks. A Chunk represents a simple typed data buffer. It is used as an argument to methods like ColumnSource::FillChunk() and MutableColumnSource::FillFromChunk.
Subclassed by deephaven::dhcore::chunk::GenericChunk< T >
Public Functions
-
virtual void AcceptVisitor(ChunkVisitor *visitor) const = 0¶
Implementation of the visitor pattern.
-
virtual void AcceptVisitor(ChunkVisitor *visitor) const = 0¶
-
template<typename T>
class GenericChunk : public deephaven::dhcore::chunk::Chunk¶ Concrete implementing class for Deephaven chunks.
Public Functions
-
GenericChunk() = default¶
Constructor.
-
GenericChunk(GenericChunk &&other) noexcept = default¶
Move constructor.
-
GenericChunk &operator=(GenericChunk &&other) noexcept = default¶
Move assignment operator.
-
~GenericChunk() final = default¶
Destructor.
-
GenericChunk Take(size_t size) const¶
Create a new GenericChunk that is a prefix of the current GenericChunk. The new object shares the same underlying buffer, but has new size ‘size’. ‘size’ is required to be less than or equal to the size of this object.
-
GenericChunk Drop(size_t size) const¶
Create a new GenericChunk that is a suffix of the current GenericChunk. The new object shares the same underlying buffer, but has new size (this->size() - size). ‘size’ is required to be less than or equal to the size of this object.
-
virtual void AcceptVisitor(ChunkVisitor *visitor) const final¶
Implementation of the visitor pattern.
-
inline T *data()¶
Returns a pointer to the start of the data represented by this GenericChunk.
-
inline const T *data() const¶
Returns a pointer to the start of the data represented by this GenericChunk.
-
inline T *begin()¶
Returns a pointer to the start of the data represented by this GenericChunk.
-
inline const T *begin() const¶
Returns a pointer to the start of the data represented by this GenericChunk.
-
inline T *end()¶
Returns a pointer to the (exlusive) end of the data represented by this GenericChunk.
-
inline const T *end() const¶
Returns a pointer to the (exlusive) end of the data represented by this GenericChunk.
Public Static Functions
-
static GenericChunk<T> Create(size_t size)¶
Factory method. Create a Chunk having the specified size, with a privately allocated buffer.
-
GenericChunk() = default¶
-
using deephaven::dhcore::chunk::Int8Chunk = GenericChunk<int8_t>¶
Convenience using.
-
using deephaven::dhcore::chunk::Int16Chunk = GenericChunk<int16_t>¶
Convenience using.
-
using deephaven::dhcore::chunk::Int32Chunk = GenericChunk<int32_t>¶
Convenience using.
-
using deephaven::dhcore::chunk::Int64Chunk = GenericChunk<int64_t>¶
Convenience using.
-
using deephaven::dhcore::chunk::FloatChunk = GenericChunk<float>¶
Convenience using.
-
using deephaven::dhcore::chunk::DoubleChunk = GenericChunk<double>¶
Convenience using.
-
using deephaven::dhcore::chunk::BooleanChunk = GenericChunk<bool>¶
Convenience using.
-
using deephaven::dhcore::chunk::StringChunk = GenericChunk<std::string>¶
Convenience using.
-
using deephaven::dhcore::chunk::DateTimeChunk = GenericChunk<deephaven::dhcore::DateTime>¶
Convenience using.
Utility Declarations¶
-
class AnyChunk¶
Typesafe union of all the Chunk types. This is used when you need to have a method that creates a Chunk (with a type determined at runtime) or for example you need to have a vector of such Chunk objects.
-
class ChunkVisitor¶
Abstract base class that implements the visitor pattern for Chunk.
Public Functions
-
virtual void Visit(const CharChunk&) = 0¶
Implements the visitor pattern.
-
virtual void Visit(const Int16Chunk&) = 0¶
Implements the visitor pattern.
-
virtual void Visit(const Int32Chunk&) = 0¶
Implements the visitor pattern.
-
virtual void Visit(const Int64Chunk&) = 0¶
Implements the visitor pattern.
-
virtual void Visit(const UInt16Chunk&) = 0¶
Implements the visitor pattern.
-
virtual void Visit(const UInt64Chunk&) = 0¶
Implements the visitor pattern.
-
virtual void Visit(const FloatChunk&) = 0¶
Implements the visitor pattern.
-
virtual void Visit(const DoubleChunk&) = 0¶
Implements the visitor pattern.
-
virtual void Visit(const BooleanChunk&) = 0¶
Implements the visitor pattern.
-
virtual void Visit(const StringChunk&) = 0¶
Implements the visitor pattern.
-
virtual void Visit(const DateTimeChunk&) = 0¶
Implements the visitor pattern.
-
virtual void Visit(const LocalDateChunk&) = 0¶
Implements the visitor pattern.
-
virtual void Visit(const LocalTimeChunk&) = 0¶
Implements the visitor pattern.
-
virtual void Visit(const CharChunk&) = 0¶
-
class ChunkMaker¶
Factory class for creating Chunk objects.
Public Static Functions
-
static AnyChunk CreateChunkFor(const ColumnSource &column_source, size_t chunk_size)¶
Create a Chunk compatible with the specified ColumnSource. For example if the underlying element type of the ColumnSource is int32_t, this method will Create an Int32Chunk.
- Parameters:
column_source – The column source whose underlying element type will be inspected.
chunk_size – The requested size of the chunk.
- Returns:
An AnyChunk, which is a variant value containing the requested chunk.
-
static AnyChunk CreateChunkFor(const ColumnSource &column_source, size_t chunk_size)¶