mirror of https://gitee.com/bigwinds/arangodb
add engine capabilities
This commit is contained in:
parent
e42813dafb
commit
f59c78b587
|
@ -55,6 +55,8 @@ class IndexFactory {
|
||||||
virtual void fillSystemIndexes(
|
virtual void fillSystemIndexes(
|
||||||
arangodb::LogicalCollection* col,
|
arangodb::LogicalCollection* col,
|
||||||
std::vector<std::shared_ptr<arangodb::Index>>& systemIndexes) const = 0;
|
std::vector<std::shared_ptr<arangodb::Index>>& systemIndexes) const = 0;
|
||||||
|
|
||||||
|
virtual std::vector<std::string> supportedIndexes() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace arangodb
|
} // namespace arangodb
|
||||||
|
|
|
@ -448,3 +448,7 @@ void MMFilesIndexFactory::fillSystemIndexes(
|
||||||
std::make_shared<arangodb::MMFilesEdgeIndex>(1, col));
|
std::make_shared<arangodb::MMFilesEdgeIndex>(1, col));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> MMFilesIndexFactory::supportedIndexes() const {
|
||||||
|
return std::vector<std::string>{ "primary", "edge", "hash", "skiplist", "persistent", "geo", "fulltext" };
|
||||||
|
}
|
||||||
|
|
|
@ -45,6 +45,8 @@ class MMFilesIndexFactory final : public IndexFactory {
|
||||||
void fillSystemIndexes(arangodb::LogicalCollection* col,
|
void fillSystemIndexes(arangodb::LogicalCollection* col,
|
||||||
std::vector<std::shared_ptr<arangodb::Index>>&
|
std::vector<std::shared_ptr<arangodb::Index>>&
|
||||||
systemIndexes) const override;
|
systemIndexes) const override;
|
||||||
|
|
||||||
|
std::vector<std::string> supportedIndexes() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include "RestEngineHandler.h"
|
#include "RestEngineHandler.h"
|
||||||
#include "Rest/HttpRequest.h"
|
#include "Rest/HttpRequest.h"
|
||||||
#include "StorageEngine/EngineSelectorFeature.h"
|
#include "StorageEngine/EngineSelectorFeature.h"
|
||||||
|
#include "StorageEngine/StorageEngine.h"
|
||||||
|
|
||||||
#include <velocypack/Builder.h>
|
#include <velocypack/Builder.h>
|
||||||
#include <velocypack/velocypack-aliases.h>
|
#include <velocypack/velocypack-aliases.h>
|
||||||
|
@ -38,9 +39,9 @@ RestEngineHandler::RestEngineHandler(GeneralRequest* request,
|
||||||
|
|
||||||
RestStatus RestEngineHandler::execute() {
|
RestStatus RestEngineHandler::execute() {
|
||||||
VPackBuilder result;
|
VPackBuilder result;
|
||||||
result.add(VPackValue(VPackValueType::Object));
|
StorageEngine* engine = EngineSelectorFeature::ENGINE;
|
||||||
result.add("name", VPackValue(EngineSelectorFeature::engineName()));
|
engine->getCapabilities(result);
|
||||||
result.close();
|
|
||||||
generateResult(rest::ResponseCode::OK, result.slice());
|
generateResult(rest::ResponseCode::OK, result.slice());
|
||||||
return RestStatus::DONE;
|
return RestStatus::DONE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -421,3 +421,7 @@ void RocksDBIndexFactory::fillSystemIndexes(
|
||||||
2, col, builder.slice(), StaticStrings::ToString));
|
2, col, builder.slice(), StaticStrings::ToString));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> RocksDBIndexFactory::supportedIndexes() const {
|
||||||
|
return std::vector<std::string>{ "primary", "edge", "hash", "skiplist", "persistent" };
|
||||||
|
}
|
||||||
|
|
|
@ -45,6 +45,8 @@ class RocksDBIndexFactory final : public IndexFactory {
|
||||||
void fillSystemIndexes(arangodb::LogicalCollection* col,
|
void fillSystemIndexes(arangodb::LogicalCollection* col,
|
||||||
std::vector<std::shared_ptr<arangodb::Index>>&
|
std::vector<std::shared_ptr<arangodb::Index>>&
|
||||||
systemIndexes) const override;
|
systemIndexes) const override;
|
||||||
|
|
||||||
|
std::vector<std::string> supportedIndexes() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -329,7 +329,7 @@ class StorageEngine : public application_features::ApplicationFeature {
|
||||||
// Returns the StorageEngine-specific implementation
|
// Returns the StorageEngine-specific implementation
|
||||||
// of the IndexFactory. This is used to validate
|
// of the IndexFactory. This is used to validate
|
||||||
// information about indexes.
|
// information about indexes.
|
||||||
IndexFactory const* indexFactory() {
|
IndexFactory const* indexFactory() const {
|
||||||
// The factory has to be created by the implementation
|
// The factory has to be created by the implementation
|
||||||
// and shall never be deleted
|
// and shall never be deleted
|
||||||
TRI_ASSERT(_indexFactory.get() != nullptr);
|
TRI_ASSERT(_indexFactory.get() != nullptr);
|
||||||
|
@ -407,6 +407,21 @@ class StorageEngine : public application_features::ApplicationFeature {
|
||||||
virtual int removeReplicationApplierConfiguration(TRI_vocbase_t* vocbase) = 0;
|
virtual int removeReplicationApplierConfiguration(TRI_vocbase_t* vocbase) = 0;
|
||||||
virtual int saveReplicationApplierConfiguration(TRI_vocbase_t* vocbase, arangodb::velocypack::Slice slice, bool doSync) = 0;
|
virtual int saveReplicationApplierConfiguration(TRI_vocbase_t* vocbase, arangodb::velocypack::Slice slice, bool doSync) = 0;
|
||||||
|
|
||||||
|
void getCapabilities(VPackBuilder& builder) const {
|
||||||
|
builder.openObject();
|
||||||
|
builder.add("name", VPackValue(typeName()));
|
||||||
|
builder.add("supports", VPackValue(VPackValueType::Object));
|
||||||
|
builder.add("indexes", VPackValue(VPackValueType::Array));
|
||||||
|
|
||||||
|
for (auto const& it : indexFactory()->supportedIndexes()) {
|
||||||
|
builder.add(VPackValue(it));
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.close(); // indexes
|
||||||
|
builder.close(); // supports
|
||||||
|
builder.close(); // object
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void registerCollection(TRI_vocbase_t* vocbase,
|
void registerCollection(TRI_vocbase_t* vocbase,
|
||||||
arangodb::LogicalCollection* collection) {
|
arangodb::LogicalCollection* collection) {
|
||||||
|
|
|
@ -2785,6 +2785,7 @@ static void JS_CompletionsVocbase(
|
||||||
result->Set(j++, TRI_V8_ASCII_STRING("_drop()"));
|
result->Set(j++, TRI_V8_ASCII_STRING("_drop()"));
|
||||||
result->Set(j++, TRI_V8_ASCII_STRING("_dropDatabase()"));
|
result->Set(j++, TRI_V8_ASCII_STRING("_dropDatabase()"));
|
||||||
result->Set(j++, TRI_V8_ASCII_STRING("_dropView()"));
|
result->Set(j++, TRI_V8_ASCII_STRING("_dropView()"));
|
||||||
|
result->Set(j++, TRI_V8_ASCII_STRING("_engine()"));
|
||||||
result->Set(j++, TRI_V8_ASCII_STRING("_executeTransaction()"));
|
result->Set(j++, TRI_V8_ASCII_STRING("_executeTransaction()"));
|
||||||
result->Set(j++, TRI_V8_ASCII_STRING("_exists()"));
|
result->Set(j++, TRI_V8_ASCII_STRING("_exists()"));
|
||||||
result->Set(j++, TRI_V8_ASCII_STRING("_id"));
|
result->Set(j++, TRI_V8_ASCII_STRING("_id"));
|
||||||
|
|
|
@ -1694,10 +1694,12 @@ static void JS_EngineServer(v8::FunctionCallbackInfo<v8::Value> const& args) {
|
||||||
TRI_V8_TRY_CATCH_BEGIN(isolate);
|
TRI_V8_TRY_CATCH_BEGIN(isolate);
|
||||||
v8::HandleScope scope(isolate);
|
v8::HandleScope scope(isolate);
|
||||||
|
|
||||||
// return engine name
|
// return engine data
|
||||||
v8::Handle<v8::Object> result = v8::Object::New(isolate);
|
StorageEngine* engine = EngineSelectorFeature::ENGINE;
|
||||||
result->Set(TRI_V8_ASCII_STRING("name"), TRI_V8_ASCII_STRING(EngineSelectorFeature::engineName()));
|
VPackBuilder builder;
|
||||||
TRI_V8_RETURN(result);
|
engine->getCapabilities(builder);
|
||||||
|
|
||||||
|
TRI_V8_RETURN(TRI_VPackToV8(isolate, builder.slice()));
|
||||||
|
|
||||||
TRI_V8_TRY_CATCH_END
|
TRI_V8_TRY_CATCH_END
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue