Skip to content

Commit

Permalink
remove old structures
Browse files Browse the repository at this point in the history
Signed-off-by: Ruihang Xia <[email protected]>
  • Loading branch information
waynexia committed Feb 22, 2024
1 parent c5f982a commit 591f0a4
Showing 1 changed file with 0 additions and 73 deletions.
73 changes: 0 additions & 73 deletions src/mito2/src/memtable/key_values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,6 @@ impl KeyValues {
Some(KeyValues { mutation, helper })
}

/// Creates [KeyValues] from specific `mutation`. This method is used for [Mutation] that
/// has not been filled with all columns.
///
/// Returns `None` if `rows` of the `mutation` is `None`.
pub fn new_sparse(metadata: &RegionMetadata, mutation: Mutation) -> Option<KeyValues> {
let rows = mutation.rows.as_ref()?;
let helper = SparseReadRowHelper::new(metadata, rows);

Some(KeyValues { mutation, helper })
}

/// Returns a key value iterator.
pub fn iter(&self) -> impl Iterator<Item = KeyValue> {
let rows = self.mutation.rows.as_ref().unwrap();
Expand Down Expand Up @@ -149,68 +138,6 @@ impl<'a> KeyValue<'a> {
}
}

/// Helper to read rows in key, value order.
#[derive(Debug)]
struct ReadRowHelper {
/// Key and value column indices.
///
/// `indices[..num_primary_key_column]` are primary key columns, `indices[num_primary_key_column]`
/// is the timestamp column and remainings are field columns.
indices: Vec<usize>,
/// Number of primary key columns.
num_primary_key_column: usize,
}

impl ReadRowHelper {
/// Creates a [ReadRowHelper] for specific `rows`.
///
/// # Panics
/// The `rows` must fill their missing columns first and have same columns with `metadata`.
/// Otherwise this method will panic.
fn new(metadata: &RegionMetadata, rows: &Rows) -> ReadRowHelper {
assert_eq!(
metadata.column_metadatas.len(),
rows.schema.len(),
"Length mismatch, column_metas: {:?}, rows_schema: {:?}",
metadata.column_metadatas,
rows.schema
);

// Build a name to index mapping for rows.
let name_to_index: HashMap<_, _> = rows
.schema
.iter()
.enumerate()
.map(|(index, col)| (&col.column_name, index))
.collect();
let mut indices = Vec::with_capacity(metadata.column_metadatas.len());

// Get primary key indices.
for pk_id in &metadata.primary_key {
// Safety: Id comes from primary key.
let column = metadata.column_by_id(*pk_id).unwrap();
let index = name_to_index.get(&column.column_schema.name).unwrap();
indices.push(*index);
}
// Get timestamp index.
let ts_index = name_to_index
.get(&metadata.time_index_column().column_schema.name)
.unwrap();
indices.push(*ts_index);
// Iterate columns and find field columns.
for column in metadata.field_columns() {
// Get index in request for each field column.
let index = name_to_index.get(&column.column_schema.name).unwrap();
indices.push(*index);
}

ReadRowHelper {
indices,
num_primary_key_column: metadata.primary_key.len(),
}
}
}

/// Helper to read rows in key, value order for sparse data.
#[derive(Debug)]
struct SparseReadRowHelper {
Expand Down

0 comments on commit 591f0a4

Please sign in to comment.