Skip to content

Commit 86cc620

Browse files
authored
feat(blob): Remove blob external storage mode (alibaba#393)
1 parent e3123ae commit 86cc620

57 files changed

Lines changed: 107 additions & 1338 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

include/paimon/defs.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -403,17 +403,6 @@ struct PAIMON_EXPORT Options {
403403
/// serialized BlobViewStruct bytes inline in data files and resolve from upstream tables at
404404
/// read time. No default value.
405405
static const char BLOB_VIEW_FIELD[];
406-
/// "blob-external-storage-field" - Comma-separated BLOB field names (must be a subset of
407-
/// blob-descriptor-field ) whose raw data will be written to external storage at write time.
408-
/// The external storage path is configured via blob-external-storage-path. Orphan file cleanup
409-
/// is not applied to that path. No default value.
410-
static const char BLOB_EXTERNAL_STORAGE_FIELD[];
411-
/// "blob-external-storage-path" - The external storage path where raw BLOB data from fields
412-
/// configured by 'blob-external-storage-field' is written at write time. Orphan file cleanup is
413-
/// not applied to this path. No default value.
414-
/// @note: this option differs from the Java paimon and will be deprecated once
415-
/// RestCatalog is supported.
416-
static const char BLOB_EXTERNAL_STORAGE_PATH[];
417406
/// "blob-view-upstream-warehouse" - Since the catalog capabilities are partially missing, when
418407
/// Blob View is enabled, cpp paimon cannot automatically obtain the upstream table warehouse
419408
/// path and requires manual configuration by the user. No default value.

src/paimon/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,6 @@ set(PAIMON_CORE_SRCS
239239
core/io/map_shared_shredding_core_utils.cpp
240240
core/io/shredding_append_data_file_writer_factory.cpp
241241
core/io/shredding_key_value_data_file_writer_factory.cpp
242-
core/io/external_storage_blob_writer.cpp
243242
core/io/multiple_blob_file_writer.cpp
244243
core/io/rolling_blob_file_writer.cpp
245244
core/manifest/file_kind.cpp
@@ -634,7 +633,6 @@ if(PAIMON_BUILD_TESTS)
634633
core/io/file_index_evaluator_test.cpp
635634
core/io/single_file_writer_test.cpp
636635
core/io/rolling_blob_file_writer_test.cpp
637-
core/io/external_storage_blob_writer_test.cpp
638636
core/global_index/indexed_split_test.cpp
639637
core/manifest/file_source_test.cpp
640638
core/manifest/file_kind_test.cpp

src/paimon/common/defs.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,6 @@ const char Options::BLOB_DESCRIPTOR_FIELD[] = "blob-descriptor-field";
101101
const char Options::FALLBACK_BLOB_DESCRIPTOR_FIELD[] = "blob.stored-descriptor-fields";
102102
const char Options::BLOB_VIEW_FIELD[] = "blob-view-field";
103103
const char Options::BLOB_VIEW_UPSTREAM_WAREHOUSE[] = "blob-view-upstream-warehouse";
104-
const char Options::BLOB_EXTERNAL_STORAGE_FIELD[] = "blob-external-storage-field";
105-
const char Options::BLOB_EXTERNAL_STORAGE_PATH[] = "blob-external-storage-path";
106104
const char Options::GLOBAL_INDEX_ENABLED[] = "global-index.enabled";
107105
const char Options::GLOBAL_INDEX_THREAD_NUM[] = "global-index.thread-num";
108106
const char Options::GLOBAL_INDEX_EXTERNAL_PATH[] = "global-index.external-path";

src/paimon/core/append/append_only_writer.cpp

Lines changed: 7 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
#include "paimon/core/io/compact_increment.h"
3737
#include "paimon/core/io/data_file_path_factory.h"
3838
#include "paimon/core/io/data_increment.h"
39-
#include "paimon/core/io/external_storage_blob_writer.h"
4039
#include "paimon/core/io/multiple_blob_file_writer.h"
4140
#include "paimon/core/io/rolling_blob_file_writer.h"
4241
#include "paimon/core/io/rolling_file_writer.h"
@@ -85,22 +84,6 @@ Status AppendOnlyWriter::Write(std::unique_ptr<RecordBatch>&& batch) {
8584
PAIMON_ASSIGN_OR_RAISE(writer_, CreateRollingRowWriter());
8685
}
8786

88-
// Transform batch for external storage descriptor fields before writing.
89-
if (external_storage_writer_) {
90-
auto data_type = arrow::struct_(write_schema_->fields());
91-
PAIMON_ASSIGN_OR_RAISE_FROM_ARROW(std::shared_ptr<arrow::Array> arrow_array,
92-
arrow::ImportArray(batch->GetData(), data_type));
93-
auto struct_array = std::dynamic_pointer_cast<arrow::StructArray>(arrow_array);
94-
PAIMON_ASSIGN_OR_RAISE(std::shared_ptr<arrow::Array> transformed,
95-
external_storage_writer_->TransformBatch(struct_array));
96-
auto transformed_struct = std::dynamic_pointer_cast<arrow::StructArray>(transformed);
97-
PAIMON_RETURN_NOT_OK(BlobUtils::ValidateBlobInlineFields(
98-
transformed_struct, inline_descriptor_fields_, "blob-descriptor-field"));
99-
::ArrowArray c_transformed;
100-
PAIMON_RETURN_NOT_OK_FROM_ARROW(arrow::ExportArray(*transformed, &c_transformed));
101-
return writer_->Write(&c_transformed);
102-
}
103-
10487
if (!inline_descriptor_fields_.empty() || !inline_view_fields_.empty()) {
10588
auto data_type = arrow::struct_(write_schema_->fields());
10689
PAIMON_ASSIGN_OR_RAISE_FROM_ARROW(std::shared_ptr<arrow::Array> arrow_array,
@@ -188,47 +171,24 @@ Status AppendOnlyWriter::Flush(bool wait_for_latest_compaction, bool forced_full
188171

189172
AppendOnlyWriter::RollingFileWriterResult AppendOnlyWriter::CreateRollingRowWriter() {
190173
auto blob_context = BlobFileContext::Create(write_schema_, options_);
191-
std::optional<std::vector<std::string>> main_write_cols = write_cols_;
192174

193175
// Save inline descriptor and view fields for validation in Write()
194176
if (blob_context) {
195177
inline_descriptor_fields_ = blob_context->GetDescriptorFields();
196178
inline_view_fields_ = blob_context->GetViewFields();
197179
}
198180

199-
// Initialize ExternalStorageBlobWriter if needed
200-
if (blob_context && blob_context->RequireExternalStorageWriter()) {
201-
assert(blob_context->GetExternalStoragePath());
202-
external_storage_writer_ = std::make_unique<ExternalStorageBlobWriter>(
203-
write_schema_, blob_context->GetExternalStorageFields(),
204-
blob_context->GetExternalStoragePath().value(), schema_id_, seq_num_counter_,
205-
path_factory_, options_, memory_pool_);
206-
if (!main_write_cols) {
207-
// To align with java, when require external storage writer, main writer will set write
208-
// cols in DataFileMeta
209-
main_write_cols = write_schema_->field_names();
210-
}
211-
}
212-
213181
if (blob_context && blob_context->RequireBlobFileWriter()) {
214182
// Use context-aware schema separation: inline BLOB fields stay in main
215183
auto schemas =
216184
BlobUtils::SeparateBlobSchema(write_schema_, blob_context->GetInlineFields());
217185
return CreateRollingBlobWriter(schemas, blob_context->GetInlineFields());
218186
}
219187

220-
if (!blob_context) {
221-
// No BLOB fields at all -> plain rolling writer
222-
return std::make_unique<RollingFileWriter<::ArrowArray*, std::shared_ptr<DataFileMeta>>>(
223-
options_.GetTargetFileSize(/*has_primary_key=*/false),
224-
GetDataFileWriterFactory(write_schema_, main_write_cols));
225-
} else {
226-
// All BLOB fields are inline, no .blob files needed -> plain rolling writer
227-
// The main data file contains all fields including inline descriptors/views.
228-
return std::make_unique<RollingFileWriter<::ArrowArray*, std::shared_ptr<DataFileMeta>>>(
229-
options_.GetTargetFileSize(/*has_primary_key=*/false),
230-
GetDataFileWriterFactory(write_schema_, main_write_cols));
231-
}
188+
// No BLOB fields, or all BLOB fields are inline and no .blob files are needed.
189+
return std::make_unique<RollingFileWriter<::ArrowArray*, std::shared_ptr<DataFileMeta>>>(
190+
options_.GetTargetFileSize(/*has_primary_key=*/false),
191+
GetDataFileWriterFactory(write_schema_, write_cols_));
232192
}
233193

234194
AppendOnlyWriter::WriterFactory AppendOnlyWriter::GetDataFileWriterFactory(
@@ -248,10 +208,9 @@ AppendOnlyWriter::WriterFactory AppendOnlyWriter::GetBlobFileWriterFactory(
248208
const std::shared_ptr<arrow::Schema>& single_field_schema,
249209
const std::optional<std::vector<std::string>>& write_cols) const {
250210
std::shared_ptr<DataFilePathFactory> path_factory = path_factory_;
251-
return std::make_shared<BlobDataFileWriterFactory>(
252-
options_, schema_id_, single_field_schema, write_cols, seq_num_counter_, path_factory,
253-
[path_factory]() { return path_factory->NewBlobPath(); },
254-
blob::BlobFormatWriter::WriteConsumer(), memory_pool_);
211+
return std::make_shared<BlobDataFileWriterFactory>(options_, schema_id_, single_field_schema,
212+
write_cols, seq_num_counter_, path_factory,
213+
memory_pool_);
255214
}
256215

257216
AppendOnlyWriter::RollingFileWriterResult AppendOnlyWriter::CreateRollingBlobWriter(
@@ -306,11 +265,6 @@ Status AppendOnlyWriter::Close() {
306265
writer_.reset();
307266
}
308267

309-
if (external_storage_writer_) {
310-
PAIMON_RETURN_NOT_OK(external_storage_writer_->Close());
311-
external_storage_writer_.reset();
312-
}
313-
314268
if (compact_deletion_file_ != nullptr) {
315269
compact_deletion_file_->Clean();
316270
}

src/paimon/core/append/append_only_writer.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ class Schema;
4242
namespace paimon {
4343

4444
class CommitIncrement;
45-
class ExternalStorageBlobWriter;
4645
class MapSharedShreddingContext;
4746
class RecordBatch;
4847
template <typename T, typename R>
@@ -133,7 +132,6 @@ class AppendOnlyWriter : public BatchWriter {
133132

134133
std::shared_ptr<CompactDeletionFile> compact_deletion_file_;
135134
std::unique_ptr<RollingFileWriter<::ArrowArray*, std::shared_ptr<DataFileMeta>>> writer_;
136-
std::unique_ptr<ExternalStorageBlobWriter> external_storage_writer_;
137135
std::set<std::string> inline_descriptor_fields_;
138136
std::set<std::string> inline_view_fields_;
139137

src/paimon/core/core_options.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,6 @@ struct CoreOptions::Impl {
382382
std::vector<std::string> blob_fields;
383383
std::vector<std::string> blob_descriptor_fields;
384384
std::vector<std::string> blob_view_fields;
385-
std::vector<std::string> blob_external_storage_fields;
386385

387386
std::string partition_default_name = "__DEFAULT_PARTITION__";
388387
StartupMode startup_mode = StartupMode::Default();
@@ -395,7 +394,6 @@ struct CoreOptions::Impl {
395394
std::optional<std::string> field_default_func;
396395
std::optional<std::string> scan_fallback_branch;
397396
std::optional<std::string> data_file_external_paths;
398-
std::optional<std::string> blob_external_storage_path;
399397
std::optional<std::string> blob_view_upstream_warehouse;
400398

401399
std::map<std::string, std::string> raw_options;
@@ -564,13 +562,6 @@ struct CoreOptions::Impl {
564562
// Parse blob-view-upstream-warehouse - warehouse path for configured blob view fields
565563
PAIMON_RETURN_NOT_OK(
566564
parser.Parse(Options::BLOB_VIEW_UPSTREAM_WAREHOUSE, &blob_view_upstream_warehouse));
567-
// Parse blob-external-storage-field - descriptor BLOB fields written to external storage
568-
PAIMON_RETURN_NOT_OK(parser.ParseList<std::string>(
569-
Options::BLOB_EXTERNAL_STORAGE_FIELD, Options::FIELDS_SEPARATOR,
570-
&blob_external_storage_fields, /*need_trim=*/true));
571-
// Parse blob-external-storage-path - external storage path for configured BLOB fields
572-
PAIMON_RETURN_NOT_OK(
573-
parser.Parse(Options::BLOB_EXTERNAL_STORAGE_PATH, &blob_external_storage_path));
574565
return Status::OK();
575566
}
576567

@@ -1492,14 +1483,6 @@ std::vector<std::string> CoreOptions::GetBlobInlineFields() const {
14921483
return blob_inline_fields;
14931484
}
14941485

1495-
const std::vector<std::string>& CoreOptions::GetBlobExternalStorageFields() const {
1496-
return impl_->blob_external_storage_fields;
1497-
}
1498-
1499-
std::optional<std::string> CoreOptions::GetBlobExternalStoragePath() const {
1500-
return impl_->blob_external_storage_path;
1501-
}
1502-
15031486
int64_t CoreOptions::GetLookupCacheFileRetentionMs() const {
15041487
return impl_->lookup_cache_file_retention_ms;
15051488
}

src/paimon/core/core_options.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,6 @@ class PAIMON_EXPORT CoreOptions {
197197
const std::vector<std::string>& GetBlobViewFields() const;
198198
std::optional<std::string> GetBlobViewUpstreamWarehouse() const;
199199
std::vector<std::string> GetBlobInlineFields() const;
200-
const std::vector<std::string>& GetBlobExternalStorageFields() const;
201-
std::optional<std::string> GetBlobExternalStoragePath() const;
202200

203201
const std::map<std::string, std::string>& ToMap() const;
204202

src/paimon/core/core_options_test.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,7 @@ TEST(CoreOptionsTest, TestDefaultValue) {
122122
ASSERT_TRUE(core_options.GetBlobDescriptorFields().empty());
123123
ASSERT_TRUE(core_options.GetBlobViewFields().empty());
124124
ASSERT_TRUE(core_options.GetBlobInlineFields().empty());
125-
ASSERT_TRUE(core_options.GetBlobExternalStorageFields().empty());
126125
ASSERT_EQ(std::nullopt, core_options.GetBlobViewUpstreamWarehouse());
127-
ASSERT_EQ(std::nullopt, core_options.GetBlobExternalStoragePath());
128126
ASSERT_TRUE(core_options.LegacyPartitionNameEnabled());
129127
ASSERT_TRUE(core_options.GlobalIndexEnabled());
130128
ASSERT_EQ(std::nullopt, core_options.GetGlobalIndexExternalPath());
@@ -227,8 +225,6 @@ TEST(CoreOptionsTest, TestFromMap) {
227225
{Options::BLOB_FIELD, "blob1,blob2"},
228226
{Options::BLOB_DESCRIPTOR_FIELD, "blob3,blob4"},
229227
{Options::BLOB_VIEW_FIELD, "blob5"},
230-
{Options::BLOB_EXTERNAL_STORAGE_FIELD, "blob3,blob4"},
231-
{Options::BLOB_EXTERNAL_STORAGE_PATH, "FILE:///tmp/blob_external_storage/"},
232228
{Options::BLOB_VIEW_UPSTREAM_WAREHOUSE, "FILE:///tmp/blob_view_upstream_warehouse/"},
233229
{Options::PARTITION_GENERATE_LEGACY_NAME, "false"},
234230
{Options::GLOBAL_INDEX_ENABLED, "false"},
@@ -367,10 +363,6 @@ TEST(CoreOptionsTest, TestFromMap) {
367363
ASSERT_EQ(core_options.GetBlobViewFields(), std::vector<std::string>({"blob5"}));
368364
ASSERT_EQ(core_options.GetBlobInlineFields(),
369365
std::vector<std::string>({"blob3", "blob4", "blob5"}));
370-
ASSERT_EQ(core_options.GetBlobExternalStorageFields(),
371-
std::vector<std::string>({"blob3", "blob4"}));
372-
ASSERT_EQ(core_options.GetBlobExternalStoragePath(),
373-
std::optional<std::string>("FILE:///tmp/blob_external_storage/"));
374366
ASSERT_EQ(core_options.GetBlobViewUpstreamWarehouse(),
375367
std::optional<std::string>("FILE:///tmp/blob_view_upstream_warehouse/"));
376368
ASSERT_FALSE(core_options.LegacyPartitionNameEnabled());

src/paimon/core/io/blob_data_file_writer_factory.cpp

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "paimon/core/core_options.h"
2323
#include "paimon/core/io/data_file_path_factory.h"
2424
#include "paimon/core/manifest/file_source.h"
25-
#include "paimon/format/blob/blob_writer_builder.h"
2625
#include "paimon/format/file_format.h"
2726
#include "paimon/format/file_format_factory.h"
2827
#include "paimon/fs/file_system.h"
@@ -34,15 +33,13 @@ BlobDataFileWriterFactory::BlobDataFileWriterFactory(
3433
const std::shared_ptr<arrow::Schema>& file_schema,
3534
const std::optional<std::vector<std::string>>& write_cols,
3635
const std::shared_ptr<LongCounter>& seq_num_counter,
37-
const std::shared_ptr<DataFilePathFactory>& path_factory, PathCreator path_creator,
38-
blob::BlobFormatWriter::WriteConsumer write_consumer, const std::shared_ptr<MemoryPool>& pool)
36+
const std::shared_ptr<DataFilePathFactory>& path_factory,
37+
const std::shared_ptr<MemoryPool>& pool)
3938
: DataFileWriterFactory(options, schema_id, pool),
4039
file_schema_(file_schema),
4140
write_cols_(write_cols),
4241
seq_num_counter_(seq_num_counter),
43-
path_factory_(path_factory),
44-
path_creator_(std::move(path_creator)),
45-
write_consumer_(std::move(write_consumer)) {}
42+
path_factory_(path_factory) {}
4643

4744
Result<std::unique_ptr<SingleFileWriter<::ArrowArray*, std::shared_ptr<DataFileMeta>>>>
4845
BlobDataFileWriterFactory::CreateWriter() const {
@@ -51,26 +48,12 @@ BlobDataFileWriterFactory::CreateWriter() const {
5148
PAIMON_ASSIGN_OR_RAISE(WriterResources resources,
5249
CreateWriterResources(*format, file_schema_,
5350
/*create_stats_extractor=*/true));
54-
if (write_consumer_) {
55-
auto blob_writer_builder =
56-
std::dynamic_pointer_cast<blob::BlobWriterBuilder>(resources.writer_builder);
57-
if (!blob_writer_builder) {
58-
return Status::Invalid(
59-
"writer_builder cannot be casted to BlobWriterBuilder "
60-
"in BlobDataFileWriterFactory");
61-
}
62-
blob_writer_builder->WithWriteConsumer(write_consumer_);
63-
}
64-
6551
auto writer = std::make_unique<DataFileWriter>(
6652
/*compression=*/"none", std::function<Status(::ArrowArray*, ::ArrowArray*)>(), schema_id_,
6753
seq_num_counter_, FileSource::Append(), resources.stats_extractor,
6854
path_factory_->IsExternalPath(), write_cols_, pool_);
69-
if (!path_creator_) {
70-
return Status::Invalid("BlobDataFileWriterFactory path creator is empty.");
71-
}
72-
PAIMON_RETURN_NOT_OK(
73-
writer->Init(options_.GetFileSystem(), path_creator_(), resources.writer_builder));
55+
PAIMON_RETURN_NOT_OK(writer->Init(options_.GetFileSystem(), path_factory_->NewBlobPath(),
56+
resources.writer_builder));
7457
return std::unique_ptr<SingleFileWriter<::ArrowArray*, std::shared_ptr<DataFileMeta>>>(
7558
std::move(writer));
7659
}

src/paimon/core/io/blob_data_file_writer_factory.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#pragma once
1818

1919
#include <cstdint>
20-
#include <functional>
2120
#include <memory>
2221
#include <optional>
2322
#include <string>
@@ -27,7 +26,6 @@
2726
#include "paimon/core/io/data_file_writer.h"
2827
#include "paimon/core/io/data_file_writer_factory.h"
2928
#include "paimon/core/io/single_file_writer_factory.h"
30-
#include "paimon/format/blob/blob_format_writer.h"
3129
#include "paimon/result.h"
3230

3331
namespace arrow {
@@ -45,15 +43,11 @@ class BlobDataFileWriterFactory
4543
: public DataFileWriterFactory,
4644
public SingleFileWriterFactory<::ArrowArray*, std::shared_ptr<DataFileMeta>> {
4745
public:
48-
using PathCreator = std::function<std::string()>;
49-
5046
BlobDataFileWriterFactory(const CoreOptions& options, int64_t schema_id,
5147
const std::shared_ptr<arrow::Schema>& file_schema,
5248
const std::optional<std::vector<std::string>>& write_cols,
5349
const std::shared_ptr<LongCounter>& seq_num_counter,
5450
const std::shared_ptr<DataFilePathFactory>& path_factory,
55-
PathCreator path_creator,
56-
blob::BlobFormatWriter::WriteConsumer write_consumer,
5751
const std::shared_ptr<MemoryPool>& pool);
5852

5953
Result<std::unique_ptr<SingleFileWriter<::ArrowArray*, std::shared_ptr<DataFileMeta>>>>
@@ -64,8 +58,6 @@ class BlobDataFileWriterFactory
6458
std::optional<std::vector<std::string>> write_cols_;
6559
std::shared_ptr<LongCounter> seq_num_counter_;
6660
std::shared_ptr<DataFilePathFactory> path_factory_;
67-
PathCreator path_creator_;
68-
blob::BlobFormatWriter::WriteConsumer write_consumer_;
6961
};
7062

7163
} // namespace paimon

0 commit comments

Comments
 (0)