Пример #1
0
bool RestEdgesHandler::getEdgesForVertex (std::string const& id,
                                          std::vector<traverser::TraverserExpression*> const& expressions,
                                          TRI_edge_direction_e direction,
                                          SingleCollectionReadOnlyTransaction& trx,
                                          triagens::basics::Json& result,
                                          size_t& scannedIndex,
                                          size_t& filtered) {
  triagens::arango::traverser::VertexId start;
  try {
    start = triagens::arango::traverser::IdStringToVertexId (
      trx.resolver(),
      id
    );
  }
  catch (triagens::basics::Exception& e) {
    handleError(e);
    return false;
  }
  TRI_document_collection_t* docCol = trx.trxCollection()->_collection->_collection;

  std::vector<TRI_doc_mptr_copy_t>&& edges = TRI_LookupEdgesDocumentCollection(
    docCol,
    direction,
    start.cid,
    const_cast<char*>(start.key)
  );

  // generate result
  result.reserve(edges.size());
  scannedIndex += edges.size();

  if (expressions.empty()) {
    for (auto& e : edges) {
      DocumentAccessor da(trx.resolver(), docCol, &e);
      result.add(da.toJson());
    }
  }
  else {
    for (auto& e : edges) {
      bool add = true;
      // Expressions symbolize an and, so all have to be matched
      for (auto& exp : expressions) {
        if (exp->isEdgeAccess && ! exp->matchesCheck(e, docCol, trx.resolver())) {
          ++filtered;
          add = false;
          break;
        }
      }
      if (add) {
        DocumentAccessor da(trx.resolver(), docCol, &e);
        result.add(da.toJson());
      }
    }
  }
  return true;
}
Пример #2
0
DistributeNode::DistributeNode (ExecutionPlan* plan, 
                                triagens::basics::Json const& base)
  : ExecutionNode(plan, base),
    _vocbase(plan->getAst()->query()->vocbase()),
    _collection(plan->getAst()->query()->collections()->get(JsonHelper::checkAndGetStringValue(base.json(), "collection"))),
    _varId(JsonHelper::checkAndGetNumericValue<VariableId>(base.json(), "varId")),
    _alternativeVarId(JsonHelper::checkAndGetNumericValue<VariableId>(base.json(), "alternativeVarId")),
    _createKeys(JsonHelper::checkAndGetBooleanValue(base.json(), "createKeys")),
    _allowKeyConversionToObject(JsonHelper::checkAndGetBooleanValue(base.json(), "allowKeyConversionToObject")) {
}
Пример #3
0
RemoteNode::RemoteNode (ExecutionPlan* plan,
                        triagens::basics::Json const& base)
  : ExecutionNode(plan, base),
    _vocbase(plan->getAst()->query()->vocbase()),
    _collection(plan->getAst()->query()->collections()->get(JsonHelper::checkAndGetStringValue(base.json(), "collection"))),
    _server(JsonHelper::checkAndGetStringValue(base.json(), "server")), 
    _ownName(JsonHelper::checkAndGetStringValue(base.json(), "ownName")), 
    _queryId(JsonHelper::checkAndGetStringValue(base.json(), "queryId")),
    _isResponsibleForInitCursor(JsonHelper::checkAndGetBooleanValue(base.json(), "isResponsibleForInitCursor")) {
}
Пример #4
0
RangeInfo::RangeInfo (triagens::basics::Json const& json) 
  : _var(basics::JsonHelper::checkAndGetStringValue(json.json(), "variable")),
    _attr(basics::JsonHelper::checkAndGetStringValue(json.json(), "attr")),
    _valid(basics::JsonHelper::checkAndGetBooleanValue(json.json(), "valid")),
    _defined(true),
    _equality(basics::JsonHelper::checkAndGetBooleanValue(json.json(), "equality")) {

  triagens::basics::Json jsonLowList = json.get("lows");
  if (! jsonLowList.isList()) {
    THROW_INTERNAL_ERROR("low attribute must be a list");
  }
  triagens::basics::Json jsonHighList = json.get("highs");
  if (! jsonHighList.isList()) {
    THROW_INTERNAL_ERROR("high attribute must be a list");
  }
  // If an exception is thrown from within these loops, then the
  // vectors _low and _high will be destroyed properly, so no 
  // try/catch is needed.
  for (size_t i = 0; i < jsonLowList.size(); i++) {
    _lows.emplace_back(jsonLowList.at(static_cast<int>(i)));
  }
  for (size_t i = 0; i < jsonHighList.size(); i++) {
    _highs.emplace_back(jsonHighList.at(static_cast<int>(i)));
  }
  _lowConst.assign(json.get("lowConst"));
  _highConst.assign(json.get("highConst"));
}
Пример #5
0
UpsertNode::UpsertNode (ExecutionPlan* plan, 
                        triagens::basics::Json const& base)
  : ModificationNode(plan, base),
    _inDocVariable(varFromJson(plan->getAst(), base, "inDocVariable")),
    _insertVariable(varFromJson(plan->getAst(), base, "insertVariable")),
    _updateVariable(varFromJson(plan->getAst(), base, "updateVariable")),
    _isReplace(JsonHelper::checkAndGetBooleanValue(base.json(), "isReplace")) {

}
Пример #6
0
GatherNode::GatherNode (ExecutionPlan* plan, 
                        triagens::basics::Json const& base,
                        SortElementVector const& elements)
  : ExecutionNode(plan, base),
    _elements(elements),
    _vocbase(plan->getAst()->query()->vocbase()),
    _collection(plan->getAst()->query()->collections()->get(JsonHelper::checkAndGetStringValue(base.json(), "collection"))) {
}
Пример #7
0
ScatterNode::ScatterNode (ExecutionPlan* plan, 
                          triagens::basics::Json const& base)
  : ExecutionNode(plan, base),
    _vocbase(plan->getAst()->query()->vocbase()),
    _collection(plan->getAst()->query()->collections()->get(JsonHelper::checkAndGetStringValue(base.json(), "collection"))) {
}
Пример #8
0
ModificationNode::ModificationNode (ExecutionPlan* plan,
                                    triagens::basics::Json const& base)
  : ExecutionNode(plan, base), 
    _vocbase(plan->getAst()->query()->vocbase()),
    _collection(plan->getAst()->query()->collections()->get(JsonHelper::checkAndGetStringValue(base.json(), "collection"))),
    _options(base),
    _outVariableOld(varFromJson(plan->getAst(), base, "outVariableOld", Optional)),
    _outVariableNew(varFromJson(plan->getAst(), base, "outVariableNew", Optional)) {

  TRI_ASSERT(_vocbase != nullptr);
  TRI_ASSERT(_collection != nullptr);
}
Пример #9
0
Variable::Variable (triagens::basics::Json const& json)
  : Variable(JsonHelper::checkAndGetStringValue(json.json(), "name"), JsonHelper::checkAndGetNumericValue<VariableId>(json.json(), "id")) {
}
Пример #10
0
Expression::Expression (Ast* ast,
                        triagens::basics::Json const& json)
  : Expression(ast, new AstNode(ast, json.get("expression"))) {

}