refactor: satisfy new clippy lints

pull/24376/head
Edd Robinson 2021-04-20 18:05:55 +01:00 committed by kodiakhq[bot]
parent 508aa8be8c
commit d55bf73860
2 changed files with 27 additions and 27 deletions

View File

@ -1313,7 +1313,7 @@ mod test {
let arr = StringArray::from(input); let arr = StringArray::from(input);
let col = Column::from(arr); let col = Column::from(arr);
if let Column::String(meta, StringEncoding::RLEDictionary(enc)) = col { if let Column::String(meta, StringEncoding::RleDictionary(enc)) = col {
assert_eq!( assert_eq!(
meta, meta,
super::MetaData::<String> { super::MetaData::<String> {
@ -1339,7 +1339,7 @@ mod test {
fn from_strs() { fn from_strs() {
let arr = vec!["world", "hello"]; let arr = vec!["world", "hello"];
let col = Column::from(arr.as_slice()); let col = Column::from(arr.as_slice());
if let Column::String(meta, StringEncoding::RLEDictionary(enc)) = col { if let Column::String(meta, StringEncoding::RleDictionary(enc)) = col {
assert_eq!( assert_eq!(
meta, meta,
super::MetaData::<String> { super::MetaData::<String> {

View File

@ -18,7 +18,7 @@ use crate::column::{RowIDs, Value, Values};
pub const TEMP_CARDINALITY_DICTIONARY_ENCODING_LIMIT: usize = 100_000; pub const TEMP_CARDINALITY_DICTIONARY_ENCODING_LIMIT: usize = 100_000;
pub enum StringEncoding { pub enum StringEncoding {
RLEDictionary(RLE), RleDictionary(RLE),
Dictionary(Plain), Dictionary(Plain),
// TODO - simple array encoding, e.g., via Arrow String array. // TODO - simple array encoding, e.g., via Arrow String array.
} }
@ -29,7 +29,7 @@ impl StringEncoding {
/// The total size in bytes of the store columnar data. /// The total size in bytes of the store columnar data.
pub fn size(&self) -> usize { pub fn size(&self) -> usize {
match self { match self {
Self::RLEDictionary(enc) => enc.size(), Self::RleDictionary(enc) => enc.size(),
Self::Dictionary(enc) => enc.size(), Self::Dictionary(enc) => enc.size(),
} }
} }
@ -37,7 +37,7 @@ impl StringEncoding {
/// The total number of rows in the column. /// The total number of rows in the column.
pub fn num_rows(&self) -> u32 { pub fn num_rows(&self) -> u32 {
match self { match self {
Self::RLEDictionary(enc) => enc.num_rows(), Self::RleDictionary(enc) => enc.num_rows(),
Self::Dictionary(enc) => enc.num_rows(), Self::Dictionary(enc) => enc.num_rows(),
} }
} }
@ -45,7 +45,7 @@ impl StringEncoding {
/// The lexicographical min and max values in the column. /// The lexicographical min and max values in the column.
pub fn column_range(&self) -> Option<(String, String)> { pub fn column_range(&self) -> Option<(String, String)> {
match self { match self {
Self::RLEDictionary(enc) => match (enc.column_min(), enc.column_max()) { Self::RleDictionary(enc) => match (enc.column_min(), enc.column_max()) {
(None, None) => None, (None, None) => None,
(Some(min), Some(max)) => Some((min.to_owned(), max.to_owned())), (Some(min), Some(max)) => Some((min.to_owned(), max.to_owned())),
(min, max) => panic!("invalid column range: ({:?}, {:?})", min, max), (min, max) => panic!("invalid column range: ({:?}, {:?})", min, max),
@ -61,7 +61,7 @@ impl StringEncoding {
/// Determines if the column contains a NULL value. /// Determines if the column contains a NULL value.
pub fn contains_null(&self) -> bool { pub fn contains_null(&self) -> bool {
match self { match self {
Self::RLEDictionary(enc) => enc.contains_null(), Self::RleDictionary(enc) => enc.contains_null(),
Self::Dictionary(enc) => enc.contains_null(), Self::Dictionary(enc) => enc.contains_null(),
} }
} }
@ -69,7 +69,7 @@ impl StringEncoding {
/// Returns true if encoding can return row ID sets for logical values. /// Returns true if encoding can return row ID sets for logical values.
pub fn has_pre_computed_row_id_sets(&self) -> bool { pub fn has_pre_computed_row_id_sets(&self) -> bool {
match &self { match &self {
Self::RLEDictionary(_) => true, Self::RleDictionary(_) => true,
Self::Dictionary(_) => false, Self::Dictionary(_) => false,
} }
} }
@ -77,7 +77,7 @@ impl StringEncoding {
/// Determines if the column contains a non-null value /// Determines if the column contains a non-null value
pub fn has_any_non_null_value(&self) -> bool { pub fn has_any_non_null_value(&self) -> bool {
match &self { match &self {
Self::RLEDictionary(c) => c.has_any_non_null_value(), Self::RleDictionary(c) => c.has_any_non_null_value(),
Self::Dictionary(c) => c.has_any_non_null_value(), Self::Dictionary(c) => c.has_any_non_null_value(),
} }
} }
@ -86,7 +86,7 @@ impl StringEncoding {
/// provided rows. /// provided rows.
pub fn has_non_null_value(&self, row_ids: &[u32]) -> bool { pub fn has_non_null_value(&self, row_ids: &[u32]) -> bool {
match &self { match &self {
Self::RLEDictionary(c) => c.has_non_null_value(row_ids), Self::RleDictionary(c) => c.has_non_null_value(row_ids),
Self::Dictionary(c) => c.has_non_null_value(row_ids), Self::Dictionary(c) => c.has_non_null_value(row_ids),
} }
} }
@ -95,7 +95,7 @@ impl StringEncoding {
/// Short-circuits execution as soon as it finds a value not in `values`. /// Short-circuits execution as soon as it finds a value not in `values`.
pub fn has_other_non_null_values(&self, values: &BTreeSet<String>) -> bool { pub fn has_other_non_null_values(&self, values: &BTreeSet<String>) -> bool {
match &self { match &self {
Self::RLEDictionary(c) => c.has_other_non_null_values(values), Self::RleDictionary(c) => c.has_other_non_null_values(values),
Self::Dictionary(c) => c.has_other_non_null_values(values), Self::Dictionary(c) => c.has_other_non_null_values(values),
} }
} }
@ -103,7 +103,7 @@ impl StringEncoding {
/// Returns the logical value found at the provided row id. /// Returns the logical value found at the provided row id.
pub fn value(&self, row_id: u32) -> Value<'_> { pub fn value(&self, row_id: u32) -> Value<'_> {
match &self { match &self {
Self::RLEDictionary(c) => match c.value(row_id) { Self::RleDictionary(c) => match c.value(row_id) {
Some(v) => Value::String(v), Some(v) => Value::String(v),
None => Value::Null, None => Value::Null,
}, },
@ -119,7 +119,7 @@ impl StringEncoding {
/// TODO(edd): perf - pooling of destination vectors. /// TODO(edd): perf - pooling of destination vectors.
pub fn values(&self, row_ids: &[u32]) -> Values<'_> { pub fn values(&self, row_ids: &[u32]) -> Values<'_> {
match &self { match &self {
Self::RLEDictionary(c) => Values::String(c.values(row_ids, vec![])), Self::RleDictionary(c) => Values::String(c.values(row_ids, vec![])),
Self::Dictionary(c) => Values::String(c.values(row_ids, vec![])), Self::Dictionary(c) => Values::String(c.values(row_ids, vec![])),
} }
} }
@ -129,7 +129,7 @@ impl StringEncoding {
/// TODO(edd): perf - pooling of destination vectors. /// TODO(edd): perf - pooling of destination vectors.
pub fn all_values(&self) -> Values<'_> { pub fn all_values(&self) -> Values<'_> {
match &self { match &self {
Self::RLEDictionary(c) => Values::String(c.all_values(vec![])), Self::RleDictionary(c) => Values::String(c.all_values(vec![])),
Self::Dictionary(c) => Values::String(c.all_values(vec![])), Self::Dictionary(c) => Values::String(c.all_values(vec![])),
} }
} }
@ -137,7 +137,7 @@ impl StringEncoding {
/// Returns the logical value for the specified encoded representation. /// Returns the logical value for the specified encoded representation.
pub fn decode_id(&self, encoded_id: u32) -> Value<'_> { pub fn decode_id(&self, encoded_id: u32) -> Value<'_> {
match &self { match &self {
Self::RLEDictionary(c) => match c.decode_id(encoded_id) { Self::RleDictionary(c) => match c.decode_id(encoded_id) {
Some(v) => Value::String(v), Some(v) => Value::String(v),
None => Value::Null, None => Value::Null,
}, },
@ -153,7 +153,7 @@ impl StringEncoding {
/// TODO(edd): perf - pooling of destination sets. /// TODO(edd): perf - pooling of destination sets.
pub fn distinct_values(&self, row_ids: impl Iterator<Item = u32>) -> BTreeSet<Option<&'_ str>> { pub fn distinct_values(&self, row_ids: impl Iterator<Item = u32>) -> BTreeSet<Option<&'_ str>> {
match &self { match &self {
Self::RLEDictionary(c) => c.distinct_values(row_ids, BTreeSet::new()), Self::RleDictionary(c) => c.distinct_values(row_ids, BTreeSet::new()),
Self::Dictionary(c) => c.distinct_values(row_ids, BTreeSet::new()), Self::Dictionary(c) => c.distinct_values(row_ids, BTreeSet::new()),
} }
} }
@ -161,7 +161,7 @@ impl StringEncoding {
/// Returns the row ids that satisfy the provided predicate. /// Returns the row ids that satisfy the provided predicate.
pub fn row_ids_filter(&self, op: &cmp::Operator, value: &str, dst: RowIDs) -> RowIDs { pub fn row_ids_filter(&self, op: &cmp::Operator, value: &str, dst: RowIDs) -> RowIDs {
match &self { match &self {
Self::RLEDictionary(c) => c.row_ids_filter(value, op, dst), Self::RleDictionary(c) => c.row_ids_filter(value, op, dst),
Self::Dictionary(c) => c.row_ids_filter(value, op, dst), Self::Dictionary(c) => c.row_ids_filter(value, op, dst),
} }
} }
@ -171,7 +171,7 @@ impl StringEncoding {
/// ids. /// ids.
pub fn min(&self, row_ids: &[u32]) -> Value<'_> { pub fn min(&self, row_ids: &[u32]) -> Value<'_> {
match &self { match &self {
Self::RLEDictionary(c) => match c.min(row_ids) { Self::RleDictionary(c) => match c.min(row_ids) {
Some(min) => Value::String(min), Some(min) => Value::String(min),
None => Value::Null, None => Value::Null,
}, },
@ -187,7 +187,7 @@ impl StringEncoding {
/// ids. /// ids.
pub fn max(&self, row_ids: &[u32]) -> Value<'_> { pub fn max(&self, row_ids: &[u32]) -> Value<'_> {
match &self { match &self {
Self::RLEDictionary(c) => match c.max(row_ids) { Self::RleDictionary(c) => match c.max(row_ids) {
Some(max) => Value::String(max), Some(max) => Value::String(max),
None => Value::Null, None => Value::Null,
}, },
@ -201,7 +201,7 @@ impl StringEncoding {
/// The number of non-null values at the provided row ids. /// The number of non-null values at the provided row ids.
pub fn count(&self, row_ids: &[u32]) -> u32 { pub fn count(&self, row_ids: &[u32]) -> u32 {
match &self { match &self {
Self::RLEDictionary(c) => c.count(row_ids), Self::RleDictionary(c) => c.count(row_ids),
Self::Dictionary(c) => c.count(row_ids), Self::Dictionary(c) => c.count(row_ids),
} }
} }
@ -209,7 +209,7 @@ impl StringEncoding {
/// Calculate all row ids for each distinct value in the column. /// Calculate all row ids for each distinct value in the column.
pub fn group_row_ids(&self) -> Either<Vec<&RowIDs>, Vec<RowIDs>> { pub fn group_row_ids(&self) -> Either<Vec<&RowIDs>, Vec<RowIDs>> {
match self { match self {
Self::RLEDictionary(enc) => Either::Left(enc.group_row_ids()), Self::RleDictionary(enc) => Either::Left(enc.group_row_ids()),
Self::Dictionary(enc) => Either::Right(enc.group_row_ids()), Self::Dictionary(enc) => Either::Right(enc.group_row_ids()),
} }
} }
@ -219,7 +219,7 @@ impl StringEncoding {
/// TODO(edd): perf - pooling of destination vectors. /// TODO(edd): perf - pooling of destination vectors.
pub fn encoded_values(&self, row_ids: &[u32], dst: Vec<u32>) -> Vec<u32> { pub fn encoded_values(&self, row_ids: &[u32], dst: Vec<u32>) -> Vec<u32> {
match &self { match &self {
Self::RLEDictionary(c) => c.encoded_values(row_ids, dst), Self::RleDictionary(c) => c.encoded_values(row_ids, dst),
Self::Dictionary(c) => c.encoded_values(row_ids, dst), Self::Dictionary(c) => c.encoded_values(row_ids, dst),
} }
} }
@ -229,7 +229,7 @@ impl StringEncoding {
/// TODO(edd): perf - pooling of destination vectors. /// TODO(edd): perf - pooling of destination vectors.
pub fn all_encoded_values(&self, dst: Vec<u32>) -> Vec<u32> { pub fn all_encoded_values(&self, dst: Vec<u32>) -> Vec<u32> {
match &self { match &self {
Self::RLEDictionary(c) => c.all_encoded_values(dst), Self::RleDictionary(c) => c.all_encoded_values(dst),
Self::Dictionary(c) => c.all_encoded_values(dst), Self::Dictionary(c) => c.all_encoded_values(dst),
} }
} }
@ -238,7 +238,7 @@ impl StringEncoding {
impl std::fmt::Display for StringEncoding { impl std::fmt::Display for StringEncoding {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self { match self {
Self::RLEDictionary(data) => write!(f, "{}", data), Self::RleDictionary(data) => write!(f, "{}", data),
Self::Dictionary(data) => write!(f, "{}", data), Self::Dictionary(data) => write!(f, "{}", data),
} }
} }
@ -300,7 +300,7 @@ impl From<arrow::array::StringArray> for StringEncoding {
}; };
match data { match data {
Encoding::RLE(enc) => Self::RLEDictionary(enc), Encoding::RLE(enc) => Self::RleDictionary(enc),
Encoding::Plain(enc) => Self::Dictionary(enc), Encoding::Plain(enc) => Self::Dictionary(enc),
} }
} }
@ -345,7 +345,7 @@ impl From<&[Option<&str>]> for StringEncoding {
}; };
match data { match data {
Encoding::RLE(enc) => Self::RLEDictionary(enc), Encoding::RLE(enc) => Self::RleDictionary(enc),
Encoding::Plain(enc) => Self::Dictionary(enc), Encoding::Plain(enc) => Self::Dictionary(enc),
} }
} }
@ -379,7 +379,7 @@ impl From<&[&str]> for StringEncoding {
data.push_additional(Some(prev.to_string()), count); data.push_additional(Some(prev.to_string()), count);
match data { match data {
Encoding::RLE(enc) => Self::RLEDictionary(enc), Encoding::RLE(enc) => Self::RleDictionary(enc),
Encoding::Plain(enc) => Self::Dictionary(enc), Encoding::Plain(enc) => Self::Dictionary(enc),
} }
} }