fix:fix some error

This commit is contained in:
liangxingjian
2022-10-10 15:23:38 +08:00
parent 8a91e26020
commit c0893ac19b
5 changed files with 38 additions and 210 deletions

1
Cargo.lock generated
View File

@@ -2084,6 +2084,7 @@ dependencies = [
"approx",
"num-traits",
"rstar",
"serde",
]
[[package]]

View File

@@ -20,7 +20,7 @@ paste = "1.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
snafu = { version = "0.7", features = ["backtraces"] }
geo = { version = "0.23.0", features = ["serde"] }
geo = { version = "0.23.0", features = ["use-serde"] }
[dependencies.arrow]
package = "arrow2"

View File

@@ -308,14 +308,14 @@ impl Ord for ListValue {
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize,)]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Eq)]
pub enum GeometryValue {
Point(f64, f64),
Point(geo::Point<OrderedF64>),
}
impl Default for GeometryValue {
fn default() -> Self {
GeometryValue::Point(0.0, 0.0)
todo!()
}
}
/// Reference to [Value].

View File

@@ -1,5 +1,7 @@
use arrow::array::Array;
use snafu::ensure;
use self::point::PointVector;
use super::{MutableVector, Vector};
use crate::{
error,
@@ -10,7 +12,9 @@ use crate::{
mod point;
#[derive(Debug, Clone, PartialEq)]
pub enum GeometryVector {}
pub enum GeometryVector {
PointVector(PointVector),
}
impl Vector for GeometryVector {
fn data_type(&self) -> crate::data_type::ConcreteDataType {
@@ -42,11 +46,15 @@ impl Vector for GeometryVector {
}
fn memory_size(&self) -> usize {
todo!()
match self {
GeometryVector::PointVector(point_vector) => point_vector.memory_size(),
}
}
fn is_null(&self, row: usize) -> bool {
todo!()
match self {
GeometryVector::PointVector(point_vector) => point_vector.array.is_null(row),
}
}
fn slice(&self, offset: usize, length: usize) -> super::VectorRef {
@@ -60,37 +68,6 @@ impl Vector for GeometryVector {
fn get_ref(&self, index: usize) -> crate::value::ValueRef {
todo!()
}
fn is_empty(&self) -> bool {
self.len() == 0
}
fn null_count(&self) -> usize {
match self.validity() {
super::Validity::Slots(bitmap) => bitmap.null_count(),
super::Validity::AllValid => 0,
super::Validity::AllNull => self.len(),
}
}
fn is_const(&self) -> bool {
false
}
fn only_null(&self) -> bool {
self.null_count() == self.len()
}
fn try_get(&self, index: usize) -> crate::Result<crate::value::Value> {
ensure!(
index < self.len(),
error::BadArrayAccessSnafu {
index,
size: self.len()
}
);
Ok(self.get(index))
}
}
impl ScalarVector for GeometryVector {
@@ -122,7 +99,9 @@ impl<'a> Iterator for GeometryVectorIter<'a> {
}
}
pub enum GeometryVectorBuilder {}
pub enum GeometryVectorBuilder {
}
impl MutableVector for GeometryVectorBuilder {
fn data_type(&self) -> crate::data_type::ConcreteDataType {

View File

@@ -1,174 +1,22 @@
// use arrow::array::{FixedSizeListArray, MutableFixedSizeListArray};
// use geo::Point;
use arrow::array::{Array, FixedSizeListArray, ListArray, MutableFixedSizeListArray, StructArray};
use arrow::datatypes::DataType::List;
use geo::Point;
// use crate::{
// prelude::{ScalarVector, ScalarVectorBuilder, Vector},
// vectors::MutableVector,
// };
// #[derive(Debug, Clone, PartialEq)]
// struct PointVector {
// array: FixedSizeListArray,
// }
use crate::{
prelude::{ScalarVector, ScalarVectorBuilder, Vector},
vectors::MutableVector,
};
#[derive(Debug, Clone, PartialEq)]
pub struct PointVector {
pub array: StructArray,
}
// impl Vector for PointVector {
// fn data_type(&self) -> crate::data_type::ConcreteDataType {
// todo!()
// }
impl PointVector {
pub fn memory_size(&self) -> usize {
2 * self.array.len() * std::mem::size_of::<f64>()
}
}
// fn vector_type_name(&self) -> String {
// todo!()
// }
// fn as_any(&self) -> &dyn std::any::Any {
// todo!()
// }
// fn len(&self) -> usize {
// todo!()
// }
// fn to_arrow_array(&self) -> arrow::array::ArrayRef {
// todo!()
// }
// fn to_boxed_arrow_array(&self) -> Box<dyn arrow::array::Array> {
// todo!()
// }
// fn validity(&self) -> crate::vectors::Validity {
// todo!()
// }
// fn memory_size(&self) -> usize {
// todo!()
// }
// fn is_null(&self, row: usize) -> bool {
// todo!()
// }
// fn slice(&self, offset: usize, length: usize) -> crate::vectors::VectorRef {
// todo!()
// }
// fn get(&self, index: usize) -> crate::value::Value {
// todo!()
// }
// fn get_ref(&self, index: usize) -> crate::value::ValueRef {
// todo!()
// }
// fn is_empty(&self) -> bool {
// self.len() == 0
// }
// fn null_count(&self) -> usize {
// match self.validity() {
// crate::vectors::Validity::Slots(bitmap) => bitmap.null_count(),
// crate::vectors::Validity::AllValid => 0,
// crate::vectors::Validity::AllNull => self.len(),
// }
// }
// fn is_const(&self) -> bool {
// false
// }
// fn only_null(&self) -> bool {
// self.null_count() == self.len()
// }
// fn try_get(&self, index: usize) -> crate::Result<crate::value::Value> {
// ensure!(
// index < self.len(),
// error::BadArrayAccessSnafu {
// index,
// size: self.len()
// }
// );
// Ok(self.get(index))
// }
// }
// impl ScalarVector for PointVector {
// type OwnedItem;
// type RefItem<'a>
// where
// Self: 'a;
// type Iter<'a>
// where
// Self: 'a;
// type Builder;
// fn get_data(&self, idx: usize) -> Option<Self::RefItem<'_>> {
// todo!()
// }
// fn iter_data(&self) -> Self::Iter<'_> {
// todo!()
// }
// fn from_slice(data: &[Self::RefItem<'_>]) -> Self {
// let mut builder = Self::Builder::with_capacity(data.len());
// for item in data {
// builder.push(Some(*item));
// }
// builder.finish()
// }
// fn from_iterator<'a>(it: impl Iterator<Item = Self::RefItem<'a>>) -> Self {
// let mut builder = Self::Builder::with_capacity(get_iter_capacity(&it));
// for item in it {
// builder.push(Some(item));
// }
// builder.finish()
// }
// fn from_owned_iterator(it: impl Iterator<Item = Option<Self::OwnedItem>>) -> Self {
// let mut builder = Self::Builder::with_capacity(get_iter_capacity(&it));
// for item in it {
// match item {
// Some(item) => builder.push(Some(item.as_scalar_ref())),
// None => builder.push(None),
// }
// }
// builder.finish()
// }
// fn from_vec<I: Into<Self::OwnedItem>>(values: Vec<I>) -> Self {
// let it = values.into_iter();
// let mut builder = Self::Builder::with_capacity(get_iter_capacity(&it));
// for item in it {
// builder.push(Some(item.into().as_scalar_ref()));
// }
// builder.finish()
// }
// }
// struct PointVectorBuilder {
// buffer: MutableFixedSizeListArray<f64>,
// }
// impl MutableVector for PointVectorBuilder {}
// impl ScalarVectorBuilder for PointVectorBuilder {
// type VectorType = PointVector;
// fn with_capacity(capacity: usize) -> Self {
// todo!()
// }
// fn push(
// &mut self,
// value: Option<<Self::VectorType as crate::prelude::ScalarVector>::RefItem<'_>>,
// ) {
// }
// fn finish(&mut self) -> Self::VectorType {
// todo!()
// }
// }
pub struct PointVectorBuilder {
//pub array: MutableFixedSizeListArray,
}