Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cpp/core/jni/JniWrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ Java_org_apache_gluten_vectorized_PlanEvaluatorJniWrapper_nativeCreateKernelWith
// Handle the Java iters
jsize itersLen = env->GetArrayLength(iterArr);
std::vector<std::shared_ptr<ResultIterator>> inputIters;
inputIters.reserve(itersLen);
for (int idx = 0; idx < itersLen; idx++) {
jobject iter = env->GetObjectArrayElement(iterArr, idx);
auto arrayIter = std::make_unique<JniColumnarBatchIterator>(env, iter, ctx, idx);
Expand Down Expand Up @@ -835,6 +836,7 @@ JNIEXPORT jlong JNICALL Java_org_apache_gluten_columnarbatch_ColumnarBatchJniWra
auto safeArray = getIntArrayElementsSafe(env, jcolumnIndices);
int size = env->GetArrayLength(jcolumnIndices);
std::vector<int32_t> columnIndices;
columnIndices.reserve(size);
for (int32_t i = 0; i < size; i++) {
columnIndices.push_back(safeArray.elems()[i]);
}
Expand Down
1 change: 1 addition & 0 deletions cpp/core/shuffle/Utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ arrow::Result<std::string> gluten::createTempShuffleFile(const std::string& dir)
arrow::Result<std::vector<std::shared_ptr<arrow::DataType>>> gluten::toShuffleTypeId(
const std::vector<std::shared_ptr<arrow::Field>>& fields) {
std::vector<std::shared_ptr<arrow::DataType>> shuffleTypeId;
shuffleTypeId.reserve(fields.size());
for (auto field : fields) {
switch (field->type()->id()) {
case arrow::BooleanType::type_id:
Expand Down
2 changes: 2 additions & 0 deletions cpp/velox/benchmarks/GenericBenchmark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ auto BM_Generic = [](::benchmark::State& state,

auto plan = getPlanFromFile("Plan", planFile);
std::vector<std::string> splits{};
splits.reserve(splitFiles.size());
for (const auto& splitFile : splitFiles) {
splits.push_back(getPlanFromFile("ReadRel.LocalFiles", splitFile));
}
Expand All @@ -428,6 +429,7 @@ auto BM_Generic = [](::benchmark::State& state,
ScopedTimer timer(&elapsedTime);
for (auto _ : state) {
std::vector<std::shared_ptr<gluten::ResultIterator>> inputIters;
inputIters.reserve(dataFiles.size());
std::vector<FileReaderIterator*> inputItersRaw;
if (!dataFiles.empty()) {
for (const auto& input : dataFiles) {
Expand Down
1 change: 1 addition & 0 deletions cpp/velox/compute/iceberg/IcebergWriter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ std::shared_ptr<IcebergInsertTableHandle> createIcebergInsertTableHandle(
std::vector<std::shared_ptr<const iceberg::IcebergColumnHandle>> columnHandles;

std::vector<std::string> columnNames = outputRowType->names();
columnHandles.reserve(columnNames.size());
std::vector<TypePtr> columnTypes = outputRowType->children();
std::vector<std::string> partitionColumns;
partitionColumns.reserve(spec->fields.size());
Expand Down
1 change: 1 addition & 0 deletions cpp/velox/jni/JniFileSystem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ class JniFileSystem : public facebook::velox::filesystems::FileSystem {
static_cast<jobjectArray>(env->CallObjectMethod(obj_, jniFileSystemList, createJString(env, path)));
checkException(env);
jsize length = env->GetArrayLength(jarray);
out.reserve(length);
for (jsize i = 0; i < length; ++i) {
jstring element = static_cast<jstring>(env->GetObjectArrayElement(jarray, i));
std::string cElement = jStringToCString(env, element);
Expand Down
1 change: 1 addition & 0 deletions cpp/velox/jni/VeloxJniWrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ JNIEXPORT jlong JNICALL Java_org_apache_gluten_columnarbatch_VeloxColumnarBatchJ
auto safeArray = getLongArrayElementsSafe(env, batchHandles);

std::vector<std::shared_ptr<ColumnarBatch>> batches;
batches.reserve(handleCount);
for (int i = 0; i < handleCount; ++i) {
int64_t handle = safeArray.elems()[i];
auto batch = ObjectStore::retrieve<ColumnarBatch>(handle);
Expand Down
3 changes: 3 additions & 0 deletions cpp/velox/shuffle/VeloxHashShuffleWriter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ arrow::Status VeloxHashShuffleWriter::write(std::shared_ptr<ColumnarBatch> cb, i
}
END_TIMING();
std::vector<int32_t> range;
range.reserve(numColumns);
for (int32_t i = 1; i < numColumns; i++) {
range.push_back(i);
}
Expand Down Expand Up @@ -377,6 +378,7 @@ arrow::Status VeloxHashShuffleWriter::buildPartition2Row(uint32_t rowNum) {

// calc valid partition list
partitionUsed_.clear();
partitionUsed_.reserve(numPartitions_);
for (auto pid = 0; pid != numPartitions_; ++pid) {
if (partition2RowCount_[pid] > 0) {
partitionUsed_.push_back(pid);
Expand Down Expand Up @@ -737,6 +739,7 @@ arrow::Status VeloxHashShuffleWriter::splitComplexType(const facebook::velox::Ro

arrow::Status VeloxHashShuffleWriter::initColumnTypes(const facebook::velox::RowVector& rv) {
schema_ = toArrowSchema(rv.type(), veloxPool_.get());
veloxColumnTypes_.reserve(rv.childrenSize());
for (size_t i = 0; i < rv.childrenSize(); ++i) {
veloxColumnTypes_.push_back(rv.childAt(i)->type());
}
Expand Down
1 change: 1 addition & 0 deletions cpp/velox/shuffle/VeloxRssSortShuffleWriter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ arrow::Status VeloxRssSortShuffleWriter::write(std::shared_ptr<ColumnarBatch> cb
RETURN_NOT_OK(partitioner_->compute(pidArr, pidBatch->numRows(), batches_.size(), rowVectorIndexMap_));
END_TIMING();
std::vector<int32_t> range;
range.reserve(numColumns);
for (int32_t i = 1; i < numColumns; i++) {
range.push_back(i);
}
Expand Down
1 change: 1 addition & 0 deletions cpp/velox/shuffle/VeloxSortShuffleWriter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ arrow::Result<facebook::velox::RowVectorPtr> VeloxSortShuffleWriter::getPeeledRo
RETURN_NOT_OK(partitioner_->compute(pidArr, pidBatch->numRows(), row2Partition_));

std::vector<int32_t> range;
range.reserve(numColumns);
for (int32_t i = 1; i < numColumns; i++) {
range.push_back(i);
}
Expand Down
1 change: 1 addition & 0 deletions cpp/velox/substrait/SubstraitToVeloxPlan.cc
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,7 @@ std::shared_ptr<CudfHiveInsertTableHandle> makeCudfHiveInsertTableHandle(
const std::unordered_map<std::string, std::string>& serdeParameters,
const std::shared_ptr<dwio::common::WriterOptions>& writerOptions) {
std::vector<std::shared_ptr<const CudfHiveColumnHandle>> columnHandles;
columnHandles.reserve(tableColumnNames.size());

for (int i = 0; i < tableColumnNames.size(); ++i) {
columnHandles.push_back(std::make_shared<CudfHiveColumnHandle>(
Expand Down
3 changes: 3 additions & 0 deletions cpp/velox/tests/MemoryManagerTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ TEST_F(MemoryManagerTest, memoryPoolWithBlockReseravtion) {
std::vector<Allocation> allocations;
std::vector<uint64_t> sizes{
kMemoryReservationBlockSizeDefault - 1 * kMB, kMemoryReservationBlockSizeDefault - 2 * kMB};
allocations.reserve(sizes.size());
for (const auto& size : sizes) {
auto buf = pool->allocate(size);
allocations.push_back({buf, size, pool.get()});
Expand All @@ -100,6 +101,7 @@ TEST_F(MemoryManagerTest, memoryAllocatorWithBlockReservation) {
std::vector<Allocation> allocations;
std::vector<uint64_t> sizes{
kMemoryReservationBlockSizeDefault - 1 * kMB, kMemoryReservationBlockSizeDefault - 2 * kMB};
allocations.reserve(sizes.size());
for (auto i = 0; i < sizes.size(); i++) {
auto size = sizes[i];
auto currentBytes = allocator_->getBytes();
Expand Down Expand Up @@ -353,6 +355,7 @@ TEST_F(MultiMemoryManagerTest, spill) {
std::vector<std::unique_ptr<VeloxMemoryManager>> vmms{};
std::vector<std::thread> threads{};
std::vector<std::vector<void*>> buffs{};
buffs.reserve(numThreads);
for (size_t i = 0; i < numThreads; ++i) {
buffs.push_back({});
vmms.emplace_back(nullptr);
Expand Down
1 change: 1 addition & 0 deletions cpp/velox/tests/VeloxBatchResizerTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class VeloxBatchResizerTest : public ::testing::Test, public test::VectorTestBas

void checkResize(int32_t min, int32_t max, int64_t preferredBatchBytes, std::vector<int32_t> inSizes, std::vector<int32_t> outSizes) {
auto inBatches = std::vector<std::shared_ptr<ColumnarBatch>>();
inBatches.reserve(inSizes.size());
for (const auto& size : inSizes) {
inBatches.push_back(std::make_shared<VeloxColumnarBatch>(newVector(size)));
}
Expand Down
1 change: 1 addition & 0 deletions cpp/velox/tests/VeloxSubstraitRoundTripTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class VeloxSubstraitRoundTripTest : public OperatorTestBase {
/// @param batchSize The batch Size of the data.
std::vector<RowVectorPtr> makeVectors(int64_t size, int64_t childSize, int64_t batchSize) {
std::vector<RowVectorPtr> vectors;
vectors.reserve(size);
std::mt19937 gen(std::mt19937::default_seed);
for (int i = 0; i < size; i++) {
std::vector<VectorPtr> children;
Expand Down
Loading