@@ -39,13 +39,10 @@ namespace iceberg {
3939class PositionDeleteWriter ::Impl {
4040 public:
4141 static Result<std::unique_ptr<Impl>> Make (PositionDeleteWriterOptions options) {
42- // TODO: Support writing row data if options.row_schema is provided.
43- // The V2 spec allows position deletes to optionally include the deleted row.
44- std::vector<SchemaField> fields;
45- fields.push_back (MetadataColumns::kDeleteFilePath );
46- fields.push_back (MetadataColumns::kDeleteFilePos );
47-
48- auto delete_schema = std::make_shared<Schema>(std::move (fields));
42+ auto delete_schema = std::make_shared<Schema>(std::vector<SchemaField>{
43+ MetadataColumns::kDeleteFilePath ,
44+ MetadataColumns::kDeleteFilePos ,
45+ });
4946
5047 WriterOptions writer_options{
5148 .path = options.path ,
@@ -62,31 +59,27 @@ class PositionDeleteWriter::Impl {
6259 }
6360
6461 Status Write (ArrowArray* data) {
65- ICEBERG_DCHECK (writer_, " Writer not initialized " );
66- // TODO: Extract file paths from ArrowArray to update referenced_paths_ so that
67- // Metadata() can correctly populate referenced_data_file for batch writes .
62+ ICEBERG_PRECHECK (buffered_paths_. empty (),
63+ " Cannot write batch data when there are buffered deletes. " );
64+ // TODO(anyone): Extract file paths from ArrowArray to update referenced_paths_ .
6865 return writer_->Write (data);
6966 }
7067
7168 Status WriteDelete (std::string_view file_path, int64_t pos) {
72- ICEBERG_DCHECK (writer_, " Writer not initialized " );
69+ // TODO(anyone): check if the sort order of file_path and pos observes the spec.
7370 buffered_paths_.emplace_back (file_path);
7471 buffered_positions_.push_back (pos);
7572 referenced_paths_.emplace (file_path);
7673
77- if (static_cast < int64_t >( buffered_paths_.size () ) >= options_.flush_threshold ) {
74+ if (buffered_paths_.size () >= options_.flush_threshold ) {
7875 return FlushBuffer ();
7976 }
8077 return {};
8178 }
8279
83- Result<int64_t > Length () const {
84- ICEBERG_DCHECK (writer_, " Writer not initialized" );
85- return writer_->length ();
86- }
80+ Result<int64_t > Length () const { return writer_->length (); }
8781
8882 Status Close () {
89- ICEBERG_DCHECK (writer_, " Writer not initialized" );
9083 if (closed_) {
9184 return {};
9285 }
0 commit comments