Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove Uint256 functionality and related code #9073

Merged
merged 1 commit into from
Apr 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion proto/data.proto
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ enum ArrayType {
JSONB = 16;
SERIAL = 17;
INT256 = 18;
UINT256 = 19;
}

message Array {
Expand Down
1 change: 0 additions & 1 deletion src/common/src/array/arrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,6 @@ impl From<&ListArray> for arrow_array::ListArray {
|b, v| b.append_option(v),
),
ArrayImpl::Int256(_a) => todo!(),
ArrayImpl::Uint256(_a) => todo!(),
ArrayImpl::Bool(a) => {
build(array, a, BooleanBuilder::with_capacity(a.len()), |b, v| {
b.append_option(v)
Expand Down
12 changes: 1 addition & 11 deletions src/common/src/array/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ pub use utf8_array::*;
pub use vis::{Vis, VisRef};

pub use self::error::ArrayError;
pub use crate::array::num256_array::{
Int256Array, Int256ArrayBuilder, Uint256Array, Uint256ArrayBuilder,
};
pub use crate::array::num256_array::{Int256Array, Int256ArrayBuilder};
use crate::buffer::Bitmap;
use crate::collection::estimate_size::EstimateSize;
use crate::types::*;
Expand Down Expand Up @@ -346,7 +344,6 @@ macro_rules! for_all_variants {
{ Int32, int32, I32Array, I32ArrayBuilder },
{ Int64, int64, I64Array, I64ArrayBuilder },
{ Int256, int256, Int256Array, Int256ArrayBuilder },
{ Uint256, uint256, Uint256Array, Uint256ArrayBuilder },
{ Float32, float32, F32Array, F32ArrayBuilder },
{ Float64, float64, F64Array, F64ArrayBuilder },
{ Utf8, utf8, Utf8Array, Utf8ArrayBuilder },
Expand Down Expand Up @@ -390,12 +387,6 @@ impl From<Int256Array> for ArrayImpl {
}
}

impl From<Uint256Array> for ArrayImpl {
fn from(arr: Uint256Array) -> Self {
Self::Uint256(arr)
}
}

impl From<BoolArray> for ArrayImpl {
fn from(arr: BoolArray) -> Self {
Self::Bool(arr)
Expand Down Expand Up @@ -731,7 +722,6 @@ impl ArrayImpl {
read_string_array::<BytesArrayBuilder, BytesValueReader>(array, cardinality)?
}
PbArrayType::Int256 => Int256Array::from_protobuf(array, cardinality)?,
PbArrayType::Uint256 => Uint256Array::from_protobuf(array, cardinality)?,
};
Ok(array)
}
Expand Down
30 changes: 2 additions & 28 deletions src/common/src/array/num256_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
use std::io::{Cursor, Read};
use std::mem::size_of;

use ethnum::{I256, U256};
use ethnum::I256;
use risingwave_pb::common::buffer::CompressionType;
use risingwave_pb::common::Buffer;
use risingwave_pb::data::PbArray;

use crate::array::{Array, ArrayBuilder, ArrayImpl, ArrayResult};
use crate::buffer::{Bitmap, BitmapBuilder};
use crate::collection::estimate_size::EstimateSize;
use crate::types::num256::{Int256, Int256Ref, Uint256, Uint256Ref};
use crate::types::num256::{Int256, Int256Ref};
use crate::types::Scalar;

#[derive(Debug)]
Expand All @@ -38,18 +38,6 @@ pub struct Int256Array {
data: Vec<I256>,
}

#[derive(Debug)]
pub struct Uint256ArrayBuilder {
bitmap: BitmapBuilder,
data: Vec<U256>,
}

#[derive(Debug, Clone)]
pub struct Uint256Array {
bitmap: Bitmap,
data: Vec<U256>,
}

#[rustfmt::skip]
macro_rules! impl_array_for_num256 {
(
Expand Down Expand Up @@ -191,14 +179,6 @@ macro_rules! impl_array_for_num256 {
};
}

impl_array_for_num256!(
Uint256Array,
Uint256ArrayBuilder,
Uint256,
Uint256Ref<'a>,
Uint256
);

impl_array_for_num256!(
Int256Array,
Int256ArrayBuilder,
Expand All @@ -207,12 +187,6 @@ impl_array_for_num256!(
Int256
);

impl EstimateSize for Uint256Array {
fn estimated_heap_size(&self) -> usize {
self.bitmap.estimated_heap_size() + self.data.capacity() * size_of::<U256>()
}
}

impl EstimateSize for Int256Array {
fn estimated_heap_size(&self) -> usize {
self.bitmap.estimated_heap_size() + self.data.capacity() * size_of::<I256>()
Expand Down
14 changes: 1 addition & 13 deletions src/common/src/hash/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use crate::array::{
};
use crate::collection::estimate_size::EstimateSize;
use crate::row::{OwnedRow, RowDeserializer};
use crate::types::num256::{Int256Ref, Uint256Ref};
use crate::types::num256::Int256Ref;
use crate::types::{DataType, Date, Decimal, ScalarRef, Time, Timestamp, F32, F64};
use crate::util::hash_util::Crc32FastBuilder;
use crate::util::iter_util::ZipEqFast;
Expand Down Expand Up @@ -431,18 +431,6 @@ impl<'a> HashKeySerDe<'a> for Int256Ref<'a> {
}
}

impl<'a> HashKeySerDe<'a> for Uint256Ref<'a> {
type S = [u8; 32];

fn serialize(self) -> Self::S {
unimplemented!("HashKeySerDe cannot be implemented for non-primitive types")
}

fn deserialize<R: Read>(_source: &mut R) -> Self {
unimplemented!("HashKeySerDe cannot be implemented for non-primitive types")
}
}

/// Same as str.
impl<'a> HashKeySerDe<'a> for &'a [u8] {
type S = Vec<u8>;
Expand Down
10 changes: 1 addition & 9 deletions src/common/src/test_utils/rand_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use rand::{Rng, SeedableRng};

use crate::array::serial_array::Serial;
use crate::array::{Array, ArrayBuilder, ArrayRef, JsonbVal, ListValue, StructValue};
use crate::types::num256::{Int256, Uint256};
use crate::types::num256::Int256;
use crate::types::{Date, Decimal, Interval, NativeType, Scalar, Time, Timestamp};

pub trait RandValue {
Expand Down Expand Up @@ -127,14 +127,6 @@ impl RandValue for Int256 {
}
}

impl RandValue for Uint256 {
fn rand_value<R: Rng>(rand: &mut R) -> Self {
let mut bytes = [0u8; 32];
rand.fill_bytes(&mut bytes);
Uint256::from_ne_bytes(bytes)
}
}

impl RandValue for JsonbVal {
fn rand_value<R: rand::Rng>(_rand: &mut R) -> Self {
JsonbVal::dummy()
Expand Down
4 changes: 1 addition & 3 deletions src/common/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ use crate::array::{
StructValue,
};
use crate::error::Result as RwResult;
use crate::types::num256::{Int256, Int256Ref, Uint256, Uint256Ref};
use crate::types::num256::{Int256, Int256Ref};

pub type F32 = ordered_float::OrderedFloat<f32>;
pub type F64 = ordered_float::OrderedFloat<f64>;
Expand Down Expand Up @@ -502,7 +502,6 @@ macro_rules! for_all_scalar_variants {
{ Int32, int32, i32, i32 },
{ Int64, int64, i64, i64 },
{ Int256, int256, Int256, Int256Ref<'scalar> },
{ Uint256, uint256, Uint256, Uint256Ref<'scalar> },
{ Serial, serial, Serial, Serial },
{ Float32, float32, F32, F32 },
{ Float64, float64, F64, F64 },
Expand Down Expand Up @@ -1034,7 +1033,6 @@ impl ScalarRefImpl<'_> {
Self::Int32(v) => v.serialize(ser)?,
Self::Int64(v) => v.serialize(ser)?,
Self::Int256(v) => v.serialize(ser)?,
Self::Uint256(v) => v.serialize(ser)?,
Self::Serial(v) => v.serialize(ser)?,
Self::Float32(v) => v.serialize(ser)?,
Self::Float64(v) => v.serialize(ser)?,
Expand Down
8 changes: 1 addition & 7 deletions src/common/src/types/num256.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use std::hash::Hasher;
use std::mem;

use bytes::Bytes;
use ethnum::{I256, U256};
use ethnum::I256;
use postgres_types::{ToSql, Type};
use risingwave_pb::data::ArrayType;
use serde::{Serialize, Serializer};
Expand All @@ -27,11 +27,6 @@ use crate::array::ArrayResult;
use crate::types::to_binary::ToBinary;
use crate::types::{to_text, DataType, Scalar, ScalarRef};

#[derive(Debug, Clone, PartialEq, Eq, Ord, PartialOrd, Default, Hash)]
pub struct Uint256(Box<U256>);
#[derive(Debug, Copy, Clone, PartialEq, Eq, Ord, PartialOrd)]
pub struct Uint256Ref<'a>(pub &'a U256);

#[derive(Debug, Clone, PartialEq, Eq, Ord, PartialOrd, Default, Hash)]
pub struct Int256(Box<I256>);
#[derive(Debug, Copy, Clone, PartialEq, Eq, Ord, PartialOrd)]
Expand Down Expand Up @@ -141,5 +136,4 @@ macro_rules! impl_common_for_num256 {
};
}

impl_common_for_num256!(Uint256, Uint256Ref<'a>, U256, Uint256);
impl_common_for_num256!(Int256, Int256Ref<'a>, I256, Int256);
1 change: 0 additions & 1 deletion src/common/src/types/to_binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ impl ToBinary for ScalarRefImpl<'_> {
ScalarRefImpl::Int32(v) => v.to_binary_with_type(ty),
ScalarRefImpl::Int64(v) => v.to_binary_with_type(ty),
ScalarRefImpl::Int256(v) => v.to_binary_with_type(ty),
ScalarRefImpl::Uint256(v) => v.to_binary_with_type(ty),
ScalarRefImpl::Serial(v) => v.to_binary_with_type(ty),
ScalarRefImpl::Float32(v) => v.to_binary_with_type(ty),
ScalarRefImpl::Float64(v) => v.to_binary_with_type(ty),
Expand Down
2 changes: 0 additions & 2 deletions src/common/src/util/value_encoding/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ fn serialize_scalar(value: ScalarRefImpl<'_>, buf: &mut impl BufMut) {
ScalarRefImpl::Int32(v) => buf.put_i32_le(v),
ScalarRefImpl::Int64(v) => buf.put_i64_le(v),
ScalarRefImpl::Int256(v) => buf.put_slice(&v.to_le_bytes()),
ScalarRefImpl::Uint256(v) => buf.put_slice(&v.to_le_bytes()),
ScalarRefImpl::Serial(v) => buf.put_i64_le(v.into_inner()),
ScalarRefImpl::Float32(v) => buf.put_f32_le(v.into_inner()),
ScalarRefImpl::Float64(v) => buf.put_f64_le(v.into_inner()),
Expand Down Expand Up @@ -241,7 +240,6 @@ fn estimate_serialize_scalar_size(value: ScalarRefImpl<'_>) -> usize {
ScalarRefImpl::Int32(_) => 4,
ScalarRefImpl::Int64(_) => 8,
ScalarRefImpl::Int256(_) => 32,
ScalarRefImpl::Uint256(_) => 32,
ScalarRefImpl::Serial(_) => 8,
ScalarRefImpl::Float32(_) => 4,
ScalarRefImpl::Float64(_) => 8,
Expand Down