1
0
Fork 0

Fixed comparator

This commit is contained in:
Simon Grätzer 2017-04-03 17:28:13 +02:00
parent f619cc5d0f
commit e6919fc6c2
1 changed files with 46 additions and 4 deletions

View File

@ -27,6 +27,8 @@
#include "RocksDBEngine/RocksDBCommon.h"
#include "RocksDBEngine/RocksDBTypes.h"
#include "Logger/Logger.h"
using namespace arangodb;
using namespace arangodb::rocksutils;
using namespace arangodb::velocypack;
@ -135,12 +137,53 @@ RocksDBKeyBounds::RocksDBKeyBounds(RocksDBEntryType type)
RocksDBKeyBounds::RocksDBKeyBounds(RocksDBEntryType type, uint64_t first)
: _type(type), _startBuffer(), _endBuffer() {
switch (_type) {
case RocksDBEntryType::IndexValue:
case RocksDBEntryType::UniqueIndexValue: {
// Unique VPack index values are stored as follows:
// 7 + 8-byte object ID of index + VPack array with index value(s) ....
// prefix is the same for non-unique indexes
// static slices with an array with one entry
VPackSlice min("\x02\x03\x1e");// [minSlice]
VPackSlice max("\x02\x03\x1f");// [maxSlice]
size_t length = sizeof(char) + sizeof(uint64_t) + min.byteSize();
_startBuffer.reserve(length);
_startBuffer.push_back(static_cast<char>(_type));
uint64ToPersistent(_startBuffer, first);
// append common prefix
_endBuffer.clear();
_endBuffer.append(_startBuffer);
// construct min max
_startBuffer.append((char*)(min.begin()), min.byteSize());
_endBuffer.append((char*)(max.begin()), max.byteSize());
break;
}
case RocksDBEntryType::Collection:
case RocksDBEntryType::Document:
case RocksDBEntryType::Document:{
// Collections are stored as follows:
// Key: 1 + 8-byte ArangoDB database ID + 8-byte ArangoDB collection ID
//
// Documents are stored as follows:
// Key: 3 + 8-byte object ID of collection + 8-byte document revision ID
size_t length = sizeof(char) + sizeof(uint64_t) * 2;
_startBuffer.reserve(length);
_startBuffer.push_back(static_cast<char>(_type));
uint64ToPersistent(_startBuffer, first);
// append common prefix
_endBuffer.clear();
_endBuffer.append(_startBuffer);
// construct min max
uint64ToPersistent(_startBuffer, 0);
uint64ToPersistent(_endBuffer, UINT64_MAX);
break;
}
case RocksDBEntryType::PrimaryIndexValue:
case RocksDBEntryType::EdgeIndexValue:
case RocksDBEntryType::IndexValue:
case RocksDBEntryType::UniqueIndexValue:
case RocksDBEntryType::View: {
size_t length = sizeof(char) + sizeof(uint64_t);
_startBuffer.reserve(length);
@ -150,7 +193,6 @@ RocksDBKeyBounds::RocksDBKeyBounds(RocksDBEntryType type, uint64_t first)
_endBuffer.clear();
_endBuffer.append(_startBuffer);
nextPrefix(_endBuffer);
break;
}