Skip to content

Commit bc3ae4f

Browse files
committed
fix little
1 parent d4d2b38 commit bc3ae4f

15 files changed

Lines changed: 153 additions & 161 deletions

include/paimon/global_index/global_index_io_meta.h

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,23 @@
1818

1919
#include <cstdint>
2020
#include <memory>
21-
#include <optional>
2221
#include <string>
23-
#include <vector>
2422

2523
#include "paimon/memory/bytes.h"
26-
#include "paimon/utils/range.h"
2724

2825
namespace paimon {
2926
/// Metadata describing a single file entry in a global index.
3027
struct PAIMON_EXPORT GlobalIndexIOMeta {
3128
GlobalIndexIOMeta(const std::string& _file_path, int64_t _file_size,
32-
const std::shared_ptr<Bytes>& _metadata,
33-
const std::optional<std::vector<int32_t>>& _extra_field_ids)
34-
: file_path(_file_path),
35-
file_size(_file_size),
36-
metadata(_metadata),
37-
extra_field_ids(_extra_field_ids) {}
29+
const std::shared_ptr<Bytes>& _metadata)
30+
: file_path(_file_path), file_size(_file_size), metadata(_metadata) {}
3831

3932
std::string file_path;
4033
int64_t file_size;
4134
/// Optional binary metadata associated with the file, such as serialized
4235
/// secondary index structures or inline index bytes.
4336
/// May be null if no additional metadata is available.
4437
std::shared_ptr<Bytes> metadata;
45-
/// Optional table field ids materialized together with the indexed field.
46-
std::optional<std::vector<int32_t>> extra_field_ids;
4738
};
4839

4940
} // namespace paimon

src/paimon/common/global_index/btree/btree_compatibility_test.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,7 @@ class BTreeCompatibilityTest : public ::testing::Test {
115115
PAIMON_ASSIGN_OR_RAISE(auto file_status, fs_->GetFileStatus(bin_path));
116116
auto file_size = file_status->GetLen();
117117

118-
GlobalIndexIOMeta io_meta(bin_path, file_size, meta_bytes,
119-
/*extra_field_ids=*/std::nullopt);
118+
GlobalIndexIOMeta io_meta(bin_path, file_size, meta_bytes);
120119
std::vector<GlobalIndexIOMeta> metas = {io_meta};
121120

122121
auto schema = arrow::schema({arrow::field("testField", arrow_type)});

src/paimon/common/global_index/btree/btree_file_meta_selector_test.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ class BTreeFileMetaSelectorTest : public ::testing::Test {
4848
// file6: only-nulls file (no keys, has_nulls=true)
4949
auto meta6 = std::make_shared<BTreeIndexMeta>(nullptr, nullptr, true);
5050
files_ = {
51-
GlobalIndexIOMeta("file1", 1, meta1->Serialize(pool_.get()), std::nullopt),
52-
GlobalIndexIOMeta("file2", 1, meta2->Serialize(pool_.get()), std::nullopt),
53-
GlobalIndexIOMeta("file3", 1, meta3->Serialize(pool_.get()), std::nullopt),
54-
GlobalIndexIOMeta("file4", 1, meta4->Serialize(pool_.get()), std::nullopt),
55-
GlobalIndexIOMeta("file5", 1, meta5->Serialize(pool_.get()), std::nullopt),
56-
GlobalIndexIOMeta("file6", 1, meta6->Serialize(pool_.get()), std::nullopt),
51+
GlobalIndexIOMeta("file1", 1, meta1->Serialize(pool_.get())),
52+
GlobalIndexIOMeta("file2", 1, meta2->Serialize(pool_.get())),
53+
GlobalIndexIOMeta("file3", 1, meta3->Serialize(pool_.get())),
54+
GlobalIndexIOMeta("file4", 1, meta4->Serialize(pool_.get())),
55+
GlobalIndexIOMeta("file5", 1, meta5->Serialize(pool_.get())),
56+
GlobalIndexIOMeta("file6", 1, meta6->Serialize(pool_.get())),
5757
};
5858
}
5959

src/paimon/common/global_index/btree/btree_global_index_integration_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1703,7 +1703,7 @@ TEST_P(BTreeGlobalIndexIntegrationTest, CreateReaderWithMultiFieldSchema) {
17031703
{BtreeDefs::kBtreeIndexCompression, GetParam()}};
17041704
ASSERT_OK_AND_ASSIGN(auto indexer, BTreeGlobalIndexer::Create(options));
17051705

1706-
GlobalIndexIOMeta meta("fake_path", 100, nullptr, /*extra_field_ids=*/std::nullopt);
1706+
GlobalIndexIOMeta meta("fake_path", 100, nullptr);
17071707
std::vector<GlobalIndexIOMeta> metas = {meta};
17081708

17091709
ASSERT_NOK_WITH_MSG(indexer->CreateReader(c_schema.get(), file_reader, metas, pool_),

src/paimon/common/global_index/btree/btree_global_index_writer.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,7 @@ Result<std::vector<GlobalIndexIOMeta>> BTreeGlobalIndexWriter::Finish() {
199199
// Create GlobalIndexIOMeta
200200
std::string file_path = file_writer_->ToPath(index_file_name_);
201201
PAIMON_ASSIGN_OR_RAISE(int64_t file_size, file_writer_->GetFileSize(index_file_name_));
202-
GlobalIndexIOMeta io_meta(file_path, file_size, meta_bytes,
203-
/*extra_field_ids=*/std::nullopt);
202+
GlobalIndexIOMeta io_meta(file_path, file_size, meta_bytes);
204203
return std::vector<GlobalIndexIOMeta>{io_meta};
205204
}
206205

src/paimon/common/global_index/wrap/file_index_writer_wrapper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class FileIndexWriterWrapper : public GlobalIndexWriter {
6666
PAIMON_RETURN_NOT_OK(out->Flush());
6767
PAIMON_RETURN_NOT_OK(out->Close());
6868
GlobalIndexIOMeta meta(file_manager_->ToPath(file_name), /*file_size=*/bytes->size(),
69-
/*metadata=*/nullptr, /*extra_field_ids=*/std::nullopt);
69+
/*metadata=*/nullptr);
7070
return std::vector<GlobalIndexIOMeta>({meta});
7171
}
7272

src/paimon/core/global_index/global_index_scan_impl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ GlobalIndexIOMeta GlobalIndexScanImpl::ToGlobalIndexIOMeta(
223223
assert(index_meta->GetGlobalIndexMeta());
224224
const auto& global_index_meta = index_meta->GetGlobalIndexMeta().value();
225225
return {index_file_manager_->ToPath(index_meta), index_meta->FileSize(),
226-
global_index_meta.index_meta, global_index_meta.extra_field_ids};
226+
global_index_meta.index_meta};
227227
}
228228

229229
Result<std::shared_ptr<GlobalIndexResult>> GlobalIndexScanImpl::Scan(

src/paimon/core/global_index/global_index_write_task.cpp

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,13 @@ Result<std::vector<DataField>> GetExtraFields(const TableSchema& table_schema,
9696
extra_fields.reserve(extra_field_names.size());
9797
std::set<std::string> dedup_field_names;
9898
for (const auto& extra_field_name : extra_field_names) {
99-
if (extra_field_name == field_name || !dedup_field_names.insert(extra_field_name).second) {
100-
continue;
99+
if (extra_field_name == field_name) {
100+
return Status::Invalid(fmt::format(
101+
"global index extra field {} must not be the indexed field", extra_field_name));
102+
}
103+
if (!dedup_field_names.insert(extra_field_name).second) {
104+
return Status::Invalid(fmt::format("global index extra field {} must not be duplicated",
105+
extra_field_name));
101106
}
102107
PAIMON_ASSIGN_OR_RAISE(DataField extra_field, table_schema.GetField(extra_field_name));
103108
extra_fields.push_back(extra_field);
@@ -174,11 +179,6 @@ Result<std::vector<GlobalIndexIOMeta>> BuildIndex(
174179
return Status::Invalid(
175180
"array read from batch reader is not a struct array in GlobalIndexWriteTask");
176181
}
177-
auto indexed_array = struct_array->GetFieldByName(field_name);
178-
if (!indexed_array) {
179-
return Status::Invalid(fmt::format(
180-
"read array does not contain {} field in GlobalIndexWriteTask", field_name));
181-
}
182182
auto row_id_array = struct_array->GetFieldByName(SpecialFields::RowId().Name());
183183
auto typed_row_id_array = std::dynamic_pointer_cast<arrow::Int64Array>(row_id_array);
184184
if (!typed_row_id_array) {
@@ -222,7 +222,8 @@ Result<std::vector<GlobalIndexIOMeta>> BuildIndex(
222222
Result<std::shared_ptr<CommitMessage>> ToCommitMessage(
223223
const std::string& index_type, int32_t field_id, const Range& range,
224224
const std::vector<GlobalIndexIOMeta>& global_index_io_metas, const BinaryRow& partition,
225-
int32_t bucket, const std::shared_ptr<GlobalIndexFileManager>& file_manager) {
225+
int32_t bucket, const std::shared_ptr<GlobalIndexFileManager>& file_manager,
226+
const std::optional<std::vector<int32_t>>& extra_field_ids) {
226227
std::vector<std::shared_ptr<IndexFileMeta>> index_file_metas;
227228
index_file_metas.reserve(global_index_io_metas.size());
228229
bool is_external_path = file_manager->IsExternalPath();
@@ -235,8 +236,7 @@ Result<std::shared_ptr<CommitMessage>> ToCommitMessage(
235236
index_file_metas.push_back(std::make_shared<IndexFileMeta>(
236237
index_type, PathUtil::GetName(io_meta.file_path), io_meta.file_size, range.Count(),
237238
/*dv_ranges=*/std::nullopt, external_path,
238-
GlobalIndexMeta(range.from, range.to, field_id, io_meta.extra_field_ids,
239-
io_meta.metadata)));
239+
GlobalIndexMeta(range.from, range.to, field_id, extra_field_ids, io_meta.metadata)));
240240
}
241241
DataIncrement data_increment(std::move(index_file_metas));
242242
return std::make_shared<CommitMessageImpl>(partition, bucket,
@@ -313,13 +313,11 @@ Result<std::shared_ptr<CommitMessage>> GlobalIndexWriteTask::WriteIndex(
313313
PAIMON_ASSIGN_OR_RAISE(std::vector<GlobalIndexIOMeta> global_index_io_metas,
314314
BuildIndex(field_name, range, writer_field_names, batch_reader.get(),
315315
global_index_writer.get()));
316-
for (auto& io_meta : global_index_io_metas) {
317-
io_meta.extra_field_ids = extra_field_ids;
318-
}
319316

320317
// generate commit message
321318
return ToCommitMessage(index_type, field.Id(), range, global_index_io_metas,
322-
data_split->Partition(), data_split->Bucket(), index_file_manager);
319+
data_split->Partition(), data_split->Bucket(), index_file_manager,
320+
extra_field_ids);
323321
}
324322

325323
} // namespace paimon

src/paimon/global_index/lucene/lucene_global_index_writer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ Result<std::vector<GlobalIndexIOMeta>> LuceneGlobalIndexWriter::Finish() {
237237
PAIMON_RETURN_NOT_OK(RapidJsonUtil::ToJsonString(options_, &options_json));
238238
auto meta_bytes = std::make_shared<Bytes>(options_json, pool_.get());
239239
GlobalIndexIOMeta meta(file_writer_->ToPath(index_file_name), file_size,
240-
/*metadata=*/meta_bytes, /*extra_field_ids=*/std::nullopt);
240+
/*metadata=*/meta_bytes);
241241
return std::vector<GlobalIndexIOMeta>({meta});
242242
}
243243

0 commit comments

Comments
 (0)