mirror of https://gitee.com/bigwinds/arangodb
fix rocksdb engine index reporting but break report for mmfiles engine
This commit is contained in:
parent
afd5d92f19
commit
2700a6d79d
|
@ -394,9 +394,7 @@ std::string Index::context() const {
|
|||
/// base functionality (called from derived classes)
|
||||
std::shared_ptr<VPackBuilder> Index::toVelocyPack(bool withFigures) const {
|
||||
auto builder = std::make_shared<VPackBuilder>();
|
||||
builder->openObject();
|
||||
toVelocyPack(*builder, withFigures);
|
||||
builder->close();
|
||||
return builder;
|
||||
}
|
||||
|
||||
|
|
|
@ -190,11 +190,44 @@ size_t RocksDBEdgeIndex::memory() const {
|
|||
/// @brief return a VelocyPack representation of the index
|
||||
void RocksDBEdgeIndex::toVelocyPack(VPackBuilder& builder,
|
||||
bool withFigures) const {
|
||||
RocksDBIndex::toVelocyPack(builder, withFigures);
|
||||
|
||||
LOG_TOPIC(ERR, Logger::FIXME) << "EDGE INDEX (" << _directionAttr << ")";
|
||||
// skip to
|
||||
if(_directionAttr == StaticStrings::ToString)
|
||||
return;
|
||||
|
||||
TRI_ASSERT(builder.isOpenArray() || builder.isEmpty());
|
||||
|
||||
//get data that needs to be modified
|
||||
VPackBuilder tmpBuilder;
|
||||
tmpBuilder.openObject();
|
||||
RocksDBIndex::toVelocyPack(tmpBuilder, withFigures);
|
||||
tmpBuilder.close();
|
||||
VPackSlice slice = tmpBuilder.slice();
|
||||
|
||||
builder.openObject();
|
||||
for(auto const& item : VPackObjectIterator(slice)){
|
||||
//add id
|
||||
//add type
|
||||
if (item.key.compareString("fields") == 0){
|
||||
// modify fields
|
||||
builder.add("fields", VPackValue(VPackValueType::Array, false));
|
||||
builder.add(VPackValue(StaticStrings::FromString));
|
||||
builder.add(VPackValue(StaticStrings::ToString));
|
||||
builder.close();
|
||||
} else {
|
||||
// copy other items
|
||||
auto ref = StringRef(item.key);
|
||||
builder.add(ref.data(), ref.length(), item.value);
|
||||
}
|
||||
}
|
||||
|
||||
// add slectivity estimate
|
||||
// hard-coded
|
||||
builder.add("unique", VPackValue(false));
|
||||
builder.add("sparse", VPackValue(false));
|
||||
|
||||
builder.close();
|
||||
}
|
||||
|
||||
/// @brief return a VelocyPack representation of the index figures
|
||||
|
|
|
@ -275,10 +275,13 @@ size_t RocksDBPrimaryIndex::memory() const {
|
|||
/// @brief return a VelocyPack representation of the index
|
||||
void RocksDBPrimaryIndex::toVelocyPack(VPackBuilder& builder,
|
||||
bool withFigures) const {
|
||||
TRI_ASSERT(builder.isOpenArray() || builder.isEmpty());
|
||||
builder.openObject();
|
||||
RocksDBIndex::toVelocyPack(builder, withFigures);
|
||||
// hard-coded
|
||||
builder.add("unique", VPackValue(true));
|
||||
builder.add("sparse", VPackValue(false));
|
||||
builder.close();
|
||||
}
|
||||
|
||||
/// @brief return a VelocyPack representation of the index figures
|
||||
|
|
|
@ -180,9 +180,12 @@ size_t RocksDBVPackIndex::memory() const {
|
|||
/// @brief return a VelocyPack representation of the index
|
||||
void RocksDBVPackIndex::toVelocyPack(VPackBuilder& builder,
|
||||
bool withFigures) const {
|
||||
TRI_ASSERT(builder.isOpenArray() || builder.isEmpty());
|
||||
builder.openObject();
|
||||
RocksDBIndex::toVelocyPack(builder, withFigures);
|
||||
builder.add("unique", VPackValue(_unique));
|
||||
builder.add("sparse", VPackValue(_sparse));
|
||||
builder.close();
|
||||
}
|
||||
|
||||
/// @brief return a VelocyPack representation of the index figures
|
||||
|
|
|
@ -116,6 +116,21 @@ static v8::Handle<v8::Value> IndexRep(v8::Isolate* isolate,
|
|||
return scope.Escape<v8::Value>(rep);
|
||||
}
|
||||
|
||||
static void IndexRep(v8::Isolate* isolate, std::string const& collectionName,
|
||||
v8::Handle<v8::Array>& array) {
|
||||
for (size_t i = 0; i < array->Length(); i++) {
|
||||
v8::Handle<v8::Value> tmprep = array->Get(i);
|
||||
// TODO -- modify rep inplace?!
|
||||
v8::Handle<v8::Object> rep = v8::Handle<v8::Object>::Cast(tmprep);
|
||||
std::string iid = TRI_ObjectToString(rep->Get(TRI_V8_ASCII_STRING("id")));
|
||||
std::string const id =
|
||||
collectionName + TRI_INDEX_HANDLE_SEPARATOR_STR + iid;
|
||||
LOG_TOPIC(ERR, Logger::FIXME) << "FINAL INDEX ID = " << id;
|
||||
rep->Set(TRI_V8_ASCII_STRING("id"), TRI_V8_STD_STRING(id));
|
||||
array->Set(i, rep);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief enhances the json of an index
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -200,13 +215,14 @@ static void EnsureIndexLocal(v8::FunctionCallbackInfo<v8::Value> const& args,
|
|||
}
|
||||
|
||||
transaction::BuilderLeaser builder(&trx);
|
||||
builder->openObject();
|
||||
// TODO FIXME FOR MMFILES
|
||||
// builder->openObject();
|
||||
try {
|
||||
idx->toVelocyPack(*(builder.get()), false);
|
||||
} catch (...) {
|
||||
TRI_V8_THROW_EXCEPTION_MEMORY();
|
||||
}
|
||||
builder->close();
|
||||
// builder->close();
|
||||
|
||||
v8::Handle<v8::Value> ret =
|
||||
IndexRep(isolate, collection->name(), builder->slice());
|
||||
|
@ -574,18 +590,26 @@ static void JS_GetIndexesVocbaseCol(
|
|||
trx.finish(res);
|
||||
// READ-LOCK end
|
||||
|
||||
builder->clear();
|
||||
size_t const n = indexes.size();
|
||||
v8::Handle<v8::Array> result = v8::Array::New(isolate, static_cast<int>(n));
|
||||
|
||||
builder->openArray();
|
||||
VPackBuilder tmpBuilder;
|
||||
for (size_t i = 0; i < n; ++i) {
|
||||
tmpBuilder.clear();
|
||||
auto const& idx = indexes[i];
|
||||
builder->clear();
|
||||
builder->openObject();
|
||||
idx->toVelocyPack(*(builder.get()), withFigures);
|
||||
builder->close();
|
||||
result->Set(static_cast<uint32_t>(i),
|
||||
IndexRep(isolate, collectionName, builder->slice()));
|
||||
// TODO FIXME FOR MMFILES
|
||||
//builder->openObject();
|
||||
idx->toVelocyPack(tmpBuilder, withFigures);
|
||||
//builder->close();
|
||||
if(!tmpBuilder.isEmpty()){
|
||||
builder->add(tmpBuilder.slice());
|
||||
}
|
||||
}
|
||||
builder->close();
|
||||
v8::Handle<v8::Value> objresult = TRI_VPackToV8(isolate, builder->slice());
|
||||
v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(objresult);
|
||||
|
||||
IndexRep(isolate,collectionName,result);
|
||||
|
||||
TRI_V8_RETURN(result);
|
||||
TRI_V8_TRY_CATCH_END
|
||||
|
|
|
@ -368,9 +368,7 @@ void PhysicalCollection::getIndexesVPack(VPackBuilder& result,
|
|||
bool withFigures) const {
|
||||
result.openArray();
|
||||
for (auto const& idx : _indexes) {
|
||||
result.openObject();
|
||||
idx->toVelocyPack(result, withFigures);
|
||||
result.close();
|
||||
}
|
||||
result.close();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue