From 6135e733fb8cbd0b43fb39656a838faa5f8f5405 Mon Sep 17 00:00:00 2001 From: Willi Goesgens Date: Fri, 8 Aug 2014 15:48:39 +0200 Subject: [PATCH] Cleanup - adjust sequence of functions in cpp to header - adjust documentation --- arangod/Aql/Types.cpp | 117 +++++++++++++++++++++--------------------- arangod/Aql/Types.h | 2 +- 2 files changed, 60 insertions(+), 59 deletions(-) diff --git a/arangod/Aql/Types.cpp b/arangod/Aql/Types.cpp index 2e7be78a9d..bff2946b7d 100644 --- a/arangod/Aql/Types.cpp +++ b/arangod/Aql/Types.cpp @@ -287,64 +287,6 @@ Json AqlValue::toJson (TRI_document_collection_t const* document) const { THROW_ARANGO_EXCEPTION(TRI_ERROR_INTERNAL); } -//////////////////////////////////////////////////////////////////////////////// -/// @brief splice multiple blocks, note that the new block now owns all -/// AqlValue pointers in the old blocks, therefore, the latter are all -/// set to nullptr, just to be sure. -//////////////////////////////////////////////////////////////////////////////// - -AqlItemBlock* AqlItemBlock::splice (std::vector& blocks) { - TRI_ASSERT(! blocks.empty()); - - auto it = blocks.begin(); - TRI_ASSERT(it != blocks.end()); - size_t totalSize = (*it)->size(); - RegisterId nrRegs = (*it)->getNrRegs(); - - while (true) { - if (++it == blocks.end()) { - break; - } - totalSize += (*it)->size(); - TRI_ASSERT((*it)->getNrRegs() == nrRegs); - } - - TRI_ASSERT(totalSize > 0); - TRI_ASSERT(nrRegs > 0); - - auto res = new AqlItemBlock(totalSize, nrRegs); - size_t pos = 0; - for (it = blocks.begin(); it != blocks.end(); ++it) { - // handle collections - if (it == blocks.begin()) { - // copy collection info over - for (RegisterId col = 0; col < nrRegs; ++col) { - res->setDocumentCollection(col, (*it)->getDocumentCollection(col)); - } - } - else { - for (RegisterId col = 0; col < nrRegs; ++col) { - TRI_ASSERT(res->getDocumentCollection(col) == - (*it)->getDocumentCollection(col)); - } - } - - TRI_ASSERT((*it) != res); - size_t const n = (*it)->size(); - for (size_t row = 0; row < n; ++row) { - for (RegisterId col = 0; col < nrRegs; ++col) { - // copy over value - res->setValue(pos + row, col, (*it)->getValue(row, col)); - // delete old value - (*it)->eraseValue(row, col); - } - } - pos += (*it)->size(); - } - - return res; -} - //////////////////////////////////////////////////////////////////////////////// /// @brief 3-way comparison for AqlValue objects //////////////////////////////////////////////////////////////////////////////// @@ -456,6 +398,65 @@ int triagens::aql::CompareAqlValues (AqlValue const& left, } } + +//////////////////////////////////////////////////////////////////////////////// +/// @brief splice multiple blocks, note that the new block now owns all +/// AqlValue pointers in the old blocks, therefore, the latter are all +/// set to nullptr, just to be sure. +//////////////////////////////////////////////////////////////////////////////// + +AqlItemBlock* AqlItemBlock::splice (std::vector& blocks) { + TRI_ASSERT(! blocks.empty()); + + auto it = blocks.begin(); + TRI_ASSERT(it != blocks.end()); + size_t totalSize = (*it)->size(); + RegisterId nrRegs = (*it)->getNrRegs(); + + while (true) { + if (++it == blocks.end()) { + break; + } + totalSize += (*it)->size(); + TRI_ASSERT((*it)->getNrRegs() == nrRegs); + } + + TRI_ASSERT(totalSize > 0); + TRI_ASSERT(nrRegs > 0); + + auto res = new AqlItemBlock(totalSize, nrRegs); + size_t pos = 0; + for (it = blocks.begin(); it != blocks.end(); ++it) { + // handle collections + if (it == blocks.begin()) { + // copy collection info over + for (RegisterId col = 0; col < nrRegs; ++col) { + res->setDocumentCollection(col, (*it)->getDocumentCollection(col)); + } + } + else { + for (RegisterId col = 0; col < nrRegs; ++col) { + TRI_ASSERT(res->getDocumentCollection(col) == + (*it)->getDocumentCollection(col)); + } + } + + TRI_ASSERT((*it) != res); + size_t const n = (*it)->size(); + for (size_t row = 0; row < n; ++row) { + for (RegisterId col = 0; col < nrRegs; ++col) { + // copy over value + res->setValue(pos + row, col, (*it)->getValue(row, col)); + // delete old value + (*it)->eraseValue(row, col); + } + } + pos += (*it)->size(); + } + + return res; +} + // Local Variables: // mode: outline-minor // outline-regexp: "^\\(/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|// --SECTION--\\|/// @\\}\\)" diff --git a/arangod/Aql/Types.h b/arangod/Aql/Types.h index 8c02813aef..9bd96cd721 100644 --- a/arangod/Aql/Types.h +++ b/arangod/Aql/Types.h @@ -486,7 +486,7 @@ namespace triagens { } //////////////////////////////////////////////////////////////////////////////// -/// @brief slice/clone for a subset +/// @brief slice/clone chosen columns for a subset //////////////////////////////////////////////////////////////////////////////// AqlItemBlock* slice (vector& chosen, size_t from, size_t to) {