Skip to content

Commit

Permalink
Clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiimk committed Jun 9, 2024
1 parent e64f38c commit c09cc8b
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 85 deletions.
2 changes: 1 addition & 1 deletion benches/perf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ fn bench_write_parquet(batch: &RecordBatch, out_path: &Path) {
None,
)
.unwrap();
writer.write(&batch).unwrap();
writer.write(batch).unwrap();
writer.close().unwrap();
}

Expand Down
38 changes: 19 additions & 19 deletions src/array_digest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ impl<Dig: Digest> ArrayDigestV0<Dig> {
let pos = i * item_size;
self.hasher.update(&slice[pos..pos + item_size]);
} else {
self.hasher.update(&Self::NULL_MARKER);
self.hasher.update(Self::NULL_MARKER);
}
}
}
Expand All @@ -182,17 +182,17 @@ impl<Dig: Digest> ArrayDigestV0<Dig> {
for i in 0..bool_array.len() {
// Safety: boundary check is right above
let value = unsafe { bool_array.value_unchecked(i) };
self.hasher.update(&[value as u8 + 1]);
self.hasher.update([value as u8 + 1]);
}
}
Some(null_bitmap) => {
for i in 0..bool_array.len() {
if null_bitmap.is_valid(i) {
// Safety: boundary check is right above
let value = unsafe { bool_array.value_unchecked(i) };
self.hasher.update(&[value as u8 + 1]);
self.hasher.update([value as u8 + 1]);
} else {
self.hasher.update(&Self::NULL_MARKER);
self.hasher.update(Self::NULL_MARKER);
}
}
}
Expand All @@ -208,18 +208,18 @@ impl<Dig: Digest> ArrayDigestV0<Dig> {
None => {
for i in 0..array.len() {
let s = array.value(i);
self.hasher.update(&(s.len() as u64).to_le_bytes());
self.hasher.update((s.len() as u64).to_le_bytes());
self.hasher.update(s.as_bytes());
}
}
Some(null_bitmap) => {
for i in 0..array.len() {
if null_bitmap.is_valid(i) {
let s = array.value(i);
self.hasher.update(&(s.len() as u64).to_le_bytes());
self.hasher.update((s.len() as u64).to_le_bytes());
self.hasher.update(s.as_bytes());
} else {
self.hasher.update(&Self::NULL_MARKER);
self.hasher.update(Self::NULL_MARKER);
}
}
}
Expand All @@ -235,18 +235,18 @@ impl<Dig: Digest> ArrayDigestV0<Dig> {
None => {
for i in 0..array.len() {
let slice = array.value(i);
self.hasher.update(&(slice.len() as u64).to_le_bytes());
self.hasher.update((slice.len() as u64).to_le_bytes());
self.hasher.update(slice);
}
}
Some(null_bitmap) => {
for i in 0..array.len() {
if null_bitmap.is_valid(i) {
let slice = array.value(i);
self.hasher.update(&(slice.len() as u64).to_le_bytes());
self.hasher.update((slice.len() as u64).to_le_bytes());
self.hasher.update(slice);
} else {
self.hasher.update(&Self::NULL_MARKER);
self.hasher.update(Self::NULL_MARKER);
}
}
}
Expand All @@ -263,18 +263,18 @@ impl<Dig: Digest> ArrayDigestV0<Dig> {
None => {
for i in 0..array.len() {
let slice = array.value(i);
self.hasher.update(&(size as u64).to_le_bytes());
self.hasher.update((size as u64).to_le_bytes());
self.hasher.update(slice);
}
}
Some(null_bitmap) => {
for i in 0..array.len() {
if null_bitmap.is_valid(i) {
let slice = array.value(i);
self.hasher.update(&(size as u64).to_le_bytes());
self.hasher.update((size as u64).to_le_bytes());
self.hasher.update(slice);
} else {
self.hasher.update(&Self::NULL_MARKER);
self.hasher.update(Self::NULL_MARKER);
}
}
}
Expand All @@ -290,18 +290,18 @@ impl<Dig: Digest> ArrayDigestV0<Dig> {
None => {
for i in 0..array.len() {
let sub_array = array.value(i);
self.hasher.update(&(sub_array.len() as u64).to_le_bytes());
self.hasher.update((sub_array.len() as u64).to_le_bytes());
self.update(sub_array.as_ref(), None);
}
}
Some(null_bitmap) => {
for i in 0..array.len() {
if null_bitmap.is_valid(i) {
let sub_array = array.value(i);
self.hasher.update(&(sub_array.len() as u64).to_le_bytes());
self.hasher.update((sub_array.len() as u64).to_le_bytes());
self.update(sub_array.as_ref(), None);
} else {
self.hasher.update(&Self::NULL_MARKER);
self.hasher.update(Self::NULL_MARKER);
}
}
}
Expand All @@ -317,18 +317,18 @@ impl<Dig: Digest> ArrayDigestV0<Dig> {
None => {
for i in 0..array.len() {
let sub_array = array.value(i);
self.hasher.update(&(sub_array.len() as u64).to_le_bytes());
self.hasher.update((sub_array.len() as u64).to_le_bytes());
self.update(sub_array.as_ref(), None);
}
}
Some(null_bitmap) => {
for i in 0..array.len() {
if null_bitmap.is_valid(i) {
let sub_array = array.value(i);
self.hasher.update(&(sub_array.len() as u64).to_le_bytes());
self.hasher.update((sub_array.len() as u64).to_le_bytes());
self.update(sub_array.as_ref(), None);
} else {
self.hasher.update(&Self::NULL_MARKER);
self.hasher.update(Self::NULL_MARKER);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/record_digest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ impl<Dig: Digest> RecordDigest for RecordDigestV0<Dig> {
let mut columns = Vec::new();

Self::walk_nested_fields(schema.fields(), 0, &mut |field, level| {
hasher.update(&(field.name().len() as u64).to_le_bytes());
hasher.update((field.name().len() as u64).to_le_bytes());
hasher.update(field.name().as_bytes());
hasher.update(&(level as u64).to_le_bytes());
hasher.update((level as u64).to_le_bytes());

match field.data_type() {
DataType::Struct(_) => (),
Expand Down Expand Up @@ -68,7 +68,7 @@ impl<Dig: Digest> RecordDigest for RecordDigestV0<Dig> {
}

impl<Dig: Digest> RecordDigestV0<Dig> {
fn walk_nested_fields<'a>(fields: &Fields, level: usize, fun: &mut impl FnMut(&Field, usize)) {
fn walk_nested_fields(fields: &Fields, level: usize, fun: &mut impl FnMut(&Field, usize)) {
for field in fields {
match field.data_type() {
DataType::Struct(nested_fields) => {
Expand Down Expand Up @@ -104,7 +104,7 @@ impl<Dig: Digest> RecordDigestV0<Dig> {
);
}
}
_ => fun(array, parent_null_bitmap.clone()),
_ => fun(array, parent_null_bitmap),
}
}
}
Expand Down
122 changes: 61 additions & 61 deletions src/schema_digest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ pub(crate) enum TypeID {

#[repr(u16)]
pub(crate) enum DateUnitID {
DAY = 0,
MILLISECOND = 1,
Day = 0,
Millisecond = 1,
}

/////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -64,123 +64,123 @@ impl From<&TimeUnit> for TimeUnitID {
pub(crate) fn hash_data_type<Dig: Digest>(data_type: &DataType, hasher: &mut Dig) {
match data_type {
DataType::Null => {
hasher.update(&(TypeID::Null as u16).to_le_bytes());
hasher.update((TypeID::Null as u16).to_le_bytes());
}
DataType::Boolean => {
hasher.update(&(TypeID::Bool as u16).to_le_bytes());
hasher.update((TypeID::Bool as u16).to_le_bytes());
}
DataType::Int8 => {
hasher.update(&(TypeID::Int as u16).to_le_bytes());
hasher.update(&1u8.to_le_bytes());
hasher.update(&8u64.to_le_bytes());
hasher.update((TypeID::Int as u16).to_le_bytes());
hasher.update(1u8.to_le_bytes());
hasher.update(8u64.to_le_bytes());
}
DataType::Int16 => {
hasher.update(&(TypeID::Int as u16).to_le_bytes());
hasher.update(&1u8.to_le_bytes());
hasher.update(&16u64.to_le_bytes());
hasher.update((TypeID::Int as u16).to_le_bytes());
hasher.update(1u8.to_le_bytes());
hasher.update(16u64.to_le_bytes());
}
DataType::Int32 => {
hasher.update(&(TypeID::Int as u16).to_le_bytes());
hasher.update(&1u8.to_le_bytes());
hasher.update(&32u64.to_le_bytes());
hasher.update((TypeID::Int as u16).to_le_bytes());
hasher.update(1u8.to_le_bytes());
hasher.update(32u64.to_le_bytes());
}
DataType::Int64 => {
hasher.update(&(TypeID::Int as u16).to_le_bytes());
hasher.update(&1u8.to_le_bytes());
hasher.update(&64u64.to_le_bytes());
hasher.update((TypeID::Int as u16).to_le_bytes());
hasher.update(1u8.to_le_bytes());
hasher.update(64u64.to_le_bytes());
}
DataType::UInt8 => {
hasher.update(&(TypeID::Int as u16).to_le_bytes());
hasher.update(&0u8.to_le_bytes());
hasher.update(&8u64.to_le_bytes());
hasher.update((TypeID::Int as u16).to_le_bytes());
hasher.update(0u8.to_le_bytes());
hasher.update(8u64.to_le_bytes());
}
DataType::UInt16 => {
hasher.update(&(TypeID::Int as u16).to_le_bytes());
hasher.update(&0u8.to_le_bytes());
hasher.update(&16u64.to_le_bytes());
hasher.update((TypeID::Int as u16).to_le_bytes());
hasher.update(0u8.to_le_bytes());
hasher.update(16u64.to_le_bytes());
}
DataType::UInt32 => {
hasher.update(&(TypeID::Int as u16).to_le_bytes());
hasher.update(&0u8.to_le_bytes());
hasher.update(&32u64.to_le_bytes());
hasher.update((TypeID::Int as u16).to_le_bytes());
hasher.update(0u8.to_le_bytes());
hasher.update(32u64.to_le_bytes());
}
DataType::UInt64 => {
hasher.update(&(TypeID::Int as u16).to_le_bytes());
hasher.update(&0u8.to_le_bytes());
hasher.update(&64u64.to_le_bytes());
hasher.update((TypeID::Int as u16).to_le_bytes());
hasher.update(0u8.to_le_bytes());
hasher.update(64u64.to_le_bytes());
}
DataType::Float16 => {
hasher.update(&(TypeID::FloatingPoint as u16).to_le_bytes());
hasher.update(&16u64.to_le_bytes());
hasher.update((TypeID::FloatingPoint as u16).to_le_bytes());
hasher.update(16u64.to_le_bytes());
}
DataType::Float32 => {
hasher.update(&(TypeID::FloatingPoint as u16).to_le_bytes());
hasher.update(&32u64.to_le_bytes());
hasher.update((TypeID::FloatingPoint as u16).to_le_bytes());
hasher.update(32u64.to_le_bytes());
}
DataType::Float64 => {
hasher.update(&(TypeID::FloatingPoint as u16).to_le_bytes());
hasher.update(&64u64.to_le_bytes());
hasher.update((TypeID::FloatingPoint as u16).to_le_bytes());
hasher.update(64u64.to_le_bytes());
}
DataType::Timestamp(time_unit, time_zone) => {
hasher.update(&(TypeID::Timestamp as u16).to_le_bytes());
hasher.update(&(TimeUnitID::from(time_unit) as u16).to_le_bytes());
hasher.update((TypeID::Timestamp as u16).to_le_bytes());
hasher.update((TimeUnitID::from(time_unit) as u16).to_le_bytes());
match time_zone {
None => hasher.update(&[0u8]),
None => hasher.update([0u8]),
Some(tz) => {
hasher.update(&(tz.len() as u64).to_le_bytes());
hasher.update((tz.len() as u64).to_le_bytes());
hasher.update(tz.as_bytes());
}
}
}
DataType::Date32 => {
hasher.update(&(TypeID::Date as u16).to_le_bytes());
hasher.update(&32u64.to_le_bytes());
hasher.update(&(DateUnitID::DAY as u16).to_le_bytes());
hasher.update((TypeID::Date as u16).to_le_bytes());
hasher.update(32u64.to_le_bytes());
hasher.update((DateUnitID::Day as u16).to_le_bytes());
}
DataType::Date64 => {
hasher.update(&(TypeID::Date as u16).to_le_bytes());
hasher.update(&64u64.to_le_bytes());
hasher.update(&(DateUnitID::MILLISECOND as u16).to_le_bytes());
hasher.update((TypeID::Date as u16).to_le_bytes());
hasher.update(64u64.to_le_bytes());
hasher.update((DateUnitID::Millisecond as u16).to_le_bytes());
}
DataType::Time32(time_unit) => {
hasher.update(&(TypeID::Time as u16).to_le_bytes());
hasher.update(&32u64.to_le_bytes());
hasher.update(&(TimeUnitID::from(time_unit) as u16).to_le_bytes());
hasher.update((TypeID::Time as u16).to_le_bytes());
hasher.update(32u64.to_le_bytes());
hasher.update((TimeUnitID::from(time_unit) as u16).to_le_bytes());
}
DataType::Time64(time_unit) => {
hasher.update(&(TypeID::Time as u16).to_le_bytes());
hasher.update(&64u64.to_le_bytes());
hasher.update(&(TimeUnitID::from(time_unit) as u16).to_le_bytes());
hasher.update((TypeID::Time as u16).to_le_bytes());
hasher.update(64u64.to_le_bytes());
hasher.update((TimeUnitID::from(time_unit) as u16).to_le_bytes());
}
DataType::Duration(_) => unimplemented!(),
DataType::Interval(_) => unimplemented!(),
DataType::Binary | DataType::FixedSizeBinary(_) | DataType::LargeBinary => {
hasher.update(&(TypeID::Binary as u16).to_le_bytes());
hasher.update((TypeID::Binary as u16).to_le_bytes());
}
DataType::BinaryView => unimplemented!(),
DataType::Utf8 | DataType::LargeUtf8 => {
hasher.update(&(TypeID::Utf8 as u16).to_le_bytes());
hasher.update((TypeID::Utf8 as u16).to_le_bytes());
}
DataType::Utf8View => unimplemented!(),
DataType::List(field) | DataType::FixedSizeList(field, _) | DataType::LargeList(field) => {
hasher.update(&(TypeID::List as u16).to_le_bytes());
hasher.update((TypeID::List as u16).to_le_bytes());
hash_data_type(field.data_type(), hasher);
}
DataType::ListView(_) | DataType::LargeListView(_) => unimplemented!(),
DataType::Struct(_) => unimplemented!(),
DataType::Union(_, _) => unimplemented!(),
DataType::Dictionary(..) => unimplemented!(),
DataType::Decimal128(p, s) => {
hasher.update(&(TypeID::Decimal as u16).to_le_bytes());
hasher.update(&128u64.to_le_bytes());
hasher.update(&(*p as u64).to_le_bytes());
hasher.update(&(*s as u64).to_le_bytes());
hasher.update((TypeID::Decimal as u16).to_le_bytes());
hasher.update(128u64.to_le_bytes());
hasher.update((*p as u64).to_le_bytes());
hasher.update((*s as u64).to_le_bytes());
}
DataType::Decimal256(p, s) => {
hasher.update(&(TypeID::Decimal as u16).to_le_bytes());
hasher.update(&256u64.to_le_bytes());
hasher.update(&(*p as u64).to_le_bytes());
hasher.update(&(*s as u64).to_le_bytes());
hasher.update((TypeID::Decimal as u16).to_le_bytes());
hasher.update(256u64.to_le_bytes());
hasher.update((*p as u64).to_le_bytes());
hasher.update((*s as u64).to_le_bytes());
}
DataType::Map(..) => unimplemented!(),
DataType::RunEndEncoded(..) => unimplemented!(),
Expand Down

0 comments on commit c09cc8b

Please sign in to comment.