[jira] [Commented] (ARROW-2396) Unify Rust Errors

2018-04-05 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARROW-2396?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16426556#comment-16426556
 ] 

ASF GitHub Bot commented on ARROW-2396:
---

xhochy closed pull request #1836: ARROW-2396: [Rust] Unify Rust Errors
URL: https://github.com/apache/arrow/pull/1836
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/rust/src/array.rs b/rust/src/array.rs
index 7fd343346..1c0a653d7 100644
--- a/rust/src/array.rs
+++ b/rust/src/array.rs
@@ -42,7 +42,7 @@ pub enum ArrayData {
 }
 
 macro_rules! arraydata_from_primitive {
-($DT:ty, $AT:ident) => {
+($DT: ty, $AT: ident) => {
 impl From> for ArrayData {
 fn from(v: Vec<$DT>) -> Self {
 ArrayData::$AT(Buffer::from(v))
@@ -91,7 +91,7 @@ impl Array {
 }
 
 macro_rules! array_from_primitive {
-($DT:ty) => {
+($DT: ty) => {
 impl From> for Array {
 fn from(v: Vec<$DT>) -> Self {
 Array {
@@ -117,7 +117,7 @@ array_from_primitive!(i32);
 array_from_primitive!(i64);
 
 macro_rules! array_from_optional_primitive {
-($DT:ty, $DEFAULT:expr) => {
+($DT: ty, $DEFAULT: expr) => {
 impl From>> for Array {
 fn from(v: Vec>) -> Self {
 let mut null_count = 0;
diff --git a/rust/src/buffer.rs b/rust/src/buffer.rs
index 7d5cc7c49..517583e90 100644
--- a/rust/src/buffer.rs
+++ b/rust/src/buffer.rs
@@ -92,7 +92,7 @@ where
 }
 
 macro_rules! array_from_primitive {
-($DT:ty) => {
+($DT: ty) => {
 impl From> for Buffer<$DT> {
 fn from(v: Vec<$DT>) -> Self {
 // allocate aligned memory buffer
diff --git a/rust/src/datatypes.rs b/rust/src/datatypes.rs
index 4f022ba45..b9fb94caf 100644
--- a/rust/src/datatypes.rs
+++ b/rust/src/datatypes.rs
@@ -17,11 +17,7 @@
 
 use serde_json;
 use serde_json::Value;
-
-#[derive(Debug, Clone, PartialEq)]
-pub enum ArrowError {
-ParseError(String),
-}
+use super::error::ArrowError;
 
 #[derive(Debug, Clone, PartialEq)]
 pub enum DataType {
diff --git a/rust/src/error.rs b/rust/src/error.rs
index d1fb742ef..6a342e063 100644
--- a/rust/src/error.rs
+++ b/rust/src/error.rs
@@ -15,17 +15,8 @@
 // specific language governing permissions and limitations
 // under the License.
 
-use std::convert::*;
-
-#[derive(Debug, Clone)]
-pub struct Error {
-msg: String,
-}
-
-impl From<&'static str> for Error where {
-fn from(msg: &'static str) -> Self {
-Error {
-msg: String::from(msg),
-}
-}
+#[derive(Debug, Clone, PartialEq)]
+pub enum ArrowError {
+MemoryError(String),
+ParseError(String),
 }
diff --git a/rust/src/memory.rs b/rust/src/memory.rs
index 2e5aaf0f9..41d4c53ee 100644
--- a/rust/src/memory.rs
+++ b/rust/src/memory.rs
@@ -18,17 +18,19 @@
 use libc;
 use std::mem;
 
-use super::error::Error;
+use super::error::ArrowError;
 
 const ALIGNMENT: usize = 64;
 
-pub fn allocate_aligned(size: i64) -> Result<*const u8, Error> {
+pub fn allocate_aligned(size: i64) -> Result<*const u8, ArrowError> {
 unsafe {
 let mut page: *mut libc::c_void = mem::uninitialized();
 let result = libc::posix_memalign(&mut page, ALIGNMENT, size as usize);
 match result {
 0 => Ok(mem::transmute::<*mut libc::c_void, *const u8>(page)),
-_ => Err(Error::from("Failed to allocate memory")),
+_ => Err(ArrowError::MemoryError(format!(
+"Failed to allocate memory"
+))),
 }
 }
 }


 


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Unify Rust Errors
> -
>
> Key: ARROW-2396
> URL: https://issues.apache.org/jira/browse/ARROW-2396
> Project: Apache Arrow
>  Issue Type: Improvement
>  Components: Rust
>Reporter: Maximilian Roos
>Priority: Trivial
>  Labels: pull-request-available
>
> Currently there are two Error items - one Enum and one Struct. These should 
> be unified under a single ArrowError Enum



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (ARROW-2396) Unify Rust Errors

2018-04-04 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARROW-2396?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16426407#comment-16426407
 ] 

ASF GitHub Bot commented on ARROW-2396:
---

maxim-lian commented on issue #1836: ARROW-2396: [Rust] Unify Rust Errors
URL: https://github.com/apache/arrow/pull/1836#issuecomment-378799435
 
 
   Thanks @andygrove. There's more to do (I'm looking at 
http://lucumr.pocoo.org/2014/11/6/error-handling-in-rust/), but this moves 
forward at least


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Unify Rust Errors
> -
>
> Key: ARROW-2396
> URL: https://issues.apache.org/jira/browse/ARROW-2396
> Project: Apache Arrow
>  Issue Type: Improvement
>  Components: Rust
>Reporter: Maximilian Roos
>Priority: Trivial
>  Labels: pull-request-available
>
> Currently there are two Error items - one Enum and one Struct. These should 
> be unified under a single ArrowError Enum



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (ARROW-2396) Unify Rust Errors

2018-04-04 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARROW-2396?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16426406#comment-16426406
 ] 

ASF GitHub Bot commented on ARROW-2396:
---

andygrove commented on issue #1836: ARROW-2396: [Rust] Unify Rust Errors
URL: https://github.com/apache/arrow/pull/1836#issuecomment-378799009
 
 
   :+1: LGTM. Thanks for taking care of this.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Unify Rust Errors
> -
>
> Key: ARROW-2396
> URL: https://issues.apache.org/jira/browse/ARROW-2396
> Project: Apache Arrow
>  Issue Type: Improvement
>  Components: Rust
>Reporter: Maximilian Roos
>Priority: Trivial
>  Labels: pull-request-available
>
> Currently there are two Error items - one Enum and one Struct. These should 
> be unified under a single ArrowError Enum



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (ARROW-2396) Unify Rust Errors

2018-04-04 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARROW-2396?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16426396#comment-16426396
 ] 

ASF GitHub Bot commented on ARROW-2396:
---

maxim-lian opened a new pull request #1836: ARROW-2396: [Rust] Unify Rust Errors
URL: https://github.com/apache/arrow/pull/1836
 
 
   Currently there are two Error items - one Enum and one Struct. This unifies 
them under a single ArrowError Enum.
   
   Let me know any feedback
   
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Unify Rust Errors
> -
>
> Key: ARROW-2396
> URL: https://issues.apache.org/jira/browse/ARROW-2396
> Project: Apache Arrow
>  Issue Type: Improvement
>  Components: Rust
>Reporter: Maximilian Roos
>Priority: Trivial
>  Labels: pull-request-available
>
> Currently there are two Error items - one Enum and one Struct. These should 
> be unified under a single ArrowError Enum



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)