You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by uw...@apache.org on 2018/05/21 12:13:07 UTC
[arrow] branch master updated: ARROW-2615: [Rust] Post refactor
cleanup
This is an automated email from the ASF dual-hosted git repository.
uwe pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/master by this push:
new 6132fd3 ARROW-2615: [Rust] Post refactor cleanup
6132fd3 is described below
commit 6132fd387bc4adb15eea05ad5567e03d63e16e26
Author: Andy Grove <an...@gmail.com>
AuthorDate: Mon May 21 14:12:54 2018 +0200
ARROW-2615: [Rust] Post refactor cleanup
Just a couple of trivial changes that got missed in the refactor:
- Derive Eq trait for DataType and Field (because I rely on that as a user of this library)
- ArrowPrimitiveType should NOT be implemented for strings
Author: Andy Grove <an...@gmail.com>
Closes #2070 from andygrove/post_refactor_cleanup and squashes the following commits:
6b245a4e <Andy Grove> add accessor methods to ListArray
3289e3bc <Andy Grove> Update examples
236fde8e <Andy Grove> Minor post-refactor cleanup
82765f93 <Andy Grove> Merge remote-tracking branch 'upstream/master'
d1bfdca5 <Andy Grove> Merge branch 'master' of github.com:andygrove/arrow
52de6a10 <Andy Grove> Merge branch 'master' of github.com:andygrove/arrow
0e2606b2 <Andy Grove> Merge remote-tracking branch 'upstream/master'
d883da2f <Andy Grove> Merge remote-tracking branch 'upstream/master'
589ef71d <Andy Grove> Merge remote-tracking branch 'upstream/master'
bd4fbb55 <Andy Grove> Merge remote-tracking branch 'upstream/master'
9c8a10a4 <Andy Grove> Merge remote-tracking branch 'upstream/master'
05592f8c <Andy Grove> Merge remote-tracking branch 'upstream/master'
8c0e6982 <Andy Grove> Merge remote-tracking branch 'upstream/master'
31ef90ba <Andy Grove> Merge remote-tracking branch 'upstream/master'
2f87c703 <Andy Grove> Fix build - add missing import
---
rust/examples/dynamic_types.rs | 2 +-
rust/src/array.rs | 16 ++++++++++++++++
rust/src/datatypes.rs | 5 ++---
rust/src/record_batch.rs | 2 +-
4 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/rust/examples/dynamic_types.rs b/rust/examples/dynamic_types.rs
index acfd515..86a1890 100644
--- a/rust/examples/dynamic_types.rs
+++ b/rust/examples/dynamic_types.rs
@@ -43,7 +43,7 @@ fn main() {
let id = PrimitiveArray::from(vec![1, 2, 3, 4, 5]);
let nested = StructArray::from(vec![
- Rc::new(PrimitiveArray::from(vec!["a", "b", "c", "d", "e"])) as Rc<Array>,
+ Rc::new(ListArray::from(vec!["a", "b", "c", "d", "e"])) as Rc<Array>,
Rc::new(PrimitiveArray::from(vec![1.1, 2.2, 3.3, 4.4, 5.5])),
Rc::new(PrimitiveArray::from(vec![2.2, 3.3, 4.4, 5.5, 6.6])),
]);
diff --git a/rust/src/array.rs b/rust/src/array.rs
index 5305279..34294a5 100644
--- a/rust/src/array.rs
+++ b/rust/src/array.rs
@@ -55,6 +55,18 @@ impl<T> ListArray<T>
where
T: ArrowPrimitiveType,
{
+ pub fn len(&self) -> usize {
+ self.len
+ }
+
+ pub fn null_count(&self) -> usize {
+ self.null_count
+ }
+
+ pub fn validity_bitmap(&self) -> &Option<Bitmap> {
+ &self.validity_bitmap
+ }
+
pub fn get(&self, i: usize) -> &[T] {
self.data.get(i)
}
@@ -145,6 +157,10 @@ where
self.len
}
+ pub fn get(&self, i: usize) -> &T {
+ self.data.get(i)
+ }
+
pub fn iter(&self) -> BufferIterator<T> {
self.data.iter()
}
diff --git a/rust/src/datatypes.rs b/rust/src/datatypes.rs
index d1ac454..83a157a 100644
--- a/rust/src/datatypes.rs
+++ b/rust/src/datatypes.rs
@@ -20,7 +20,7 @@ use serde_json::Value;
use std::fmt;
/// Arrow data type
-#[derive(Debug, Clone, PartialEq)]
+#[derive(Debug, Clone, PartialEq, Eq)]
pub enum DataType {
Boolean,
Int8,
@@ -40,7 +40,7 @@ pub enum DataType {
}
/// Arrow struct/schema field
-#[derive(Debug, Clone, PartialEq)]
+#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Field {
name: String,
data_type: DataType,
@@ -61,7 +61,6 @@ impl ArrowPrimitiveType for i32 {}
impl ArrowPrimitiveType for i64 {}
impl ArrowPrimitiveType for f32 {}
impl ArrowPrimitiveType for f64 {}
-impl ArrowPrimitiveType for &'static str {}
impl DataType {
/// Parse a data type from a JSON representation
diff --git a/rust/src/record_batch.rs b/rust/src/record_batch.rs
index d8ca2f1..69509e4 100644
--- a/rust/src/record_batch.rs
+++ b/rust/src/record_batch.rs
@@ -66,7 +66,7 @@ mod tests {
]);
let a = PrimitiveArray::from(vec![1, 2, 3, 4, 5]);
- let b = PrimitiveArray::from(vec!["a", "b", "c", "d", "e"]);
+ let b = ListArray::from(vec!["a", "b", "c", "d", "e"]);
let record_batch = RecordBatch::new(Rc::new(schema), vec![Rc::new(a), Rc::new(b)]);
--
To stop receiving notification emails like this one, please contact
uwe@apache.org.