// COPYING file in the root directory) and Apache 2.0 License
// (found in the LICENSE.Apache file in the root directory).
-#ifndef __STDC_FORMAT_MACROS
-#define __STDC_FORMAT_MACROS
-#endif
-
#if !defined(GFLAGS) || defined(ROCKSDB_LITE)
#include <cstdio>
int main() {
#include "rocksdb/db.h"
#include "rocksdb/status.h"
#include "rocksdb/table.h"
+#include "test_util/testharness.h"
#include "util/gflags_compat.h"
-#include "util/testharness.h"
const int MAX_SHARDS = 100000;
Reader* reader;
char pad2[128] __attribute__((__unused__));
std::atomic<uint64_t> last_read{0};
- std::unique_ptr<rocksdb::Iterator> it;
- std::unique_ptr<rocksdb::Iterator> it_cacheonly;
+ std::unique_ptr<ROCKSDB_NAMESPACE::Iterator> it;
+ std::unique_ptr<ROCKSDB_NAMESPACE::Iterator> it_cacheonly;
Key upper_bound;
- rocksdb::Slice upper_bound_slice;
+ ROCKSDB_NAMESPACE::Slice upper_bound_slice;
char pad3[128] __attribute__((__unused__));
};
struct Reader {
public:
- explicit Reader(std::vector<ShardState>* shard_states, rocksdb::DB* db)
+ explicit Reader(std::vector<ShardState>* shard_states,
+ ROCKSDB_NAMESPACE::DB* db)
: shard_states_(shard_states), db_(db) {
sem_init(&sem_, 0, 0);
thread_ = port::Thread(&Reader::run, this);
ShardState& state = (*shard_states_)[shard];
if (!state.it) {
// Initialize iterators
- rocksdb::ReadOptions options;
+ ROCKSDB_NAMESPACE::ReadOptions options;
options.tailing = true;
if (FLAGS_iterate_upper_bound) {
state.upper_bound = Key(shard, std::numeric_limits<uint64_t>::max());
- state.upper_bound_slice = rocksdb::Slice(
+ state.upper_bound_slice = ROCKSDB_NAMESPACE::Slice(
(const char*)&state.upper_bound, sizeof(state.upper_bound));
options.iterate_upper_bound = &state.upper_bound_slice;
}
state.it.reset(db_->NewIterator(options));
if (FLAGS_cache_only_first) {
- options.read_tier = rocksdb::ReadTier::kBlockCacheTier;
+ options.read_tier = ROCKSDB_NAMESPACE::ReadTier::kBlockCacheTier;
state.it_cacheonly.reset(db_->NewIterator(options));
}
}
const uint64_t upto = state.last_written.load();
- for (rocksdb::Iterator* it : {state.it_cacheonly.get(), state.it.get()}) {
+ for (ROCKSDB_NAMESPACE::Iterator* it :
+ {state.it_cacheonly.get(), state.it.get()}) {
if (it == nullptr) {
continue;
}
for (uint64_t seq = state.last_read.load() + 1; seq <= upto; ++seq) {
if (need_seek) {
Key from(shard, state.last_read.load() + 1);
- it->Seek(rocksdb::Slice((const char*)&from, sizeof(from)));
+ it->Seek(ROCKSDB_NAMESPACE::Slice((const char*)&from, sizeof(from)));
need_seek = false;
} else {
it->Next();
private:
char pad1[128] __attribute__((__unused__));
std::vector<ShardState>* shard_states_;
- rocksdb::DB* db_;
- rocksdb::port::Thread thread_;
+ ROCKSDB_NAMESPACE::DB* db_;
+ ROCKSDB_NAMESPACE::port::Thread thread_;
sem_t sem_;
std::mutex queue_mutex_;
std::bitset<MAX_SHARDS + 1> shards_pending_set_;
};
struct Writer {
- explicit Writer(std::vector<ShardState>* shard_states, rocksdb::DB* db)
+ explicit Writer(std::vector<ShardState>* shard_states,
+ ROCKSDB_NAMESPACE::DB* db)
: shard_states_(shard_states), db_(db) {}
void start() { thread_ = port::Thread(&Writer::run, this); }
uint64_t seqno = state.last_written.load() + 1;
Key key(shard, seqno);
// fprintf(stderr, "Writing (%ld, %ld)\n", shard, seqno);
- rocksdb::Status status =
- db_->Put(rocksdb::WriteOptions(),
- rocksdb::Slice((const char*)&key, sizeof(key)),
- rocksdb::Slice(value));
+ ROCKSDB_NAMESPACE::Status status =
+ db_->Put(ROCKSDB_NAMESPACE::WriteOptions(),
+ ROCKSDB_NAMESPACE::Slice((const char*)&key, sizeof(key)),
+ ROCKSDB_NAMESPACE::Slice(value));
assert(status.ok());
state.last_written.store(seqno);
state.reader->onWrite(shard);
private:
char pad1[128] __attribute__((__unused__));
std::vector<ShardState>* shard_states_;
- rocksdb::DB* db_;
- rocksdb::port::Thread thread_;
+ ROCKSDB_NAMESPACE::DB* db_;
+ ROCKSDB_NAMESPACE::port::Thread thread_;
char pad2[128] __attribute__((__unused__));
};
struct StatsThread {
- explicit StatsThread(rocksdb::DB* db)
+ explicit StatsThread(ROCKSDB_NAMESPACE::DB* db)
: db_(db), thread_(&StatsThread::run, this) {}
void run() {
}
private:
- rocksdb::DB* db_;
+ ROCKSDB_NAMESPACE::DB* db_;
std::mutex cvm_;
std::condition_variable cv_;
- rocksdb::port::Thread thread_;
+ ROCKSDB_NAMESPACE::port::Thread thread_;
std::atomic<bool> done_{false};
};
GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
std::mt19937 rng{std::random_device()()};
- rocksdb::Status status;
- std::string path = rocksdb::test::PerThreadDBPath("forward_iterator_test");
+ ROCKSDB_NAMESPACE::Status status;
+ std::string path =
+ ROCKSDB_NAMESPACE::test::PerThreadDBPath("forward_iterator_test");
fprintf(stderr, "db path is %s\n", path.c_str());
- rocksdb::Options options;
+ ROCKSDB_NAMESPACE::Options options;
options.create_if_missing = true;
- options.compression = rocksdb::CompressionType::kNoCompression;
- options.compaction_style = rocksdb::CompactionStyle::kCompactionStyleNone;
+ options.compression = ROCKSDB_NAMESPACE::CompressionType::kNoCompression;
+ options.compaction_style =
+ ROCKSDB_NAMESPACE::CompactionStyle::kCompactionStyleNone;
options.level0_slowdown_writes_trigger = 99999;
options.level0_stop_writes_trigger = 99999;
options.use_direct_io_for_flush_and_compaction = true;
options.write_buffer_size = FLAGS_memtable_size;
- rocksdb::BlockBasedTableOptions table_options;
- table_options.block_cache = rocksdb::NewLRUCache(FLAGS_block_cache_size);
+ ROCKSDB_NAMESPACE::BlockBasedTableOptions table_options;
+ table_options.block_cache =
+ ROCKSDB_NAMESPACE::NewLRUCache(FLAGS_block_cache_size);
table_options.block_size = FLAGS_block_size;
options.table_factory.reset(
- rocksdb::NewBlockBasedTableFactory(table_options));
+ ROCKSDB_NAMESPACE::NewBlockBasedTableFactory(table_options));
- status = rocksdb::DestroyDB(path, options);
+ status = ROCKSDB_NAMESPACE::DestroyDB(path, options);
assert(status.ok());
- rocksdb::DB* db_raw;
- status = rocksdb::DB::Open(options, path, &db_raw);
+ ROCKSDB_NAMESPACE::DB* db_raw;
+ status = ROCKSDB_NAMESPACE::DB::Open(options, path, &db_raw);
assert(status.ok());
- std::unique_ptr<rocksdb::DB> db(db_raw);
+ std::unique_ptr<ROCKSDB_NAMESPACE::DB> db(db_raw);
std::vector<ShardState> shard_states(FLAGS_shards + 1);
std::deque<Reader> readers;