MCPcopy Create free account
hub / github.com/apache/paimon-rust / create_kv_writer

Method create_kv_writer

crates/paimon/src/table/table_write.rs:651–694  ·  view source on GitHub ↗

Create a key-value writer for PK tables with normal buckets.

(
        &mut self,
        partition_path: String,
        bucket: i32,
        partition_bytes: &[u8],
    )

Source from the content-addressed store, hash-verified

649
650 /// Create a key-value writer for PK tables with normal buckets.
651 async fn create_kv_writer(
652 &mut self,
653 partition_path: String,
654 bucket: i32,
655 partition_bytes: &[u8],
656 ) -> Result<FileWriter> {
657 // Lazily scan partition sequence numbers on first writer creation per partition.
658 // Overwrite mode skips this — old data will be replaced, so seq starts at 0.
659 if !self.is_overwrite && !self.partition_seq_cache.contains_key(partition_bytes) {
660 let bucket_seq =
661 Self::scan_partition_sequence_numbers(&self.table, partition_bytes).await?;
662 self.partition_seq_cache
663 .insert(partition_bytes.to_vec(), bucket_seq);
664 }
665 let next_seq = self
666 .partition_seq_cache
667 .get(partition_bytes)
668 .and_then(|m| m.get(&bucket))
669 .copied()
670 .unwrap_or(0);
671
672 Ok(FileWriter::KeyValue(KeyValueFileWriter::new(
673 self.table.file_io().clone(),
674 KeyValueWriteConfig {
675 table_name: self.table.identifier().full_name(),
676 table_options: self.table.schema().options().clone(),
677 table_location: self.table.location().to_string(),
678 partition_path,
679 bucket,
680 schema_id: self.schema_id,
681 file_compression: self.file_compression.clone(),
682 file_compression_zstd_level: self.file_compression_zstd_level,
683 write_buffer_size: self.write_buffer_size,
684 file_format: self.file_format.clone(),
685 primary_key_indices: self.primary_key_indices.clone(),
686 primary_key_types: self.primary_key_types.clone(),
687 sequence_field_indices: self.sequence_field_indices.clone(),
688 merge_engine: self.merge_engine,
689 deletion_vectors_enabled: CoreOptions::new(self.table.schema().options())
690 .deletion_vectors_enabled(),
691 },
692 next_seq,
693 )?))
694 }
695}
696
697#[cfg(test)]

Callers 1

create_writerMethod · 0.80

Calls 10

insertMethod · 0.80
to_vecMethod · 0.80
full_nameMethod · 0.80
getMethod · 0.45
file_ioMethod · 0.45
identifierMethod · 0.45
optionsMethod · 0.45
schemaMethod · 0.45
locationMethod · 0.45

Tested by

no test coverage detected