Skip to content

Commit

Permalink
Clean up FOLLY nullable annotation (facebookincubator#9247)
Browse files Browse the repository at this point in the history
Summary: Pull Request resolved: facebookincubator#9247

Reviewed By: tanjialiang

Differential Revision: D55354910

Pulled By: xiaoxmeng

fbshipit-source-id: 0e488d1b60b92086db966fffbf191ad622b5a8c0
  • Loading branch information
duanmeng authored and facebook-github-bot committed Mar 26, 2024
1 parent 3aa020d commit 4f3d32f
Show file tree
Hide file tree
Showing 71 changed files with 352 additions and 466 deletions.
2 changes: 1 addition & 1 deletion pyvelox/serde.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace facebook::velox::py {
namespace py = pybind11;

namespace {
VectorPtr pyRestoreVectorFromFileHelper(const char* FOLLY_NONNULL filePath) {
VectorPtr pyRestoreVectorFromFileHelper(const char* filePath) {
using namespace facebook::velox;
memory::MemoryPool* pool = PyVeloxContext::getSingletonInstance().pool();
return restoreVectorFromFile(filePath, pool);
Expand Down
8 changes: 3 additions & 5 deletions velox/common/base/BloomFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,14 @@ class BloomFilter {
}

inline static void
set(uint64_t* FOLLY_NONNULL bloom, int32_t bloomSize, uint64_t hashCode) {
set(uint64_t* bloom, int32_t bloomSize, uint64_t hashCode) {
auto mask = bloomMask(hashCode);
auto index = bloomIndex(bloomSize, hashCode);
bloom[index] |= mask;
}

inline static bool test(
const uint64_t* FOLLY_NONNULL bloom,
int32_t bloomSize,
uint64_t hashCode) {
inline static bool
test(const uint64_t* bloom, int32_t bloomSize, uint64_t hashCode) {
auto mask = bloomMask(hashCode);
auto index = bloomIndex(bloomSize, hashCode);
return mask == (bloom[index] & mask);
Expand Down
6 changes: 3 additions & 3 deletions velox/common/base/tests/Memcpy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ uint64_t sum(uint64_t* data, int32_t size) {
}

struct CopyCallable {
void* FOLLY_NULLABLE source;
void* FOLLY_NULLABLE destination;
void* source;
void* destination;
int64_t size;
Semaphore* FOLLY_NULLABLE sem;
Semaphore* sem;

void operator()() {
if (FLAGS_system_memcpy) {
Expand Down
6 changes: 3 additions & 3 deletions velox/common/caching/ScanTracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class ScanTracker {
std::string_view id,
std::function<void(ScanTracker* FOLLY_NONNULL)> unregisterer,
int32_t loadQuantum,
FileGroupStats* FOLLY_NULLABLE fileGroupStats = nullptr)
FileGroupStats* fileGroupStats = nullptr)
: id_(id),
unregisterer_(unregisterer),
loadQuantum_(loadQuantum),
Expand Down Expand Up @@ -172,7 +172,7 @@ class ScanTracker {
return id_;
}

FileGroupStats* FOLLY_NULLABLE fileGroupStats() const {
FileGroupStats* fileGroupStats() const {
return fileGroupStats_;
}

Expand All @@ -190,7 +190,7 @@ class ScanTracker {
// single 10MB reference for 'fileGroupStats_'. 0 means the read
// size is unlimited.
const int32_t loadQuantum_;
FileGroupStats* FOLLY_NULLABLE fileGroupStats_;
FileGroupStats* fileGroupStats_;
};

} // namespace facebook::velox::cache
23 changes: 10 additions & 13 deletions velox/common/file/File.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ class ReadFile {
// buffer 'buf'. The bytes are returned as a string_view pointing to 'buf'.
//
// This method should be thread safe.
virtual std::string_view
pread(uint64_t offset, uint64_t length, void* FOLLY_NONNULL buf) const = 0;
virtual std::string_view pread(uint64_t offset, uint64_t length, void* buf)
const = 0;

// Same as above, but returns owned data directly.
//
Expand Down Expand Up @@ -174,10 +174,8 @@ class InMemoryReadFile : public ReadFile {
explicit InMemoryReadFile(std::string file)
: ownedFile_(std::move(file)), file_(ownedFile_) {}

std::string_view pread(
uint64_t offset,
uint64_t length,
void* FOLLY_NONNULL buf) const override;
std::string_view pread(uint64_t offset, uint64_t length, void* buf)
const override;

std::string pread(uint64_t offset, uint64_t length) const override;

Expand Down Expand Up @@ -213,7 +211,7 @@ class InMemoryReadFile : public ReadFile {

class InMemoryWriteFile final : public WriteFile {
public:
explicit InMemoryWriteFile(std::string* FOLLY_NONNULL file) : file_(file) {}
explicit InMemoryWriteFile(std::string* file) : file_(file) {}

void append(std::string_view data) final;
void append(std::unique_ptr<folly::IOBuf> data) final;
Expand All @@ -222,7 +220,7 @@ class InMemoryWriteFile final : public WriteFile {
uint64_t size() const final;

private:
std::string* FOLLY_NONNULL file_;
std::string* file_;
};

// Current implementation for the local version is quite simple (e.g. no
Expand All @@ -237,8 +235,8 @@ class LocalReadFile final : public ReadFile {

~LocalReadFile();

std::string_view
pread(uint64_t offset, uint64_t length, void* FOLLY_NONNULL buf) const final;
std::string_view pread(uint64_t offset, uint64_t length, void* buf)
const final;

uint64_t size() const final;

Expand All @@ -264,8 +262,7 @@ class LocalReadFile final : public ReadFile {
}

private:
void preadInternal(uint64_t offset, uint64_t length, char* FOLLY_NONNULL pos)
const;
void preadInternal(uint64_t offset, uint64_t length, char* pos) const;

std::string path_;
int32_t fd_;
Expand All @@ -289,7 +286,7 @@ class LocalWriteFile final : public WriteFile {
uint64_t size() const final;

private:
FILE* FOLLY_NONNULL file_;
FILE* file_;
mutable long size_;
bool closed_{false};
};
Expand Down
2 changes: 1 addition & 1 deletion velox/connectors/fuzzer/FuzzerConnector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace facebook::velox::connector::fuzzer {
FuzzerDataSource::FuzzerDataSource(
const std::shared_ptr<const RowType>& outputType,
const std::shared_ptr<connector::ConnectorTableHandle>& tableHandle,
velox::memory::MemoryPool* FOLLY_NONNULL pool)
velox::memory::MemoryPool* pool)
: outputType_(outputType), pool_(pool) {
auto fuzzerTableHandle =
std::dynamic_pointer_cast<FuzzerTableHandle>(tableHandle);
Expand Down
14 changes: 7 additions & 7 deletions velox/connectors/fuzzer/FuzzerConnector.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class FuzzerDataSource : public DataSource {
FuzzerDataSource(
const std::shared_ptr<const RowType>& outputType,
const std::shared_ptr<connector::ConnectorTableHandle>& tableHandle,
velox::memory::MemoryPool* FOLLY_NONNULL pool);
velox::memory::MemoryPool* pool);

void addSplit(std::shared_ptr<ConnectorSplit> split) override;

Expand Down Expand Up @@ -96,15 +96,15 @@ class FuzzerDataSource : public DataSource {
size_t completedRows_{0};
size_t completedBytes_{0};

memory::MemoryPool* FOLLY_NONNULL pool_;
memory::MemoryPool* pool_;
};

class FuzzerConnector final : public Connector {
public:
FuzzerConnector(
const std::string& id,
std::shared_ptr<const Config> config,
folly::Executor* FOLLY_NULLABLE /*executor*/)
folly::Executor* /*executor*/)
: Connector(id) {}

std::unique_ptr<DataSource> createDataSource(
Expand All @@ -113,7 +113,7 @@ class FuzzerConnector final : public Connector {
const std::unordered_map<
std::string,
std::shared_ptr<connector::ColumnHandle>>& /*columnHandles*/,
ConnectorQueryCtx* FOLLY_NONNULL connectorQueryCtx) override final {
ConnectorQueryCtx* connectorQueryCtx) override final {
return std::make_unique<FuzzerDataSource>(
outputType, tableHandle, connectorQueryCtx->memoryPool());
}
Expand All @@ -130,17 +130,17 @@ class FuzzerConnector final : public Connector {

class FuzzerConnectorFactory : public ConnectorFactory {
public:
static constexpr const char* FOLLY_NONNULL kFuzzerConnectorName{"fuzzer"};
static constexpr const char* kFuzzerConnectorName{"fuzzer"};

FuzzerConnectorFactory() : ConnectorFactory(kFuzzerConnectorName) {}

explicit FuzzerConnectorFactory(const char* FOLLY_NONNULL connectorName)
explicit FuzzerConnectorFactory(const char* connectorName)
: ConnectorFactory(connectorName) {}

std::shared_ptr<Connector> newConnector(
const std::string& id,
std::shared_ptr<const Config> config,
folly::Executor* FOLLY_NULLABLE executor = nullptr) override {
folly::Executor* executor = nullptr) override {
return std::make_shared<FuzzerConnector>(id, config, executor);
}
};
Expand Down
2 changes: 1 addition & 1 deletion velox/connectors/hive/HiveConnector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ namespace facebook::velox::connector::hive {
HiveConnector::HiveConnector(
const std::string& id,
std::shared_ptr<const Config> config,
folly::Executor* FOLLY_NULLABLE executor)
folly::Executor* executor)
: Connector(id),
hiveConfig_(std::make_shared<HiveConfig>(config)),
fileHandleFactory_(
Expand Down
15 changes: 7 additions & 8 deletions velox/connectors/hive/HiveConnector.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class HiveConnector : public Connector {
HiveConnector(
const std::string& id,
std::shared_ptr<const Config> config,
folly::Executor* FOLLY_NULLABLE executor);
folly::Executor* executor);

const std::shared_ptr<const Config>& connectorConfig() const override {
return hiveConfig_->config();
Expand Down Expand Up @@ -60,7 +60,7 @@ class HiveConnector : public Connector {
ConnectorQueryCtx* connectorQueryCtx,
CommitStrategy commitStrategy) override final;

folly::Executor* FOLLY_NULLABLE executor() const override {
folly::Executor* executor() const override {
return executor_;
}

Expand All @@ -77,18 +77,17 @@ class HiveConnector : public Connector {
protected:
const std::shared_ptr<HiveConfig> hiveConfig_;
FileHandleFactory fileHandleFactory_;
folly::Executor* FOLLY_NULLABLE executor_;
folly::Executor* executor_;
};

class HiveConnectorFactory : public ConnectorFactory {
public:
static constexpr const char* FOLLY_NONNULL kHiveConnectorName = "hive";
static constexpr const char* FOLLY_NONNULL kHiveHadoop2ConnectorName =
"hive-hadoop2";
static constexpr const char* kHiveConnectorName = "hive";
static constexpr const char* kHiveHadoop2ConnectorName = "hive-hadoop2";

HiveConnectorFactory() : ConnectorFactory(kHiveConnectorName) {}

explicit HiveConnectorFactory(const char* FOLLY_NONNULL connectorName)
explicit HiveConnectorFactory(const char* connectorName)
: ConnectorFactory(connectorName) {}

/// Register HiveConnector components such as Dwrf, Parquet readers and
Expand All @@ -98,7 +97,7 @@ class HiveConnectorFactory : public ConnectorFactory {
std::shared_ptr<Connector> newConnector(
const std::string& id,
std::shared_ptr<const Config> config,
folly::Executor* FOLLY_NULLABLE executor = nullptr) override {
folly::Executor* executor = nullptr) override {
return std::make_shared<HiveConnector>(id, config, executor);
}
};
Expand Down
2 changes: 1 addition & 1 deletion velox/connectors/hive/SplitReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class SplitReader {
const std::shared_ptr<const velox::RowType>& tableSchema);

void setPartitionValue(
common::ScanSpec* FOLLY_NONNULL spec,
common::ScanSpec* spec,
const std::string& partitionKey,
const std::optional<std::string>& value) const;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class AbfsConfig {
}

private:
const Config* FOLLY_NONNULL config_;
const Config* config_;
};

class AbfsReadFile::Impl {
Expand Down
2 changes: 1 addition & 1 deletion velox/connectors/tpch/TpchConnector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ TpchDataSource::TpchDataSource(
const std::unordered_map<
std::string,
std::shared_ptr<connector::ColumnHandle>>& columnHandles,
velox::memory::MemoryPool* FOLLY_NONNULL pool)
velox::memory::MemoryPool* pool)
: pool_(pool) {
auto tpchTableHandle =
std::dynamic_pointer_cast<TpchTableHandle>(tableHandle);
Expand Down
14 changes: 7 additions & 7 deletions velox/connectors/tpch/TpchConnector.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class TpchDataSource : public DataSource {
const std::unordered_map<
std::string,
std::shared_ptr<connector::ColumnHandle>>& columnHandles,
velox::memory::MemoryPool* FOLLY_NONNULL pool);
velox::memory::MemoryPool* pool);

void addSplit(std::shared_ptr<ConnectorSplit> split) override;

Expand Down Expand Up @@ -123,15 +123,15 @@ class TpchDataSource : public DataSource {
size_t completedRows_{0};
size_t completedBytes_{0};

memory::MemoryPool* FOLLY_NONNULL pool_;
memory::MemoryPool* pool_;
};

class TpchConnector final : public Connector {
public:
TpchConnector(
const std::string& id,
std::shared_ptr<const Config> config,
folly::Executor* FOLLY_NULLABLE /*executor*/)
folly::Executor* /*executor*/)
: Connector(id) {}

std::unique_ptr<DataSource> createDataSource(
Expand All @@ -140,7 +140,7 @@ class TpchConnector final : public Connector {
const std::unordered_map<
std::string,
std::shared_ptr<connector::ColumnHandle>>& columnHandles,
ConnectorQueryCtx* FOLLY_NONNULL connectorQueryCtx) override final {
ConnectorQueryCtx* connectorQueryCtx) override final {
return std::make_unique<TpchDataSource>(
outputType,
tableHandle,
Expand All @@ -160,17 +160,17 @@ class TpchConnector final : public Connector {

class TpchConnectorFactory : public ConnectorFactory {
public:
static constexpr const char* FOLLY_NONNULL kTpchConnectorName{"tpch"};
static constexpr const char* kTpchConnectorName{"tpch"};

TpchConnectorFactory() : ConnectorFactory(kTpchConnectorName) {}

explicit TpchConnectorFactory(const char* FOLLY_NONNULL connectorName)
explicit TpchConnectorFactory(const char* connectorName)
: ConnectorFactory(connectorName) {}

std::shared_ptr<Connector> newConnector(
const std::string& id,
std::shared_ptr<const Config> config,
folly::Executor* FOLLY_NULLABLE executor = nullptr) override {
folly::Executor* executor = nullptr) override {
return std::make_shared<TpchConnector>(id, config, executor);
}
};
Expand Down
6 changes: 3 additions & 3 deletions velox/docs/develop/arena.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ non-contiguous allocation, it frees all the blocks in that allocation.

// Allocates 'size' contiguous bytes preceded by a Header. Returns
// the address of Header.
Header* FOLLY_NONNULL allocate(int32_t size);
Header* allocate(int32_t size);

// Adds the allocation of 'header' and any extensions (if header has
// kContinued set) to the free list.
void free(Header* FOLLY_NONNULL header);
void free(Header* header);

StlAllocator, an allocator backed by HashStringAllocator that can be used with
STL containers, is implemented using the above allocate() and free() methods.
Expand Down Expand Up @@ -116,7 +116,7 @@ The prepareRead() method allows deserializing the data using ByteInputStream.
// Sets 'stream' to range over the data in the range of 'header' and
// possible continuation ranges.
static void prepareRead(
const Header* FOLLY_NONNULL header,
const Header* header,
ByteInputStream& stream);

Examples of Usage
Expand Down
4 changes: 2 additions & 2 deletions velox/dwio/common/BitConcatenation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
namespace facebook::velox::dwio::common {

void BitConcatenation::append(
const uint64_t* FOLLY_NULLABLE bits,
const uint64_t* bits,
int32_t begin,
int32_t end) {
int32_t numBits = end - begin;
Expand All @@ -46,7 +46,7 @@ void BitConcatenation::appendOnes(int32_t numOnes) {
}
}

uint64_t* FOLLY_NONNULL BitConcatenation::ensureSpace(int32_t numBits) {
uint64_t* BitConcatenation::ensureSpace(int32_t numBits) {
if (!*buffer_) {
*buffer_ = AlignedBuffer::allocate<bool>(numBits_ + numBits, &pool_, true);
} else if (numBits_ + numBits > (*buffer_)->capacity() * 8) {
Expand Down
Loading

0 comments on commit 4f3d32f

Please sign in to comment.