@@ -139,6 +139,13 @@ Result<ArrowArray*> ManifestAdapter::FinishAppending() {
139139 return &array_;
140140}
141141
142+ ManifestEntryAdapter::ManifestEntryAdapter (std::shared_ptr<PartitionSpec> partition_spec)
143+ : partition_spec_(std::move(partition_spec)) {
144+ if (!partition_spec_) {
145+ partition_spec_ = PartitionSpec::Unpartitioned ();
146+ }
147+ }
148+
142149ManifestEntryAdapter::~ManifestEntryAdapter () {
143150 if (array_.release != nullptr ) {
144151 ArrowArrayRelease (&array_);
@@ -148,14 +155,6 @@ ManifestEntryAdapter::~ManifestEntryAdapter() {
148155 }
149156}
150157
151- Result<std::shared_ptr<StructType>> ManifestEntryAdapter::GetManifestEntryType () {
152- if (partition_spec_ == nullptr ) [[unlikely]] {
153- return ManifestEntry::TypeFromPartitionType (nullptr );
154- }
155- ICEBERG_ASSIGN_OR_RAISE (auto partition_type, partition_spec_->PartitionType ());
156- return ManifestEntry::TypeFromPartitionType (std::move (partition_type));
157- }
158-
159158Status ManifestEntryAdapter::AppendPartitionValues (
160159 ArrowArray* array, const std::shared_ptr<StructType>& partition_type,
161160 const std::vector<Literal>& partition_values) {
@@ -436,37 +435,6 @@ Status ManifestEntryAdapter::AppendInternal(const ManifestEntry& entry) {
436435 return {};
437436}
438437
439- Status ManifestEntryAdapter::InitSchema (const std::unordered_set<int32_t >& fields_ids) {
440- ICEBERG_ASSIGN_OR_RAISE (auto manifest_entry_type, GetManifestEntryType ())
441- auto fields_span = manifest_entry_type->fields ();
442- std::vector<SchemaField> fields;
443- // TODO(xiao.dong) Make this a common function to recursively handle
444- // all nested fields in the schema
445- for (const auto & field : fields_span) {
446- if (field.field_id () == 2 ) {
447- // handle data_file field
448- auto data_file_struct = internal::checked_pointer_cast<StructType>(field.type ());
449- std::vector<SchemaField> data_file_fields;
450- for (const auto & data_file_field : data_file_struct->fields ()) {
451- if (fields_ids.contains (data_file_field.field_id ())) {
452- data_file_fields.emplace_back (data_file_field);
453- }
454- }
455- auto type = std::make_shared<StructType>(data_file_fields);
456- auto data_file_field = SchemaField::MakeRequired (
457- field.field_id (), std::string (field.name ()), std::move (type));
458- fields.emplace_back (std::move (data_file_field));
459- } else {
460- if (fields_ids.contains (field.field_id ())) {
461- fields.emplace_back (field);
462- }
463- }
464- }
465- manifest_schema_ = std::make_shared<Schema>(fields);
466- ICEBERG_RETURN_UNEXPECTED (ToArrowSchema (*manifest_schema_, &schema_));
467- return {};
468- }
469-
470438ManifestFileAdapter::~ManifestFileAdapter () {
471439 if (array_.release != nullptr ) {
472440 ArrowArrayRelease (&array_);
@@ -671,16 +639,4 @@ Status ManifestFileAdapter::AppendInternal(const ManifestFile& file) {
671639 return {};
672640}
673641
674- Status ManifestFileAdapter::InitSchema (const std::unordered_set<int32_t >& fields_ids) {
675- std::vector<SchemaField> fields;
676- for (const auto & field : ManifestFile::Type ().fields ()) {
677- if (fields_ids.contains (field.field_id ())) {
678- fields.emplace_back (field);
679- }
680- }
681- manifest_list_schema_ = std::make_shared<Schema>(fields);
682- ICEBERG_RETURN_UNEXPECTED (ToArrowSchema (*manifest_list_schema_, &schema_));
683- return {};
684- }
685-
686642} // namespace iceberg
0 commit comments