Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions include/paimon/global_index/global_index_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,16 @@ namespace paimon {
class PAIMON_EXPORT GlobalIndexReader : public FunctionVisitor<std::shared_ptr<GlobalIndexResult>> {
public:
/// VisitVectorSearch performs approximate vector similarity search.
/// @note `VisitVectorSearch` is thread-safe (not coroutine-safe) while other `VisitXXX` is not
/// thread-safe.
/// @warning `VisitVectorSearch` may return error status when it is incorrectly invoked (e.g.,
/// BitmapGlobalIndexReader call `VisitVectorSearch`).
virtual Result<std::shared_ptr<VectorSearchGlobalIndexResult>> VisitVectorSearch(
const std::shared_ptr<VectorSearch>& vector_search) = 0;

/// @return true if the reader is thread-safe; false otherwise.
virtual bool IsThreadSafe() const = 0;

/// @return An identifier representing the index type. (e.g., "bitmap", "lumina").
virtual std::string GetIndexType() const = 0;
};

} // namespace paimon
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Result<std::shared_ptr<GlobalIndexReader>> BitmapGlobalIndex::CreateReader(
-> Result<std::shared_ptr<GlobalIndexResult>> {
return ToGlobalIndexResult(range_end, result);
};
return std::make_shared<FileIndexReaderWrapper>(reader, transform);
return std::make_shared<BitmapGlobalIndexReader>(reader, transform);
}

Result<std::shared_ptr<GlobalIndexResult>> BitmapGlobalIndex::ToGlobalIndexResult(
Expand Down
19 changes: 19 additions & 0 deletions src/paimon/common/global_index/bitmap/bitmap_global_index.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <vector>

#include "paimon/common/file_index/bitmap/bitmap_file_index.h"
#include "paimon/common/global_index/wrap/file_index_reader_wrapper.h"
#include "paimon/global_index/global_indexer.h"

namespace paimon {
Expand All @@ -46,4 +47,22 @@ class BitmapGlobalIndex : public GlobalIndexer {
std::shared_ptr<BitmapFileIndex> index_;
};

class BitmapGlobalIndexReader : public FileIndexReaderWrapper {
public:
BitmapGlobalIndexReader(const std::shared_ptr<FileIndexReader>& reader,
const std::function<Result<std::shared_ptr<GlobalIndexResult>>(
const std::shared_ptr<FileIndexResult>&)>& transform)
: FileIndexReaderWrapper(reader, transform) {}

static inline const char kIdentifier[] = "bitmap";

bool IsThreadSafe() const override {
return false;
}

std::string GetIndexType() const override {
return kIdentifier;
}
};

} // namespace paimon
8 changes: 8 additions & 0 deletions src/paimon/global_index/lucene/lucene_global_index.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,14 @@ class LuceneGlobalIndexReader : public GlobalIndexReader {
Result<std::shared_ptr<VectorSearchGlobalIndexResult>> VisitFullTextSearch(
const std::shared_ptr<FullTextSearch>& full_text_search);

bool IsThreadSafe() const override {
return false;
}

std::string GetIndexType() const override {
return kIdentifier;
}

private:
LuceneGlobalIndexReader(const std::wstring& wfield_name, int64_t range_end,
const Lucene::IndexSearcherPtr& searcher)
Expand Down
11 changes: 11 additions & 0 deletions src/paimon/global_index/lumina/lumina_global_index.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "paimon/global_index/bitmap_global_index_result.h"
#include "paimon/global_index/global_indexer.h"
#include "paimon/global_index/lumina/lumina_memory_pool.h"
#include "paimon/global_index/lumina/lumina_utils.h"

namespace paimon::lumina {
/// @note When enabling the lumina global index in `paimon-cpp`, all configuration parameters
Expand Down Expand Up @@ -122,6 +123,8 @@ class LuminaIndexReader : public GlobalIndexReader {
[[maybe_unused]] auto status = searcher_->Close();
}

/// @note `VisitVectorSearch` is thread-safe (not coroutine-safe) while other `VisitXXX` is not
/// thread-safe.
Result<std::shared_ptr<VectorSearchGlobalIndexResult>> VisitVectorSearch(
const std::shared_ptr<VectorSearch>& vector_search) override;

Expand Down Expand Up @@ -180,6 +183,14 @@ class LuminaIndexReader : public GlobalIndexReader {
return BitmapGlobalIndexResult::FromRanges({Range(0, range_end_)});
}

bool IsThreadSafe() const override {
return true;
}

std::string GetIndexType() const override {
return LuminaDefines::kIdentifier;
}

static Result<LuminaIndexReader::IndexInfo> GetIndexInfo(const GlobalIndexIOMeta& io_meta);

private:
Expand Down
Loading