|
| | PrimitiveDictionary (Allocator &allocator_p, idx_t maximum_size_p, idx_t maximum_target_capacity_p) |
| template<bool ADD_TO_TARGET = false> |
| void | Insert (SRC value) |
| | Insert value into dictionary (if not full).
|
| uint32_t | GetIndex (const SRC &value) const |
| | Get dictionary index of an already inserted value.
|
| template<typename U = SRC, typename std::enable_if<!std::is_same< U, string_t >::value, int >::type = 0> |
| void | IterateValues (const std::function< void(const SRC &, const TGT &)> &fun) const |
| | Iterates over inserted values.
|
| template<typename U = SRC, typename std::enable_if< std::is_same< U, string_t >::value, int >::type = 0> |
| void | IterateValues (const std::function< void(const SRC &, const TGT &)> &fun) const |
| | Specialized template to iterate over string_t values.
|
| idx_t | GetSize () const |
| | Get the number of unique values in the dictionary.
|
| bool | IsFull () const |
| | If any of the inserts caused the dictionary to be full, this returns true.
|
| unique_ptr< MemoryStream > | GetTargetMemoryStream () const |
| | Get the target written values as a memory stream (zero-copy).
|
| void | Reset () |
| void | Clear () |
| primitive_dictionary_entry_t & | Lookup (const SRC &value) const |
| | Look up a value in the dictionary using linear probing.
|
|
|
static constexpr uint32_t | MAXIMUM_POSSIBLE_SIZE = INVALID_INDEX - 1 |
|
static constexpr idx_t | INITIAL_TARGET_CAPACITY = 1048576 |
|
| template<typename S = SRC, typename std::enable_if<!std::is_same< S, string_t >::value, int >::type = 0> |
| bool | AddToTarget (const SRC &src_value) |
| | Write a value to the target data (if source is not string).
|
| template<typename S = SRC, typename std::enable_if< std::is_same< S, string_t >::value, int >::type = 0> |
| bool | AddToTarget (SRC &src_value) |
| | Write a value to the target data (if source is string).
|
|
|
Allocator & | allocator |
|
const idx_t | maximum_size |
| | Maximum size and current size.
|
|
uint32_t | size |
|
const idx_t | capacity |
| | Dictionary capacity (power of two) and corresponding mask.
|
|
const idx_t | capacity_mask |
|
const idx_t | maximum_target_capacity |
| | Capacity of target encoded data.
|
|
AllocatedData | allocated_dictionary |
| | Allocated regions for dictionary/target.
|
|
AllocatedData | allocated_target |
|
MemoryStream | target_stream |
|
primitive_dictionary_entry_t *const | dictionary |
| | Pointers to allocated regions for convenience.
|
|
bool | full |
| | More values inserted than possible.
|
|
|
static constexpr idx_t | LOAD_FACTOR = 2 |
|
static constexpr uint32_t | INVALID_INDEX = static_cast<uint32_t>(-1) |
|
static constexpr idx_t | MAXIMUM_TARGET_CAPACITY_INCREMENT = 33554432ULL |
◆ PrimitiveDictionary()
template<class SRC, class TGT = SRC, class OP = PrimitiveCastOperator>
PrimitiveDictionary is a fixed-size linear probing hash table for primitive types It is used to dictionary-encode data in, e.g., Parquet files
397973 target_stream(allocated_target.get(), allocated_target.GetSize()),
397975 Clear();
397976 }
Definition duckdb.cpp:397946
primitive_dictionary_entry_t *const dictionary
Pointers to allocated regions for convenience.
Definition duckdb.cpp:398150
const idx_t maximum_target_capacity
Capacity of target encoded data.
Definition duckdb.cpp:398141
bool full
More values inserted than possible.
Definition duckdb.cpp:398153
const idx_t maximum_size
Maximum size and current size.
Definition duckdb.cpp:398133
AllocatedData allocated_dictionary
Allocated regions for dictionary/target.
Definition duckdb.cpp:398145
const idx_t capacity
Dictionary capacity (power of two) and corresponding mask.
Definition duckdb.cpp:398137
Definition duckdb.cpp:397951
◆ Insert()
template<class SRC, class TGT = SRC, class OP = PrimitiveCastOperator>
template<bool ADD_TO_TARGET = false>
Insert value into dictionary (if not full).
397981 {
397983 return;
397984 }
397986 if (
entry.IsEmpty()) {
397989 return;
397990 }
397992 entry.index = size++;
397993 }
397994 }
primitive_dictionary_entry_t & Lookup(const SRC &value) const
Look up a value in the dictionary using linear probing.
Definition duckdb.cpp:398058
bool AddToTarget(const SRC &src_value)
Write a value to the target data (if source is not string).
Definition duckdb.cpp:398069
◆ GetIndex()
template<class SRC, class TGT = SRC, class OP = PrimitiveCastOperator>
Get dictionary index of an already inserted value.
397997 {
398000 return entry.index;
398001 }
◆ IterateValues() [1/2]
template<class SRC, class TGT = SRC, class OP = PrimitiveCastOperator>
template<typename U = SRC, typename std::enable_if<!std::is_same< U,
string_t >::value, int >::type = 0>
Iterates over inserted values.
398005 {
398006 const auto target_values =
reinterpret_cast<const TGT *
>(allocated_target.get());
398009 if (
entry.IsEmpty()) {
398010 continue;
398011 }
398013 }
398014 }
◆ IterateValues() [2/2]
template<class SRC, class TGT = SRC, class OP = PrimitiveCastOperator>
template<typename U = SRC, typename std::enable_if< std::is_same< U,
string_t >::value, int >::type = 0>
Specialized template to iterate over string_t values.
398018 {
398021 if (
entry.IsEmpty()) {
398022 continue;
398023 }
398025 }
398026 }
◆ GetSize()
template<class SRC, class TGT = SRC, class OP = PrimitiveCastOperator>
Get the number of unique values in the dictionary.
398029 {
398030 return size;
398031 }
◆ IsFull()
template<class SRC, class TGT = SRC, class OP = PrimitiveCastOperator>
If any of the inserts caused the dictionary to be full, this returns true.
◆ GetTargetMemoryStream()
template<class SRC, class TGT = SRC, class OP = PrimitiveCastOperator>
Get the target written values as a memory stream (zero-copy).
398039 {
398041 result->SetPosition(target_stream.GetPosition());
398043 }
◆ Reset()
template<class SRC, class TGT = SRC, class OP = PrimitiveCastOperator>
398045 {
398047 allocated_target.Reset();
398048 }
◆ Clear()
template<class SRC, class TGT = SRC, class OP = PrimitiveCastOperator>
398050 {
398053 }
398054 size = 0;
398056 }
◆ Lookup()
template<class SRC, class TGT = SRC, class OP = PrimitiveCastOperator>
Look up a value in the dictionary using linear probing.
398058 {
398061 ++
offset &= capacity_mask;
398062 }
398064 }
◆ AddToTarget() [1/2]
template<class SRC, class TGT = SRC, class OP = PrimitiveCastOperator>
template<typename S = SRC, typename std::enable_if<!std::is_same< S,
string_t >::value, int >::type = 0>
Write a value to the target data (if source is not string).
398069 {
398072 return false;
398073 }
398075 return true;
398076 }
◆ AddToTarget() [2/2]
template<class SRC, class TGT = SRC, class OP = PrimitiveCastOperator>
template<typename S = SRC, typename std::enable_if< std::is_same< S,
string_t >::value, int >::type = 0>
Write a value to the target data (if source is string).
398080 {
398081
398084
398088 return false;
398089 }
398090
398092
398094 }
398096
398097
398098 const auto old_ptr = allocated_target.get();
398102
398103
398107
398108
398111 if (
entry.IsEmpty() ||
entry.value.IsInlined()) {
398112 continue;
398113 }
398114 entry.value.SetPointer(
398116 }
398117 }
398118
398119 const auto ptr = target_stream.GetData() + target_stream.GetPosition() +
sizeof(
uint32_t);
398121
398124 }
398125
398126 return true;
398127 }
idx_t GetSize() const
Get the number of unique values in the dictionary.
Definition duckdb.cpp:398029
The documentation for this class was generated from the following file: