diff --git a/arangod/RocksDBEngine/RocksDBEngine.cpp b/arangod/RocksDBEngine/RocksDBEngine.cpp index 4d0edc31bf..f2c3b589d5 100644 --- a/arangod/RocksDBEngine/RocksDBEngine.cpp +++ b/arangod/RocksDBEngine/RocksDBEngine.cpp @@ -211,9 +211,9 @@ void RocksDBEngine::start() { _options.compaction_readahead_size = static_cast(opts->_compactionReadaheadSize); - _options.env->SetBackgroundThreads(opts->_numThreadsHigh, + _options.env->SetBackgroundThreads((int)opts->_numThreadsHigh, rocksdb::Env::Priority::HIGH); - _options.env->SetBackgroundThreads(opts->_numThreadsLow, + _options.env->SetBackgroundThreads((int)opts->_numThreadsLow, rocksdb::Env::Priority::LOW); _options.create_if_missing = true; diff --git a/arangod/RocksDBEngine/RocksDBGeoIndex.cpp b/arangod/RocksDBEngine/RocksDBGeoIndex.cpp index 8ea354319f..cc25903cfa 100644 --- a/arangod/RocksDBEngine/RocksDBGeoIndex.cpp +++ b/arangod/RocksDBEngine/RocksDBGeoIndex.cpp @@ -384,7 +384,7 @@ bool RocksDBGeoIndex::matchesDefinition(VPackSlice const& info) const { return true; } -int RocksDBGeoIndex::insert(transaction::Methods*, TRI_voc_rid_t revisionId, +int RocksDBGeoIndex::insert(transaction::Methods *, TRI_voc_rid_t revisionId, VPackSlice const& doc, bool isRollback) { double latitude; double longitude; @@ -453,6 +453,12 @@ int RocksDBGeoIndex::insert(transaction::Methods*, TRI_voc_rid_t revisionId, return TRI_ERROR_NO_ERROR; } +int RocksDBGeoIndex::insertRaw(rocksdb::WriteBatchWithIndex* batch, + TRI_voc_rid_t revisionId, + arangodb::velocypack::Slice const& doc) { + return this->insert(nullptr, revisionId, doc, false); +} + int RocksDBGeoIndex::remove(transaction::Methods*, TRI_voc_rid_t revisionId, VPackSlice const& doc, bool isRollback) { double latitude = 0.0; @@ -512,6 +518,12 @@ int RocksDBGeoIndex::remove(transaction::Methods*, TRI_voc_rid_t revisionId, return TRI_ERROR_NO_ERROR; } +int RocksDBGeoIndex::removeRaw(rocksdb::WriteBatch*, TRI_voc_rid_t revisionId, + arangodb::velocypack::Slice const& doc) { + return this->remove(nullptr, revisionId, doc, false); +} + + int RocksDBGeoIndex::unload() { // create a new, empty index auto empty = GeoIndex_new(_objectId); diff --git a/arangod/RocksDBEngine/RocksDBGeoIndex.h b/arangod/RocksDBEngine/RocksDBGeoIndex.h index 2c62edb25c..1f03c142eb 100644 --- a/arangod/RocksDBEngine/RocksDBGeoIndex.h +++ b/arangod/RocksDBEngine/RocksDBGeoIndex.h @@ -140,9 +140,12 @@ class RocksDBGeoIndex final : public RocksDBIndex { int insert(transaction::Methods*, TRI_voc_rid_t, arangodb::velocypack::Slice const&, bool isRollback) override; - + int insertRaw(rocksdb::WriteBatchWithIndex*, TRI_voc_rid_t, + arangodb::velocypack::Slice const&) override; int remove(transaction::Methods*, TRI_voc_rid_t, arangodb::velocypack::Slice const&, bool isRollback) override; + int removeRaw(rocksdb::WriteBatch*, TRI_voc_rid_t, + arangodb::velocypack::Slice const&) override; int unload() override; diff --git a/arangod/RocksDBEngine/RocksDBGeoIndexImplHelper.h b/arangod/RocksDBEngine/RocksDBGeoIndexImplHelper.h index 225634009a..0cde7ac7cd 100644 --- a/arangod/RocksDBEngine/RocksDBGeoIndexImplHelper.h +++ b/arangod/RocksDBEngine/RocksDBGeoIndexImplHelper.h @@ -90,26 +90,26 @@ VPackBuilder PotToVpack(GeoPot* pot){ GeoPot VpackToPot(VPackSlice const& slice){ GeoPot rv{}; TRI_ASSERT(slice.isArray()); - rv.LorLeaf = slice.at(0).getInt(); // int - rv.RorPoints = slice.at(1).getInt(); // int + rv.LorLeaf = (int) slice.at(0).getInt(); // int + rv.RorPoints = (int) slice.at(1).getInt(); // int rv.middle = slice.at(2).getUInt(); // GeoString { auto maxdistSlice = slice.at(3); TRI_ASSERT(maxdistSlice.isArray()); TRI_ASSERT(maxdistSlice.length() == GeoIndexFIXEDPOINTS); for(std::size_t i = 0; i < GeoIndexFIXEDPOINTS; i++){ - rv.maxdist[i] = maxdistSlice.at(i).getUInt(); //unit 16/33 + rv.maxdist[i] = (int) maxdistSlice.at(i).getUInt(); //unit 16/33 } } - rv.start = slice.at(4).getUInt(); // GeoString + rv.start = (int) slice.at(4).getUInt(); // GeoString rv.end = slice.at(5).getUInt(); // GeoString - rv.level = slice.at(6).getInt(); // int + rv.level = (int) slice.at(6).getInt(); // int { auto pointsSlice = slice.at(7); TRI_ASSERT(pointsSlice.isArray()); TRI_ASSERT(pointsSlice.length() == GeoIndexFIXEDPOINTS); for(std::size_t i = 0; i < GeoIndexPOTSIZE; i++){ - rv.points[i] = pointsSlice.at(i).getInt(); //int + rv.points[i] = (int) pointsSlice.at(i).getInt(); //int } } return rv; diff --git a/arangod/RocksDBEngine/RocksDBKey.cpp b/arangod/RocksDBEngine/RocksDBKey.cpp index 2d9b30c336..c5fd730d81 100644 --- a/arangod/RocksDBEngine/RocksDBKey.cpp +++ b/arangod/RocksDBEngine/RocksDBKey.cpp @@ -182,19 +182,12 @@ VPackSlice RocksDBKey::indexedVPack(rocksdb::Slice const& slice) { } std::pair RocksDBKey::geoValues(rocksdb::Slice const& slice) { - TRI_ASSERT(size >= sizeof(char) + sizeof(uint64_t) * 2); - RocksDBEntryType type = static_cast(data[0]); + TRI_ASSERT(slice.size() >= sizeof(char) + sizeof(uint64_t) * 2); + RocksDBEntryType type = static_cast(*slice.data()); TRI_ASSERT(type == RocksDBEntryType::GeoIndexValue); - uint64_t val = uint64FromPersistent(data + sizeof(char) + sizeof(uint64_t)); + uint64_t val = uint64FromPersistent(slice.data() + sizeof(char) + sizeof(uint64_t)); bool isSlot = (val >> 63) & 0x1; - return std::pair(isSlot, (val & ); - - size_t length = sizeof(char) + sizeof(objectId) + sizeof(offset); - _buffer.reserve(length); - _buffer.push_back(static_cast(_type)); - offset |= std::uint64_t{isSlot} << 63; //encode slot|pot in highest bit - uint64ToPersistent(_buffer, objectId); - uint64ToPersistent(_buffer, offset); + return std::pair(isSlot, (val & 0xffffffff)); } std::string const& RocksDBKey::string() const { return _buffer; } @@ -332,7 +325,7 @@ RocksDBKey::RocksDBKey(RocksDBEntryType type, uint64_t objectId, uint32_t offset _buffer.push_back(static_cast(_type)); uint64ToPersistent(_buffer, objectId); uint64_t norm = offset; - if (isSlot) norm |= 1 << 63;//encode slot|pot in highest bit + if (isSlot) norm |= uint64_t(1) << 63;//encode slot|pot in highest bit uint64ToPersistent(_buffer, norm); break; } diff --git a/arangod/RocksDBEngine/RocksDBKey.h b/arangod/RocksDBEngine/RocksDBKey.h index 4cfc8e1256..4e2c4ba1f5 100644 --- a/arangod/RocksDBEngine/RocksDBKey.h +++ b/arangod/RocksDBEngine/RocksDBKey.h @@ -226,7 +226,7 @@ class RocksDBKey { /// /// May be called only on GeoIndexValues ////////////////////////////////////////////////////////////////////////////// - std::pair geoValues(rocksdb::Slice const&); + std::pair geoValues(rocksdb::Slice const& slice); public: ////////////////////////////////////////////////////////////////////////////// diff --git a/arangod/RocksDBEngine/RocksDBKeyBounds.cpp b/arangod/RocksDBEngine/RocksDBKeyBounds.cpp index 4df1015413..8ea793f163 100644 --- a/arangod/RocksDBEngine/RocksDBKeyBounds.cpp +++ b/arangod/RocksDBEngine/RocksDBKeyBounds.cpp @@ -73,6 +73,10 @@ RocksDBKeyBounds RocksDBKeyBounds::UniqueIndex(uint64_t indexId) { return RocksDBKeyBounds(RocksDBEntryType::UniqueIndexValue, indexId); } +RocksDBKeyBounds RocksDBKeyBounds::FulltextIndex(uint64_t indexId) { + return RocksDBKeyBounds(RocksDBEntryType::FulltextIndexValue, indexId); +} + RocksDBKeyBounds RocksDBKeyBounds::GeoIndex(uint64_t indexId) { return RocksDBKeyBounds(RocksDBEntryType::GeoIndexValue, indexId); } @@ -98,11 +102,6 @@ RocksDBKeyBounds RocksDBKeyBounds::CounterValues() { return RocksDBKeyBounds(RocksDBEntryType::CounterValue); } -RocksDBKeyBounds RocksDBKeyBounds::FulltextIndex(uint64_t indexId) { - return RocksDBKeyBounds(RocksDBEntryType::FulltextIndexValue, indexId); -} - - RocksDBKeyBounds RocksDBKeyBounds::FulltextIndexPrefix(uint64_t indexId, arangodb::StringRef const& word) { // I did not want to pass a bool to the constructor for this @@ -236,8 +235,9 @@ RocksDBKeyBounds::RocksDBKeyBounds(RocksDBEntryType type, uint64_t first) case RocksDBEntryType::PrimaryIndexValue: case RocksDBEntryType::EdgeIndexValue: - case RocksDBEntryType::View: - case RocksDBEntryType::FulltextIndexValue: { + case RocksDBEntryType::FulltextIndexValue: + case RocksDBEntryType::GeoIndexValue: + case RocksDBEntryType::View: { size_t length = sizeof(char) + sizeof(uint64_t); _startBuffer.reserve(length); _startBuffer.push_back(static_cast(_type)); diff --git a/arangod/RocksDBEngine/RocksDBKeyBounds.h b/arangod/RocksDBEngine/RocksDBKeyBounds.h index 9badb2a718..f402f0acbf 100644 --- a/arangod/RocksDBEngine/RocksDBKeyBounds.h +++ b/arangod/RocksDBEngine/RocksDBKeyBounds.h @@ -85,6 +85,11 @@ class RocksDBKeyBounds { ////////////////////////////////////////////////////////////////////////////// static RocksDBKeyBounds UniqueIndex(uint64_t indexId); + ////////////////////////////////////////////////////////////////////////////// + /// @brief Bounds for all entries of a fulltext index + ////////////////////////////////////////////////////////////////////////////// + static RocksDBKeyBounds FulltextIndex(uint64_t indexId); + ////////////////////////////////////////////////////////////////////////////// /// @brief Bounds for all entries belonging to a specified unique index ////////////////////////////////////////////////////////////////////////////// @@ -114,12 +119,7 @@ class RocksDBKeyBounds { /// @brief Bounds for all counter values ////////////////////////////////////////////////////////////////////////////// static RocksDBKeyBounds CounterValues(); - - ////////////////////////////////////////////////////////////////////////////// - /// @brief Bounds for all entries of a fulltext index - ////////////////////////////////////////////////////////////////////////////// - static RocksDBKeyBounds FulltextIndex(uint64_t indexId); - + ////////////////////////////////////////////////////////////////////////////// /// @brief Bounds for all entries of a fulltext index, matching prefixes ////////////////////////////////////////////////////////////////////////////// diff --git a/arangod/RocksDBEngine/RocksDBTypes.cpp b/arangod/RocksDBEngine/RocksDBTypes.cpp index b65edf5c38..0af06df592 100644 --- a/arangod/RocksDBEngine/RocksDBTypes.cpp +++ b/arangod/RocksDBEngine/RocksDBTypes.cpp @@ -72,6 +72,20 @@ static rocksdb::Slice UniqueIndexValue( reinterpret_cast::type*>( &uniqueIndexValue), 1); + +static RocksDBEntryType fulltextIndexValue = +RocksDBEntryType::FulltextIndexValue; +static rocksdb::Slice FulltextIndexValue( + reinterpret_cast::type*>( + &fulltextIndexValue), + 1); + +static RocksDBEntryType geoIndexValue = +RocksDBEntryType::GeoIndexValue; +static rocksdb::Slice GeoIndexValue( + reinterpret_cast::type*>( + &geoIndexValue), + 1); static RocksDBEntryType view = RocksDBEntryType::View; static rocksdb::Slice View( @@ -89,13 +103,6 @@ static rocksdb::Slice ReplicationApplierConfig( reinterpret_cast::type*>( &replicationApplierConfig), 1); - -static RocksDBEntryType fulltextIndexValue = - RocksDBEntryType::FulltextIndexValue; -static rocksdb::Slice FulltextIndexValue( - reinterpret_cast::type*>( - &fulltextIndexValue), - 1); } rocksdb::Slice const& arangodb::rocksDBSlice(RocksDBEntryType const& type) { @@ -116,14 +123,16 @@ rocksdb::Slice const& arangodb::rocksDBSlice(RocksDBEntryType const& type) { return IndexValue; case RocksDBEntryType::UniqueIndexValue: return UniqueIndexValue; + case RocksDBEntryType::FulltextIndexValue: + return FulltextIndexValue; + case RocksDBEntryType::GeoIndexValue: + return GeoIndexValue; case RocksDBEntryType::View: return View; case RocksDBEntryType::SettingsValue: return SettingsValue; case RocksDBEntryType::ReplicationApplierConfig: return ReplicationApplierConfig; - case RocksDBEntryType::FulltextIndexValue: - return FulltextIndexValue; } return Document; // avoids warning - errorslice instead ?!