1
0
Fork 0

next hack attempt (#8802)

This commit is contained in:
Jan 2019-04-29 17:09:05 +02:00 committed by GitHub
parent 1145c7c053
commit ca94c88a79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 45 additions and 26 deletions

View File

@ -555,11 +555,11 @@ bool RocksDBCollection::dropIndex(TRI_idx_iid_t iid) {
}
std::unique_ptr<IndexIterator> RocksDBCollection::getAllIterator(transaction::Methods* trx) const {
return std::make_unique<RocksDBAllIndexIterator>(&_logicalCollection, trx, primaryIndex());
return std::make_unique<RocksDBAllIndexIterator>(&_logicalCollection, trx);
}
std::unique_ptr<IndexIterator> RocksDBCollection::getAnyIterator(transaction::Methods* trx) const {
return std::make_unique<RocksDBAnyIndexIterator>(&_logicalCollection, trx, primaryIndex());
return std::make_unique<RocksDBAnyIndexIterator>(&_logicalCollection, trx);
}
void RocksDBCollection::invokeOnAllElements(transaction::Methods* trx,

View File

@ -68,6 +68,8 @@ inline void uint64ToPersistentBE(std::string& p, uint64_t value) {
namespace arangodb {
namespace rocksutils {
RocksDBEndianness rocksDBEndianness = RocksDBEndianness::Invalid;
uint16_t (*uint16FromPersistent)(char const* p) = nullptr;
uint32_t (*uint32FromPersistent)(char const* p) = nullptr;
uint64_t (*uint64FromPersistent)(char const* p) = nullptr;
@ -77,6 +79,8 @@ void (*uint32ToPersistent)(std::string& p, uint32_t value) = nullptr;
void (*uint64ToPersistent)(std::string& p, uint64_t value) = nullptr;
void setRocksDBKeyFormatEndianess(RocksDBEndianness e) {
rocksDBEndianness = e;
if (e == RocksDBEndianness::Little) {
LOG_TOPIC("799b9", DEBUG, Logger::ENGINES) << "using little-endian keys";
uint16FromPersistent = &uint16FromPersistentLE;
@ -96,7 +100,7 @@ void setRocksDBKeyFormatEndianess(RocksDBEndianness e) {
uint64ToPersistent = &uint64ToPersistentBE;
return;
}
LOG_TOPIC("b8243", FATAL, Logger::ENGINES) << "Invalid key endianess";
LOG_TOPIC("b8243", FATAL, Logger::ENGINES) << "Invalid key endianness";
FATAL_ERROR_EXIT();
}

View File

@ -30,6 +30,7 @@
namespace arangodb {
namespace rocksutils {
extern RocksDBEndianness rocksDBEndianness;
/* function pointers to serialization implementation */
extern uint16_t (*uint16FromPersistent)(char const* p);

View File

@ -40,8 +40,7 @@ constexpr bool AnyIteratorFillBlockCache = false;
// ================ All Iterator ==================
RocksDBAllIndexIterator::RocksDBAllIndexIterator(LogicalCollection* col,
transaction::Methods* trx,
RocksDBPrimaryIndex const* index)
transaction::Methods* trx)
: IndexIterator(col, trx),
_bounds(RocksDBKeyBounds::CollectionDocuments(
static_cast<RocksDBCollection*>(col->getPhysical())->objectId())),
@ -143,8 +142,7 @@ void RocksDBAllIndexIterator::reset() {
// ================ Any Iterator ================
RocksDBAnyIndexIterator::RocksDBAnyIndexIterator(LogicalCollection* col,
transaction::Methods* trx,
RocksDBPrimaryIndex const* index)
transaction::Methods* trx)
: IndexIterator(col, trx),
_cmp(RocksDBColumnFamily::documents()->GetComparator()),
_objectId(static_cast<RocksDBCollection*>(col->getPhysical())->objectId()),

View File

@ -48,8 +48,7 @@ typedef std::function<bool(rocksdb::Slice const& key, rocksdb::Slice const& valu
/// basically sorted after LocalDocumentId
class RocksDBAllIndexIterator final : public IndexIterator {
public:
RocksDBAllIndexIterator(LogicalCollection* collection, transaction::Methods* trx,
RocksDBPrimaryIndex const* index);
RocksDBAllIndexIterator(LogicalCollection* collection, transaction::Methods* trx);
~RocksDBAllIndexIterator() {}
char const* typeName() const override { return "all-index-iterator"; }
@ -72,9 +71,7 @@ class RocksDBAllIndexIterator final : public IndexIterator {
class RocksDBAnyIndexIterator final : public IndexIterator {
public:
RocksDBAnyIndexIterator(LogicalCollection* collection, transaction::Methods* trx,
RocksDBPrimaryIndex const* index);
RocksDBAnyIndexIterator(LogicalCollection* collection, transaction::Methods* trx);
~RocksDBAnyIndexIterator() {}
char const* typeName() const override { return "any-index-iterator"; }

View File

@ -155,7 +155,7 @@ RocksDBKeyBounds RocksDBKeyBounds::FulltextIndexComplete(uint64_t indexId,
RocksDBKeyBounds::RocksDBKeyBounds(RocksDBKeyBounds const& other)
: _type(other._type), _internals(other._internals) {}
RocksDBKeyBounds::RocksDBKeyBounds(RocksDBKeyBounds&& other)
RocksDBKeyBounds::RocksDBKeyBounds(RocksDBKeyBounds&& other) noexcept
: _type(other._type), _internals(std::move(other._internals)) {}
RocksDBKeyBounds& RocksDBKeyBounds::operator=(RocksDBKeyBounds const& other) {
@ -167,7 +167,7 @@ RocksDBKeyBounds& RocksDBKeyBounds::operator=(RocksDBKeyBounds const& other) {
return *this;
}
RocksDBKeyBounds& RocksDBKeyBounds::operator=(RocksDBKeyBounds&& other) {
RocksDBKeyBounds& RocksDBKeyBounds::operator=(RocksDBKeyBounds&& other) noexcept {
if (this != &other) {
_type = other._type;
_internals = std::move(other._internals);
@ -318,8 +318,16 @@ RocksDBKeyBounds::RocksDBKeyBounds(RocksDBEntryType type, uint64_t first)
_internals.separate();
if (rocksDBEndianness == RocksDBEndianness::Big) {
// if we are in big-endian mode, we can cheat a bit...
// for the upper bound we can use the object id + 1, which will always compare higher in a
// bytewise comparison
uint64ToPersistent(_internals.buffer(), first + 1);
_internals.buffer().append((char*)(min.begin()), min.byteSize());
} else {
uint64ToPersistent(_internals.buffer(), first);
_internals.buffer().append((char*)(max.begin()), max.byteSize());
}
break;
}
@ -360,12 +368,23 @@ RocksDBKeyBounds::RocksDBKeyBounds(RocksDBEntryType type, uint64_t first)
_internals.push_back('\0');
_internals.push_back(_stringSeparator);
}
_internals.separate();
if (type == RocksDBEntryType::PrimaryIndexValue &&
rocksDBEndianness == RocksDBEndianness::Big) {
// if we are in big-endian mode, we can cheat a bit...
// for the upper bound we can use the object id + 1, which will always compare higher in a
// bytewise comparison
uint64ToPersistent(_internals.buffer(), first + 1);
_internals.push_back(0x00U); // lower/equal to any ascii char
} else {
uint64ToPersistent(_internals.buffer(), first);
_internals.push_back(0xFFU); // higher than any ascci char
_internals.push_back(0xFFU); // higher than any ascii char
if (type == RocksDBEntryType::EdgeIndexValue) {
_internals.push_back(_stringSeparator);
}
}
break;
}

View File

@ -168,9 +168,9 @@ class RocksDBKeyBounds {
public:
RocksDBKeyBounds(RocksDBKeyBounds const& other);
RocksDBKeyBounds(RocksDBKeyBounds&& other);
RocksDBKeyBounds(RocksDBKeyBounds&& other) noexcept;
RocksDBKeyBounds& operator=(RocksDBKeyBounds const& other);
RocksDBKeyBounds& operator=(RocksDBKeyBounds&& other);
RocksDBKeyBounds& operator=(RocksDBKeyBounds&& other) noexcept;
RocksDBEntryType type() const { return _type; }
@ -231,7 +231,7 @@ class RocksDBKeyBounds {
BoundsBuffer(BoundsBuffer const& other)
: _buffer(other._buffer), _separatorPosition(other._separatorPosition) {}
BoundsBuffer(BoundsBuffer&& other)
BoundsBuffer(BoundsBuffer&& other) noexcept
: _buffer(std::move(other._buffer)),
_separatorPosition(other._separatorPosition) {
other._separatorPosition = 0;
@ -245,7 +245,7 @@ class RocksDBKeyBounds {
return *this;
}
BoundsBuffer& operator=(BoundsBuffer&& other) {
BoundsBuffer& operator=(BoundsBuffer&& other) noexcept {
if (this != &other) {
_buffer = std::move(other._buffer);
_separatorPosition = other._separatorPosition;

View File

@ -178,7 +178,7 @@ class RocksDBVPackIndexIterator final : public IndexIterator {
bool reverse, RocksDBKeyBounds&& bounds)
: IndexIterator(collection, trx),
_index(index),
_cmp(index->comparator()),
_cmp(static_cast<RocksDBVPackComparator const*>(index->comparator())),
_fullEnumerationObjectId(0),
_reverse(reverse),
_bounds(std::move(bounds)) {
@ -339,7 +339,7 @@ class RocksDBVPackIndexIterator final : public IndexIterator {
}
arangodb::RocksDBVPackIndex const* _index;
rocksdb::Comparator const* _cmp;
RocksDBVPackComparator const* _cmp;
std::unique_ptr<rocksdb::Iterator> _iterator;
uint64_t _fullEnumerationObjectId;
bool const _reverse;