static SharedCursorHandle* createStandard (const MouseCursor::StandardCursorType type)
    {
        const SpinLock::ScopedLockType sl (lock);

        for (int i = 0; i < getCursors().size(); ++i)
        {
            SharedCursorHandle* const sc = getCursors().getUnchecked(i);

            if (sc->standardType == type)
                return sc->retain();
        }

        SharedCursorHandle* const sc = new SharedCursorHandle (type);
        getCursors().add (sc);
        return sc;
    }
Esempio n. 2
0
arangodb::traverser::EdgeCursor*
arangodb::traverser::TraverserOptions::nextCursorLocal(ManagedDocumentResult* mmdr,
    VPackSlice vertex, size_t depth, std::vector<LookupInfo>& list) const {
  TRI_ASSERT(mmdr != nullptr);
  auto allCursor = std::make_unique<SingleServerEdgeCursor>(mmdr, _trx, list.size());
  auto& opCursors = allCursor->getCursors();
  VPackValueLength vidLength;
  char const* vid = vertex.getString(vidLength);
  for (auto& info : list) {
    auto& node = info.indexCondition;
    TRI_ASSERT(node->numMembers() > 0);
    if (info.conditionNeedUpdate) {
      // We have to inject _from/_to iff the condition needs it
      auto dirCmp = node->getMemberUnchecked(info.conditionMemberToUpdate);
      TRI_ASSERT(dirCmp->type == aql::NODE_TYPE_OPERATOR_BINARY_EQ);
      TRI_ASSERT(dirCmp->numMembers() == 2);

      auto idNode = dirCmp->getMemberUnchecked(1);
      TRI_ASSERT(idNode->type == aql::NODE_TYPE_VALUE);
      TRI_ASSERT(idNode->isValueType(aql::VALUE_TYPE_STRING));
      idNode->setStringValue(vid, vidLength);
    }
    std::vector<OperationCursor*> csrs;
    csrs.reserve(info.idxHandles.size());
    for (auto const& it : info.idxHandles) {
      csrs.emplace_back(_trx->indexScanForCondition(
          it, node, _tmpVar, mmdr, UINT64_MAX, 1000, false));
    }
    opCursors.emplace_back(std::move(csrs));
  }
  return allCursor.release();
}
    void release()
    {
        if (--refCount == 0)
        {
            if (isStandard)
            {
                const SpinLock::ScopedLockType sl (lock);
                getCursors().removeValue (this);
            }

            delete this;
        }
    }