Skip to content

Commit

Permalink
Merge pull request #1606 from zhyass/refactor_datavalues
Browse files Browse the repository at this point in the history
Remove DataType::Utf8
  • Loading branch information
databend-bot authored Sep 2, 2021
2 parents cbd8a3c + 7fc1d54 commit 6822281
Show file tree
Hide file tree
Showing 139 changed files with 842 additions and 1,249 deletions.
35 changes: 24 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions common/arrow/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ simd = ["arrow/simd"]
# Workspace dependencies

# Github dependencies
arrow = { package = "arrow2", git="https://github.com/datafuse-extras/arrow2", rev = "7765067" }
arrow-flight = { git="https://github.com/datafuse-extras/arrow2", rev = "7765067" }
arrow = { package = "arrow2", git="https://github.com/zhyass/arrow2", rev = "23682f0" }
arrow-flight = { git="https://github.com/zhyass/arrow2", rev = "23682f0" }
parquet = {package = "parquet2", git = "https://github.com/datafuse-extras/parquet2", rev = "d28330f"}
# Crates.io dependencies

Expand Down
2 changes: 1 addition & 1 deletion common/datablocks/src/kernels/data_block_concat_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use crate::*;
fn test_data_block_concat() -> Result<()> {
let schema = DataSchemaRefExt::create(vec![
DataField::new("a", DataType::Int64, false),
DataField::new("b", DataType::Utf8, false),
DataField::new("b", DataType::String, false),
]);

let blocks = vec![
Expand Down
4 changes: 2 additions & 2 deletions common/datablocks/src/kernels/data_block_group_by_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ impl HashMethodKind {
}
pub fn data_type(&self) -> DataType {
match self {
HashMethodKind::Serializer(_) => DataType::Binary,
HashMethodKind::Serializer(_) => DataType::String,
HashMethodKind::KeysU8(_) => DataType::UInt8,
HashMethodKind::KeysU16(_) => DataType::UInt16,
HashMethodKind::KeysU32(_) => DataType::UInt32,
Expand All @@ -155,7 +155,7 @@ pub struct HashMethodSerializer {}

impl HashMethodSerializer {
#[inline]
pub fn get_key(&self, array: &DFBinaryArray, row: usize) -> Vec<u8> {
pub fn get_key(&self, array: &DFStringArray, row: usize) -> Vec<u8> {
let v = array.inner().value(row);
v.to_owned()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fn test_data_block_group_by_hash() -> Result<()> {
DataField::new("a", DataType::Int8, false),
DataField::new("b", DataType::Int8, false),
DataField::new("c", DataType::Int8, false),
DataField::new("x", DataType::Utf8, false),
DataField::new("x", DataType::String, false),
]);

let block = DataBlock::create_by_array(schema.clone(), vec![
Expand Down
2 changes: 1 addition & 1 deletion common/datablocks/src/kernels/data_block_group_by_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use crate::*;
fn test_data_block_group_by() -> Result<()> {
let schema = DataSchemaRefExt::create(vec![
DataField::new("a", DataType::Int8, false),
DataField::new("b", DataType::Utf8, false),
DataField::new("b", DataType::String, false),
]);

let block = DataBlock::create_by_array(schema.clone(), vec![
Expand Down
4 changes: 2 additions & 2 deletions common/datablocks/src/kernels/data_block_sort_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use crate::*;
fn test_data_block_sort() -> Result<()> {
let schema = DataSchemaRefExt::create(vec![
DataField::new("a", DataType::Int64, false),
DataField::new("b", DataType::Utf8, false),
DataField::new("b", DataType::String, false),
]);

let raw = DataBlock::create_by_array(schema.clone(), vec![
Expand Down Expand Up @@ -77,7 +77,7 @@ fn test_data_block_sort() -> Result<()> {
fn test_data_block_merge_sort() -> Result<()> {
let schema = DataSchemaRefExt::create(vec![
DataField::new("a", DataType::Int64, false),
DataField::new("b", DataType::Utf8, false),
DataField::new("b", DataType::String, false),
]);

let raw1 = DataBlock::create_by_array(schema.clone(), vec![
Expand Down
2 changes: 1 addition & 1 deletion common/datablocks/src/kernels/data_block_take_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use crate::*;
fn test_data_block_take() -> Result<()> {
let schema = DataSchemaRefExt::create(vec![
DataField::new("a", DataType::Int64, false),
DataField::new("b", DataType::Utf8, false),
DataField::new("b", DataType::String, false),
]);

let raw = DataBlock::create_by_array(schema.clone(), vec![
Expand Down
27 changes: 13 additions & 14 deletions common/datavalues/src/arrays/arithmetic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,24 +312,23 @@ where
}
}

fn concat_strings(l: &str, r: &str) -> String {
// fastest way to concat strings according to https://github.com/hoodie/concatenation_benchmarks-rs
let mut s = String::with_capacity(l.len() + r.len());
s.push_str(l);
s.push_str(r);
fn concat_strings(l: &[u8], r: &[u8]) -> Vec<u8> {
let mut s = Vec::with_capacity(l.len() + r.len());
s.extend_from_slice(l);
s.extend_from_slice(r);
s
}

impl Add for &DFUtf8Array {
type Output = Result<DFUtf8Array>;
impl Add for &DFStringArray {
type Output = Result<DFStringArray>;

fn add(self, rhs: Self) -> Self::Output {
// broadcasting path
if rhs.len() == 1 {
let rhs = rhs.get(0);
return match rhs {
Some(rhs) => self.add(rhs),
None => Ok(DFUtf8Array::full_null(self.len())),
None => Ok(DFStringArray::full_null(self.len())),
};
}

Expand All @@ -346,18 +345,18 @@ impl Add for &DFUtf8Array {
}
}

impl Add for DFUtf8Array {
type Output = Result<DFUtf8Array>;
impl Add for DFStringArray {
type Output = Result<DFStringArray>;

fn add(self, rhs: Self) -> Self::Output {
(&self).add(&rhs)
}
}

impl Add<&str> for &DFUtf8Array {
type Output = Result<DFUtf8Array>;
impl Add<&[u8]> for &DFStringArray {
type Output = Result<DFStringArray>;

fn add(self, rhs: &str) -> Self::Output {
fn add(self, rhs: &[u8]) -> Self::Output {
Ok(match self.null_count() {
0 => self
.into_no_null_iter()
Expand Down Expand Up @@ -401,5 +400,5 @@ where
}

impl Pow for DFBooleanArray {}
impl Pow for DFUtf8Array {}
impl Pow for DFStringArray {}
impl Pow for DFListArray {}
44 changes: 0 additions & 44 deletions common/datavalues/src/arrays/binary/builder.rs

This file was deleted.

Loading

0 comments on commit 6822281

Please sign in to comment.