MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / compact_preserves_string_data

Function compact_preserves_string_data

nodedb-columnar/src/compaction/tests.rs:138–165  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

136
137#[test]
138fn compact_preserves_string_data() {
139 let segment = write_segment(20);
140 let mut deletes = DeleteBitmap::new();
141 deletes.mark_deleted(0); // Delete first row.
142
143 let result =
144 compact_segment(&segment, &deletes, &test_schema(), 0, None, None).expect("compact");
145 let new_seg = result.segment.as_ref().expect("segment");
146 let reader = SegmentReader::open(new_seg).expect("open");
147
148 // Read the name column (string).
149 let col = reader.read_column(1).expect("read name");
150 match col {
151 DecodedColumn::Binary {
152 data,
153 offsets,
154 valid,
155 } => {
156 // First row should be "user_1" (user_0 was deleted).
157 let start = offsets[0] as usize;
158 let end = offsets[1] as usize;
159 let first_name = std::str::from_utf8(&data[start..end]).expect("utf8");
160 assert_eq!(first_name, "user_1");
161 assert!(valid[0]);
162 }
163 _ => panic!("expected Binary"),
164 }
165}

Callers

nothing calls this directly

Calls 8

compact_segmentFunction · 0.85
write_segmentFunction · 0.70
test_schemaFunction · 0.70
openFunction · 0.50
mark_deletedMethod · 0.45
expectMethod · 0.45
as_refMethod · 0.45
read_columnMethod · 0.45

Tested by

no test coverage detected