Skip to content

Commit

Permalink
[VL] Minor fix for cpp code style (part 1) (#8157)
Browse files Browse the repository at this point in the history
  • Loading branch information
rui-mo authored Dec 5, 2024
1 parent 98b15c4 commit 731c5b5
Show file tree
Hide file tree
Showing 57 changed files with 133 additions and 82 deletions.
3 changes: 0 additions & 3 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,7 @@ if(ENABLE_IAA)
add_definitions(-DGLUTEN_ENABLE_IAA)
endif()

#
# Subdirectories
#

add_subdirectory(core)

if(BUILD_VELOX_BACKEND)
Expand Down
16 changes: 8 additions & 8 deletions cpp/velox/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,12 @@ endmacro()
set(VELOX_SRCS
compute/VeloxBackend.cc
compute/VeloxRuntime.cc
compute/WholeStageResultIterator.cc
compute/VeloxPlanConverter.cc
compute/WholeStageResultIterator.cc
compute/iceberg/IcebergPlanConverter.cc
jni/VeloxJniWrapper.cc
jni/JniFileSystem.cc
jni/JniUdf.cc
jni/VeloxJniWrapper.cc
memory/BufferOutputStream.cc
memory/VeloxColumnarBatch.cc
memory/VeloxMemoryManager.cc
Expand All @@ -154,30 +154,30 @@ set(VELOX_SRCS
operators/functions/SparkExprToSubfieldFilterParser.cc
operators/reader/FileReaderIterator.cc
operators/reader/ParquetReaderIterator.cc
operators/serializer/VeloxColumnarToRowConverter.cc
operators/serializer/VeloxColumnarBatchSerializer.cc
operators/serializer/VeloxColumnarToRowConverter.cc
operators/serializer/VeloxRowToColumnarConverter.cc
operators/writer/VeloxArrowWriter.cc
operators/writer/VeloxParquetDataSource.cc
shuffle/VeloxHashShuffleWriter.cc
shuffle/VeloxRssSortShuffleWriter.cc
shuffle/VeloxShuffleReader.cc
shuffle/VeloxShuffleWriter.cc
shuffle/VeloxHashShuffleWriter.cc
shuffle/VeloxSortShuffleWriter.cc
shuffle/VeloxRssSortShuffleWriter.cc
substrait/SubstraitExtensionCollector.cc
substrait/SubstraitParser.cc
substrait/SubstraitToVeloxExpr.cc
substrait/SubstraitToVeloxPlan.cc
substrait/SubstraitToVeloxPlanValidator.cc
substrait/VariantToVectorConverter.cc
substrait/SubstraitExtensionCollector.cc
substrait/VeloxSubstraitSignature.cc
substrait/VeloxToSubstraitExpr.cc
substrait/VeloxToSubstraitPlan.cc
substrait/VeloxToSubstraitType.cc
udf/UdfLoader.cc
utils/VeloxArrowUtils.cc
utils/ConfigExtractor.cc
utils/Common.cc
utils/ConfigExtractor.cc
utils/VeloxArrowUtils.cc
utils/VeloxBatchResizer.cc)

if(ENABLE_S3)
Expand Down
2 changes: 1 addition & 1 deletion cpp/velox/compute/WholeStageResultIterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class WholeStageResultIterator : public ColumnarBatchIterator {
/// All the children plan node ids with postorder traversal.
std::vector<facebook::velox::core::PlanNodeId> orderedNodeIds_;

/// Node ids should be ommited in metrics.
/// Node ids should be omitted in metrics.
std::unordered_set<facebook::velox::core::PlanNodeId> omittedNodeIds_;
std::vector<facebook::velox::core::PlanNodeId> scanNodeIds_;
std::vector<std::shared_ptr<SplitInfo>> scanInfos_;
Expand Down
6 changes: 3 additions & 3 deletions cpp/velox/jni/JniFileSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@

namespace gluten {

// Register JNI-or-local (or JVM-over-local, as long as it describes what happens here)
// file system. maxFileSize is necessary (!= 0) because we use this size to decide
// whether a new file can fit in JVM heap, otherwise we write it via local fs directly.
// Register JNI-or-local (or JVM-over-local, as long as it describes what happens here) file system. maxFileSize is
// necessary (!= 0) because we use this size to decide whether a new file can fit in JVM heap, otherwise we write it via
// local fs directly.
void registerJolFileSystem(uint64_t maxFileSize);

void initVeloxJniFileSystem(JNIEnv* env);
Expand Down
1 change: 1 addition & 0 deletions cpp/velox/memory/VeloxMemoryManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ T getConfig(
return defaultValue;
}
} // namespace

/// We assume in a single Spark task. No thread-safety should be guaranteed.
class ListenableArbitrator : public velox::memory::MemoryArbitrator {
public:
Expand Down
2 changes: 2 additions & 0 deletions cpp/velox/operators/functions/RegistrationAllFunctions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ void registerPrestoVectorFunctions() {
VELOX_REGISTER_VECTOR_FUNCTION(udf_transform_values, "transform_values");
}
} // namespace facebook::velox::functions

namespace gluten {
namespace {

void registerFunctionOverwrite() {
velox::functions::registerUnaryNumeric<RoundFunction>({"round"});
velox::registerFunction<RoundFunction, int8_t, int8_t, int32_t>({"round"});
Expand Down
2 changes: 2 additions & 0 deletions cpp/velox/operators/functions/RowConstructorWithNull.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "velox/expression/VectorFunction.h"

namespace gluten {

facebook::velox::TypePtr RowConstructorWithNullCallToSpecialForm::resolveType(
const std::vector<facebook::velox::TypePtr>& argTypes) {
auto numInput = argTypes.size();
Expand Down Expand Up @@ -52,4 +53,5 @@ facebook::velox::exec::ExprPtr RowConstructorWithNullCallToSpecialForm::construc
return std::make_shared<facebook::velox::exec::Expr>(
type, std::move(compiledChildren), function, metadata, name, trackCpuUsage);
}

} // namespace gluten
2 changes: 2 additions & 0 deletions cpp/velox/operators/functions/RowConstructorWithNull.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "velox/expression/SpecialForm.h"

namespace gluten {

class RowConstructorWithNullCallToSpecialForm : public facebook::velox::exec::FunctionCallToSpecialForm {
public:
RowConstructorWithNullCallToSpecialForm(const std::string& rowFunctionName) {
Expand Down Expand Up @@ -49,4 +50,5 @@ class RowConstructorWithNullCallToSpecialForm : public facebook::velox::exec::Fu
private:
std::string rowFunctionName;
};

} // namespace gluten
6 changes: 2 additions & 4 deletions cpp/velox/operators/functions/RowFunctionWithNull.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@

namespace gluten {

/**
* @tparam allNull If true, set struct as null when all of arguments are all, else will
* set it null when one of its arguments is null.
*/
///@tparam allNull If true, set struct as null when all of arguments are all, else will
/// set it null when one of its arguments is null.
template <bool allNull>
class RowFunctionWithNull final : public facebook::velox::exec::VectorFunction {
public:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,5 @@ std::unique_ptr<common::Filter> SparkExprToSubfieldFilterParser::leafCallToSubfi
}
return nullptr;
}

} // namespace gluten
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ class SparkExprToSubfieldFilterParser : public facebook::velox::exec::ExprToSubf
// Compared to the upstream 'toSubfield', the push-down of filter on nested field is disabled.
bool toSparkSubfield(const facebook::velox::core::ITypedExpr* field, facebook::velox::common::Subfield& subfield);
};

} // namespace gluten
7 changes: 5 additions & 2 deletions cpp/velox/operators/plannodes/RowVectorStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "velox/exec/Task.h"

namespace {

class SuspendedSection {
public:
explicit SuspendedSection(facebook::velox::exec::Driver* driver) : driver_(driver) {
Expand All @@ -42,9 +43,11 @@ class SuspendedSection {
private:
facebook::velox::exec::Driver* const driver_;
};

} // namespace

namespace gluten {

class RowVectorStream {
public:
explicit RowVectorStream(
Expand All @@ -67,7 +70,7 @@ class RowVectorStream {
// possibility that this spill call hangs. See https://github.com/apache/incubator-gluten/issues/7243.
// As of now, non-zero running threads usually happens when:
// 1. Task A spills task B;
// 2. Task A trys to grow buffers created by task B, during which spill is requested on task A again.
// 2. Task A tries to grow buffers created by task B, during which spill is requested on task A again.
SuspendedSection ss(driverCtx_->driver);
hasNext = iterator_->hasNext();
}
Expand All @@ -77,7 +80,7 @@ class RowVectorStream {
return hasNext;
}

// Convert arrow batch to rowvector and use new output columns
// Convert arrow batch to row vector and use new output columns
facebook::velox::RowVectorPtr next() {
if (finished_) {
return nullptr;
Expand Down
1 change: 1 addition & 0 deletions cpp/velox/operators/reader/FileReaderIterator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,5 @@ std::shared_ptr<gluten::ResultIterator> FileReaderIterator::getInputIteratorFrom
}
throw new GlutenException("Unreachable.");
}

} // namespace gluten
1 change: 1 addition & 0 deletions cpp/velox/operators/reader/FileReaderIterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "velox/common/memory/MemoryPool.h"

namespace gluten {

enum FileReaderType { kBuffered, kStream, kNone };

class FileReaderIterator : public ColumnarBatchIterator {
Expand Down
3 changes: 2 additions & 1 deletion cpp/velox/operators/reader/ParquetReaderIterator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,5 @@ void ParquetBufferedReaderIterator::collectBatches() {
auto endTime = std::chrono::steady_clock::now();
collectBatchTime_ += std::chrono::duration_cast<std::chrono::nanoseconds>(endTime - startTime).count();
}
} // namespace gluten

} // namespace gluten
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@
using namespace facebook::velox;

namespace gluten {

namespace {

std::unique_ptr<ByteInputStream> toByteStream(uint8_t* data, int32_t size) {
std::vector<ByteRange> byteRanges;
byteRanges.push_back(ByteRange{data, size, 0});
auto byteStream = std::make_unique<BufferInputStream>(byteRanges);
return byteStream;
}

} // namespace

VeloxColumnarBatchSerializer::VeloxColumnarBatchSerializer(
Expand Down Expand Up @@ -89,4 +90,5 @@ std::shared_ptr<ColumnarBatch> VeloxColumnarBatchSerializer::deserialize(uint8_t
serde_->deserialize(byteStream.get(), veloxPool_.get(), rowType_, &result, &options_);
return std::make_shared<VeloxColumnarBatch>(result);
}

} // namespace gluten
2 changes: 2 additions & 0 deletions cpp/velox/operators/serializer/VeloxRowToColumnarConverter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ bool supporteType(const RowTypePtr rowType) {
}

} // namespace

VeloxRowToColumnarConverter::VeloxRowToColumnarConverter(
struct ArrowSchema* cSchema,
std::shared_ptr<memory::MemoryPool> memoryPool)
Expand Down Expand Up @@ -301,4 +302,5 @@ VeloxRowToColumnarConverter::convertPrimitive(int64_t numRows, int64_t* rowLengt
auto rowVector = std::make_shared<RowVector>(pool_.get(), rowType_, BufferPtr(nullptr), numRows, std::move(columns));
return std::make_shared<VeloxColumnarBatch>(rowVector);
}

} // namespace gluten
1 change: 1 addition & 0 deletions cpp/velox/operators/writer/VeloxArrowWriter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ std::shared_ptr<ColumnarBatch> VeloxArrowWriter::retrieveColumnarBatch() {
}
return reader_->next();
}

} // namespace gluten
2 changes: 2 additions & 0 deletions cpp/velox/operators/writer/VeloxArrowWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "operators/writer/ArrowWriter.h"

namespace gluten {

class VeloxArrowWriter : public ArrowWriter {
public:
explicit VeloxArrowWriter(const std::string& path, int64_t batchSize, facebook::velox::memory::MemoryPool* pool);
Expand All @@ -32,4 +33,5 @@ class VeloxArrowWriter : public ArrowWriter {
facebook::velox::memory::MemoryPool* pool_;
std::unique_ptr<ParquetStreamReaderIterator> reader_{nullptr};
};

} // namespace gluten
1 change: 0 additions & 1 deletion cpp/velox/operators/writer/VeloxParquetDataSource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ using namespace facebook::velox::common;
using namespace facebook::velox::filesystems;

namespace gluten {

namespace {
const int32_t kGzipWindowBits4k = 12;
}
Expand Down
1 change: 1 addition & 0 deletions cpp/velox/operators/writer/VeloxParquetDataSourceABFS.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,5 @@ class VeloxParquetDataSourceABFS final : public VeloxParquetDataSource {
abfsFileSystem->openFileForWrite(filePath_, {{}, sinkPool_.get()}), filePath_);
}
};

} // namespace gluten
2 changes: 2 additions & 0 deletions cpp/velox/operators/writer/VeloxParquetDataSourceGCS.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "velox/dwio/common/Options.h"

namespace gluten {

class VeloxParquetDataSourceGCS final : public VeloxParquetDataSource {
public:
VeloxParquetDataSourceGCS(
Expand All @@ -48,4 +49,5 @@ class VeloxParquetDataSourceGCS final : public VeloxParquetDataSource {
gcsFileSystem->openFileForWrite(filePath_, {{}, sinkPool_.get()}), filePath_);
}
};

} // namespace gluten
1 change: 1 addition & 0 deletions cpp/velox/operators/writer/VeloxParquetDataSourceHDFS.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,5 @@ class VeloxParquetDataSourceHDFS final : public VeloxParquetDataSource {
sink_ = dwio::common::FileSink::create(filePath_, {.connectorProperties = hiveConf, .pool = sinkPool_.get()});
}
};

} // namespace gluten
1 change: 1 addition & 0 deletions cpp/velox/operators/writer/VeloxParquetDataSourceS3.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,5 @@ class VeloxParquetDataSourceS3 final : public VeloxParquetDataSource {
sink_ = dwio::common::FileSink::create(filePath_, {.connectorProperties = hiveConf, .pool = sinkPool_.get()});
}
};

} // namespace gluten
2 changes: 2 additions & 0 deletions cpp/velox/shuffle/GlutenByteStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "velox/common/memory/ByteStream.h"

namespace facebook::velox {

class GlutenByteInputStream : public ByteInputStream {
protected:
/// TODO Remove after refactoring SpillInput.
Expand Down Expand Up @@ -264,4 +265,5 @@ inline int128_t GlutenByteInputStream::read<int128_t>() {
readBytes(reinterpret_cast<uint8_t*>(&value), sizeof(value));
return value;
}

} // namespace facebook::velox
Loading

0 comments on commit 731c5b5

Please sign in to comment.