Use Result instead of Status

This commit is contained in:
Joris Van den Bossche committed 2019-12-10 11:14:55 +01:00
1 parent 8b3161937a
commit da2a2b3ea7
4 files changed
+11 -12

No files matched your search

+3 -4
View File
@@ -491,8 +491,8 @@ std::shared_ptr<DataType> FixedSizeListArray::value_type() const {
std::shared_ptr<Array> FixedSizeListArray::values() const { return values_; }
Status FixedSizeListArray::FromArrays(const std::shared_ptr<Array>& values,
int32_t list_size, std::shared_ptr<Array>* out) {
Result<std::shared_ptr<Array>> FixedSizeListArray::FromArrays(
const std::shared_ptr<Array>& values, int32_t list_size) {
if (list_size < 0) {
return Status::Invalid("list_size needs to be a positive integer");
}
@@ -504,9 +504,8 @@ Status FixedSizeListArray::FromArrays(const std::shared_ptr<Array>& values,
auto list_type = std::make_shared<FixedSizeListType>(values->type(), list_size);
std::shared_ptr<Buffer> validity_buf;
*out = std::make_shared<FixedSizeListArray>(list_type, length, values, validity_buf,
return std::make_shared<FixedSizeListArray>(list_type, length, values, validity_buf,
/*null_count=*/0, /*offset=*/0);
return Status::OK();
}
// ----------------------------------------------------------------------
+2 -2
View File
@@ -741,8 +741,8 @@ class ARROW_EXPORT FixedSizeListArray : public Array {
/// \param[in] values Array containing list values
/// \param[in] list_size The fixed length of each list
/// \param[out] out Will have length equal to values.length() / list_size
static Status FromArrays(const std::shared_ptr<Array>& values, int32_t list_size,
std::shared_ptr<Array>* out);
static Result<std::shared_ptr<Array>> FromArrays(const std::shared_ptr<Array>& values,
int32_t list_size);
protected:
void SetData(const std::shared_ptr<ArrayData>& data);
+4 -4
View File
@@ -1460,14 +1460,14 @@ cdef class FixedSizeListArray(Array):
"""
cdef:
Array _values
shared_ptr[CArray] out
CResult[shared_ptr[CArray]] c_result
_values = asarray(values)
with nogil:
check_status(CFixedSizeListArray.FromArrays(
_values.sp_array, list_size, &out))
cdef Array result = pyarrow_wrap_array(out)
c_result = CFixedSizeListArray.FromArrays(
_values.sp_array, list_size)
cdef Array result = pyarrow_wrap_array(GetResultValue(c_result))
result.validate()
return result
+2 -2
View File
@@ -489,8 +489,8 @@ cdef extern from "arrow/api.h" namespace "arrow" nogil:
cdef cppclass CFixedSizeListArray" arrow::FixedSizeListArray"(CArray):
@staticmethod
CStatus FromArrays(const shared_ptr[CArray]& values, int32_t list_size,
shared_ptr[CArray]* out)
CResult[shared_ptr[CArray]] FromArrays(
const shared_ptr[CArray]& values, int32_t list_size)
int64_t value_offset(int i)
int64_t value_length(int i)