mirror of https://gitee.com/bigwinds/arangodb
changed storage format
This commit is contained in:
parent
f20a0a8c3d
commit
3ad939ea41
|
@ -328,13 +328,12 @@ void RocksDBEdgeIndexIterator::lookupInRocksDB(StringRef fromTo) {
|
||||||
rocksdb::Comparator const* cmp = _index->comparator();
|
rocksdb::Comparator const* cmp = _index->comparator();
|
||||||
|
|
||||||
_builder.openArray();
|
_builder.openArray();
|
||||||
RocksDBToken token;
|
|
||||||
auto end = _bounds.end();
|
auto end = _bounds.end();
|
||||||
while (_iterator->Valid() &&
|
while (_iterator->Valid() &&
|
||||||
(cmp->Compare(_iterator->key(), end) < 0)) {
|
(cmp->Compare(_iterator->key(), end) < 0)) {
|
||||||
StringRef edgeKey = RocksDBKey::primaryKey(_iterator->key());
|
TRI_voc_rid_t revisionId = RocksDBKey::revisionId(_iterator->key());
|
||||||
Result res = rocksColl->lookupDocumentToken(_trx, edgeKey, token);
|
RocksDBToken token(revisionId);
|
||||||
if (res.ok()) {
|
|
||||||
ManagedDocumentResult mmdr;
|
ManagedDocumentResult mmdr;
|
||||||
if (rocksColl->readDocument(_trx, token, mmdr)) {
|
if (rocksColl->readDocument(_trx, token, mmdr)) {
|
||||||
_builder.add(VPackValue(token.revisionId()));
|
_builder.add(VPackValue(token.revisionId()));
|
||||||
|
@ -346,13 +345,6 @@ void RocksDBEdgeIndexIterator::lookupInRocksDB(StringRef fromTo) {
|
||||||
// We have a revision id without a document...
|
// We have a revision id without a document...
|
||||||
TRI_ASSERT(false);
|
TRI_ASSERT(false);
|
||||||
}
|
}
|
||||||
#ifdef USE_MAINTAINER_MODE
|
|
||||||
} else {
|
|
||||||
// Index inconsistency, we indexed a primaryKey => revision that is
|
|
||||||
// not known any more
|
|
||||||
TRI_ASSERT(res.ok());
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
_iterator->Next();
|
_iterator->Next();
|
||||||
}
|
}
|
||||||
_builder.close();
|
_builder.close();
|
||||||
|
@ -455,12 +447,12 @@ void RocksDBEdgeIndex::toVelocyPack(VPackBuilder& builder, bool withFigures,
|
||||||
int RocksDBEdgeIndex::insert(transaction::Methods* trx,
|
int RocksDBEdgeIndex::insert(transaction::Methods* trx,
|
||||||
TRI_voc_rid_t revisionId, VPackSlice const& doc,
|
TRI_voc_rid_t revisionId, VPackSlice const& doc,
|
||||||
bool isRollback) {
|
bool isRollback) {
|
||||||
VPackSlice primaryKey = doc.get(StaticStrings::KeyString);
|
//VPackSlice primaryKey = doc.get(StaticStrings::KeyString);
|
||||||
VPackSlice fromTo = doc.get(_directionAttr);
|
VPackSlice fromTo = doc.get(_directionAttr);
|
||||||
TRI_ASSERT(primaryKey.isString() && fromTo.isString());
|
TRI_ASSERT(fromTo.isString());
|
||||||
auto fromToRef = StringRef(fromTo);
|
auto fromToRef = StringRef(fromTo);
|
||||||
RocksDBKey key =
|
RocksDBKey key =
|
||||||
RocksDBKey::EdgeIndexValue(_objectId, fromToRef, StringRef(primaryKey));
|
RocksDBKey::EdgeIndexValue(_objectId, fromToRef, revisionId);
|
||||||
// blacklist key in cache
|
// blacklist key in cache
|
||||||
blackListKey(fromToRef);
|
blackListKey(fromToRef);
|
||||||
|
|
||||||
|
@ -486,12 +478,12 @@ int RocksDBEdgeIndex::insertRaw(RocksDBMethods*, TRI_voc_rid_t,
|
||||||
int RocksDBEdgeIndex::remove(transaction::Methods* trx,
|
int RocksDBEdgeIndex::remove(transaction::Methods* trx,
|
||||||
TRI_voc_rid_t revisionId, VPackSlice const& doc,
|
TRI_voc_rid_t revisionId, VPackSlice const& doc,
|
||||||
bool isRollback) {
|
bool isRollback) {
|
||||||
VPackSlice primaryKey = doc.get(StaticStrings::KeyString);
|
//VPackSlice primaryKey = doc.get(StaticStrings::KeyString);
|
||||||
VPackSlice fromTo = doc.get(_directionAttr);
|
VPackSlice fromTo = doc.get(_directionAttr);
|
||||||
auto fromToRef = StringRef(fromTo);
|
auto fromToRef = StringRef(fromTo);
|
||||||
TRI_ASSERT(primaryKey.isString() && fromTo.isString());
|
TRI_ASSERT(fromTo.isString());
|
||||||
RocksDBKey key =
|
RocksDBKey key =
|
||||||
RocksDBKey::EdgeIndexValue(_objectId, fromToRef, StringRef(primaryKey));
|
RocksDBKey::EdgeIndexValue(_objectId, fromToRef, revisionId);
|
||||||
|
|
||||||
// blacklist key in cache
|
// blacklist key in cache
|
||||||
blackListKey(fromToRef);
|
blackListKey(fromToRef);
|
||||||
|
@ -521,12 +513,12 @@ void RocksDBEdgeIndex::batchInsert(
|
||||||
std::shared_ptr<arangodb::basics::LocalTaskQueue> queue) {
|
std::shared_ptr<arangodb::basics::LocalTaskQueue> queue) {
|
||||||
RocksDBMethods* mthd = rocksutils::toRocksMethods(trx);
|
RocksDBMethods* mthd = rocksutils::toRocksMethods(trx);
|
||||||
for (std::pair<TRI_voc_rid_t, VPackSlice> const& doc : documents) {
|
for (std::pair<TRI_voc_rid_t, VPackSlice> const& doc : documents) {
|
||||||
VPackSlice primaryKey = doc.second.get(StaticStrings::KeyString);
|
//VPackSlice primaryKey = doc.second.get(StaticStrings::KeyString);
|
||||||
VPackSlice fromTo = doc.second.get(_directionAttr);
|
VPackSlice fromTo = doc.second.get(_directionAttr);
|
||||||
TRI_ASSERT(primaryKey.isString() && fromTo.isString());
|
TRI_ASSERT(fromTo.isString());
|
||||||
auto fromToRef = StringRef(fromTo);
|
auto fromToRef = StringRef(fromTo);
|
||||||
RocksDBKey key =
|
RocksDBKey key =
|
||||||
RocksDBKey::EdgeIndexValue(_objectId, fromToRef, StringRef(primaryKey));
|
RocksDBKey::EdgeIndexValue(_objectId, fromToRef, doc.first);
|
||||||
|
|
||||||
blackListKey(fromToRef);
|
blackListKey(fromToRef);
|
||||||
Result r = mthd->Put(_cf, rocksdb::Slice(key.string()), rocksdb::Slice(),
|
Result r = mthd->Put(_cf, rocksdb::Slice(key.string()), rocksdb::Slice(),
|
||||||
|
@ -657,11 +649,10 @@ void RocksDBEdgeIndex::warmup(arangodb::transaction::Methods* trx) {
|
||||||
std::string previous = "";
|
std::string previous = "";
|
||||||
VPackBuilder builder;
|
VPackBuilder builder;
|
||||||
ManagedDocumentResult mmdr;
|
ManagedDocumentResult mmdr;
|
||||||
RocksDBToken token;
|
|
||||||
bool needsInsert = false;
|
bool needsInsert = false;
|
||||||
|
|
||||||
rocksutils::iterateBounds(bounds, [&](rocksdb::Iterator* it) {
|
rocksutils::iterateBounds(bounds, [&](rocksdb::Iterator* it) {
|
||||||
auto key = it->key();
|
rocksdb::Slice key = it->key();
|
||||||
StringRef v = RocksDBKey::vertexId(key);
|
StringRef v = RocksDBKey::vertexId(key);
|
||||||
if (previous.empty()) {
|
if (previous.empty()) {
|
||||||
// First call.
|
// First call.
|
||||||
|
@ -707,14 +698,11 @@ void RocksDBEdgeIndex::warmup(arangodb::transaction::Methods* trx) {
|
||||||
needsInsert = true;
|
needsInsert = true;
|
||||||
builder.openArray();
|
builder.openArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
if (needsInsert) {
|
if (needsInsert) {
|
||||||
StringRef edgeKey = RocksDBKey::primaryKey(key);
|
TRI_voc_rid_t revisionId = RocksDBKey::revisionId(key);
|
||||||
Result res = rocksColl->lookupDocumentToken(trx, edgeKey, token);
|
RocksDBToken token(revisionId);
|
||||||
if (res.ok() && rocksColl->readDocument(trx, token, mmdr)) {
|
if (rocksColl->readDocument(trx, token, mmdr)) {
|
||||||
builder.add(VPackValue(token.revisionId()));
|
builder.add(VPackValue(token.revisionId()));
|
||||||
VPackSlice doc(mmdr.vpack());
|
VPackSlice doc(mmdr.vpack());
|
||||||
TRI_ASSERT(doc.isObject());
|
TRI_ASSERT(doc.isObject());
|
||||||
|
|
|
@ -201,14 +201,13 @@ int RocksDBFulltextIndex::insert(transaction::Methods* trx,
|
||||||
RocksDBMethods* mthd = rocksutils::toRocksMethods(trx);
|
RocksDBMethods* mthd = rocksutils::toRocksMethods(trx);
|
||||||
// now we are going to construct the value to insert into rocksdb
|
// now we are going to construct the value to insert into rocksdb
|
||||||
// unique indexes have a different key structure
|
// unique indexes have a different key structure
|
||||||
StringRef docKey(doc.get(StaticStrings::KeyString));
|
|
||||||
RocksDBValue value = RocksDBValue::IndexValue();
|
RocksDBValue value = RocksDBValue::IndexValue();
|
||||||
|
|
||||||
int res = TRI_ERROR_NO_ERROR;
|
int res = TRI_ERROR_NO_ERROR;
|
||||||
// size_t const count = words.size();
|
// size_t const count = words.size();
|
||||||
for (std::string const& word : words) {
|
for (std::string const& word : words) {
|
||||||
RocksDBKey key =
|
RocksDBKey key =
|
||||||
RocksDBKey::FulltextIndexValue(_objectId, StringRef(word), docKey);
|
RocksDBKey::FulltextIndexValue(_objectId, StringRef(word), revisionId);
|
||||||
|
|
||||||
Result r = mthd->Put(_cf, key, value.string(), rocksutils::index);
|
Result r = mthd->Put(_cf, key, value.string(), rocksutils::index);
|
||||||
if (!r.ok()) {
|
if (!r.ok()) {
|
||||||
|
@ -220,14 +219,14 @@ int RocksDBFulltextIndex::insert(transaction::Methods* trx,
|
||||||
for (size_t j = 0; j < i; ++j) {
|
for (size_t j = 0; j < i; ++j) {
|
||||||
std::string const& word = words[j];
|
std::string const& word = words[j];
|
||||||
RocksDBKey key =
|
RocksDBKey key =
|
||||||
RocksDBKey::FulltextIndexValue(_objectId, StringRef(word), docKey);
|
RocksDBKey::FulltextIndexValue(_objectId, StringRef(word), revisionId);
|
||||||
rtrx->Delete(key.string());
|
rtrx->Delete(key.string());
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
int RocksDBFulltextIndex::insertRaw(RocksDBMethods* batch, TRI_voc_rid_t,
|
int RocksDBFulltextIndex::insertRaw(RocksDBMethods* batch, TRI_voc_rid_t revisionId,
|
||||||
arangodb::velocypack::Slice const& doc) {
|
arangodb::velocypack::Slice const& doc) {
|
||||||
std::set<std::string> words = wordlist(doc);
|
std::set<std::string> words = wordlist(doc);
|
||||||
if (words.empty()) {
|
if (words.empty()) {
|
||||||
|
@ -236,12 +235,12 @@ int RocksDBFulltextIndex::insertRaw(RocksDBMethods* batch, TRI_voc_rid_t,
|
||||||
|
|
||||||
// now we are going to construct the value to insert into rocksdb
|
// now we are going to construct the value to insert into rocksdb
|
||||||
// unique indexes have a different key structure
|
// unique indexes have a different key structure
|
||||||
StringRef docKey(doc.get(StaticStrings::KeyString));
|
//StringRef docKey(doc.get(StaticStrings::KeyString));
|
||||||
RocksDBValue value = RocksDBValue::IndexValue();
|
RocksDBValue value = RocksDBValue::IndexValue();
|
||||||
|
|
||||||
for (std::string const& word : words) {
|
for (std::string const& word : words) {
|
||||||
RocksDBKey key =
|
RocksDBKey key =
|
||||||
RocksDBKey::FulltextIndexValue(_objectId, StringRef(word), docKey);
|
RocksDBKey::FulltextIndexValue(_objectId, StringRef(word), revisionId);
|
||||||
batch->Put(_cf, key, value.string());
|
batch->Put(_cf, key, value.string());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,11 +260,10 @@ int RocksDBFulltextIndex::remove(transaction::Methods* trx,
|
||||||
RocksDBMethods* mthd = rocksutils::toRocksMethods(trx);
|
RocksDBMethods* mthd = rocksutils::toRocksMethods(trx);
|
||||||
// now we are going to construct the value to insert into rocksdb
|
// now we are going to construct the value to insert into rocksdb
|
||||||
// unique indexes have a different key structure
|
// unique indexes have a different key structure
|
||||||
StringRef docKey(doc.get(StaticStrings::KeyString));
|
|
||||||
int res = TRI_ERROR_NO_ERROR;
|
int res = TRI_ERROR_NO_ERROR;
|
||||||
for (std::string const& word : words) {
|
for (std::string const& word : words) {
|
||||||
RocksDBKey key =
|
RocksDBKey key =
|
||||||
RocksDBKey::FulltextIndexValue(_objectId, StringRef(word), docKey);
|
RocksDBKey::FulltextIndexValue(_objectId, StringRef(word), revisionId);
|
||||||
|
|
||||||
Result r = mthd->Delete(_cf, key);
|
Result r = mthd->Delete(_cf, key);
|
||||||
if (!r.ok()) {
|
if (!r.ok()) {
|
||||||
|
@ -276,15 +274,14 @@ int RocksDBFulltextIndex::remove(transaction::Methods* trx,
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
int RocksDBFulltextIndex::removeRaw(RocksDBMethods* batch, TRI_voc_rid_t,
|
int RocksDBFulltextIndex::removeRaw(RocksDBMethods* batch, TRI_voc_rid_t revisionId,
|
||||||
arangodb::velocypack::Slice const& doc) {
|
arangodb::velocypack::Slice const& doc) {
|
||||||
std::set<std::string> words = wordlist(doc);
|
std::set<std::string> words = wordlist(doc);
|
||||||
// now we are going to construct the value to insert into rocksdb
|
// now we are going to construct the value to insert into rocksdb
|
||||||
// unique indexes have a different key structure
|
// unique indexes have a different key structure
|
||||||
StringRef docKey(doc.get(StaticStrings::KeyString));
|
|
||||||
for (std::string const& word : words) {
|
for (std::string const& word : words) {
|
||||||
RocksDBKey key =
|
RocksDBKey key =
|
||||||
RocksDBKey::FulltextIndexValue(_objectId, StringRef(word), docKey);
|
RocksDBKey::FulltextIndexValue(_objectId, StringRef(word), revisionId);
|
||||||
batch->Delete(_cf, key);
|
batch->Delete(_cf, key);
|
||||||
}
|
}
|
||||||
return TRI_ERROR_NO_ERROR;
|
return TRI_ERROR_NO_ERROR;
|
||||||
|
@ -462,7 +459,7 @@ Result RocksDBFulltextIndex::executeQuery(transaction::Methods* trx,
|
||||||
FulltextQuery const& query,
|
FulltextQuery const& query,
|
||||||
size_t maxResults,
|
size_t maxResults,
|
||||||
VPackBuilder& builder) {
|
VPackBuilder& builder) {
|
||||||
std::set<std::string> resultSet;
|
std::set<TRI_voc_rid_t> resultSet;
|
||||||
for (FulltextQueryToken const& token : query) {
|
for (FulltextQueryToken const& token : query) {
|
||||||
applyQueryToken(trx, token, resultSet);
|
applyQueryToken(trx, token, resultSet);
|
||||||
}
|
}
|
||||||
|
@ -477,15 +474,13 @@ Result RocksDBFulltextIndex::executeQuery(transaction::Methods* trx,
|
||||||
|
|
||||||
builder.openArray();
|
builder.openArray();
|
||||||
// get the first N results
|
// get the first N results
|
||||||
std::set<std::string>::iterator it = resultSet.cbegin();
|
std::set<TRI_voc_rid_t>::iterator it = resultSet.cbegin();
|
||||||
while (maxResults > 0 && it != resultSet.cend()) {
|
while (maxResults > 0 && it != resultSet.cend()) {
|
||||||
RocksDBToken token = idx->lookupKey(trx, StringRef(*it));
|
RocksDBToken token(*it);
|
||||||
if (token.revisionId()) {
|
if (token.revisionId() && physical->readDocument(trx, token, mmdr)) {
|
||||||
if (physical->readDocument(trx, token, mmdr)) {
|
|
||||||
mmdr.addToBuilder(builder, true);
|
mmdr.addToBuilder(builder, true);
|
||||||
maxResults--;
|
maxResults--;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
builder.close();
|
builder.close();
|
||||||
|
@ -505,7 +500,7 @@ static RocksDBKeyBounds MakeBounds(uint64_t oid,
|
||||||
|
|
||||||
Result RocksDBFulltextIndex::applyQueryToken(transaction::Methods* trx,
|
Result RocksDBFulltextIndex::applyQueryToken(transaction::Methods* trx,
|
||||||
FulltextQueryToken const& token,
|
FulltextQueryToken const& token,
|
||||||
std::set<std::string>& resultSet) {
|
std::set<TRI_voc_rid_t>& resultSet) {
|
||||||
RocksDBMethods* mthds = rocksutils::toRocksMethods(trx);
|
RocksDBMethods* mthds = rocksutils::toRocksMethods(trx);
|
||||||
// why can't I have an assignment operator when I want one
|
// why can't I have an assignment operator when I want one
|
||||||
RocksDBKeyBounds bounds = MakeBounds(_objectId, token);
|
RocksDBKeyBounds bounds = MakeBounds(_objectId, token);
|
||||||
|
@ -518,7 +513,7 @@ Result RocksDBFulltextIndex::applyQueryToken(transaction::Methods* trx,
|
||||||
iter->Seek(bounds.start());
|
iter->Seek(bounds.start());
|
||||||
|
|
||||||
// set is used to perform an intersection with the result set
|
// set is used to perform an intersection with the result set
|
||||||
std::set<std::string> intersect;
|
std::set<TRI_voc_rid_t> intersect;
|
||||||
// apply left to right logic, merging all current results with ALL previous
|
// apply left to right logic, merging all current results with ALL previous
|
||||||
while (iter->Valid() && cmp->Compare(iter->key(), end) < 0) {
|
while (iter->Valid() && cmp->Compare(iter->key(), end) < 0) {
|
||||||
TRI_ASSERT(_objectId == RocksDBKey::objectId(iter->key()));
|
TRI_ASSERT(_objectId == RocksDBKey::objectId(iter->key()));
|
||||||
|
@ -528,13 +523,13 @@ Result RocksDBFulltextIndex::applyQueryToken(transaction::Methods* trx,
|
||||||
return rocksutils::convertStatus(s);
|
return rocksutils::convertStatus(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
StringRef key = RocksDBKey::primaryKey(iter->key());
|
TRI_voc_rid_t revisionId = RocksDBKey::revisionId(iter->key());
|
||||||
if (token.operation == FulltextQueryToken::AND) {
|
if (token.operation == FulltextQueryToken::AND) {
|
||||||
intersect.insert(key.toString());
|
intersect.insert(revisionId);
|
||||||
} else if (token.operation == FulltextQueryToken::OR) {
|
} else if (token.operation == FulltextQueryToken::OR) {
|
||||||
resultSet.insert(key.toString());
|
resultSet.insert(revisionId);
|
||||||
} else if (token.operation == FulltextQueryToken::EXCLUDE) {
|
} else if (token.operation == FulltextQueryToken::EXCLUDE) {
|
||||||
resultSet.erase(key.toString());
|
resultSet.erase(revisionId);
|
||||||
}
|
}
|
||||||
iter->Next();
|
iter->Next();
|
||||||
}
|
}
|
||||||
|
@ -542,7 +537,7 @@ Result RocksDBFulltextIndex::applyQueryToken(transaction::Methods* trx,
|
||||||
if (resultSet.empty() || intersect.empty()) {
|
if (resultSet.empty() || intersect.empty()) {
|
||||||
resultSet.clear();
|
resultSet.clear();
|
||||||
} else {
|
} else {
|
||||||
std::set<std::string> output;
|
std::set<TRI_voc_rid_t> output;
|
||||||
std::set_intersection(resultSet.begin(), resultSet.end(),
|
std::set_intersection(resultSet.begin(), resultSet.end(),
|
||||||
intersect.begin(), intersect.end(),
|
intersect.begin(), intersect.end(),
|
||||||
std::inserter(output, output.begin()));
|
std::inserter(output, output.begin()));
|
||||||
|
|
|
@ -141,7 +141,7 @@ class RocksDBFulltextIndex final : public RocksDBIndex {
|
||||||
|
|
||||||
arangodb::Result applyQueryToken(transaction::Methods* trx,
|
arangodb::Result applyQueryToken(transaction::Methods* trx,
|
||||||
FulltextQueryToken const&,
|
FulltextQueryToken const&,
|
||||||
std::set<std::string>& resultSet);
|
std::set<TRI_voc_rid_t>& resultSet);
|
||||||
};
|
};
|
||||||
} // namespace arangodb
|
} // namespace arangodb
|
||||||
|
|
||||||
|
|
|
@ -164,6 +164,14 @@ TRI_voc_rid_t RocksDBKey::revisionId(rocksdb::Slice const& slice) {
|
||||||
return revisionId(slice.data(), slice.size());
|
return revisionId(slice.data(), slice.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
arangodb::StringRef RocksDBKey::primaryKey(RocksDBKey const& key) {
|
||||||
|
return primaryKey(key._buffer.data(), key._buffer.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
arangodb::StringRef RocksDBKey::primaryKey(rocksdb::Slice const& slice) {
|
||||||
|
return primaryKey(slice.data(), slice.size());
|
||||||
|
}
|
||||||
|
|
||||||
StringRef RocksDBKey::vertexId(RocksDBKey const& key) {
|
StringRef RocksDBKey::vertexId(RocksDBKey const& key) {
|
||||||
return vertexId(key._buffer.data(), key._buffer.size());
|
return vertexId(key._buffer.data(), key._buffer.size());
|
||||||
}
|
}
|
||||||
|
@ -420,12 +428,19 @@ TRI_voc_rid_t RocksDBKey::revisionId(char const* data, size_t size) {
|
||||||
TRI_ASSERT(size >= (sizeof(char) + (2 * sizeof(uint64_t))));
|
TRI_ASSERT(size >= (sizeof(char) + (2 * sizeof(uint64_t))));
|
||||||
return uint64FromPersistent(data + sizeof(char) + sizeof(uint64_t));
|
return uint64FromPersistent(data + sizeof(char) + sizeof(uint64_t));
|
||||||
}
|
}
|
||||||
|
case RocksDBEntryType::EdgeIndexValue:
|
||||||
|
case RocksDBEntryType::IndexValue:
|
||||||
|
case RocksDBEntryType::FulltextIndexValue: {
|
||||||
|
TRI_ASSERT(size >= (sizeof(char) + (2 * sizeof(uint64_t))));
|
||||||
|
// last 8 bytes should by revision
|
||||||
|
return uint64FromPersistent(data + size - sizeof(uint64_t));
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
THROW_ARANGO_EXCEPTION(TRI_ERROR_TYPE_ERROR);
|
THROW_ARANGO_EXCEPTION(TRI_ERROR_TYPE_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
arangodb::StringRef RocksDBKey::primaryKey(char const* data, size_t size) {
|
arangodb::StringRef RocksDBKey::primaryKey(char const* data, size_t size) {
|
||||||
TRI_ASSERT(data != nullptr);
|
TRI_ASSERT(data != nullptr);
|
||||||
TRI_ASSERT(size >= sizeof(char));
|
TRI_ASSERT(size >= sizeof(char));
|
||||||
|
@ -437,19 +452,11 @@ arangodb::StringRef RocksDBKey::primaryKey(char const* data, size_t size) {
|
||||||
return arangodb::StringRef(data + sizeof(char) + sizeof(uint64_t),
|
return arangodb::StringRef(data + sizeof(char) + sizeof(uint64_t),
|
||||||
keySize);
|
keySize);
|
||||||
}
|
}
|
||||||
case RocksDBEntryType::EdgeIndexValue:
|
|
||||||
case RocksDBEntryType::IndexValue:
|
|
||||||
case RocksDBEntryType::FulltextIndexValue: {
|
|
||||||
TRI_ASSERT(size > (sizeof(char) + sizeof(uint64_t) + sizeof(uint8_t)));
|
|
||||||
size_t keySize = static_cast<size_t>(data[size - 1]);
|
|
||||||
return arangodb::StringRef(data + (size - (keySize + sizeof(uint8_t))),
|
|
||||||
keySize);
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
THROW_ARANGO_EXCEPTION(TRI_ERROR_TYPE_ERROR);
|
THROW_ARANGO_EXCEPTION(TRI_ERROR_TYPE_ERROR);
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
|
|
||||||
StringRef RocksDBKey::vertexId(char const* data, size_t size) {
|
StringRef RocksDBKey::vertexId(char const* data, size_t size) {
|
||||||
TRI_ASSERT(data != nullptr);
|
TRI_ASSERT(data != nullptr);
|
||||||
|
|
|
@ -161,7 +161,6 @@ class RocksDBKey {
|
||||||
return type(slice.data(), slice.size());
|
return type(slice.data(), slice.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief Extracts the object id
|
/// @brief Extracts the object id
|
||||||
///
|
///
|
||||||
|
@ -218,8 +217,8 @@ class RocksDBKey {
|
||||||
/// May be called only on the following key types: PrimaryIndexValue,
|
/// May be called only on the following key types: PrimaryIndexValue,
|
||||||
/// EdgeIndexValue, IndexValue, FulltextIndexValue. Other types will throw.
|
/// EdgeIndexValue, IndexValue, FulltextIndexValue. Other types will throw.
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
//static StringRef primaryKey(RocksDBKey const&);
|
static StringRef primaryKey(RocksDBKey const&);
|
||||||
//static StringRef primaryKey(rocksdb::Slice const&);
|
static StringRef primaryKey(rocksdb::Slice const&);
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief Extracts the vertex ID from a key
|
/// @brief Extracts the vertex ID from a key
|
||||||
|
@ -276,7 +275,7 @@ class RocksDBKey {
|
||||||
static TRI_voc_cid_t objectId(char const* data, size_t size);
|
static TRI_voc_cid_t objectId(char const* data, size_t size);
|
||||||
static TRI_voc_cid_t viewId(char const* data, size_t size);
|
static TRI_voc_cid_t viewId(char const* data, size_t size);
|
||||||
static TRI_voc_rid_t revisionId(char const* data, size_t size);
|
static TRI_voc_rid_t revisionId(char const* data, size_t size);
|
||||||
//static StringRef primaryKey(char const* data, size_t size);
|
static StringRef primaryKey(char const* data, size_t size);
|
||||||
static StringRef vertexId(char const* data, size_t size);
|
static StringRef vertexId(char const* data, size_t size);
|
||||||
static VPackSlice indexedVPack(char const* data, size_t size);
|
static VPackSlice indexedVPack(char const* data, size_t size);
|
||||||
|
|
||||||
|
|
|
@ -80,11 +80,10 @@ static std::vector<arangodb::basics::AttributeName> const KeyAttribute{
|
||||||
RocksDBVPackIndexIterator::RocksDBVPackIndexIterator(
|
RocksDBVPackIndexIterator::RocksDBVPackIndexIterator(
|
||||||
LogicalCollection* collection, transaction::Methods* trx,
|
LogicalCollection* collection, transaction::Methods* trx,
|
||||||
ManagedDocumentResult* mmdr, arangodb::RocksDBVPackIndex const* index,
|
ManagedDocumentResult* mmdr, arangodb::RocksDBVPackIndex const* index,
|
||||||
arangodb::RocksDBPrimaryIndex* primaryIndex, bool reverse,
|
bool reverse,
|
||||||
VPackSlice const& left, VPackSlice const& right)
|
VPackSlice const& left, VPackSlice const& right)
|
||||||
: IndexIterator(collection, trx, mmdr, index),
|
: IndexIterator(collection, trx, mmdr, index),
|
||||||
_index(index),
|
_index(index),
|
||||||
_primaryIndex(primaryIndex),
|
|
||||||
_cmp(index->comparator()),
|
_cmp(index->comparator()),
|
||||||
_reverse(reverse),
|
_reverse(reverse),
|
||||||
_bounds(index->_unique ? RocksDBKeyBounds::UniqueIndexRange(
|
_bounds(index->_unique ? RocksDBKeyBounds::UniqueIndexRange(
|
||||||
|
@ -141,16 +140,11 @@ bool RocksDBVPackIndexIterator::next(TokenCallback const& cb, size_t limit) {
|
||||||
while (limit > 0) {
|
while (limit > 0) {
|
||||||
TRI_ASSERT(_index->objectId() == RocksDBKey::objectId(_iterator->key()));
|
TRI_ASSERT(_index->objectId() == RocksDBKey::objectId(_iterator->key()));
|
||||||
|
|
||||||
|
TRI_voc_rid_t revisionId = _index->_unique ? RocksDBValue::revisionId(_iterator->value())
|
||||||
|
: RocksDBKey::revisionId(_iterator->key());
|
||||||
StringRef primaryKey = _index->_unique
|
cb(RocksDBToken(revisionId));
|
||||||
? RocksDBValue::primaryKey(_iterator->value())
|
|
||||||
: RocksDBKey::primaryKey(_iterator->key());
|
|
||||||
RocksDBToken token(_primaryIndex->lookupKey(_trx, primaryKey));
|
|
||||||
cb(token);
|
|
||||||
|
|
||||||
--limit;
|
--limit;
|
||||||
|
|
||||||
if (_reverse) {
|
if (_reverse) {
|
||||||
_iterator->Prev();
|
_iterator->Prev();
|
||||||
} else {
|
} else {
|
||||||
|
@ -309,7 +303,6 @@ int RocksDBVPackIndex::fillElement(VPackBuilder& leased,
|
||||||
THROW_ARANGO_EXCEPTION(TRI_ERROR_OUT_OF_MEMORY);
|
THROW_ARANGO_EXCEPTION(TRI_ERROR_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
StringRef key(doc.get(StaticStrings::KeyString));
|
|
||||||
if (_unique) {
|
if (_unique) {
|
||||||
// Unique VPack index values are stored as follows:
|
// Unique VPack index values are stored as follows:
|
||||||
// - Key: 7 + 8-byte object ID of index + VPack array with index
|
// - Key: 7 + 8-byte object ID of index + VPack array with index
|
||||||
|
@ -325,20 +318,21 @@ int RocksDBVPackIndex::fillElement(VPackBuilder& leased,
|
||||||
// + separator (NUL) byte + primary key
|
// + separator (NUL) byte + primary key
|
||||||
// - Value: empty
|
// - Value: empty
|
||||||
elements.emplace_back(
|
elements.emplace_back(
|
||||||
RocksDBKey::IndexValue(_objectId, key, leased.slice()));
|
RocksDBKey::IndexValue(_objectId, leased.slice(), revisionId));
|
||||||
hashes.push_back(leased.slice().normalizedHash());
|
hashes.push_back(leased.slice().normalizedHash());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// other path for handling array elements, too
|
// other path for handling array elements, too
|
||||||
|
|
||||||
std::vector<VPackSlice> sliceStack;
|
std::vector<VPackSlice> sliceStack;
|
||||||
buildIndexValues(leased, doc, 0, elements, sliceStack, hashes);
|
buildIndexValues(leased, revisionId, doc, 0, elements, sliceStack, hashes);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRI_ERROR_NO_ERROR;
|
return TRI_ERROR_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RocksDBVPackIndex::addIndexValue(VPackBuilder& leased,
|
void RocksDBVPackIndex::addIndexValue(VPackBuilder& leased,
|
||||||
|
TRI_voc_rid_t revisionId,
|
||||||
VPackSlice const& document,
|
VPackSlice const& document,
|
||||||
std::vector<RocksDBKey>& elements,
|
std::vector<RocksDBKey>& elements,
|
||||||
std::vector<VPackSlice>& sliceStack,
|
std::vector<VPackSlice>& sliceStack,
|
||||||
|
@ -350,7 +344,6 @@ void RocksDBVPackIndex::addIndexValue(VPackBuilder& leased,
|
||||||
}
|
}
|
||||||
leased.close();
|
leased.close();
|
||||||
|
|
||||||
StringRef key(document.get(StaticStrings::KeyString));
|
|
||||||
if (_unique) {
|
if (_unique) {
|
||||||
// Unique VPack index values are stored as follows:
|
// Unique VPack index values are stored as follows:
|
||||||
// - Key: 7 + 8-byte object ID of index + VPack array with index value(s)
|
// - Key: 7 + 8-byte object ID of index + VPack array with index value(s)
|
||||||
|
@ -363,14 +356,15 @@ void RocksDBVPackIndex::addIndexValue(VPackBuilder& leased,
|
||||||
// + primary key
|
// + primary key
|
||||||
// - Value: empty
|
// - Value: empty
|
||||||
elements.emplace_back(
|
elements.emplace_back(
|
||||||
RocksDBKey::IndexValue(_objectId, key, leased.slice()));
|
RocksDBKey::IndexValue(_objectId, leased.slice(), revisionId));
|
||||||
hashes.push_back(leased.slice().normalizedHash());
|
hashes.push_back(leased.slice().normalizedHash());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief helper function to create a set of index combinations to insert
|
/// @brief helper function to create a set of index combinations to insert
|
||||||
void RocksDBVPackIndex::buildIndexValues(VPackBuilder& leased,
|
void RocksDBVPackIndex::buildIndexValues(VPackBuilder& leased,
|
||||||
VPackSlice const document,
|
TRI_voc_rid_t revisionId,
|
||||||
|
VPackSlice const doc,
|
||||||
size_t level,
|
size_t level,
|
||||||
std::vector<RocksDBKey>& elements,
|
std::vector<RocksDBKey>& elements,
|
||||||
std::vector<VPackSlice>& sliceStack,
|
std::vector<VPackSlice>& sliceStack,
|
||||||
|
@ -379,12 +373,12 @@ void RocksDBVPackIndex::buildIndexValues(VPackBuilder& leased,
|
||||||
|
|
||||||
// Stop the recursion:
|
// Stop the recursion:
|
||||||
if (level == _paths.size()) {
|
if (level == _paths.size()) {
|
||||||
addIndexValue(leased, document, elements, sliceStack, hashes);
|
addIndexValue(leased, revisionId, doc, elements, sliceStack, hashes);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_expanding[level] == -1) { // the trivial, non-expanding case
|
if (_expanding[level] == -1) { // the trivial, non-expanding case
|
||||||
VPackSlice slice = document.get(_paths[level]);
|
VPackSlice slice = doc.get(_paths[level]);
|
||||||
if (slice.isNone() || slice.isNull()) {
|
if (slice.isNone() || slice.isNull()) {
|
||||||
if (_sparse) {
|
if (_sparse) {
|
||||||
return;
|
return;
|
||||||
|
@ -393,7 +387,7 @@ void RocksDBVPackIndex::buildIndexValues(VPackBuilder& leased,
|
||||||
} else {
|
} else {
|
||||||
sliceStack.emplace_back(slice);
|
sliceStack.emplace_back(slice);
|
||||||
}
|
}
|
||||||
buildIndexValues(leased, document, level + 1, elements, sliceStack, hashes);
|
buildIndexValues(leased, revisionId, doc, level + 1, elements, sliceStack, hashes);
|
||||||
sliceStack.pop_back();
|
sliceStack.pop_back();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -414,14 +408,14 @@ void RocksDBVPackIndex::buildIndexValues(VPackBuilder& leased,
|
||||||
for (size_t i = level; i < _paths.size(); i++) {
|
for (size_t i = level; i < _paths.size(); i++) {
|
||||||
sliceStack.emplace_back(illegalSlice);
|
sliceStack.emplace_back(illegalSlice);
|
||||||
}
|
}
|
||||||
addIndexValue(leased, document, elements, sliceStack, hashes);
|
addIndexValue(leased, revisionId, doc, elements, sliceStack, hashes);
|
||||||
for (size_t i = level; i < _paths.size(); i++) {
|
for (size_t i = level; i < _paths.size(); i++) {
|
||||||
sliceStack.pop_back();
|
sliceStack.pop_back();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
size_t const n = _paths[level].size();
|
size_t const n = _paths[level].size();
|
||||||
// We have 0 <= _expanding[level] < n.
|
// We have 0 <= _expanding[level] < n.
|
||||||
VPackSlice current(document);
|
VPackSlice current(doc);
|
||||||
for (size_t i = 0; i <= static_cast<size_t>(_expanding[level]); i++) {
|
for (size_t i = 0; i <= static_cast<size_t>(_expanding[level]); i++) {
|
||||||
if (!current.isObject()) {
|
if (!current.isObject()) {
|
||||||
finishWithNones();
|
finishWithNones();
|
||||||
|
@ -449,7 +443,7 @@ void RocksDBVPackIndex::buildIndexValues(VPackBuilder& leased,
|
||||||
if (it == seen.end()) {
|
if (it == seen.end()) {
|
||||||
seen.insert(something);
|
seen.insert(something);
|
||||||
sliceStack.emplace_back(something);
|
sliceStack.emplace_back(something);
|
||||||
buildIndexValues(leased, document, level + 1, elements, sliceStack,
|
buildIndexValues(leased, revisionId, doc, level + 1, elements, sliceStack,
|
||||||
hashes);
|
hashes);
|
||||||
sliceStack.pop_back();
|
sliceStack.pop_back();
|
||||||
}
|
}
|
||||||
|
@ -528,8 +522,7 @@ int RocksDBVPackIndex::insert(transaction::Methods* trx,
|
||||||
|
|
||||||
// now we are going to construct the value to insert into rocksdb
|
// now we are going to construct the value to insert into rocksdb
|
||||||
// unique indexes have a different key structure
|
// unique indexes have a different key structure
|
||||||
StringRef docKey(doc.get(StaticStrings::KeyString));
|
RocksDBValue value = _unique ? RocksDBValue::UniqueIndexValue(revisionId)
|
||||||
RocksDBValue value = _unique ? RocksDBValue::UniqueIndexValue(docKey)
|
|
||||||
: RocksDBValue::IndexValue();
|
: RocksDBValue::IndexValue();
|
||||||
|
|
||||||
RocksDBMethods* mthds = rocksutils::toRocksMethods(trx);
|
RocksDBMethods* mthds = rocksutils::toRocksMethods(trx);
|
||||||
|
@ -596,8 +589,7 @@ int RocksDBVPackIndex::insertRaw(RocksDBMethods* batch,
|
||||||
|
|
||||||
// now we are going to construct the value to insert into rocksdb
|
// now we are going to construct the value to insert into rocksdb
|
||||||
// unique indexes have a different key structure
|
// unique indexes have a different key structure
|
||||||
StringRef docKey(doc.get(StaticStrings::KeyString));
|
RocksDBValue value = _unique ? RocksDBValue::UniqueIndexValue(revisionId)
|
||||||
RocksDBValue value = _unique ? RocksDBValue::UniqueIndexValue(docKey)
|
|
||||||
: RocksDBValue::IndexValue();
|
: RocksDBValue::IndexValue();
|
||||||
|
|
||||||
for (RocksDBKey const& key : elements) {
|
for (RocksDBKey const& key : elements) {
|
||||||
|
@ -808,8 +800,7 @@ RocksDBVPackIndexIterator* RocksDBVPackIndex::lookup(
|
||||||
// _collection at least as long as trx is running.
|
// _collection at least as long as trx is running.
|
||||||
// Same for the iterator
|
// Same for the iterator
|
||||||
auto physical = static_cast<RocksDBCollection*>(_collection->getPhysical());
|
auto physical = static_cast<RocksDBCollection*>(_collection->getPhysical());
|
||||||
auto idx = physical->primaryIndex();
|
return new RocksDBVPackIndexIterator(_collection, trx, mmdr, this,
|
||||||
return new RocksDBVPackIndexIterator(_collection, trx, mmdr, this, idx,
|
|
||||||
reverse, leftBorder, rightBorder);
|
reverse, leftBorder, rightBorder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,6 @@ class RocksDBVPackIndexIterator final : public IndexIterator {
|
||||||
transaction::Methods* trx,
|
transaction::Methods* trx,
|
||||||
ManagedDocumentResult* mmdr,
|
ManagedDocumentResult* mmdr,
|
||||||
arangodb::RocksDBVPackIndex const* index,
|
arangodb::RocksDBVPackIndex const* index,
|
||||||
arangodb::RocksDBPrimaryIndex* primaryIndex,
|
|
||||||
bool reverse,
|
bool reverse,
|
||||||
arangodb::velocypack::Slice const& left,
|
arangodb::velocypack::Slice const& left,
|
||||||
arangodb::velocypack::Slice const& right);
|
arangodb::velocypack::Slice const& right);
|
||||||
|
@ -88,7 +87,6 @@ class RocksDBVPackIndexIterator final : public IndexIterator {
|
||||||
bool outOfRange() const;
|
bool outOfRange() const;
|
||||||
|
|
||||||
arangodb::RocksDBVPackIndex const* _index;
|
arangodb::RocksDBVPackIndex const* _index;
|
||||||
arangodb::RocksDBPrimaryIndex* _primaryIndex;
|
|
||||||
rocksdb::Comparator const* _cmp;
|
rocksdb::Comparator const* _cmp;
|
||||||
std::unique_ptr<rocksdb::Iterator> _iterator;
|
std::unique_ptr<rocksdb::Iterator> _iterator;
|
||||||
bool const _reverse;
|
bool const _reverse;
|
||||||
|
@ -216,7 +214,8 @@ protected:
|
||||||
/// @brief helper function to build the key and value for rocksdb from the
|
/// @brief helper function to build the key and value for rocksdb from the
|
||||||
/// vector of slices
|
/// vector of slices
|
||||||
/// @param hashes list of VPackSlice hashes for the estimator.
|
/// @param hashes list of VPackSlice hashes for the estimator.
|
||||||
void addIndexValue(velocypack::Builder& leased, VPackSlice const& document,
|
void addIndexValue(velocypack::Builder& leased, TRI_voc_rid_t revisionId,
|
||||||
|
VPackSlice const& document,
|
||||||
std::vector<RocksDBKey>& elements,
|
std::vector<RocksDBKey>& elements,
|
||||||
std::vector<VPackSlice>& sliceStack,
|
std::vector<VPackSlice>& sliceStack,
|
||||||
std::vector<uint64_t>& hashes);
|
std::vector<uint64_t>& hashes);
|
||||||
|
@ -226,7 +225,8 @@ protected:
|
||||||
/// @param elements vector of resulting index entries
|
/// @param elements vector of resulting index entries
|
||||||
/// @param sliceStack working list of values to insert into the index
|
/// @param sliceStack working list of values to insert into the index
|
||||||
/// @param hashes list of VPackSlice hashes for the estimator.
|
/// @param hashes list of VPackSlice hashes for the estimator.
|
||||||
void buildIndexValues(velocypack::Builder& leased, VPackSlice const document,
|
void buildIndexValues(velocypack::Builder& leased, TRI_voc_rid_t revisionId,
|
||||||
|
VPackSlice const document,
|
||||||
size_t level, std::vector<RocksDBKey>& elements,
|
size_t level, std::vector<RocksDBKey>& elements,
|
||||||
std::vector<VPackSlice>& sliceStack,
|
std::vector<VPackSlice>& sliceStack,
|
||||||
std::vector<uint64_t>& hashes);
|
std::vector<uint64_t>& hashes);
|
||||||
|
|
|
@ -45,17 +45,16 @@ RocksDBValue RocksDBValue::PrimaryIndexValue(TRI_voc_rid_t revisionId) {
|
||||||
return RocksDBValue(RocksDBEntryType::PrimaryIndexValue, revisionId);
|
return RocksDBValue(RocksDBEntryType::PrimaryIndexValue, revisionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
RocksDBValue RocksDBValue::EdgeIndexValue(TRI_voc_rid_t revisionId) {
|
RocksDBValue RocksDBValue::EdgeIndexValue() {
|
||||||
return RocksDBValue(RocksDBEntryType::EdgeIndexValue, revisionId);
|
return RocksDBValue(RocksDBEntryType::EdgeIndexValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
RocksDBValue RocksDBValue::IndexValue(TRI_voc_rid_t revisionId) {
|
RocksDBValue RocksDBValue::IndexValue() {
|
||||||
return RocksDBValue(RocksDBEntryType::IndexValue, revisionId);
|
return RocksDBValue(RocksDBEntryType::IndexValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
RocksDBValue RocksDBValue::UniqueIndexValue(TRI_voc_rid_t revisionId,
|
RocksDBValue RocksDBValue::UniqueIndexValue(TRI_voc_rid_t revisionId) {
|
||||||
StringRef const& primaryKey) {
|
return RocksDBValue(RocksDBEntryType::UniqueIndexValue, revisionId);
|
||||||
return RocksDBValue(RocksDBEntryType::UniqueIndexValue, revisionId, primaryKey);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RocksDBValue RocksDBValue::View(VPackSlice const& data) {
|
RocksDBValue RocksDBValue::View(VPackSlice const& data) {
|
||||||
|
@ -111,8 +110,7 @@ RocksDBValue::RocksDBValue(RocksDBEntryType type) : _type(type), _buffer() {}
|
||||||
RocksDBValue::RocksDBValue(RocksDBEntryType type, uint64_t data)
|
RocksDBValue::RocksDBValue(RocksDBEntryType type, uint64_t data)
|
||||||
: _type(type), _buffer() {
|
: _type(type), _buffer() {
|
||||||
switch (_type) {
|
switch (_type) {
|
||||||
case RocksDBEntryType::EdgeIndexValue:
|
case RocksDBEntryType::UniqueIndexValue:
|
||||||
case RocksDBEntryType::IndexValue:
|
|
||||||
case RocksDBEntryType::PrimaryIndexValue: {
|
case RocksDBEntryType::PrimaryIndexValue: {
|
||||||
_buffer.reserve(sizeof(uint64_t));
|
_buffer.reserve(sizeof(uint64_t));
|
||||||
uint64ToPersistent(_buffer, data); // revision id
|
uint64ToPersistent(_buffer, data); // revision id
|
||||||
|
@ -124,24 +122,6 @@ RocksDBValue::RocksDBValue(RocksDBEntryType type, uint64_t data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RocksDBValue::RocksDBValue(RocksDBEntryType type,
|
|
||||||
uint64_t rev,
|
|
||||||
arangodb::StringRef const& data)
|
|
||||||
: _type(type), _buffer() {
|
|
||||||
switch (_type) {
|
|
||||||
|
|
||||||
case RocksDBEntryType::UniqueIndexValue: {
|
|
||||||
_buffer.reserve(sizeof(uint64_t) + data.length());
|
|
||||||
uint64ToPersistent(_buffer, rev); // revision id
|
|
||||||
_buffer.append(data.data(), data.length()); // primary key
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
THROW_ARANGO_EXCEPTION(TRI_ERROR_BAD_PARAMETER);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RocksDBValue::RocksDBValue(RocksDBEntryType type, VPackSlice const& data)
|
RocksDBValue::RocksDBValue(RocksDBEntryType type, VPackSlice const& data)
|
||||||
: _type(type), _buffer() {
|
: _type(type), _buffer() {
|
||||||
switch (_type) {
|
switch (_type) {
|
||||||
|
|
|
@ -49,10 +49,9 @@ class RocksDBValue {
|
||||||
static RocksDBValue Collection(VPackSlice const& data);
|
static RocksDBValue Collection(VPackSlice const& data);
|
||||||
static RocksDBValue Document(VPackSlice const& data);
|
static RocksDBValue Document(VPackSlice const& data);
|
||||||
static RocksDBValue PrimaryIndexValue(TRI_voc_rid_t revisionId);
|
static RocksDBValue PrimaryIndexValue(TRI_voc_rid_t revisionId);
|
||||||
static RocksDBValue EdgeIndexValue(TRI_voc_rid_t revisionId);
|
static RocksDBValue EdgeIndexValue();
|
||||||
static RocksDBValue IndexValue(TRI_voc_rid_t revisionId);
|
static RocksDBValue IndexValue();
|
||||||
static RocksDBValue UniqueIndexValue(TRI_voc_rid_t revisionId,
|
static RocksDBValue UniqueIndexValue(TRI_voc_rid_t revisionId);
|
||||||
arangodb::StringRef const& primaryKey);
|
|
||||||
static RocksDBValue View(VPackSlice const& data);
|
static RocksDBValue View(VPackSlice const& data);
|
||||||
static RocksDBValue ReplicationApplierConfig(VPackSlice const& data);
|
static RocksDBValue ReplicationApplierConfig(VPackSlice const& data);
|
||||||
|
|
||||||
|
@ -111,7 +110,6 @@ class RocksDBValue {
|
||||||
RocksDBValue();
|
RocksDBValue();
|
||||||
explicit RocksDBValue(RocksDBEntryType type);
|
explicit RocksDBValue(RocksDBEntryType type);
|
||||||
RocksDBValue(RocksDBEntryType type, uint64_t data);
|
RocksDBValue(RocksDBEntryType type, uint64_t data);
|
||||||
RocksDBValue(RocksDBEntryType type, uint64_t rev, StringRef const& data);
|
|
||||||
RocksDBValue(RocksDBEntryType type, VPackSlice const& data);
|
RocksDBValue(RocksDBEntryType type, VPackSlice const& data);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -222,12 +222,11 @@ SECTION("test_primary_index") {
|
||||||
|
|
||||||
/// @brief test edge index
|
/// @brief test edge index
|
||||||
SECTION("test_edge_index") {
|
SECTION("test_edge_index") {
|
||||||
RocksDBKey key1 = RocksDBKey::EdgeIndexValue(0, StringRef("a/1"), StringRef("foobar"));
|
RocksDBKey key1 = RocksDBKey::EdgeIndexValue(0, StringRef("a/1"), 33);
|
||||||
auto const& s1 = key1.string();
|
auto const& s1 = key1.string();
|
||||||
|
|
||||||
CHECK(s1.size() == sizeof(char) + sizeof(uint64_t) + strlen("a/1") + sizeof(char) + strlen("foobar") + sizeof(char));
|
CHECK(s1.size() == sizeof(char) + sizeof(uint64_t) + strlen("a/1") + sizeof(char) + strlen("foobar") + sizeof(char));
|
||||||
CHECK(s1 == std::string("5\0\0\0\0\0\0\0\0a/1\0foobar\x06", 20));
|
CHECK(s1 == std::string("5\0\0\0\0\0\0\0\0a/1\0\0\0!\0\0\0\0", 20));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue