mirror of https://gitee.com/bigwinds/arangodb
Intermediate commit
This commit is contained in:
parent
13f2cd4cb9
commit
7142bf2cfc
|
@ -77,6 +77,12 @@ RocksDBKey RocksDBKey::UniqueIndexValue(uint64_t indexId,
|
|||
return RocksDBKey(RocksDBEntryType::UniqueIndexValue, indexId, indexValues);
|
||||
}
|
||||
|
||||
RocksDBKey RocksDBKey::FulltextIndexValue(uint64_t indexId,
|
||||
arangodb::StringRef const& word,
|
||||
arangodb::StringRef const& primaryKey) {
|
||||
return RocksDBKey(RocksDBEntryType::FulltextIndexValue, indexId, word, primaryKey);
|
||||
}
|
||||
|
||||
RocksDBKey RocksDBKey::GeoIndexValue(uint64_t indexId, bool isSlot, uint64_t offset){
|
||||
return RocksDBKey(RocksDBEntryType::GeoIndexValue, isSlot, offset);
|
||||
}
|
||||
|
@ -97,12 +103,6 @@ RocksDBKey RocksDBKey::ReplicationApplierConfig(TRI_voc_tick_t databaseId) {
|
|||
return RocksDBKey(RocksDBEntryType::ReplicationApplierConfig, databaseId);
|
||||
}
|
||||
|
||||
RocksDBKey RocksDBKey::FulltextIndexValue(uint64_t indexId,
|
||||
arangodb::StringRef const& word,
|
||||
arangodb::StringRef const& primaryKey) {
|
||||
return RocksDBKey(RocksDBEntryType::FulltextIndexValue, indexId, word, primaryKey);
|
||||
}
|
||||
|
||||
// ========================= Member methods ===========================
|
||||
|
||||
RocksDBEntryType RocksDBKey::type(RocksDBKey const& key) {
|
||||
|
@ -181,6 +181,22 @@ VPackSlice RocksDBKey::indexedVPack(rocksdb::Slice const& slice) {
|
|||
return indexedVPack(slice.data(), slice.size());
|
||||
}
|
||||
|
||||
std::pair<bool, uint32_t> RocksDBKey::geoValues(rocksdb::Slice const& slice) {
|
||||
TRI_ASSERT(size >= sizeof(char) + sizeof(uint64_t) * 2);
|
||||
RocksDBEntryType type = static_cast<RocksDBEntryType>(data[0]);
|
||||
TRI_ASSERT(type == RocksDBEntryType::GeoIndexValue);
|
||||
uint64_t val = uint64FromPersistent(data + sizeof(char) + sizeof(uint64_t));
|
||||
bool isSlot = (val >> 63) & 0x1;
|
||||
return std::pair<bool, uint32_t>(isSlot, (val & );
|
||||
|
||||
size_t length = sizeof(char) + sizeof(objectId) + sizeof(offset);
|
||||
_buffer.reserve(length);
|
||||
_buffer.push_back(static_cast<char>(_type));
|
||||
offset |= std::uint64_t{isSlot} << 63; //encode slot|pot in highest bit
|
||||
uint64ToPersistent(_buffer, objectId);
|
||||
uint64ToPersistent(_buffer, offset);
|
||||
}
|
||||
|
||||
std::string const& RocksDBKey::string() const { return _buffer; }
|
||||
|
||||
RocksDBKey::RocksDBKey(RocksDBEntryType type) : _type(type), _buffer() {
|
||||
|
@ -306,7 +322,7 @@ RocksDBKey::RocksDBKey(RocksDBEntryType type, uint64_t first,
|
|||
}
|
||||
}
|
||||
|
||||
RocksDBKey::RocksDBKey(RocksDBEntryType type, uint64_t objectId, uint64_t offset, bool isSlot)
|
||||
RocksDBKey::RocksDBKey(RocksDBEntryType type, uint64_t objectId, uint32_t offset, bool isSlot)
|
||||
: _type(type), _buffer() {
|
||||
switch (_type) {
|
||||
case RocksDBEntryType::GeoIndexValue: {
|
||||
|
@ -314,9 +330,10 @@ RocksDBKey::RocksDBKey(RocksDBEntryType type, uint64_t objectId, uint64_t offset
|
|||
size_t length = sizeof(char) + sizeof(objectId) + sizeof(offset);
|
||||
_buffer.reserve(length);
|
||||
_buffer.push_back(static_cast<char>(_type));
|
||||
offset |= std::uint64_t{isSlot} << 63; //encode slot|pot in highest bit
|
||||
uint64ToPersistent(_buffer, objectId);
|
||||
uint64ToPersistent(_buffer, offset);
|
||||
uint64_t norm = offset;
|
||||
if (isSlot) norm |= 1 << 63;//encode slot|pot in highest bit
|
||||
uint64ToPersistent(_buffer, norm);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -350,6 +367,8 @@ RocksDBKey::RocksDBKey(RocksDBEntryType type, uint64_t first,
|
|||
}
|
||||
}
|
||||
|
||||
// ====================== Private Methods ==========================
|
||||
|
||||
RocksDBEntryType RocksDBKey::type(char const* data, size_t size) {
|
||||
TRI_ASSERT(data != nullptr);
|
||||
TRI_ASSERT(size >= sizeof(char));
|
||||
|
|
|
@ -103,6 +103,13 @@ class RocksDBKey {
|
|||
static RocksDBKey UniqueIndexValue(uint64_t indexId,
|
||||
VPackSlice const& indexValues);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Create a fully-specified key for the fulltext index
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
static RocksDBKey FulltextIndexValue(uint64_t indexId,
|
||||
arangodb::StringRef const& word,
|
||||
arangodb::StringRef const& primaryKey);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Create a fully-specified key for a geoIndexValue
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -127,13 +134,6 @@ class RocksDBKey {
|
|||
/// @brief Create a fully-specified key for a replication applier config
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
static RocksDBKey ReplicationApplierConfig(TRI_voc_tick_t databaseId);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Create a fully-specified key for the fulltext index
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
static RocksDBKey FulltextIndexValue(uint64_t indexId,
|
||||
arangodb::StringRef const& word,
|
||||
arangodb::StringRef const& primaryKey);
|
||||
|
||||
public:
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -172,8 +172,8 @@ class RocksDBKey {
|
|||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Extracts the objectId from a key
|
||||
///
|
||||
/// May be called only on the the following key types: Document.
|
||||
/// Other types will throw.
|
||||
/// May be called only on the the following key types: Document,
|
||||
/// all kinds of index entries. Other types will throw.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
static uint64_t objectId(RocksDBKey const&);
|
||||
static uint64_t objectId(rocksdb::Slice const&);
|
||||
|
@ -221,6 +221,13 @@ class RocksDBKey {
|
|||
static VPackSlice indexedVPack(RocksDBKey const&);
|
||||
static VPackSlice indexedVPack(rocksdb::Slice const&);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Extracts the geo pot offset
|
||||
///
|
||||
/// May be called only on GeoIndexValues
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
std::pair<bool, uint64_t> geoValues(rocksdb::Slice const&);
|
||||
|
||||
public:
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Returns a reference to the full, constructed key
|
||||
|
@ -240,7 +247,7 @@ class RocksDBKey {
|
|||
std::string const& third);
|
||||
RocksDBKey(RocksDBEntryType type, uint64_t first, arangodb::StringRef const& second,
|
||||
arangodb::StringRef const& third);
|
||||
RocksDBKey(RocksDBEntryType type, uint64_t objectId, uint64_t index, bool isSlot);
|
||||
RocksDBKey(RocksDBEntryType type, uint64_t objectId, uint32_t index, bool isSlot);
|
||||
|
||||
private:
|
||||
static RocksDBEntryType type(char const* data, size_t size);
|
||||
|
|
|
@ -73,6 +73,10 @@ RocksDBKeyBounds RocksDBKeyBounds::UniqueIndex(uint64_t indexId) {
|
|||
return RocksDBKeyBounds(RocksDBEntryType::UniqueIndexValue, indexId);
|
||||
}
|
||||
|
||||
RocksDBKeyBounds RocksDBKeyBounds::GeoIndex(uint64_t indexId) {
|
||||
return RocksDBKeyBounds(RocksDBEntryType::GeoIndexValue, indexId);
|
||||
}
|
||||
|
||||
RocksDBKeyBounds RocksDBKeyBounds::IndexRange(uint64_t indexId,
|
||||
VPackSlice const& left,
|
||||
VPackSlice const& right) {
|
||||
|
|
|
@ -85,6 +85,11 @@ class RocksDBKeyBounds {
|
|||
//////////////////////////////////////////////////////////////////////////////
|
||||
static RocksDBKeyBounds UniqueIndex(uint64_t indexId);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Bounds for all entries belonging to a specified unique index
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
static RocksDBKeyBounds GeoIndex(uint64_t indexId);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Bounds for all index-entries within a value range belonging to a
|
||||
/// specified non-unique index
|
||||
|
|
Loading…
Reference in New Issue