[jira] [Commented] (ARROW-1671) [C++] Change arrow::MakeArray to not return Status

2017-10-22 Thread ASF GitHub Bot (JIRA)

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

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

wesm commented on issue #1227: ARROW-1671: [C++] Deprecate arrow::MakeArray 
that returns Status, refactor existing code to new variant
URL: https://github.com/apache/arrow/pull/1227#issuecomment-338526702
 
 
   +1


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


> [C++] Change arrow::MakeArray to not return Status
> --
>
> Key: ARROW-1671
> URL: https://issues.apache.org/jira/browse/ARROW-1671
> Project: Apache Arrow
>  Issue Type: Improvement
>  Components: C++
>Reporter: Wes McKinney
>Assignee: Wes McKinney
>  Labels: pull-request-available
> Fix For: 0.8.0
>
>
> It should not be possible for this function to fail. We can do a DCHECK 
> internally of any internal Status values for testing purposes



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (ARROW-1671) [C++] Change arrow::MakeArray to not return Status

2017-10-22 Thread ASF GitHub Bot (JIRA)

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

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

wesm closed pull request #1227: ARROW-1671: [C++] Deprecate arrow::MakeArray 
that returns Status, refactor existing code to new variant
URL: https://github.com/apache/arrow/pull/1227
 
 
   

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/cpp/src/arrow/array.cc b/cpp/src/arrow/array.cc
index a7930a139..eaac187a3 100644
--- a/cpp/src/arrow/array.cc
+++ b/cpp/src/arrow/array.cc
@@ -97,9 +97,7 @@ static inline std::shared_ptr SliceData(const 
ArrayData& data, int64_
 }
 
 std::shared_ptr Array::Slice(int64_t offset, int64_t length) const {
-  std::shared_ptr result;
-  DCHECK(MakeArray(SliceData(*data_, offset, length), ).ok());
-  return result;
+  return MakeArray(SliceData(*data_, offset, length));
 }
 
 std::shared_ptr Array::Slice(int64_t offset) const {
@@ -210,7 +208,7 @@ void ListArray::SetData(const std::shared_ptr& 
data) {
   raw_value_offsets_ = value_offsets == nullptr
? nullptr
: reinterpret_cast(value_offsets->data());
-  DCHECK(MakeArray(data_->child_data[0], _).ok());
+  values_ = MakeArray(data_->child_data[0]);
 }
 
 std::shared_ptr ListArray::value_type() const {
@@ -323,7 +321,7 @@ StructArray::StructArray(const std::shared_ptr& 
type, int64_t length,
 
 std::shared_ptr StructArray::field(int i) const {
   if (!boxed_fields_[i]) {
-DCHECK(MakeArray(data_->child_data[i], _fields_[i]).ok());
+boxed_fields_[i] = MakeArray(data_->child_data[i]);
   }
   DCHECK(boxed_fields_[i]);
   return boxed_fields_[i];
@@ -369,7 +367,7 @@ UnionArray::UnionArray(const std::shared_ptr& 
type, int64_t length,
 
 std::shared_ptr UnionArray::child(int i) const {
   if (!boxed_fields_[i]) {
-DCHECK(MakeArray(data_->child_data[i], _fields_[i]).ok());
+boxed_fields_[i] = MakeArray(data_->child_data[i]);
   }
   DCHECK(boxed_fields_[i]);
   return boxed_fields_[i];
@@ -377,7 +375,7 @@ std::shared_ptr UnionArray::child(int i) const {
 
 const Array* UnionArray::UnsafeChild(int i) const {
   if (!boxed_fields_[i]) {
-DCHECK(MakeArray(data_->child_data[i], _fields_[i]).ok());
+boxed_fields_[i] = MakeArray(data_->child_data[i]);
   }
   DCHECK(boxed_fields_[i]);
   return boxed_fields_[i].get();
@@ -407,7 +405,7 @@ void DictionaryArray::SetData(const 
std::shared_ptr& data) {
   auto indices_data = data_->ShallowCopy();
   indices_data->type = dict_type_->index_type();
   std::shared_ptr result;
-  DCHECK(MakeArray(indices_data, _).ok());
+  indices_ = MakeArray(indices_data);
 }
 
 std::shared_ptr DictionaryArray::indices() const { return indices_; }
@@ -589,6 +587,8 @@ class ArrayDataWrapper {
 
 }  // namespace internal
 
+#ifndef ARROW_NO_DEPRECATED_API
+
 Status MakeArray(const std::shared_ptr& data, 
std::shared_ptr* out) {
   internal::ArrayDataWrapper wrapper_visitor(data, out);
   RETURN_NOT_OK(VisitTypeInline(*data->type, _visitor));
@@ -596,6 +596,17 @@ Status MakeArray(const std::shared_ptr& data, 
std::shared_ptr*
   return Status::OK();
 }
 
+#endif
+
+std::shared_ptr MakeArray(const std::shared_ptr& data) {
+  std::shared_ptr out;
+  internal::ArrayDataWrapper wrapper_visitor(data, );
+  Status s = VisitTypeInline(*data->type, _visitor);
+  DCHECK(s.ok());
+  DCHECK(out);
+  return out;
+}
+
 // --
 // Instantiate templates
 
diff --git a/cpp/src/arrow/array.h b/cpp/src/arrow/array.h
index 0805cad3d..75dda4a75 100644
--- a/cpp/src/arrow/array.h
+++ b/cpp/src/arrow/array.h
@@ -144,13 +144,25 @@ struct ARROW_EXPORT ArrayData {
   std::vector child_data;
 };
 
+#ifndef ARROW_NO_DEPRECATED_API
+
 /// \brief Create a strongly-typed Array instance from generic ArrayData
 /// \param[in] data the array contents
 /// \param[out] out the resulting Array instance
 /// \return Status
+///
+/// \note Deprecated since 0.8.0
 ARROW_EXPORT
 Status MakeArray(const std::shared_ptr& data, 
std::shared_ptr* out);
 
+#endif
+
+/// \brief Create a strongly-typed Array instance from generic ArrayData
+/// \param[in] data the array contents
+/// \return the resulting Array instance
+ARROW_EXPORT
+std::shared_ptr MakeArray(const std::shared_ptr& data);
+
 // --
 // User array accessor types
 
diff --git a/cpp/src/arrow/builder.cc b/cpp/src/arrow/builder.cc
index 331de2d36..c910170dd 100644
--- a/cpp/src/arrow/builder.cc
+++ b/cpp/src/arrow/builder.cc
@@ -102,7 +102,8 @@ Status ArrayBuilder::Advance(int64_t elements) {
 Status