mirror of
https://github.com/apache/arrow.git
synced 2026-10-29 09:05:47 +08:00
Return shared_ptr<T> by value instead of const-ref
Change-Id: Ied3f3eeaf121ef6410f56a221e908e285935cc2c
This commit is contained in:
1 parent
45ed7e7a36
commit
f71deccea2
17 files changed
+40
-40
No files matched your search
@@ -53,10 +53,10 @@ class ARROW_EXPORT Array {
|
||||
int32_t length() const { return length_; }
|
||||
int32_t null_count() const { return null_count_; }
|
||||
|
||||
const std::shared_ptr<DataType>& type() const { return type_; }
|
||||
std::shared_ptr<DataType> type() const { return type_; }
|
||||
Type::type type_enum() const { return type_->type; }
|
||||
|
||||
const std::shared_ptr<Buffer>& null_bitmap() const { return null_bitmap_; }
|
||||
std::shared_ptr<Buffer> null_bitmap() const { return null_bitmap_; }
|
||||
|
||||
const uint8_t* null_bitmap_data() const { return null_bitmap_data_; }
|
||||
|
||||
|
||||
@@ -89,13 +89,13 @@ class ARROW_EXPORT ArrayBuilder {
|
||||
// this function responsibly.
|
||||
Status Advance(int32_t elements);
|
||||
|
||||
const std::shared_ptr<PoolBuffer>& null_bitmap() const { return null_bitmap_; }
|
||||
std::shared_ptr<PoolBuffer> null_bitmap() const { return null_bitmap_; }
|
||||
|
||||
// Creates new array object to hold the contents of the builder and transfers
|
||||
// ownership of the data. This resets all variables on the builder.
|
||||
virtual Status Finish(std::shared_ptr<Array>* out) = 0;
|
||||
|
||||
const std::shared_ptr<DataType>& type() const { return type_; }
|
||||
std::shared_ptr<DataType> type() const { return type_; }
|
||||
|
||||
protected:
|
||||
MemoryPool* pool_;
|
||||
|
||||
@@ -51,7 +51,7 @@ Column::Column(
|
||||
|
||||
Status Column::ValidateData() {
|
||||
for (int i = 0; i < data_->num_chunks(); ++i) {
|
||||
const std::shared_ptr<DataType>& type = data_->chunk(i)->type();
|
||||
std::shared_ptr<DataType> type = data_->chunk(i)->type();
|
||||
if (!this->type()->Equals(type)) {
|
||||
std::stringstream ss;
|
||||
ss << "In chunk " << i << " expected type " << this->type()->ToString()
|
||||
|
||||
@@ -46,7 +46,7 @@ class ARROW_EXPORT ChunkedArray {
|
||||
|
||||
int num_chunks() const { return chunks_.size(); }
|
||||
|
||||
const std::shared_ptr<Array>& chunk(int i) const { return chunks_[i]; }
|
||||
std::shared_ptr<Array> chunk(int i) const { return chunks_[i]; }
|
||||
|
||||
protected:
|
||||
ArrayVector chunks_;
|
||||
@@ -68,16 +68,16 @@ class ARROW_EXPORT Column {
|
||||
|
||||
int64_t null_count() const { return data_->null_count(); }
|
||||
|
||||
const std::shared_ptr<Field>& field() const { return field_; }
|
||||
std::shared_ptr<Field> field() const { return field_; }
|
||||
|
||||
// @returns: the column's name in the passed metadata
|
||||
const std::string& name() const { return field_->name; }
|
||||
|
||||
// @returns: the column's type according to the metadata
|
||||
const std::shared_ptr<DataType>& type() const { return field_->type; }
|
||||
std::shared_ptr<DataType> type() const { return field_->type; }
|
||||
|
||||
// @returns: the column's data as a chunked logical array
|
||||
const std::shared_ptr<ChunkedArray>& data() const { return data_; }
|
||||
std::shared_ptr<ChunkedArray> data() const { return data_; }
|
||||
// Verify that the column's array data is consistent with the passed field's
|
||||
// metadata
|
||||
Status ValidateData();
|
||||
|
||||
@@ -179,7 +179,7 @@ Status FileReader::ReadFooter() {
|
||||
return footer_->GetSchema(&schema_);
|
||||
}
|
||||
|
||||
const std::shared_ptr<Schema>& FileReader::schema() const {
|
||||
std::shared_ptr<Schema> FileReader::schema() const {
|
||||
return schema_;
|
||||
}
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ class ARROW_EXPORT FileReader {
|
||||
static Status Open(const std::shared_ptr<io::ReadableFileInterface>& file,
|
||||
int64_t footer_offset, std::shared_ptr<FileReader>* reader);
|
||||
|
||||
const std::shared_ptr<Schema>& schema() const;
|
||||
std::shared_ptr<Schema> schema() const;
|
||||
|
||||
// Shared dictionaries for dictionary-encoding cross record batches
|
||||
// TODO(wesm): Implement dictionary reading when we also have dictionary
|
||||
|
||||
@@ -285,7 +285,7 @@ Status SchemaToFlatbuffer(
|
||||
FBB& fbb, const Schema* schema, flatbuffers::Offset<flatbuf::Schema>* out) {
|
||||
std::vector<FieldOffset> field_offsets;
|
||||
for (int i = 0; i < schema->num_fields(); ++i) {
|
||||
const std::shared_ptr<Field>& field = schema->field(i);
|
||||
std::shared_ptr<Field> field = schema->field(i);
|
||||
FieldOffset offset;
|
||||
RETURN_NOT_OK(FieldToFlatbuffer(fbb, field, &offset));
|
||||
field_offsets.push_back(offset);
|
||||
|
||||
@@ -48,11 +48,11 @@ class ARROW_EXPORT RecordBatch {
|
||||
bool ApproxEquals(const RecordBatch& other) const;
|
||||
|
||||
// @returns: the table's schema
|
||||
const std::shared_ptr<Schema>& schema() const { return schema_; }
|
||||
std::shared_ptr<Schema> schema() const { return schema_; }
|
||||
|
||||
// @returns: the i-th column
|
||||
// Note: Does not boundscheck
|
||||
const std::shared_ptr<Array>& column(int i) const { return columns_[i]; }
|
||||
std::shared_ptr<Array> column(int i) const { return columns_[i]; }
|
||||
|
||||
const std::vector<std::shared_ptr<Array>>& columns() const { return columns_; }
|
||||
|
||||
@@ -88,11 +88,11 @@ class ARROW_EXPORT Table {
|
||||
const std::string& name() const { return name_; }
|
||||
|
||||
// @returns: the table's schema
|
||||
const std::shared_ptr<Schema>& schema() const { return schema_; }
|
||||
std::shared_ptr<Schema> schema() const { return schema_; }
|
||||
|
||||
// Note: Does not boundscheck
|
||||
// @returns: the i-th column
|
||||
const std::shared_ptr<Column>& column(int i) const { return columns_[i]; }
|
||||
std::shared_ptr<Column> column(int i) const { return columns_[i]; }
|
||||
|
||||
// @returns: the number of columns in the table
|
||||
int num_columns() const { return columns_.size(); }
|
||||
|
||||
@@ -81,7 +81,7 @@ std::string StructType::ToString() const {
|
||||
s << "struct<";
|
||||
for (int i = 0; i < this->num_children(); ++i) {
|
||||
if (i > 0) { s << ", "; }
|
||||
const std::shared_ptr<Field>& field = this->child(i);
|
||||
std::shared_ptr<Field> field = this->child(i);
|
||||
s << field->name << ": " << field->type->ToString();
|
||||
}
|
||||
s << ">";
|
||||
|
||||
@@ -134,7 +134,7 @@ struct ARROW_EXPORT DataType {
|
||||
return Equals(other.get());
|
||||
}
|
||||
|
||||
const std::shared_ptr<Field>& child(int i) const { return children_[i]; }
|
||||
std::shared_ptr<Field> child(int i) const { return children_[i]; }
|
||||
|
||||
const std::vector<std::shared_ptr<Field>>& children() const { return children_; }
|
||||
|
||||
@@ -319,9 +319,9 @@ struct ARROW_EXPORT ListType : public DataType, public NoExtraMeta {
|
||||
children_ = {value_field};
|
||||
}
|
||||
|
||||
const std::shared_ptr<Field>& value_field() const { return children_[0]; }
|
||||
std::shared_ptr<Field> value_field() const { return children_[0]; }
|
||||
|
||||
const std::shared_ptr<DataType>& value_type() const { return children_[0]->type; }
|
||||
std::shared_ptr<DataType> value_type() const { return children_[0]->type; }
|
||||
|
||||
Status Accept(TypeVisitor* visitor) const override;
|
||||
std::string ToString() const override;
|
||||
|
||||
@@ -63,7 +63,7 @@ Status MakeBuilder(MemoryPool* pool, const std::shared_ptr<DataType>& type,
|
||||
|
||||
case Type::LIST: {
|
||||
std::shared_ptr<ArrayBuilder> value_builder;
|
||||
const std::shared_ptr<DataType>& value_type =
|
||||
std::shared_ptr<DataType> value_type =
|
||||
static_cast<ListType*>(type.get())->value_type();
|
||||
RETURN_NOT_OK(MakeBuilder(pool, value_type, &value_builder));
|
||||
out->reset(new ListBuilder(pool, value_builder));
|
||||
|
||||
@@ -57,12 +57,12 @@ class ARROW_EXPORT ListArray : public Array {
|
||||
|
||||
// Return a shared pointer in case the requestor desires to share ownership
|
||||
// with this array.
|
||||
const std::shared_ptr<Array>& values() const { return values_; }
|
||||
std::shared_ptr<Array> values() const { return values_; }
|
||||
std::shared_ptr<Buffer> offsets() const {
|
||||
return std::static_pointer_cast<Buffer>(offset_buffer_);
|
||||
}
|
||||
|
||||
const std::shared_ptr<DataType>& value_type() const { return values_->type(); }
|
||||
std::shared_ptr<DataType> value_type() const { return values_->type(); }
|
||||
|
||||
const int32_t* raw_offsets() const { return offsets_; }
|
||||
|
||||
@@ -152,7 +152,7 @@ class ARROW_EXPORT ListBuilder : public ArrayBuilder {
|
||||
|
||||
Status AppendNull() { return Append(false); }
|
||||
|
||||
const std::shared_ptr<ArrayBuilder>& value_builder() const {
|
||||
std::shared_ptr<ArrayBuilder> value_builder() const {
|
||||
DCHECK(!values_) << "Using value builder is pointless when values_ is set";
|
||||
return value_builder_;
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ class ARROW_EXPORT PrimitiveArray : public Array {
|
||||
public:
|
||||
virtual ~PrimitiveArray() {}
|
||||
|
||||
const std::shared_ptr<Buffer>& data() const { return data_; }
|
||||
std::shared_ptr<Buffer> data() const { return data_; }
|
||||
|
||||
bool EqualsExact(const PrimitiveArray& other) const;
|
||||
bool Equals(const std::shared_ptr<Array>& arr) const override;
|
||||
|
||||
@@ -46,7 +46,7 @@ class ARROW_EXPORT StructArray : public Array {
|
||||
|
||||
// Return a shared pointer in case the requestor desires to share ownership
|
||||
// with this array.
|
||||
const std::shared_ptr<Array>& field(int32_t pos) const {
|
||||
std::shared_ptr<Array> field(int32_t pos) const {
|
||||
DCHECK_GT(field_arrays_.size(), 0);
|
||||
return field_arrays_[pos];
|
||||
}
|
||||
@@ -99,7 +99,7 @@ class ARROW_EXPORT StructBuilder : public ArrayBuilder {
|
||||
|
||||
Status AppendNull() { return Append(false); }
|
||||
|
||||
const std::shared_ptr<ArrayBuilder> field_builder(int pos) const {
|
||||
std::shared_ptr<ArrayBuilder> field_builder(int pos) const {
|
||||
DCHECK_GT(field_builders_.size(), 0);
|
||||
return field_builders_[pos];
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ class ARROW_EXPORT Buffer : public std::enable_shared_from_this<Buffer> {
|
||||
|
||||
int64_t size() const { return size_; }
|
||||
|
||||
const std::shared_ptr<Buffer> parent() const { return parent_; }
|
||||
std::shared_ptr<Buffer> parent() const { return parent_; }
|
||||
|
||||
protected:
|
||||
bool is_mutable_;
|
||||
|
||||
@@ -91,12 +91,12 @@ cdef extern from "arrow/api.h" namespace "arrow" nogil:
|
||||
|
||||
c_bool Equals(const shared_ptr[CSchema]& other)
|
||||
|
||||
const shared_ptr[CField]& field(int i)
|
||||
shared_ptr[CField] field(int i)
|
||||
int num_fields()
|
||||
c_string ToString()
|
||||
|
||||
cdef cppclass CArray" arrow::Array":
|
||||
const shared_ptr[CDataType]& type()
|
||||
shared_ptr[CDataType] type()
|
||||
|
||||
int32_t length()
|
||||
int32_t null_count()
|
||||
@@ -142,8 +142,8 @@ cdef extern from "arrow/api.h" namespace "arrow" nogil:
|
||||
const int32_t* offsets()
|
||||
int32_t offset(int i)
|
||||
int32_t value_length(int i)
|
||||
const shared_ptr[CArray]& values()
|
||||
const shared_ptr[CDataType]& value_type()
|
||||
shared_ptr[CArray] values()
|
||||
shared_ptr[CDataType] value_type()
|
||||
|
||||
cdef cppclass CStringArray" arrow::StringArray"(CListArray):
|
||||
c_string GetString(int i)
|
||||
@@ -152,7 +152,7 @@ cdef extern from "arrow/api.h" namespace "arrow" nogil:
|
||||
int64_t length()
|
||||
int64_t null_count()
|
||||
int num_chunks()
|
||||
const shared_ptr[CArray]& chunk(int i)
|
||||
shared_ptr[CArray] chunk(int i)
|
||||
|
||||
cdef cppclass CColumn" arrow::Column":
|
||||
CColumn(const shared_ptr[CField]& field,
|
||||
@@ -164,8 +164,8 @@ cdef extern from "arrow/api.h" namespace "arrow" nogil:
|
||||
int64_t length()
|
||||
int64_t null_count()
|
||||
const c_string& name()
|
||||
const shared_ptr[CDataType]& type()
|
||||
const shared_ptr[CChunkedArray]& data()
|
||||
shared_ptr[CDataType] type()
|
||||
shared_ptr[CChunkedArray] data()
|
||||
|
||||
cdef cppclass CRecordBatch" arrow::RecordBatch":
|
||||
CRecordBatch(const shared_ptr[CSchema]& schema, int32_t num_rows,
|
||||
@@ -173,8 +173,8 @@ cdef extern from "arrow/api.h" namespace "arrow" nogil:
|
||||
|
||||
c_bool Equals(const CRecordBatch& other)
|
||||
|
||||
const shared_ptr[CSchema]& schema()
|
||||
const shared_ptr[CArray]& column(int i)
|
||||
shared_ptr[CSchema] schema()
|
||||
shared_ptr[CArray] column(int i)
|
||||
const c_string& column_name(int i)
|
||||
|
||||
const vector[shared_ptr[CArray]]& columns()
|
||||
@@ -191,8 +191,8 @@ cdef extern from "arrow/api.h" namespace "arrow" nogil:
|
||||
|
||||
const c_string& name()
|
||||
|
||||
const shared_ptr[CSchema]& schema()
|
||||
const shared_ptr[CColumn]& column(int i)
|
||||
shared_ptr[CSchema] schema()
|
||||
shared_ptr[CColumn] column(int i)
|
||||
|
||||
|
||||
cdef extern from "arrow/ipc/metadata.h" namespace "arrow::ipc" nogil:
|
||||
|
||||
@@ -44,7 +44,7 @@ cdef extern from "arrow/ipc/file.h" namespace "arrow::ipc" nogil:
|
||||
CStatus Open2" Open"(const shared_ptr[ReadableFileInterface]& file,
|
||||
int64_t footer_offset, shared_ptr[CFileReader]* out)
|
||||
|
||||
const shared_ptr[CSchema]& schema()
|
||||
shared_ptr[CSchema] schema()
|
||||
|
||||
int num_dictionaries()
|
||||
int num_record_batches()
|
||||
|
||||
Reference in new issue
Block a user