diff --git a/arangod/CMakeLists.txt b/arangod/CMakeLists.txt index 879e89dea7..d5dc42ec80 100644 --- a/arangod/CMakeLists.txt +++ b/arangod/CMakeLists.txt @@ -284,6 +284,7 @@ SET(ARANGOD_SOURCES RocksDBEngine/RocksDBTransactionCollection.cpp RocksDBEngine/RocksDBTransactionContextData.cpp RocksDBEngine/RocksDBTransactionState.cpp + RocksDBEngine/RocksDBTypes.cpp RocksDBEngine/RocksDBView.cpp Scheduler/Acceptor.cpp Scheduler/AcceptorTcp.cpp diff --git a/arangod/RocksDBEngine/RocksDBEngine.cpp b/arangod/RocksDBEngine/RocksDBEngine.cpp index a97fc14678..d55b9522df 100644 --- a/arangod/RocksDBEngine/RocksDBEngine.cpp +++ b/arangod/RocksDBEngine/RocksDBEngine.cpp @@ -6,6 +6,7 @@ #include "ProgramOptions/Section.h" #include "RestServer/DatabasePathFeature.h" #include "RocksDBEngine.h" +#include "RocksDBTypes.h" #include #include #include @@ -124,7 +125,17 @@ PhysicalView* RocksDBEngine::createPhysicalView(LogicalView*, // ----------------------- void RocksDBEngine::getDatabases(arangodb::velocypack::Builder& result) { - throw std::runtime_error("not implemented"); + LOG_TOPIC(WARN, Logger::STARTUP) << "getting databases for rocksdb"; + + rocksdb::ReadOptions read_options; + read_options.total_order_seek = true; + auto iter = _db->NewIterator(read_options); + + RocksDBEntryType dbPrefix = RocksDBEntryType::Database; + rocksdb::Slice key(reinterpret_cast(&dbPrefix),1); + iter->Seek(key); + + } void RocksDBEngine::getCollectionInfo(TRI_vocbase_t* vocbase, TRI_voc_cid_t cid, arangodb::velocypack::Builder& result, diff --git a/arangod/RocksDBEngine/RocksDBTypes.cpp b/arangod/RocksDBEngine/RocksDBTypes.cpp new file mode 100644 index 0000000000..2108edb8b5 --- /dev/null +++ b/arangod/RocksDBEngine/RocksDBTypes.cpp @@ -0,0 +1,96 @@ +//////////////////////////////////////////////////////////////////////////////// +/// DISCLAIMER +/// +/// Copyright 2014-2017 ArangoDB GmbH, Cologne, Germany +/// Copyright 2004-2014 triAGENS GmbH, Cologne, Germany +/// +/// Licensed under the Apache License, Version 2.0 (the "License"); +/// you may not use this file except in compliance with the License. +/// You may obtain a copy of the License at +/// +/// http://www.apache.org/licenses/LICENSE-2.0 +/// +/// Unless required by applicable law or agreed to in writing, software +/// distributed under the License is distributed on an "AS IS" BASIS, +/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +/// See the License for the specific language governing permissions and +/// limitations under the License. +/// +/// Copyright holder is ArangoDB GmbH, Cologne, Germany +/// +/// @author Jan Christoph Uhde +//////////////////////////////////////////////////////////////////////////////// + +#include "RocksDBTypes.h" + +namespace arangodb { + +rocksdb::Slice const& rocksDBSlice(RocksDBEntryType const& type) { + static RocksDBEntryType database = RocksDBEntryType::Database; + static rocksdb::Slice Database( + reinterpret_cast::type*>( + &database), + 1); + + static RocksDBEntryType collection = RocksDBEntryType::Collection; + static rocksdb::Slice Collection( + reinterpret_cast::type*>( + &collection), + 1); + + static RocksDBEntryType index = RocksDBEntryType::Index; + static rocksdb::Slice Index( + reinterpret_cast::type*>(&index), + 1); + + static RocksDBEntryType document = RocksDBEntryType::Document; + static rocksdb::Slice Document( + reinterpret_cast::type*>( + &document), + 1); + + static RocksDBEntryType indexValue = RocksDBEntryType::IndexValue; + static rocksdb::Slice IndexValue( + reinterpret_cast::type*>( + &indexValue), + 1); + + static RocksDBEntryType uniqueIndexValue = RocksDBEntryType::UniqueIndexValue; + static rocksdb::Slice UniqueIndexValue( + reinterpret_cast::type*>( + &uniqueIndexValue), + 1); + + static RocksDBEntryType view = RocksDBEntryType::View; + static rocksdb::Slice View( + reinterpret_cast::type*>(&view), + 1); + + static RocksDBEntryType crossReference = RocksDBEntryType::Database; + static rocksdb::Slice CrossReference( + reinterpret_cast::type*>( + &crossReference), + 1); + + switch (type) { + case RocksDBEntryType::Document: + return Document; + case RocksDBEntryType::Collection: + return Collection; + case RocksDBEntryType::Database: + return Database; + case RocksDBEntryType::Index: + return Index; + case RocksDBEntryType::IndexValue: + return IndexValue; + case RocksDBEntryType::UniqueIndexValue: + return UniqueIndexValue; + case RocksDBEntryType::View: + return View; + case RocksDBEntryType::CrossReference: + return CrossReference; + } + + return Document; //avoids warning - errorslice instead ?! +} +} diff --git a/arangod/RocksDBEngine/RocksDBTypes.h b/arangod/RocksDBEngine/RocksDBTypes.h index e043db4769..3250c5e00a 100644 --- a/arangod/RocksDBEngine/RocksDBTypes.h +++ b/arangod/RocksDBEngine/RocksDBTypes.h @@ -25,10 +25,12 @@ #ifndef ARANGO_ROCKSDB_ROCKSDB_TYPES_H #define ARANGO_ROCKSDB_ROCKSDB_TYPES_H 1 +#include #include + namespace arangodb { -enum class RocksDBEntryType : std::uint8_t { +enum class RocksDBEntryType : char { Database = '0', Collection = '1', Index = '2', @@ -39,6 +41,7 @@ enum class RocksDBEntryType : std::uint8_t { CrossReference = '9' }; +rocksdb::Slice const& rocksDBSlice(RocksDBEntryType const& type); } #endif