fix: resolve lint warnings

This commit is contained in:
Ning Sun
2022-10-18 11:31:43 +08:00
parent 92ab3002c9
commit 788001b4bc
5 changed files with 16 additions and 12 deletions

View File

@@ -366,7 +366,7 @@ impl<'a> ScalarRef<'a> for GeometryValueRef<'a> {
Value::Geometry(value) => value,
_ => unreachable!(),
},
GeometryValueRef::Ref { val } => (*val).clone(),
GeometryValueRef::Ref { val } => **val,
}
}
}

View File

@@ -1,5 +1,3 @@
use crate::types::GeometryType;
/// Unique identifier for logical data type.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum LogicalTypeId {
@@ -46,6 +44,7 @@ impl LogicalTypeId {
#[cfg(any(test, feature = "test"))]
pub fn data_type(&self) -> crate::data_type::ConcreteDataType {
use crate::data_type::ConcreteDataType;
use crate::types::GeometryType;
match self {
LogicalTypeId::Null => ConcreteDataType::null_datatype(),
@@ -68,7 +67,6 @@ impl LogicalTypeId {
LogicalTypeId::List => {
ConcreteDataType::list_datatype(ConcreteDataType::null_datatype())
}
// FIXME(sunng87): check if default type works
LogicalTypeId::Geometry => ConcreteDataType::geometry_datatype(GeometryType::default()),
}
}

View File

@@ -577,7 +577,7 @@ impl<'a> GeometryValueRef<'a> {
fn to_value(self) -> Value {
match self {
GeometryValueRef::Indexed { vector, idx } => vector.get(idx),
GeometryValueRef::Ref { val } => Value::Geometry(val.clone()),
GeometryValueRef::Ref { val } => Value::Geometry(*val),
}
}
}

View File

@@ -134,7 +134,7 @@ impl<'a> Iterator for GeometryVectorIter<'a> {
type Item = Option<GeometryValueRef<'a>>;
fn next(&mut self) -> Option<Self::Item> {
let pos = self.pos;
self.pos = self.pos + 1;
self.pos += 1;
if self.vector.len() <= pos {
return None;
@@ -293,7 +293,7 @@ mod tests {
for i in iter {
assert_eq!(i, vector.get_data(cnt));
cnt = cnt + 1;
cnt += 1;
}
assert_eq!(cnt, vector.len());

View File

@@ -20,9 +20,9 @@ impl PointVector {
}
pub fn slice(&self, offset: usize, length: usize) -> Self {
return Self {
Self {
array: self.array.slice(offset, length),
};
}
}
pub fn get(&self, index: usize) -> Value {
@@ -58,13 +58,19 @@ pub struct PointVectorBuilder {
pub array_y: Float64Vec,
}
impl PointVectorBuilder {
pub fn new() -> Self {
impl Default for PointVectorBuilder {
fn default() -> Self {
Self {
array_x: Float64Vec::new(),
array_y: Float64Vec::new(),
}
}
}
impl PointVectorBuilder {
pub fn new() -> Self {
Self::default()
}
pub fn with_capacity(capacity: usize) -> Self {
Self {
@@ -93,7 +99,7 @@ impl PointVectorBuilder {
Field::new("x", Float64, true),
Field::new("y", Float64, true),
];
let validity = x.validity().map(|validity| validity.clone());
let validity = x.validity().cloned();
let array = StructArray::new(DataType::Struct(fields), vec![x, y], validity);
PointVector { array }