mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'engine-api' of https://github.com/arangodb/arangodb into engine-api
This commit is contained in:
commit
ed124e09ab
|
@ -241,11 +241,11 @@ RocksDBKey::RocksDBKey(RocksDBEntryType type, uint64_t first,
|
||||||
case RocksDBEntryType::IndexValue: {
|
case RocksDBEntryType::IndexValue: {
|
||||||
// Non-unique VPack index values are stored as follows:
|
// Non-unique VPack index values are stored as follows:
|
||||||
// - Key: 6 + 8-byte object ID of index + VPack array with index value(s)
|
// - Key: 6 + 8-byte object ID of index + VPack array with index value(s)
|
||||||
// + separator byte + primary key
|
// + separator byte + primary key + primary key length
|
||||||
// - Value: empty
|
// - Value: empty
|
||||||
size_t length = sizeof(char) + sizeof(uint64_t) +
|
size_t length = sizeof(char) + sizeof(uint64_t) +
|
||||||
static_cast<size_t>(indexData.byteSize()) + sizeof(char) +
|
static_cast<size_t>(indexData.byteSize()) + sizeof(char) +
|
||||||
docKey.length();
|
docKey.length() + sizeof(char);
|
||||||
_buffer.reserve(length);
|
_buffer.reserve(length);
|
||||||
_buffer.push_back(static_cast<char>(_type));
|
_buffer.push_back(static_cast<char>(_type));
|
||||||
uint64ToPersistent(_buffer, first);
|
uint64ToPersistent(_buffer, first);
|
||||||
|
@ -253,6 +253,7 @@ RocksDBKey::RocksDBKey(RocksDBEntryType type, uint64_t first,
|
||||||
static_cast<size_t>(indexData.byteSize()));
|
static_cast<size_t>(indexData.byteSize()));
|
||||||
_buffer.push_back(_stringSeparator);
|
_buffer.push_back(_stringSeparator);
|
||||||
_buffer.append(docKey.data(), docKey.length());
|
_buffer.append(docKey.data(), docKey.length());
|
||||||
|
_buffer.push_back(static_cast<char>(docKey.length() & 0xff));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,7 +284,7 @@ RocksDBKey::RocksDBKey(RocksDBEntryType type, uint64_t first,
|
||||||
std::string const& second, std::string const& third)
|
std::string const& second, std::string const& third)
|
||||||
: _type(type), _buffer() {
|
: _type(type), _buffer() {
|
||||||
switch (_type) {
|
switch (_type) {
|
||||||
case RocksDBEntryType::PrimaryIndexValue: {
|
case RocksDBEntryType::EdgeIndexValue: {
|
||||||
size_t length = sizeof(char) + sizeof(uint64_t) + second.size() +
|
size_t length = sizeof(char) + sizeof(uint64_t) + second.size() +
|
||||||
sizeof(char) + third.size() + sizeof(uint8_t);
|
sizeof(char) + third.size() + sizeof(uint8_t);
|
||||||
_buffer.reserve(length);
|
_buffer.reserve(length);
|
||||||
|
@ -297,18 +298,6 @@ RocksDBKey::RocksDBKey(RocksDBEntryType type, uint64_t first,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case RocksDBEntryType::EdgeIndexValue: {
|
|
||||||
size_t length = sizeof(char) + sizeof(uint64_t) + second.size() +
|
|
||||||
sizeof(char) + third.size();
|
|
||||||
_buffer.reserve(length);
|
|
||||||
_buffer.push_back(static_cast<char>(_type));
|
|
||||||
uint64ToPersistent(_buffer, first);
|
|
||||||
_buffer.append(second);
|
|
||||||
_buffer.push_back(_stringSeparator);
|
|
||||||
_buffer.append(third);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
THROW_ARANGO_EXCEPTION(TRI_ERROR_BAD_PARAMETER);
|
THROW_ARANGO_EXCEPTION(TRI_ERROR_BAD_PARAMETER);
|
||||||
}
|
}
|
||||||
|
@ -410,20 +399,13 @@ 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::EdgeIndexValue:
|
||||||
|
case RocksDBEntryType::IndexValue: {
|
||||||
TRI_ASSERT(size > (sizeof(char) + sizeof(uint64_t) + sizeof(uint8_t)));
|
TRI_ASSERT(size > (sizeof(char) + sizeof(uint64_t) + sizeof(uint8_t)));
|
||||||
size_t keySize = static_cast<size_t>(data[size - 1]);
|
size_t keySize = static_cast<size_t>(data[size - 1]);
|
||||||
return arangodb::StringRef(data + (size - (keySize + sizeof(uint8_t))),
|
return arangodb::StringRef(data + (size - (keySize + sizeof(uint8_t))),
|
||||||
keySize);
|
keySize);
|
||||||
}
|
}
|
||||||
case RocksDBEntryType::IndexValue: {
|
|
||||||
TRI_ASSERT(size > (sizeof(char) + sizeof(uint64_t)));
|
|
||||||
VPackSlice slice(data + sizeof(char) + sizeof(uint64_t));
|
|
||||||
size_t sliceSize = static_cast<size_t>(slice.byteSize());
|
|
||||||
size_t keySize =
|
|
||||||
size - (sizeof(char) + sizeof(uint64_t) + sliceSize + sizeof(char));
|
|
||||||
return arangodb::StringRef(data + (size - keySize), keySize);
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
THROW_ARANGO_EXCEPTION(TRI_ERROR_TYPE_ERROR);
|
THROW_ARANGO_EXCEPTION(TRI_ERROR_TYPE_ERROR);
|
||||||
|
|
Loading…
Reference in New Issue