Skip to content

Commit 4decf7f

Browse files
committed
Fix docstrings and change index names
1 parent 3760a3f commit 4decf7f

3 files changed

Lines changed: 14 additions & 15 deletions

File tree

cpp/src/arrow/record_batch.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class ARROW_EXPORT RecordBatch {
9090
/// in the resulting struct array.
9191
Result<std::shared_ptr<StructArray>> ToStructArray() const;
9292

93-
/// \brief Convert record batch with one data type to Tensor
93+
/// \brief Convert RecordBatch to Tensor
9494
///
9595
/// Create a Tensor object with shape (number of rows, number of columns) and
9696
/// strides (type size in bytes, type size in bytes * number of rows).

cpp/src/arrow/table.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class ARROW_EXPORT Table {
101101
static Result<std::shared_ptr<Table>> FromChunkedStructArray(
102102
const std::shared_ptr<ChunkedArray>& array);
103103

104-
/// \brief Convert table with one data type to Tensor
104+
/// \brief Convert Table to Tensor
105105
///
106106
/// Create a Tensor object with shape (number of rows, number of columns) and
107107
/// strides (type size in bytes, type size in bytes * number of rows).

cpp/src/arrow/tensor.cc

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -270,15 +270,14 @@ struct ConvertArrayToTensorRowMajorVisitor {
270270
auto in_values = ArraySpan(in_data).GetSpan<In>(1, in_data.length);
271271

272272
if (in_data.null_count == 0) {
273-
for (int64_t data_idx = 0; data_idx < in_data.length; ++data_idx) {
274-
out_values[(data_idx + chunk_idx) * num_cols + col_idx] =
275-
static_cast<Out>(in_values[data_idx]);
273+
for (int64_t i = 0; i < in_data.length; ++i) {
274+
out_values[(i + chunk_idx) * num_cols + col_idx] =
275+
static_cast<Out>(in_values[i]);
276276
}
277277
} else {
278-
for (int64_t data_idx = 0; data_idx < in_data.length; ++data_idx) {
279-
out_values[(data_idx + chunk_idx) * num_cols + col_idx] =
280-
in_data.IsNull(data_idx) ? static_cast<Out>(NAN)
281-
: static_cast<Out>(in_values[data_idx]);
278+
for (int64_t i = 0; i < in_data.length; ++i) {
279+
out_values[(i + chunk_idx) * num_cols + col_idx] =
280+
in_data.IsNull(i) ? static_cast<Out>(NAN) : static_cast<Out>(in_values[i]);
282281
}
283282
}
284283
return Status::OK();
@@ -292,21 +291,21 @@ inline void ConvertColumnsToTensor(const Table& table, uint8_t* out, bool row_ma
292291
using CType = typename arrow::TypeTraits<DataType>::CType;
293292
auto* out_values = reinterpret_cast<CType*>(out);
294293

295-
int i = 0;
294+
int col_idx = 0;
296295
for (const auto& column : table.columns()) {
297-
int j = 0;
296+
int chunk_idx = 0;
298297
for (const auto& chunk : column->chunks()) {
299298
if (row_major) {
300-
ConvertArrayToTensorRowMajorVisitor<CType> visitor{out_values, *chunk->data(),
301-
table.num_columns(), i, j};
299+
ConvertArrayToTensorRowMajorVisitor<CType> visitor{
300+
out_values, *chunk->data(), table.num_columns(), col_idx, chunk_idx};
302301
DCHECK_OK(VisitTypeInline(*chunk->type(), &visitor));
303-
j = j + static_cast<int>(chunk->length());
302+
chunk_idx = chunk_idx + static_cast<int>(chunk->length());
304303
} else {
305304
ConvertArrayToTensorVisitor<CType> visitor{out_values, *chunk->data()};
306305
DCHECK_OK(VisitTypeInline(*chunk->type(), &visitor));
307306
}
308307
}
309-
i++;
308+
col_idx++;
310309
}
311310
}
312311

0 commit comments

Comments
 (0)