Skip to content

Commit 835b26a

Browse files
author
xiao.dong
committed
use ManifestReader::MakeReader instead of CreateManifestReader
1 parent 34d0a06 commit 835b26a

File tree

4 files changed

+29
-38
lines changed

4 files changed

+29
-38
lines changed

src/iceberg/manifest_reader.cc

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,40 +28,31 @@
2828
namespace iceberg {
2929

3030
Result<std::unique_ptr<ManifestReader>> ManifestReader::MakeReader(
31-
const std::string& manifest_location, std::shared_ptr<FileIO> file_io,
31+
std::string_view manifest_location, std::shared_ptr<FileIO> file_io,
3232
std::shared_ptr<Schema> partition_schema) {
3333
auto manifest_entry_schema = ManifestEntry::TypeFromPartitionType(partition_schema);
3434
auto fields_span = manifest_entry_schema->fields();
3535
std::vector<SchemaField> fields(fields_span.begin(), fields_span.end());
3636
auto schema = std::make_shared<Schema>(fields);
3737
ICEBERG_ASSIGN_OR_RAISE(
38-
auto reader,
39-
ReaderFactoryRegistry::Open(
40-
FileFormatType::kAvro,
41-
{.path = manifest_location, .io = std::move(file_io), .projection = schema}));
38+
auto reader, ReaderFactoryRegistry::Open(FileFormatType::kAvro,
39+
{.path = std::string(manifest_location),
40+
.io = std::move(file_io),
41+
.projection = schema}));
4242
return std::make_unique<ManifestReaderImpl>(std::move(reader), std::move(schema));
4343
}
4444

4545
Result<std::unique_ptr<ManifestListReader>> ManifestListReader::MakeReader(
46-
const std::string& manifest_list_location, std::shared_ptr<FileIO> file_io) {
46+
std::string_view manifest_list_location, std::shared_ptr<FileIO> file_io) {
4747
std::vector<SchemaField> fields(ManifestFile::Type().fields().begin(),
4848
ManifestFile::Type().fields().end());
4949
auto schema = std::make_shared<Schema>(fields);
50-
ICEBERG_ASSIGN_OR_RAISE(
51-
auto reader,
52-
ReaderFactoryRegistry::Open(FileFormatType::kAvro, {.path = manifest_list_location,
53-
.io = std::move(file_io),
54-
.projection = schema}));
50+
ICEBERG_ASSIGN_OR_RAISE(auto reader, ReaderFactoryRegistry::Open(
51+
FileFormatType::kAvro,
52+
{.path = std::string(manifest_list_location),
53+
.io = std::move(file_io),
54+
.projection = schema}));
5555
return std::make_unique<ManifestListReaderImpl>(std::move(reader), std::move(schema));
5656
}
5757

58-
Result<std::unique_ptr<ManifestListReader>> CreateManifestListReader(
59-
std::string_view file_path) {
60-
return NotImplemented("CreateManifestListReader is not implemented yet.");
61-
}
62-
63-
Result<std::unique_ptr<ManifestReader>> CreateManifestReader(std::string_view file_path) {
64-
return NotImplemented("CreateManifestReader is not implemented yet.");
65-
}
66-
6758
} // namespace iceberg

src/iceberg/manifest_reader.h

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,12 @@ class ICEBERG_EXPORT ManifestReader {
3737
virtual ~ManifestReader() = default;
3838
virtual Result<std::vector<ManifestEntry>> Entries() const = 0;
3939

40+
/// \brief Creates a reader for a manifest file.
41+
/// \param manifest_location Path to the manifest file.
42+
/// \param file_io File IO implementation to use.
43+
/// \return A Result containing the reader or an error.
4044
static Result<std::unique_ptr<ManifestReader>> MakeReader(
41-
const std::string& manifest_location, std::shared_ptr<FileIO> file_io,
45+
std::string_view manifest_location, std::shared_ptr<FileIO> file_io,
4246
std::shared_ptr<Schema> partition_schema);
4347
};
4448

@@ -48,19 +52,12 @@ class ICEBERG_EXPORT ManifestListReader {
4852
virtual ~ManifestListReader() = default;
4953
virtual Result<std::vector<ManifestFile>> Files() const = 0;
5054

55+
/// \brief Creates a reader for the manifest list.
56+
/// \param manifest_list_location Path to the manifest list file.
57+
/// \param file_io File IO implementation to use.
58+
/// \return A Result containing the reader or an error.
5159
static Result<std::unique_ptr<ManifestListReader>> MakeReader(
52-
const std::string& manifest_list_location, std::shared_ptr<FileIO> file_io);
60+
std::string_view manifest_list_location, std::shared_ptr<FileIO> file_io);
5361
};
5462

55-
/// \brief Creates a reader for the manifest list.
56-
/// \param file_path Path to the manifest list file.
57-
/// \return A Result containing the reader or an error.
58-
Result<std::unique_ptr<ManifestListReader>> CreateManifestListReader(
59-
std::string_view file_path);
60-
61-
/// \brief Creates a reader for a manifest file.
62-
/// \param file_path Path to the manifest file.
63-
/// \return A Result containing the reader or an error.
64-
Result<std::unique_ptr<ManifestReader>> CreateManifestReader(std::string_view file_path);
65-
6663
} // namespace iceberg

src/iceberg/manifest_reader_internal.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ Result<std::vector<ManifestFile>> ParseManifestListEntry(ArrowSchema* schema,
218218
}
219219
}
220220
return manifest_files;
221-
} // namespace iceberg
221+
}
222222

223223
Result<std::vector<ManifestEntry>> ManifestReaderImpl::Entries() const { return {}; }
224224

src/iceberg/table_scan.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,14 +161,17 @@ DataTableScan::DataTableScan(TableScanContext context, std::shared_ptr<FileIO> f
161161
: TableScan(std::move(context), std::move(file_io)) {}
162162

163163
Result<std::vector<std::shared_ptr<FileScanTask>>> DataTableScan::PlanFiles() const {
164-
ICEBERG_ASSIGN_OR_RAISE(auto manifest_list_reader,
165-
CreateManifestListReader(context_.snapshot->manifest_list));
164+
ICEBERG_ASSIGN_OR_RAISE(
165+
auto manifest_list_reader,
166+
ManifestListReader::MakeReader(context_.snapshot->manifest_list, file_io_));
166167
ICEBERG_ASSIGN_OR_RAISE(auto manifest_files, manifest_list_reader->Files());
167168

168169
std::vector<std::shared_ptr<FileScanTask>> tasks;
169170
for (const auto& manifest_file : manifest_files) {
170-
ICEBERG_ASSIGN_OR_RAISE(auto manifest_reader,
171-
CreateManifestReader(manifest_file.manifest_path));
171+
ICEBERG_ASSIGN_OR_RAISE(
172+
auto manifest_reader,
173+
ManifestReader::MakeReader(manifest_file.manifest_path, file_io_,
174+
/* TODO(xiao.dong) partition schema*/ nullptr));
172175
ICEBERG_ASSIGN_OR_RAISE(auto manifests, manifest_reader->Entries());
173176

174177
// TODO(gty404): filter manifests using partition spec and filter expression

0 commit comments

Comments
 (0)