1
0
Fork 0

Add functon to create slices from RocksDBEntryTypes

This commit is contained in:
Jan Christoph Uhde 2017-03-22 14:45:54 +01:00
parent d93d154053
commit 0deac5fe62
4 changed files with 113 additions and 2 deletions

View File

@ -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

View File

@ -6,6 +6,7 @@
#include "ProgramOptions/Section.h"
#include "RestServer/DatabasePathFeature.h"
#include "RocksDBEngine.h"
#include "RocksDBTypes.h"
#include <Basics/Result.h>
#include <stdexcept>
#include <rocksdb/db.h>
@ -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<char*>(&dbPrefix),1);
iter->Seek(key);
}
void RocksDBEngine::getCollectionInfo(TRI_vocbase_t* vocbase, TRI_voc_cid_t cid,
arangodb::velocypack::Builder& result,

View File

@ -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<std::underlying_type<RocksDBEntryType>::type*>(
&database),
1);
static RocksDBEntryType collection = RocksDBEntryType::Collection;
static rocksdb::Slice Collection(
reinterpret_cast<std::underlying_type<RocksDBEntryType>::type*>(
&collection),
1);
static RocksDBEntryType index = RocksDBEntryType::Index;
static rocksdb::Slice Index(
reinterpret_cast<std::underlying_type<RocksDBEntryType>::type*>(&index),
1);
static RocksDBEntryType document = RocksDBEntryType::Document;
static rocksdb::Slice Document(
reinterpret_cast<std::underlying_type<RocksDBEntryType>::type*>(
&document),
1);
static RocksDBEntryType indexValue = RocksDBEntryType::IndexValue;
static rocksdb::Slice IndexValue(
reinterpret_cast<std::underlying_type<RocksDBEntryType>::type*>(
&indexValue),
1);
static RocksDBEntryType uniqueIndexValue = RocksDBEntryType::UniqueIndexValue;
static rocksdb::Slice UniqueIndexValue(
reinterpret_cast<std::underlying_type<RocksDBEntryType>::type*>(
&uniqueIndexValue),
1);
static RocksDBEntryType view = RocksDBEntryType::View;
static rocksdb::Slice View(
reinterpret_cast<std::underlying_type<RocksDBEntryType>::type*>(&view),
1);
static RocksDBEntryType crossReference = RocksDBEntryType::Database;
static rocksdb::Slice CrossReference(
reinterpret_cast<std::underlying_type<RocksDBEntryType>::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 ?!
}
}

View File

@ -25,10 +25,12 @@
#ifndef ARANGO_ROCKSDB_ROCKSDB_TYPES_H
#define ARANGO_ROCKSDB_ROCKSDB_TYPES_H 1
#include <rocksdb/slice.h>
#include <cstdint>
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