Skip to content

Commit

Permalink
Update inverted_index_reader.h
Browse files Browse the repository at this point in the history
  • Loading branch information
airborne12 authored Sep 27, 2024
1 parent 4a87900 commit c1068d8
Showing 1 changed file with 73 additions and 0 deletions.
73 changes: 73 additions & 0 deletions be/src/olap/rowset/segment_v2/inverted_index_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,79 @@ class BkdIndexReader : public InvertedIndexReader {
const KeyCoder* _value_key_coder {};
};

/**
* @brief InvertedIndexQueryParamFactory is a factory class to create QueryValue object.
* we need a template function to make predict class like in_list_predict template class to use.
* also need a function with primitive type parameter to create inverted index query value. like some function expr: function_array_index
* Now we just mapping field value in query engine to storage field value
*/
class InvertedIndexQueryParamFactory {
ENABLE_FACTORY_CREATOR(InvertedIndexQueryParamFactory);

public:
virtual ~InvertedIndexQueryParamFactory() = default;

template <PrimitiveType PT>
static Status create_query_value(const void* value,
std::unique_ptr<InvertedIndexQueryParamFactory>& result_param);

static Status create_query_value(
const PrimitiveType& primitiveType, const void* value,
std::unique_ptr<InvertedIndexQueryParamFactory>& result_param) {
switch (primitiveType) {
#define M(TYPE) \
case TYPE: { \
return create_query_value<TYPE>(value, result_param); \
}
M(PrimitiveType::TYPE_BOOLEAN)
M(PrimitiveType::TYPE_TINYINT)
M(PrimitiveType::TYPE_SMALLINT)
M(PrimitiveType::TYPE_INT)
M(PrimitiveType::TYPE_BIGINT)
M(PrimitiveType::TYPE_LARGEINT)
M(PrimitiveType::TYPE_FLOAT)
M(PrimitiveType::TYPE_DOUBLE)
M(PrimitiveType::TYPE_DECIMALV2)
M(PrimitiveType::TYPE_DECIMAL32)
M(PrimitiveType::TYPE_DECIMAL64)
M(PrimitiveType::TYPE_DECIMAL128I)
M(PrimitiveType::TYPE_DECIMAL256)
M(PrimitiveType::TYPE_DATE)
M(PrimitiveType::TYPE_DATETIME)
M(PrimitiveType::TYPE_CHAR)
M(PrimitiveType::TYPE_VARCHAR)
M(PrimitiveType::TYPE_STRING)
#undef M
default:
return Status::NotSupported("Unsupported primitive type {} for inverted index reader",
primitiveType);
}
};

virtual const void* get_value() const {
LOG_FATAL(
"Execution reached an undefined behavior code path in "
"InvertedIndexQueryParamFactory");
__builtin_unreachable();
};
};

template <PrimitiveType PT>
class InvertedIndexQueryParam : public InvertedIndexQueryParamFactory {
ENABLE_FACTORY_CREATOR(InvertedIndexQueryParam);
using storage_val = typename PrimitiveTypeTraits<PT>::StorageFieldType;

public:
void set_value(const storage_val* value) {
_value = *reinterpret_cast<const storage_val*>(value);
}

const void* get_value() const override { return &_value; }

private:
storage_val _value;
};

class InvertedIndexIterator {
ENABLE_FACTORY_CREATOR(InvertedIndexIterator);

Expand Down

0 comments on commit c1068d8

Please sign in to comment.