Skip to content

Commit

Permalink
Fix document parsing error for QLDB
Browse files Browse the repository at this point in the history
  • Loading branch information
yc1111 committed Jan 24, 2024
1 parent e25061b commit c1077d5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion exps/check_stat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ done
for host in `cat clients`
do
echo client $host
ssh $host "pgrep rangeClient"
ssh $host "pgrep verifyClient"
done
2 changes: 1 addition & 1 deletion exps/clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ for server in `cat replicas`
do
echo ${server}
rsync -a ${expdir} ${server}:${rootdir}/
ssh ${server} "killall -9 strongstore; rm -rf ${logdir}; mkdir -p /tmp/testdb; mkdir -p /tmp/testledger; rm -rf /tmp/testdb/*; rm -rf /tmp/testledger/*; rm -rf /tmp/qldb.store/"
ssh ${server} "killall -9 strongstore; rm -rf ${logdir}; mkdir -p /tmp/testdb; mkdir -p /tmp/testledger; rm -rf /tmp/testdb/*; rm -rf /tmp/testledger/*; rm -rf /tmp/qldb.store/; rm -rf /tmp/replica*.store;"
done

for client in `cat clients`
Expand Down
22 changes: 10 additions & 12 deletions ledger/common/db.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,24 @@ class DB {
}

inline void CreateCache(const std::string& id, Chunk&& chunk) {
m_cache_.emplace(id, std::move(chunk));
tbb::concurrent_hash_map<std::string, Chunk>::accessor a;
m_cache_.insert(a, std::make_pair(id, std::move(chunk)));
}

inline bool Get(const std::string& key, std::string* value) const {
return db_->Get(rocksdb::ReadOptions(), key, value).ok();
}

inline Chunk* Get(const std::string& key) {
auto it = m_cache_.find(key);
if (it != m_cache_.end()) {
return &it->second;
}
rocksdb::PinnableSlice value;
if (db_->Get(rocksdb::ReadOptions(), db_->DefaultColumnFamily(),
rocksdb::Slice(key), &value).ok()) {
m_cache_.emplace(key, ToChunk(value));
tbb::concurrent_hash_map<std::string, Chunk>::accessor a;
if (m_cache_.find(a, key)) return &(a->second);
std::string value;
if (db_->Get(rocksdb::ReadOptions(), key, &value).ok()) {
m_cache_.insert(a, std::make_pair(key, ToChunk(value)));
} else {
m_cache_.emplace(key, Chunk());
m_cache_.insert(a, std::make_pair(key, Chunk()));
}
return &m_cache_[key];
return &(a->second);
}

inline Chunk* Get(const Hash& key) {
Expand Down Expand Up @@ -154,7 +152,7 @@ class DB {
rocksdb::DB* db_;
long total_;
tbb::concurrent_hash_map<std::string, Chunk> cache_;
std::unordered_map<std::string, Chunk> m_cache_;
tbb::concurrent_hash_map<std::string, Chunk> m_cache_;
};

} // namespace ledgebase
Expand Down
2 changes: 1 addition & 1 deletion ledger/qldb/qlnode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Chunk Document::Encode(const Slice& key,
const Slice& val,
const BlockAddress& addr,
const MetaData& meta) {
auto ledger_nm_bytes = addr.ledger_name.len();
auto ledger_nm_bytes = uint32_t(addr.ledger_name.len());
auto key_bytes = key.len();
auto entry_bytes = key.len() + val.len() + sizeof(uint32_t) * 2;
size_t bytes = Document::fixed_length + key.len() + val.len()
Expand Down

0 comments on commit c1077d5

Please sign in to comment.