mirror of https://gitee.com/bigwinds/arangodb
added stubs for indexes
This commit is contained in:
parent
2405ebee25
commit
f17ff29518
|
@ -276,16 +276,6 @@ SET(ARANGOD_SOURCES
|
|||
RestServer/ViewTypesFeature.cpp
|
||||
RestServer/VocbaseContext.cpp
|
||||
RestServer/WorkMonitorFeature.cpp
|
||||
RocksDBEngine/RocksDBCollection.cpp
|
||||
RocksDBEngine/RocksDBComparator.cpp
|
||||
RocksDBEngine/RocksDBEngine.cpp
|
||||
RocksDBEngine/RocksDBEntry.cpp
|
||||
RocksDBEngine/RocksDBIndexFactory.cpp
|
||||
RocksDBEngine/RocksDBTransactionCollection.cpp
|
||||
RocksDBEngine/RocksDBTransactionContextData.cpp
|
||||
RocksDBEngine/RocksDBTransactionState.cpp
|
||||
RocksDBEngine/RocksDBTypes.cpp
|
||||
RocksDBEngine/RocksDBView.cpp
|
||||
Scheduler/Acceptor.cpp
|
||||
Scheduler/AcceptorTcp.cpp
|
||||
Scheduler/Job.cpp
|
||||
|
@ -436,6 +426,23 @@ set(ARANGOD_SOURCES
|
|||
MMFiles/MMFilesWalSlots.cpp
|
||||
MMFiles/mmfiles-replication-dump.cpp
|
||||
)
|
||||
|
||||
# add sources for rocksdb engine
|
||||
set(ARANGOD_SOURCES
|
||||
${ARANGOD_SOURCES}
|
||||
RocksDBEngine/RocksDBCollection.cpp
|
||||
RocksDBEngine/RocksDBComparator.cpp
|
||||
RocksDBEngine/RocksDBEdgeIndex.cpp
|
||||
RocksDBEngine/RocksDBEngine.cpp
|
||||
RocksDBEngine/RocksDBEntry.cpp
|
||||
RocksDBEngine/RocksDBIndexFactory.cpp
|
||||
RocksDBEngine/RocksDBPrimaryIndex.cpp
|
||||
RocksDBEngine/RocksDBTransactionCollection.cpp
|
||||
RocksDBEngine/RocksDBTransactionContextData.cpp
|
||||
RocksDBEngine/RocksDBTransactionState.cpp
|
||||
RocksDBEngine/RocksDBTypes.cpp
|
||||
RocksDBEngine/RocksDBView.cpp
|
||||
)
|
||||
|
||||
if (NOT MSVC)
|
||||
set(ARANGOD_SOURCES ${ARANGOD_SOURCES} Scheduler/AcceptorUnixDomain.cpp Scheduler/SocketUnixDomain.cpp)
|
||||
|
|
|
@ -28,32 +28,34 @@
|
|||
|
||||
namespace arangodb {
|
||||
|
||||
class Index;
|
||||
class LogicalCollection;
|
||||
class Index;
|
||||
class LogicalCollection;
|
||||
|
||||
namespace velocypack {
|
||||
class Builder;
|
||||
class Slice;
|
||||
}
|
||||
namespace velocypack {
|
||||
class Builder;
|
||||
class Slice;
|
||||
}
|
||||
|
||||
class IndexFactory {
|
||||
public:
|
||||
IndexFactory() {}
|
||||
class IndexFactory {
|
||||
public:
|
||||
IndexFactory() = default;
|
||||
IndexFactory(IndexFactory const&) = delete;
|
||||
IndexFactory& operator=(IndexFactory const&) = delete;
|
||||
|
||||
virtual ~IndexFactory() {}
|
||||
virtual ~IndexFactory() = default;
|
||||
|
||||
virtual int enhanceIndexDefinition(
|
||||
arangodb::velocypack::Slice const definition,
|
||||
arangodb::velocypack::Builder& enhanced, bool isCreation) const = 0;
|
||||
virtual int enhanceIndexDefinition(
|
||||
arangodb::velocypack::Slice const definition,
|
||||
arangodb::velocypack::Builder& enhanced, bool isCreation) const = 0;
|
||||
|
||||
virtual std::shared_ptr<arangodb::Index> prepareIndexFromSlice(
|
||||
arangodb::velocypack::Slice info, bool generateKey,
|
||||
arangodb::LogicalCollection* col, bool isClusterConstructor) const = 0;
|
||||
virtual std::shared_ptr<arangodb::Index> prepareIndexFromSlice(
|
||||
arangodb::velocypack::Slice info, bool generateKey,
|
||||
arangodb::LogicalCollection* col, bool isClusterConstructor) const = 0;
|
||||
|
||||
virtual void fillSystemIndexes(
|
||||
arangodb::LogicalCollection* col,
|
||||
std::vector<std::shared_ptr<arangodb::Index>>& systemIndexes) const = 0;
|
||||
};
|
||||
virtual void fillSystemIndexes(
|
||||
arangodb::LogicalCollection* col,
|
||||
std::vector<std::shared_ptr<arangodb::Index>>& systemIndexes) const = 0;
|
||||
};
|
||||
|
||||
} // namespace arangodb
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
/// @author Dr. Frank Celler
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef ARANGOD_STORAGE_ENGINE_MM_FILES_CLEANUP_THREAD_H
|
||||
#define ARANGOD_STORAGE_ENGINE_MM_FILES_CLEANUP_THREAD_H 1
|
||||
#ifndef ARANGOD_MMFILES_MMFILES_CLEANUP_THREAD_H
|
||||
#define ARANGOD_MMFILES_MMFILES_CLEANUP_THREAD_H 1
|
||||
|
||||
#include "Basics/Common.h"
|
||||
#include "Basics/ConditionVariable.h"
|
||||
|
|
|
@ -1880,7 +1880,7 @@ void MMFilesCollection::prepareIndexes(VPackSlice indexesSlice) {
|
|||
}
|
||||
|
||||
if (ServerState::instance()->isRunningInCluster()) {
|
||||
addIndexCoordinator(idx, false);
|
||||
addIndexCoordinator(idx);
|
||||
} else {
|
||||
addIndex(idx);
|
||||
}
|
||||
|
@ -1966,7 +1966,7 @@ std::shared_ptr<Index> MMFilesCollection::createIndex(transaction::Methods* trx,
|
|||
if (ServerState::instance()->isCoordinator()) {
|
||||
// In the coordinator case we do not fill the index
|
||||
// We only inform the others.
|
||||
addIndexCoordinator(idx, true);
|
||||
addIndexCoordinator(idx);
|
||||
created = true;
|
||||
return idx;
|
||||
}
|
||||
|
@ -2075,7 +2075,7 @@ void MMFilesCollection::addIndex(std::shared_ptr<arangodb::Index> idx) {
|
|||
}
|
||||
|
||||
void MMFilesCollection::addIndexCoordinator(
|
||||
std::shared_ptr<arangodb::Index> idx, bool distribute) {
|
||||
std::shared_ptr<arangodb::Index> idx) {
|
||||
auto const id = idx->id();
|
||||
for (auto const& it : _indexes) {
|
||||
if (it->id() == id) {
|
||||
|
@ -2085,9 +2085,6 @@ void MMFilesCollection::addIndexCoordinator(
|
|||
}
|
||||
|
||||
_indexes.emplace_back(idx);
|
||||
if (distribute) {
|
||||
THROW_ARANGO_EXCEPTION(TRI_ERROR_NOT_IMPLEMENTED);
|
||||
}
|
||||
}
|
||||
|
||||
int MMFilesCollection::restoreIndex(transaction::Methods* trx,
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
/// @author Dr. Frank Celler
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef ARANGOD_STORAGE_ENGINE_MM_FILES_COLLECTION_H
|
||||
#define ARANGOD_STORAGE_ENGINE_MM_FILES_COLLECTION_H 1
|
||||
#ifndef ARANGOD_MMFILES_MMFILES_COLLECTION_H
|
||||
#define ARANGOD_MMFILES_MMFILES_COLLECTION_H 1
|
||||
|
||||
#include "Basics/Common.h"
|
||||
#include "Basics/ReadWriteLock.h"
|
||||
|
@ -461,8 +461,7 @@ class MMFilesCollection final : public PhysicalCollection {
|
|||
|
||||
void addIndex(std::shared_ptr<arangodb::Index> idx);
|
||||
|
||||
void addIndexCoordinator(std::shared_ptr<arangodb::Index> idx,
|
||||
bool distribute);
|
||||
void addIndexCoordinator(std::shared_ptr<arangodb::Index> idx);
|
||||
|
||||
bool removeIndex(TRI_idx_iid_t iid);
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
/// @author Dr. Frank Celler
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef ARANGOD_STORAGE_ENGINE_MM_FILES_COMPACTOR_THREAD_H
|
||||
#define ARANGOD_STORAGE_ENGINE_MM_FILES_COMPACTOR_THREAD_H 1
|
||||
#ifndef ARANGOD_MMFILES_MMFILES_COMPACTOR_THREAD_H
|
||||
#define ARANGOD_MMFILES_MMFILES_COMPACTOR_THREAD_H 1
|
||||
|
||||
#include "Basics/Common.h"
|
||||
#include "Basics/ConditionVariable.h"
|
||||
|
@ -39,7 +39,6 @@ class LogicalCollection;
|
|||
namespace transaction {
|
||||
class Methods;
|
||||
}
|
||||
;
|
||||
|
||||
class MMFilesCompactorThread final : public Thread {
|
||||
private:
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
/// @author Dr. Frank Celler
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef ARANGOD_STORAGE_ENGINE_MMFILES_DATAFILE_H
|
||||
#define ARANGOD_STORAGE_ENGINE_MMFILES_DATAFILE_H 1
|
||||
#ifndef ARANGOD_MMFILES_MMFILES_DATAFILE_H
|
||||
#define ARANGOD_MMFILES_MMFILES_DATAFILE_H 1
|
||||
|
||||
#include "Basics/Common.h"
|
||||
#include "VocBase/vocbase.h"
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
/// @author Jan Steemann
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef ARANGOD_STORAGE_ENGINE_MMFILES_DATAFILE_HELPER_H
|
||||
#define ARANGOD_STORAGE_ENGINE_MMFILES_DATAFILE_HELPER_H 1
|
||||
#ifndef ARANGOD_MMFILES_MMFILES_DATAFILE_HELPER_H
|
||||
#define ARANGOD_MMFILES_MMFILES_DATAFILE_HELPER_H 1
|
||||
|
||||
#include "Basics/Common.h"
|
||||
#include "Basics/encoding.h"
|
||||
|
|
|
@ -32,7 +32,6 @@ class LogicalCollection;
|
|||
namespace transaction {
|
||||
class Methods;
|
||||
}
|
||||
;
|
||||
|
||||
struct MMFilesDocumentOperation {
|
||||
enum class StatusType : uint8_t {
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
/// @author Jan Steemann
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef ARANGOD_STORAGE_ENGINE_MMFILES_DOCUMENT_POSITION_H
|
||||
#define ARANGOD_STORAGE_ENGINE_MMFILES_DOCUMENT_POSITION_H 1
|
||||
#ifndef ARANGOD_MMFILES_MMFILES_DOCUMENT_POSITION_H
|
||||
#define ARANGOD_MMFILES_MMFILES_DOCUMENT_POSITION_H 1
|
||||
|
||||
#include "Basics/Common.h"
|
||||
#include "MMFiles/MMFilesDatafileHelper.h"
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
/// @author Dr. Frank Celler
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef ARANGOD_MMFILES_EDGE_INDEX_H
|
||||
#define ARANGOD_MMFILES_EDGE_INDEX_H 1
|
||||
#ifndef ARANGOD_MMFILES_MMFILES_EDGE_INDEX_H
|
||||
#define ARANGOD_MMFILES_MMFILES_EDGE_INDEX_H 1
|
||||
|
||||
#include "Basics/AssocMulti.h"
|
||||
#include "Basics/Common.h"
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
/// @author Jan Christoph Uhde
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef ARANGOD_STORAGE_ENGINE_MMFILES_ENGINE_H
|
||||
#define ARANGOD_STORAGE_ENGINE_MMFILES_ENGINE_H 1
|
||||
#ifndef ARANGOD_MMFILES_MMFILES_ENGINE_H
|
||||
#define ARANGOD_MMFILES_MMFILES_ENGINE_H 1
|
||||
|
||||
#include "Basics/Common.h"
|
||||
#include "Basics/Mutex.h"
|
||||
|
|
|
@ -28,25 +28,25 @@
|
|||
|
||||
namespace arangodb {
|
||||
|
||||
class MMFilesIndexFactory : public IndexFactory {
|
||||
public:
|
||||
MMFilesIndexFactory() : IndexFactory() {
|
||||
}
|
||||
class MMFilesIndexFactory final : public IndexFactory {
|
||||
public:
|
||||
MMFilesIndexFactory() : IndexFactory() {}
|
||||
|
||||
~MMFilesIndexFactory() override {}
|
||||
~MMFilesIndexFactory() {}
|
||||
|
||||
int enhanceIndexDefinition(
|
||||
arangodb::velocypack::Slice const definition,
|
||||
arangodb::velocypack::Builder& enhanced, bool isCreation) const override;
|
||||
int enhanceIndexDefinition(
|
||||
arangodb::velocypack::Slice const definition,
|
||||
arangodb::velocypack::Builder& enhanced, bool isCreation) const override;
|
||||
|
||||
std::shared_ptr<arangodb::Index> prepareIndexFromSlice(
|
||||
arangodb::velocypack::Slice info, bool generateKey,
|
||||
LogicalCollection* col, bool isClusterConstructor) const override;
|
||||
std::shared_ptr<arangodb::Index> prepareIndexFromSlice(
|
||||
arangodb::velocypack::Slice info, bool generateKey,
|
||||
LogicalCollection* col, bool isClusterConstructor) const override;
|
||||
|
||||
void fillSystemIndexes(arangodb::LogicalCollection* col,
|
||||
std::vector<std::shared_ptr<arangodb::Index>>&
|
||||
systemIndexes) const override;
|
||||
};
|
||||
|
||||
void fillSystemIndexes(arangodb::LogicalCollection* col,
|
||||
std::vector<std::shared_ptr<arangodb::Index>>&
|
||||
systemIndexes) const override;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -42,7 +42,6 @@ struct MMFilesSimpleIndexElement;
|
|||
namespace transaction {
|
||||
class Methods;
|
||||
}
|
||||
;
|
||||
|
||||
typedef arangodb::basics::AssocUnique<uint8_t, MMFilesSimpleIndexElement> MMFilesPrimaryIndexImpl;
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
/// @author Jan Steemann
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef ARANGOD_STORAGE_ENGINE_MMFILES_REVISIONS_CACHE_H
|
||||
#define ARANGOD_STORAGE_ENGINE_MMFILES_REVISIONS_CACHE_H 1
|
||||
#ifndef ARANGOD_MMFILES_MMFILES_REVISIONS_CACHE_H
|
||||
#define ARANGOD_MMFILES_MMFILES_REVISIONS_CACHE_H 1
|
||||
|
||||
#include "Basics/Common.h"
|
||||
#include "Basics/AssocUnique.h"
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
/// @author Jan Steemann
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef ARANGOD_STORAGE_ENGINE_MM_FILES_VIEW_H
|
||||
#define ARANGOD_STORAGE_ENGINE_MM_FILES_VIEW_H 1
|
||||
#ifndef ARANGOD_MMFILES_MMFILES_VIEW_H
|
||||
#define ARANGOD_MMFILES_MMFILES_VIEW_H 1
|
||||
|
||||
#include "Basics/Common.h"
|
||||
#include "Basics/ReadWriteLock.h"
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
/// @author Jan Steemann
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef ARANGOD_STORAGE_ENGINE_MMFILES_WAL_MARKER_H
|
||||
#define ARANGOD_STORAGE_ENGINE_MMFILES_WAL_MARKER_H 1
|
||||
#ifndef ARANGOD_MMFILES_MMFILES_WAL_MARKER_H
|
||||
#define ARANGOD_MMFILES_MMFILES_WAL_MARKER_H 1
|
||||
|
||||
#include "Basics/Common.h"
|
||||
#include "Basics/encoding.h"
|
||||
|
|
|
@ -1,8 +1,38 @@
|
|||
#include "RocksDBCollection.h"
|
||||
#include <Basics/Result.h>
|
||||
#include <stdexcept>
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2014-2016 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 "Basics/Result.h"
|
||||
#include "Basics/VelocyPackHelper.h"
|
||||
#include "Indexes/Index.h"
|
||||
#include "Indexes/IndexIterator.h"
|
||||
#include "RocksDBCollection.h"
|
||||
#include "StorageEngine/EngineSelectorFeature.h"
|
||||
#include "StorageEngine/StorageEngine.h"
|
||||
#include "VocBase/LogicalCollection.h"
|
||||
#include "VocBase/ticks.h"
|
||||
|
||||
#include <velocypack/Iterator.h>
|
||||
#include <velocypack/velocypack-aliases.h>
|
||||
|
||||
using namespace arangodb;
|
||||
|
||||
|
@ -104,7 +134,44 @@ bool RocksDBCollection::isFullyCollected() const {
|
|||
|
||||
void RocksDBCollection::prepareIndexes(
|
||||
arangodb::velocypack::Slice indexesSlice) {
|
||||
THROW_ARANGO_NOT_IMPLEMENTED();
|
||||
createInitialIndexes();
|
||||
if (indexesSlice.isArray()) {
|
||||
StorageEngine* engine = EngineSelectorFeature::ENGINE;
|
||||
IndexFactory const* idxFactory = engine->indexFactory();
|
||||
TRI_ASSERT(idxFactory != nullptr);
|
||||
for (auto const& v : VPackArrayIterator(indexesSlice)) {
|
||||
if (arangodb::basics::VelocyPackHelper::getBooleanValue(v, "error",
|
||||
false)) {
|
||||
// We have an error here.
|
||||
// Do not add index.
|
||||
// TODO Handle Properly
|
||||
continue;
|
||||
}
|
||||
|
||||
auto idx =
|
||||
idxFactory->prepareIndexFromSlice(v, false, _logicalCollection, true);
|
||||
|
||||
if (idx->type() == Index::TRI_IDX_TYPE_PRIMARY_INDEX ||
|
||||
idx->type() == Index::TRI_IDX_TYPE_EDGE_INDEX) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ServerState::instance()->isRunningInCluster()) {
|
||||
addIndexCoordinator(idx);
|
||||
} else {
|
||||
addIndex(idx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ARANGODB_ENABLE_MAINTAINER_MODE
|
||||
if (_indexes[0]->type() != Index::IndexType::TRI_IDX_TYPE_PRIMARY_INDEX) {
|
||||
LOG_TOPIC(ERR, arangodb::Logger::FIXME) << "got invalid indexes for collection '" << _logicalCollection->name() << "'";
|
||||
for (auto const& it : _indexes) {
|
||||
LOG_TOPIC(ERR, arangodb::Logger::FIXME) << "- " << it.get();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/// @brief Find index by definition
|
||||
|
@ -230,3 +297,51 @@ void RocksDBCollection::deferDropCollection(
|
|||
void RocksDBCollection::figuresSpecific(std::shared_ptr<arangodb::velocypack::Builder>&) {
|
||||
THROW_ARANGO_NOT_IMPLEMENTED();
|
||||
}
|
||||
|
||||
/// @brief creates the initial indexes for the collection
|
||||
void RocksDBCollection::createInitialIndexes() {
|
||||
if (!_indexes.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<arangodb::Index>> systemIndexes;
|
||||
StorageEngine* engine = EngineSelectorFeature::ENGINE;
|
||||
IndexFactory const* idxFactory = engine->indexFactory();
|
||||
TRI_ASSERT(idxFactory != nullptr);
|
||||
|
||||
idxFactory->fillSystemIndexes(_logicalCollection, systemIndexes);
|
||||
for (auto const& it : systemIndexes) {
|
||||
addIndex(it);
|
||||
}
|
||||
}
|
||||
|
||||
void RocksDBCollection::addIndex(std::shared_ptr<arangodb::Index> idx) {
|
||||
// primary index must be added at position 0
|
||||
TRI_ASSERT(idx->type() != arangodb::Index::TRI_IDX_TYPE_PRIMARY_INDEX ||
|
||||
_indexes.empty());
|
||||
|
||||
auto const id = idx->id();
|
||||
for (auto const& it : _indexes) {
|
||||
if (it->id() == id) {
|
||||
// already have this particular index. do not add it again
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
TRI_UpdateTickServer(static_cast<TRI_voc_tick_t>(id));
|
||||
|
||||
_indexes.emplace_back(idx);
|
||||
}
|
||||
|
||||
void RocksDBCollection::addIndexCoordinator(
|
||||
std::shared_ptr<arangodb::Index> idx) {
|
||||
auto const id = idx->id();
|
||||
for (auto const& it : _indexes) {
|
||||
if (it->id() == id) {
|
||||
// already have this particular index. do not add it again
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
_indexes.emplace_back(idx);
|
||||
}
|
||||
|
|
|
@ -18,11 +18,11 @@
|
|||
///
|
||||
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Jan-Christoph Uhde
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef ARANGOD_STORAGE_ENGINE_ROCKSDB_FILES_COLLECTION_H
|
||||
#define ARANGOD_STORAGE_ENGINE_ROCKSDB_FILES_COLLECTION_H 1
|
||||
#ifndef ARANGOD_ROCKSDB_ENGINE_ROCKSDB_COLLECTION_H
|
||||
#define ARANGOD_ROCKSDB_ENGINE_ROCKSDB_COLLECTION_H 1
|
||||
|
||||
#include "Basics/Common.h"
|
||||
#include "Basics/ReadWriteLock.h"
|
||||
|
@ -175,7 +175,12 @@ class RocksDBCollection final : public PhysicalCollection {
|
|||
private:
|
||||
/// @brief return engine-specific figures
|
||||
void figuresSpecific(std::shared_ptr<arangodb::velocypack::Builder>&) override;
|
||||
/// @brief creates the initial indexes for the collection
|
||||
void createInitialIndexes();
|
||||
void addIndex(std::shared_ptr<arangodb::Index> idx);
|
||||
void addIndexCoordinator(std::shared_ptr<arangodb::Index> idx);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,205 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2014-2016 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 Steemann
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RocksDBEdgeIndex.h"
|
||||
#include "Aql/AstNode.h"
|
||||
#include "Aql/SortCondition.h"
|
||||
#include "Basics/Exceptions.h"
|
||||
#include "Basics/StaticStrings.h"
|
||||
#include "Basics/StringRef.h"
|
||||
#include "Basics/fasthash.h"
|
||||
#include "Basics/hashes.h"
|
||||
#include "Indexes/IndexLookupContext.h"
|
||||
#include "Indexes/SimpleAttributeEqualityMatcher.h"
|
||||
#include "StorageEngine/TransactionState.h"
|
||||
#include "Transaction/Helpers.h"
|
||||
#include "Transaction/Methods.h"
|
||||
#include "Utils/CollectionNameResolver.h"
|
||||
#include "Transaction/Context.h"
|
||||
#include "VocBase/LogicalCollection.h"
|
||||
|
||||
#include <velocypack/Iterator.h>
|
||||
#include <velocypack/velocypack-aliases.h>
|
||||
|
||||
using namespace arangodb;
|
||||
|
||||
/// @brief hard-coded vector of the index attributes
|
||||
/// note that the attribute names must be hard-coded here to avoid an init-order
|
||||
/// fiasco with StaticStrings::FromString etc.
|
||||
static std::vector<std::vector<arangodb::basics::AttributeName>> const
|
||||
IndexAttributes{{arangodb::basics::AttributeName("_from", false)},
|
||||
{arangodb::basics::AttributeName("_to", false)}};
|
||||
|
||||
RocksDBEdgeIndexIterator::RocksDBEdgeIndexIterator(LogicalCollection* collection, transaction::Methods* trx,
|
||||
ManagedDocumentResult* mmdr,
|
||||
arangodb::RocksDBEdgeIndex const* index,
|
||||
std::unique_ptr<VPackBuilder>& keys)
|
||||
: IndexIterator(collection, trx, mmdr, index),
|
||||
_keys(keys.get()),
|
||||
_iterator(_keys->slice()) {
|
||||
keys.release(); // now we have ownership for _keys
|
||||
}
|
||||
|
||||
RocksDBEdgeIndexIterator::~RocksDBEdgeIndexIterator() {
|
||||
if (_keys != nullptr) {
|
||||
// return the VPackBuilder to the transaction context
|
||||
_trx->transactionContextPtr()->returnBuilder(_keys.release());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool RocksDBEdgeIndexIterator::next(TokenCallback const& cb, size_t limit) {
|
||||
THROW_ARANGO_NOT_IMPLEMENTED();
|
||||
}
|
||||
|
||||
void RocksDBEdgeIndexIterator::reset() {
|
||||
THROW_ARANGO_NOT_IMPLEMENTED();
|
||||
}
|
||||
|
||||
RocksDBEdgeIndex::RocksDBEdgeIndex(TRI_idx_iid_t iid, arangodb::LogicalCollection* collection)
|
||||
: Index(iid, collection,
|
||||
std::vector<std::vector<arangodb::basics::AttributeName>>(
|
||||
{{arangodb::basics::AttributeName(StaticStrings::FromString,
|
||||
false)},
|
||||
{arangodb::basics::AttributeName(StaticStrings::ToString,
|
||||
false)}}),
|
||||
false, false) {
|
||||
TRI_ASSERT(iid != 0);
|
||||
}
|
||||
|
||||
RocksDBEdgeIndex::~RocksDBEdgeIndex() {}
|
||||
|
||||
/// @brief return a selectivity estimate for the index
|
||||
double RocksDBEdgeIndex::selectivityEstimate(arangodb::StringRef const* attribute) const {
|
||||
THROW_ARANGO_NOT_IMPLEMENTED();
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
/// @brief return the memory usage for the index
|
||||
size_t RocksDBEdgeIndex::memory() const {
|
||||
THROW_ARANGO_NOT_IMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// @brief return a VelocyPack representation of the index
|
||||
void RocksDBEdgeIndex::toVelocyPack(VPackBuilder& builder, bool withFigures) const {
|
||||
Index::toVelocyPack(builder, withFigures);
|
||||
|
||||
// hard-coded
|
||||
builder.add("unique", VPackValue(false));
|
||||
builder.add("sparse", VPackValue(false));
|
||||
}
|
||||
|
||||
/// @brief return a VelocyPack representation of the index figures
|
||||
void RocksDBEdgeIndex::toVelocyPackFigures(VPackBuilder& builder) const {
|
||||
Index::toVelocyPackFigures(builder);
|
||||
// TODO
|
||||
THROW_ARANGO_NOT_IMPLEMENTED();
|
||||
}
|
||||
|
||||
int RocksDBEdgeIndex::insert(transaction::Methods* trx, TRI_voc_rid_t revisionId,
|
||||
VPackSlice const& doc, bool isRollback) {
|
||||
THROW_ARANGO_NOT_IMPLEMENTED();
|
||||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
int RocksDBEdgeIndex::remove(transaction::Methods* trx, TRI_voc_rid_t revisionId,
|
||||
VPackSlice const& doc, bool isRollback) {
|
||||
THROW_ARANGO_NOT_IMPLEMENTED();
|
||||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
/// @brief unload the index data from memory
|
||||
int RocksDBEdgeIndex::unload() {
|
||||
// nothing to do here
|
||||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
/// @brief provides a size hint for the edge index
|
||||
int RocksDBEdgeIndex::sizeHint(transaction::Methods* trx, size_t size) {
|
||||
// nothing to do here
|
||||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
/// @brief checks whether the index supports the condition
|
||||
bool RocksDBEdgeIndex::supportsFilterCondition(
|
||||
arangodb::aql::AstNode const* node,
|
||||
arangodb::aql::Variable const* reference, size_t itemsInIndex,
|
||||
size_t& estimatedItems, double& estimatedCost) const {
|
||||
SimpleAttributeEqualityMatcher matcher(IndexAttributes);
|
||||
return matcher.matchOne(this, node, reference, itemsInIndex, estimatedItems,
|
||||
estimatedCost);
|
||||
}
|
||||
|
||||
/// @brief creates an IndexIterator for the given Condition
|
||||
IndexIterator* RocksDBEdgeIndex::iteratorForCondition(
|
||||
transaction::Methods* trx,
|
||||
ManagedDocumentResult* mmdr,
|
||||
arangodb::aql::AstNode const* node,
|
||||
arangodb::aql::Variable const* reference, bool reverse) const {
|
||||
THROW_ARANGO_NOT_IMPLEMENTED();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/// @brief specializes the condition for use with the index
|
||||
arangodb::aql::AstNode* RocksDBEdgeIndex::specializeCondition(
|
||||
arangodb::aql::AstNode* node,
|
||||
arangodb::aql::Variable const* reference) const {
|
||||
SimpleAttributeEqualityMatcher matcher(IndexAttributes);
|
||||
return matcher.specializeOne(this, node, reference);
|
||||
}
|
||||
|
||||
/// @brief Transform the list of search slices to search values.
|
||||
/// This will multiply all IN entries and simply return all other
|
||||
/// entries.
|
||||
void RocksDBEdgeIndex::expandInSearchValues(VPackSlice const slice,
|
||||
VPackBuilder& builder) const {
|
||||
TRI_ASSERT(slice.isArray());
|
||||
builder.openArray();
|
||||
for (auto const& side : VPackArrayIterator(slice)) {
|
||||
if (side.isNull()) {
|
||||
builder.add(side);
|
||||
} else {
|
||||
TRI_ASSERT(side.isArray());
|
||||
builder.openArray();
|
||||
for (auto const& item : VPackArrayIterator(side)) {
|
||||
TRI_ASSERT(item.isObject());
|
||||
if (item.hasKey(StaticStrings::IndexEq)) {
|
||||
TRI_ASSERT(!item.hasKey(StaticStrings::IndexIn));
|
||||
builder.add(item);
|
||||
} else {
|
||||
TRI_ASSERT(item.hasKey(StaticStrings::IndexIn));
|
||||
VPackSlice list = item.get(StaticStrings::IndexIn);
|
||||
TRI_ASSERT(list.isArray());
|
||||
for (auto const& it : VPackArrayIterator(list)) {
|
||||
builder.openObject();
|
||||
builder.add(StaticStrings::IndexEq, it);
|
||||
builder.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
builder.close();
|
||||
}
|
||||
}
|
||||
builder.close();
|
||||
}
|
|
@ -0,0 +1,122 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2014-2016 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 Steemann
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef ARANGOD_ROCKSDB_ENGINE_ROCKSDB_EDGE_INDEX_H
|
||||
#define ARANGOD_ROCKSDB_ENGINE_ROCKSDB_EDGE_INDEX_H 1
|
||||
|
||||
#include "Basics/Common.h"
|
||||
#include "Indexes/Index.h"
|
||||
#include "Indexes/IndexIterator.h"
|
||||
#include "VocBase/voc-types.h"
|
||||
#include "VocBase/vocbase.h"
|
||||
|
||||
#include <velocypack/Iterator.h>
|
||||
#include <velocypack/Slice.h>
|
||||
|
||||
namespace arangodb {
|
||||
class RocksDBEdgeIndex;
|
||||
|
||||
class RocksDBEdgeIndexIterator final : public IndexIterator {
|
||||
public:
|
||||
RocksDBEdgeIndexIterator(LogicalCollection* collection, transaction::Methods* trx,
|
||||
ManagedDocumentResult* mmdr,
|
||||
arangodb::RocksDBEdgeIndex const* index,
|
||||
std::unique_ptr<VPackBuilder>& keys);
|
||||
|
||||
~RocksDBEdgeIndexIterator();
|
||||
|
||||
char const* typeName() const override { return "edge-index-iterator"; }
|
||||
|
||||
bool next(TokenCallback const& cb, size_t limit) override;
|
||||
|
||||
void reset() override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<arangodb::velocypack::Builder> _keys;
|
||||
arangodb::velocypack::ArrayIterator _iterator;
|
||||
};
|
||||
|
||||
class RocksDBEdgeIndex final : public Index {
|
||||
public:
|
||||
RocksDBEdgeIndex() = delete;
|
||||
|
||||
RocksDBEdgeIndex(TRI_idx_iid_t, arangodb::LogicalCollection*);
|
||||
|
||||
~RocksDBEdgeIndex();
|
||||
|
||||
public:
|
||||
IndexType type() const override { return Index::TRI_IDX_TYPE_EDGE_INDEX; }
|
||||
|
||||
char const* typeName() const override { return "edge"; }
|
||||
|
||||
bool allowExpansion() const override { return false; }
|
||||
|
||||
bool canBeDropped() const override { return false; }
|
||||
|
||||
bool isSorted() const override { return false; }
|
||||
|
||||
bool hasSelectivityEstimate() const override { return true; }
|
||||
|
||||
double selectivityEstimate(
|
||||
arangodb::StringRef const* = nullptr) const override;
|
||||
|
||||
size_t memory() const override;
|
||||
|
||||
void toVelocyPack(VPackBuilder&, bool) const override;
|
||||
|
||||
void toVelocyPackFigures(VPackBuilder&) const override;
|
||||
|
||||
int insert(transaction::Methods*, TRI_voc_rid_t,
|
||||
arangodb::velocypack::Slice const&, bool isRollback) override;
|
||||
|
||||
int remove(transaction::Methods*, TRI_voc_rid_t,
|
||||
arangodb::velocypack::Slice const&, bool isRollback) override;
|
||||
|
||||
int unload() override;
|
||||
|
||||
int sizeHint(transaction::Methods*, size_t) override;
|
||||
|
||||
bool hasBatchInsert() const override { return false; }
|
||||
|
||||
bool supportsFilterCondition(arangodb::aql::AstNode const*,
|
||||
arangodb::aql::Variable const*, size_t, size_t&,
|
||||
double&) const override;
|
||||
|
||||
IndexIterator* iteratorForCondition(transaction::Methods*,
|
||||
ManagedDocumentResult*,
|
||||
arangodb::aql::AstNode const*,
|
||||
arangodb::aql::Variable const*,
|
||||
bool) const override;
|
||||
|
||||
arangodb::aql::AstNode* specializeCondition(
|
||||
arangodb::aql::AstNode*, arangodb::aql::Variable const*) const override;
|
||||
|
||||
/// @brief Transform the list of search slices to search values.
|
||||
/// This will multiply all IN entries and simply return all other
|
||||
/// entries.
|
||||
void expandInSearchValues(arangodb::velocypack::Slice const,
|
||||
arangodb::velocypack::Builder&) const override;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
|
@ -35,6 +35,7 @@
|
|||
#include "RestServer/ViewTypesFeature.h"
|
||||
#include "RocksDBEngine/RocksDBCollection.h"
|
||||
#include "RocksDBEngine/RocksDBEntry.h"
|
||||
#include "RocksDBEngine/RocksDBIndexFactory.h"
|
||||
#include "RocksDBEngine/RocksDBTypes.h"
|
||||
#include "RocksDBEngine/RocksDBView.h"
|
||||
#include "VocBase/ticks.h"
|
||||
|
@ -63,8 +64,7 @@ std::string const RocksDBEngine::FeatureName("RocksDBEngine");
|
|||
|
||||
// create the storage engine
|
||||
RocksDBEngine::RocksDBEngine(application_features::ApplicationServer* server)
|
||||
: StorageEngine(server, EngineName, FeatureName, nullptr /*new
|
||||
MMFilesIndexFactory()*/),
|
||||
: StorageEngine(server, EngineName, FeatureName, new RocksDBIndexFactory()),
|
||||
_db(nullptr) {
|
||||
//inherits order from StorageEngine
|
||||
}
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
/// @author Jan Christoph Uhde
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef ARANGOD_STORAGE_ENGINE_ROCKSDB_ENGINE_H
|
||||
#define ARANGOD_STORAGE_ENGINE_ROCKSDB_ENGINE_H 1
|
||||
#ifndef ARANGOD_ROCKSDB_ENGINE_ROCKSDB_ENGINE_H
|
||||
#define ARANGOD_ROCKSDB_ENGINE_ROCKSDB_ENGINE_H 1
|
||||
|
||||
#include "Basics/Common.h"
|
||||
#include "Basics/Mutex.h"
|
||||
|
|
|
@ -22,13 +22,11 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RocksDBIndexFactory.h"
|
||||
#include "Basics/StaticStrings.h"
|
||||
#include "Basics/StringRef.h"
|
||||
#include "Basics/StringUtils.h"
|
||||
#include "Basics/VelocyPackHelper.h"
|
||||
|
||||
#include "Cluster/ServerState.h"
|
||||
#include "Indexes/Index.h"
|
||||
#include "RocksDBEngine/RocksDBEdgeIndex.h"
|
||||
#include "RocksDBEngine/RocksDBPrimaryIndex.h"
|
||||
#include "VocBase/voc-types.h"
|
||||
|
||||
#include <velocypack/Builder.h>
|
||||
|
@ -36,26 +34,104 @@
|
|||
#include <velocypack/Slice.h>
|
||||
#include <velocypack/velocypack-aliases.h>
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
using namespace arangodb;
|
||||
|
||||
int RocksDBIndexFactory::enhanceIndexDefinition(VPackSlice const definition,
|
||||
VPackBuilder& enhanced,
|
||||
bool create) const {
|
||||
throw std::runtime_error("not implemented");
|
||||
THROW_ARANGO_NOT_IMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::shared_ptr<Index> RocksDBIndexFactory::prepareIndexFromSlice(
|
||||
arangodb::velocypack::Slice info, bool generateKey, LogicalCollection* col,
|
||||
bool isClusterConstructor) const {
|
||||
throw std::runtime_error("not implemented");
|
||||
return nullptr;
|
||||
if (!info.isObject()) {
|
||||
THROW_ARANGO_EXCEPTION(TRI_ERROR_BAD_PARAMETER);
|
||||
}
|
||||
|
||||
// extract type
|
||||
VPackSlice value = info.get("type");
|
||||
|
||||
if (!value.isString()) {
|
||||
// Compatibility with old v8-vocindex.
|
||||
if (generateKey) {
|
||||
THROW_ARANGO_EXCEPTION(TRI_ERROR_OUT_OF_MEMORY);
|
||||
} else {
|
||||
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL,
|
||||
"invalid index type definition");
|
||||
}
|
||||
}
|
||||
|
||||
std::string tmp = value.copyString();
|
||||
arangodb::Index::IndexType const type = arangodb::Index::type(tmp.c_str());
|
||||
|
||||
std::shared_ptr<Index> newIdx;
|
||||
|
||||
TRI_idx_iid_t iid = 0;
|
||||
value = info.get("id");
|
||||
if (value.isString()) {
|
||||
iid = basics::StringUtils::uint64(value.copyString());
|
||||
} else if (value.isNumber()) {
|
||||
iid =
|
||||
basics::VelocyPackHelper::getNumericValue<TRI_idx_iid_t>(info, "id", 0);
|
||||
} else if (!generateKey) {
|
||||
// In the restore case it is forbidden to NOT have id
|
||||
THROW_ARANGO_EXCEPTION_MESSAGE(
|
||||
TRI_ERROR_INTERNAL, "cannot restore index without index identifier");
|
||||
}
|
||||
|
||||
if (iid == 0 && !isClusterConstructor) {
|
||||
// Restore is not allowed to generate in id
|
||||
TRI_ASSERT(generateKey);
|
||||
iid = arangodb::Index::generateId();
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case arangodb::Index::TRI_IDX_TYPE_UNKNOWN: {
|
||||
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL, "invalid index type");
|
||||
}
|
||||
case arangodb::Index::TRI_IDX_TYPE_PRIMARY_INDEX: {
|
||||
if (!isClusterConstructor) {
|
||||
// this indexes cannot be created directly
|
||||
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL,
|
||||
"cannot create primary index");
|
||||
}
|
||||
newIdx.reset(new arangodb::RocksDBPrimaryIndex(col));
|
||||
break;
|
||||
}
|
||||
case arangodb::Index::TRI_IDX_TYPE_EDGE_INDEX: {
|
||||
if (!isClusterConstructor) {
|
||||
// this indexes cannot be created directly
|
||||
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL,
|
||||
"cannot create edge index");
|
||||
}
|
||||
newIdx.reset(new arangodb::RocksDBEdgeIndex(iid, col));
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
THROW_ARANGO_NOT_IMPLEMENTED();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (newIdx == nullptr) {
|
||||
THROW_ARANGO_EXCEPTION(TRI_ERROR_OUT_OF_MEMORY);
|
||||
}
|
||||
return newIdx;
|
||||
}
|
||||
|
||||
void RocksDBIndexFactory::fillSystemIndexes(
|
||||
arangodb::LogicalCollection* col,
|
||||
std::vector<std::shared_ptr<arangodb::Index>>& systemIndexes) const {
|
||||
throw std::runtime_error("not implemented");
|
||||
// create primary index
|
||||
systemIndexes.emplace_back(
|
||||
std::make_shared<arangodb::RocksDBPrimaryIndex>(col));
|
||||
|
||||
// create edges index
|
||||
if (col->type() == TRI_COL_TYPE_EDGE) {
|
||||
systemIndexes.emplace_back(
|
||||
std::make_shared<arangodb::RocksDBEdgeIndex>(1, col));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,25 +28,25 @@
|
|||
|
||||
namespace arangodb {
|
||||
|
||||
class RocksDBIndexFactory : public IndexFactory {
|
||||
public:
|
||||
RocksDBIndexFactory() : IndexFactory() {
|
||||
}
|
||||
class RocksDBIndexFactory final : public IndexFactory {
|
||||
public:
|
||||
RocksDBIndexFactory() : IndexFactory() {}
|
||||
|
||||
~RocksDBIndexFactory() override {}
|
||||
~RocksDBIndexFactory() {}
|
||||
|
||||
int enhanceIndexDefinition(
|
||||
arangodb::velocypack::Slice const definition,
|
||||
arangodb::velocypack::Builder& enhanced, bool isCreation) const override;
|
||||
int enhanceIndexDefinition(
|
||||
arangodb::velocypack::Slice const definition,
|
||||
arangodb::velocypack::Builder& enhanced, bool isCreation) const override;
|
||||
|
||||
std::shared_ptr<arangodb::Index> prepareIndexFromSlice(
|
||||
arangodb::velocypack::Slice info, bool generateKey,
|
||||
LogicalCollection* col, bool isClusterConstructor) const override;
|
||||
std::shared_ptr<arangodb::Index> prepareIndexFromSlice(
|
||||
arangodb::velocypack::Slice info, bool generateKey,
|
||||
LogicalCollection* col, bool isClusterConstructor) const override;
|
||||
|
||||
void fillSystemIndexes(arangodb::LogicalCollection* col,
|
||||
std::vector<std::shared_ptr<arangodb::Index>>&
|
||||
systemIndexes) const override;
|
||||
};
|
||||
|
||||
void fillSystemIndexes(arangodb::LogicalCollection* col,
|
||||
std::vector<std::shared_ptr<arangodb::Index>>&
|
||||
systemIndexes) const override;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,189 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2014-2016 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 Steemann
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RocksDBPrimaryIndex.h"
|
||||
#include "Aql/AstNode.h"
|
||||
#include "Basics/Exceptions.h"
|
||||
#include "Basics/StaticStrings.h"
|
||||
#include "Indexes/SimpleAttributeEqualityMatcher.h"
|
||||
#include "Transaction/Helpers.h"
|
||||
#include "Transaction/Methods.h"
|
||||
#include "Transaction/Context.h"
|
||||
#include "VocBase/LogicalCollection.h"
|
||||
|
||||
#include <velocypack/Builder.h>
|
||||
#include <velocypack/Collection.h>
|
||||
#include <velocypack/Slice.h>
|
||||
#include <velocypack/velocypack-aliases.h>
|
||||
|
||||
using namespace arangodb;
|
||||
|
||||
/// @brief hard-coded vector of the index attributes
|
||||
/// note that the attribute names must be hard-coded here to avoid an init-order
|
||||
/// fiasco with StaticStrings::FromString etc.
|
||||
static std::vector<std::vector<arangodb::basics::AttributeName>> const IndexAttributes
|
||||
{{arangodb::basics::AttributeName("_id", false)},
|
||||
{arangodb::basics::AttributeName("_key", false)}};
|
||||
|
||||
RocksDBPrimaryIndexIterator::RocksDBPrimaryIndexIterator(LogicalCollection* collection,
|
||||
transaction::Methods* trx,
|
||||
ManagedDocumentResult* mmdr,
|
||||
RocksDBPrimaryIndex const* index,
|
||||
std::unique_ptr<VPackBuilder>& keys)
|
||||
: IndexIterator(collection, trx, mmdr, index),
|
||||
_index(index),
|
||||
_keys(keys.get()),
|
||||
_iterator(_keys->slice()) {
|
||||
|
||||
keys.release(); // now we have ownership for _keys
|
||||
TRI_ASSERT(_keys->slice().isArray());
|
||||
}
|
||||
|
||||
RocksDBPrimaryIndexIterator::~RocksDBPrimaryIndexIterator() {
|
||||
if (_keys != nullptr) {
|
||||
// return the VPackBuilder to the transaction context
|
||||
_trx->transactionContextPtr()->returnBuilder(_keys.release());
|
||||
}
|
||||
}
|
||||
|
||||
bool RocksDBPrimaryIndexIterator::next(TokenCallback const& cb, size_t limit) {
|
||||
THROW_ARANGO_NOT_IMPLEMENTED();
|
||||
return false;
|
||||
}
|
||||
|
||||
void RocksDBPrimaryIndexIterator::reset() { _iterator.reset(); }
|
||||
|
||||
RocksDBAllIndexIterator::RocksDBAllIndexIterator(LogicalCollection* collection,
|
||||
transaction::Methods* trx,
|
||||
ManagedDocumentResult* mmdr,
|
||||
RocksDBPrimaryIndex const* index,
|
||||
bool reverse)
|
||||
: IndexIterator(collection, trx, mmdr, index), _reverse(reverse), _total(0) {}
|
||||
|
||||
bool RocksDBAllIndexIterator::next(TokenCallback const& cb, size_t limit) {
|
||||
THROW_ARANGO_NOT_IMPLEMENTED();
|
||||
return true;
|
||||
}
|
||||
|
||||
void RocksDBAllIndexIterator::reset() {
|
||||
THROW_ARANGO_NOT_IMPLEMENTED();
|
||||
}
|
||||
|
||||
RocksDBAnyIndexIterator::RocksDBAnyIndexIterator(LogicalCollection* collection, transaction::Methods* trx,
|
||||
ManagedDocumentResult* mmdr,
|
||||
RocksDBPrimaryIndex const* index)
|
||||
: IndexIterator(collection, trx, mmdr, index) {}
|
||||
|
||||
bool RocksDBAnyIndexIterator::next(TokenCallback const& cb, size_t limit) {
|
||||
THROW_ARANGO_NOT_IMPLEMENTED();
|
||||
return true;
|
||||
}
|
||||
|
||||
void RocksDBAnyIndexIterator::reset() {
|
||||
THROW_ARANGO_NOT_IMPLEMENTED();
|
||||
}
|
||||
|
||||
RocksDBPrimaryIndex::RocksDBPrimaryIndex(arangodb::LogicalCollection* collection)
|
||||
: Index(0, collection,
|
||||
std::vector<std::vector<arangodb::basics::AttributeName>>(
|
||||
{{arangodb::basics::AttributeName(StaticStrings::KeyString, false)}}),
|
||||
true, false) {
|
||||
}
|
||||
|
||||
RocksDBPrimaryIndex::~RocksDBPrimaryIndex() {}
|
||||
|
||||
/// @brief return the number of documents from the index
|
||||
size_t RocksDBPrimaryIndex::size() const {
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// @brief return the memory usage of the index
|
||||
size_t RocksDBPrimaryIndex::memory() const {
|
||||
return 0; // TODO
|
||||
}
|
||||
|
||||
/// @brief return a VelocyPack representation of the index
|
||||
void RocksDBPrimaryIndex::toVelocyPack(VPackBuilder& builder, bool withFigures) const {
|
||||
Index::toVelocyPack(builder, withFigures);
|
||||
// hard-coded
|
||||
builder.add("unique", VPackValue(true));
|
||||
builder.add("sparse", VPackValue(false));
|
||||
}
|
||||
|
||||
/// @brief return a VelocyPack representation of the index figures
|
||||
void RocksDBPrimaryIndex::toVelocyPackFigures(VPackBuilder& builder) const {
|
||||
Index::toVelocyPackFigures(builder);
|
||||
// TODO: implement
|
||||
}
|
||||
|
||||
int RocksDBPrimaryIndex::insert(transaction::Methods*, TRI_voc_rid_t, VPackSlice const&, bool) {
|
||||
#ifdef ARANGODB_ENABLE_MAINTAINER_MODE
|
||||
LOG_TOPIC(WARN, arangodb::Logger::FIXME) << "insert() called for primary index";
|
||||
#endif
|
||||
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL, "insert() called for primary index");
|
||||
}
|
||||
|
||||
int RocksDBPrimaryIndex::remove(transaction::Methods*, TRI_voc_rid_t, VPackSlice const&, bool) {
|
||||
#ifdef ARANGODB_ENABLE_MAINTAINER_MODE
|
||||
LOG_TOPIC(WARN, arangodb::Logger::FIXME) << "remove() called for primary index";
|
||||
#endif
|
||||
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL, "remove() called for primary index");
|
||||
}
|
||||
|
||||
/// @brief unload the index data from memory
|
||||
int RocksDBPrimaryIndex::unload() {
|
||||
// nothing to do
|
||||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
/// @brief checks whether the index supports the condition
|
||||
bool RocksDBPrimaryIndex::supportsFilterCondition(
|
||||
arangodb::aql::AstNode const* node,
|
||||
arangodb::aql::Variable const* reference, size_t itemsInIndex,
|
||||
size_t& estimatedItems, double& estimatedCost) const {
|
||||
|
||||
SimpleAttributeEqualityMatcher matcher(IndexAttributes);
|
||||
return matcher.matchOne(this, node, reference, itemsInIndex, estimatedItems,
|
||||
estimatedCost);
|
||||
}
|
||||
|
||||
/// @brief creates an IndexIterator for the given Condition
|
||||
IndexIterator* RocksDBPrimaryIndex::iteratorForCondition(
|
||||
transaction::Methods* trx,
|
||||
ManagedDocumentResult* mmdr,
|
||||
arangodb::aql::AstNode const* node,
|
||||
arangodb::aql::Variable const* reference, bool reverse) const {
|
||||
|
||||
THROW_ARANGO_NOT_IMPLEMENTED();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/// @brief specializes the condition for use with the index
|
||||
arangodb::aql::AstNode* RocksDBPrimaryIndex::specializeCondition(
|
||||
arangodb::aql::AstNode* node,
|
||||
arangodb::aql::Variable const* reference) const {
|
||||
|
||||
SimpleAttributeEqualityMatcher matcher(IndexAttributes);
|
||||
return matcher.specializeOne(this, node, reference);
|
||||
}
|
|
@ -0,0 +1,157 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2014-2016 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 Steemann
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef ARANGOD_ROCKSDB_ENGINE_ROCKSDB_PRIMARY_INDEX_H
|
||||
#define ARANGOD_ROCKSDB_ENGINE_ROCKSDB_PRIMARY_INDEX_H 1
|
||||
|
||||
#include "Basics/Common.h"
|
||||
#include "Indexes/Index.h"
|
||||
#include "Indexes/IndexIterator.h"
|
||||
#include "VocBase/vocbase.h"
|
||||
#include "VocBase/voc-types.h"
|
||||
|
||||
#include <velocypack/Iterator.h>
|
||||
#include <velocypack/Slice.h>
|
||||
#include <velocypack/velocypack-aliases.h>
|
||||
|
||||
namespace arangodb {
|
||||
|
||||
class RocksDBPrimaryIndex;
|
||||
namespace transaction {
|
||||
class Methods;
|
||||
}
|
||||
|
||||
class RocksDBPrimaryIndexIterator final : public IndexIterator {
|
||||
public:
|
||||
RocksDBPrimaryIndexIterator(LogicalCollection* collection,
|
||||
transaction::Methods* trx,
|
||||
ManagedDocumentResult* mmdr,
|
||||
RocksDBPrimaryIndex const* index,
|
||||
std::unique_ptr<VPackBuilder>& keys);
|
||||
|
||||
~RocksDBPrimaryIndexIterator();
|
||||
|
||||
char const* typeName() const override { return "primary-index-iterator"; }
|
||||
|
||||
bool next(TokenCallback const& cb, size_t limit) override;
|
||||
|
||||
void reset() override;
|
||||
|
||||
private:
|
||||
RocksDBPrimaryIndex const* _index;
|
||||
std::unique_ptr<VPackBuilder> _keys;
|
||||
arangodb::velocypack::ArrayIterator _iterator;
|
||||
};
|
||||
|
||||
class RocksDBAllIndexIterator final : public IndexIterator {
|
||||
public:
|
||||
RocksDBAllIndexIterator(LogicalCollection* collection,
|
||||
transaction::Methods* trx,
|
||||
ManagedDocumentResult* mmdr,
|
||||
RocksDBPrimaryIndex const* index,
|
||||
bool reverse);
|
||||
|
||||
~RocksDBAllIndexIterator() {}
|
||||
|
||||
char const* typeName() const override { return "all-index-iterator"; }
|
||||
|
||||
bool next(TokenCallback const& cb, size_t limit) override;
|
||||
|
||||
void reset() override;
|
||||
|
||||
private:
|
||||
bool const _reverse;
|
||||
uint64_t _total;
|
||||
};
|
||||
|
||||
class RocksDBAnyIndexIterator final : public IndexIterator {
|
||||
public:
|
||||
RocksDBAnyIndexIterator(LogicalCollection* collection, transaction::Methods* trx,
|
||||
ManagedDocumentResult* mmdr,
|
||||
RocksDBPrimaryIndex const* index);
|
||||
|
||||
~RocksDBAnyIndexIterator() {}
|
||||
|
||||
char const* typeName() const override { return "any-index-iterator"; }
|
||||
|
||||
bool next(TokenCallback const& cb, size_t limit) override;
|
||||
|
||||
void reset() override;
|
||||
};
|
||||
|
||||
class RocksDBPrimaryIndex final : public Index {
|
||||
friend class RocksDBPrimaryIndexIterator;
|
||||
|
||||
public:
|
||||
RocksDBPrimaryIndex() = delete;
|
||||
|
||||
explicit RocksDBPrimaryIndex(arangodb::LogicalCollection*);
|
||||
|
||||
~RocksDBPrimaryIndex();
|
||||
|
||||
public:
|
||||
IndexType type() const override {
|
||||
return Index::TRI_IDX_TYPE_PRIMARY_INDEX;
|
||||
}
|
||||
|
||||
char const* typeName() const override { return "primary"; }
|
||||
|
||||
bool allowExpansion() const override { return false; }
|
||||
|
||||
bool canBeDropped() const override { return false; }
|
||||
|
||||
bool isSorted() const override { return false; }
|
||||
|
||||
bool hasSelectivityEstimate() const override { return true; }
|
||||
|
||||
double selectivityEstimate(arangodb::StringRef const* = nullptr) const override { return 1.0; }
|
||||
|
||||
size_t size() const;
|
||||
|
||||
size_t memory() const override;
|
||||
|
||||
void toVelocyPack(VPackBuilder&, bool) const override;
|
||||
void toVelocyPackFigures(VPackBuilder&) const override;
|
||||
|
||||
int insert(transaction::Methods*, TRI_voc_rid_t, arangodb::velocypack::Slice const&, bool isRollback) override;
|
||||
|
||||
int remove(transaction::Methods*, TRI_voc_rid_t, arangodb::velocypack::Slice const&, bool isRollback) override;
|
||||
|
||||
int unload() override;
|
||||
|
||||
bool supportsFilterCondition(arangodb::aql::AstNode const*,
|
||||
arangodb::aql::Variable const*, size_t, size_t&,
|
||||
double&) const override;
|
||||
|
||||
IndexIterator* iteratorForCondition(transaction::Methods*,
|
||||
ManagedDocumentResult*,
|
||||
arangodb::aql::AstNode const*,
|
||||
arangodb::aql::Variable const*,
|
||||
bool) const override;
|
||||
|
||||
arangodb::aql::AstNode* specializeCondition(
|
||||
arangodb::aql::AstNode*, arangodb::aql::Variable const*) const override;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
|
@ -34,7 +34,6 @@ struct RocksDBDocumentOperation;
|
|||
namespace transaction {
|
||||
class Methods;
|
||||
}
|
||||
;
|
||||
class TransactionState;
|
||||
|
||||
/// @brief collection used in a transaction
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
/// @author Jan Steemann
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef ARANGOD_STORAGE_ENGINE_MM_FILES_VIEW_H
|
||||
#define ARANGOD_STORAGE_ENGINE_MM_FILES_VIEW_H 1
|
||||
#ifndef ARANGOD_ROCKSDB_ENGINE_ROCKSDB_VIEW_H
|
||||
#define ARANGOD_ROCKSDB_ENGINE_ROCKSDB_VIEW_H 1
|
||||
|
||||
#include "Basics/Common.h"
|
||||
#include "Basics/ReadWriteLock.h"
|
||||
|
|
Loading…
Reference in New Issue