diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2018-06-06 10:00:59 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-06 10:00:59 +0200 |
commit | 81f6540e0bcedb2636ad5ea62f23cecf0658b4dc (patch) | |
tree | 12ea280192a44f26b9718018c7cfb39b0c4c4735 /document | |
parent | a6cefdae2ea7b40e4ea4c157cbb65426458f70b9 (diff) |
Revert "Balder/sameelement in streaming"
Diffstat (limited to 'document')
5 files changed, 16 insertions, 36 deletions
diff --git a/document/src/tests/documenttestcase.cpp b/document/src/tests/documenttestcase.cpp index ee49259e982..33d1a666d4a 100644 --- a/document/src/tests/documenttestcase.cpp +++ b/document/src/tests/documenttestcase.cpp @@ -115,22 +115,16 @@ public: ~Handler(); const std::string & getResult() const { return _result; } private: - void onPrimitive(uint32_t, const Content&) override { - std::ostringstream os; os << "P-" << getArrayIndex(); - _result += os.str(); - } + void onPrimitive(uint32_t, const Content&) override { _result += 'P'; } void onCollectionStart(const Content&) override { _result += '['; } void onCollectionEnd(const Content&) override { _result += ']'; } - void onStructStart(const Content&) override { - std::ostringstream os; os << "<" << getArrayIndex() << ":"; - _result += os.str(); - } + void onStructStart(const Content&) override { _result += '<'; } void onStructEnd(const Content&) override { _result += '>'; } std::string _result; }; -Handler::Handler() = default; -Handler::~Handler() = default; +Handler::Handler() { } +Handler::~Handler() { } void DocumentTest::testTraversing() @@ -192,7 +186,7 @@ void DocumentTest::testTraversing() FieldPath empty; doc.iterateNested(empty.getFullRange(), fullTraverser); CPPUNIT_ASSERT_EQUAL(fullTraverser.getResult(), - std::string("<0:P-0<0:P-0<0:P-0P-0[P-0P-1P-2][<0:P-0P-0><1:P-1P-1>]>>>")); + std::string("<P<P<PP[PPP][<PP><PP>]>>>")); } class VariableIteratorHandler : public IteratorHandler { diff --git a/document/src/vespa/document/fieldvalue/arrayfieldvalue.cpp b/document/src/vespa/document/fieldvalue/arrayfieldvalue.cpp index f3239553fa9..194c9b422da 100644 --- a/document/src/vespa/document/fieldvalue/arrayfieldvalue.cpp +++ b/document/src/vespa/document/fieldvalue/arrayfieldvalue.cpp @@ -37,7 +37,9 @@ ArrayFieldValue::ArrayFieldValue(const ArrayFieldValue& other) { } -ArrayFieldValue::~ArrayFieldValue() = default; +ArrayFieldValue::~ArrayFieldValue() +{ +} ArrayFieldValue& ArrayFieldValue::operator=(const ArrayFieldValue& other) @@ -192,7 +194,6 @@ ArrayFieldValue::iterateSubset(int startPos, int endPos, std::vector<int> indicesToRemove; for (int i = startPos; i <= endPos && i < static_cast<int>(_array->size()); ++i) { - handler.setArrayIndex(i); if (!variable.empty()) { handler.getVariables()[variable] = IndexValue(i); } @@ -211,7 +212,9 @@ ArrayFieldValue::iterateSubset(int startPos, int endPos, handler.getVariables().erase(variable); } - for (auto i = indicesToRemove.rbegin(); i != indicesToRemove.rend(); ++i) { + for (std::vector<int>::reverse_iterator i = indicesToRemove.rbegin(); + i != indicesToRemove.rend(); ++i) + { const_cast<ArrayFieldValue&>(*this).remove(*i); } diff --git a/document/src/vespa/document/fieldvalue/iteratorhandler.cpp b/document/src/vespa/document/fieldvalue/iteratorhandler.cpp index 8764e7908cd..2e9a525d9e6 100644 --- a/document/src/vespa/document/fieldvalue/iteratorhandler.cpp +++ b/document/src/vespa/document/fieldvalue/iteratorhandler.cpp @@ -5,14 +5,7 @@ namespace document::fieldvalue { -IteratorHandler::IteratorHandler() - : _weight(1), - _arrayIndexStack(1, 0), - _variables() -{ -} - -IteratorHandler::~IteratorHandler() = default; +IteratorHandler::~IteratorHandler() { } void @@ -25,13 +18,11 @@ IteratorHandler::handleComplex(const FieldValue & fv) { } void IteratorHandler::handleCollectionStart(const FieldValue & fv) { - _arrayIndexStack.push_back(0); onCollectionStart(Content(fv, getWeight())); } void IteratorHandler::handleCollectionEnd(const FieldValue & fv) { onCollectionEnd(Content(fv, getWeight())); - _arrayIndexStack.pop_back(); } void IteratorHandler::handleStructStart(const FieldValue & fv) { diff --git a/document/src/vespa/document/fieldvalue/iteratorhandler.h b/document/src/vespa/document/fieldvalue/iteratorhandler.h index cf71504e7a1..757cea54ef9 100644 --- a/document/src/vespa/document/fieldvalue/iteratorhandler.h +++ b/document/src/vespa/document/fieldvalue/iteratorhandler.h @@ -4,7 +4,6 @@ #include "variablemap.h" #include "modificationstatus.h" -#include <vector> namespace document::fieldvalue { @@ -56,7 +55,7 @@ protected: int _weight; }; - IteratorHandler(); + IteratorHandler() : _weight(1) {} public: virtual ~IteratorHandler(); @@ -73,8 +72,6 @@ public: void handleStructStart(const FieldValue &fv); void handleStructEnd(const FieldValue &fv); void setWeight(int weight) { _weight = weight; } - uint32_t getArrayIndex() const { return _arrayIndexStack.back(); } - void setArrayIndex(uint32_t index) { _arrayIndexStack.back() = index; } ModificationStatus modify(FieldValue &fv) { return doModify(fv); } fieldvalue::VariableMap &getVariables() { return _variables; } void setVariables(const fieldvalue::VariableMap &vars) { _variables = vars; } @@ -96,7 +93,6 @@ private: int getWeight() const { return _weight; } int _weight; - std::vector<uint32_t> _arrayIndexStack; fieldvalue::VariableMap _variables; }; diff --git a/document/src/vespa/document/fieldvalue/mapfieldvalue.cpp b/document/src/vespa/document/fieldvalue/mapfieldvalue.cpp index ebd51c82794..8e5a641ab6e 100644 --- a/document/src/vespa/document/fieldvalue/mapfieldvalue.cpp +++ b/document/src/vespa/document/fieldvalue/mapfieldvalue.cpp @@ -78,7 +78,9 @@ MapFieldValue::MapFieldValue(const DataType &mapType) { } -MapFieldValue::~MapFieldValue() = default; +MapFieldValue::~MapFieldValue() +{ +} MapFieldValue::MapFieldValue(const MapFieldValue & rhs) : FieldValue(rhs), @@ -423,7 +425,6 @@ MapFieldValue::iterateNestedImpl(PathRange nested, bool wasModified = false; const bool isWSet(complexFieldValue.inherits(WeightedSetFieldValue::classId)); - uint32_t index(0); if ( ! nested.atEnd() ) { LOG(spam, "not yet at end of field path"); const FieldPathEntry & fpe = nested.cur(); @@ -450,7 +451,6 @@ MapFieldValue::iterateNestedImpl(PathRange nested, case FieldPathEntry::MAP_ALL_KEYS: LOG(spam, "MAP_ALL_KEYS"); for (const auto & entry : *this) { - handler.setArrayIndex(index++); if (isWSet) { handler.setWeight(static_cast<const IntFieldValue &>(*entry.second).getValue()); } @@ -462,7 +462,6 @@ MapFieldValue::iterateNestedImpl(PathRange nested, case FieldPathEntry::MAP_ALL_VALUES: LOG(spam, "MAP_ALL_VALUES"); for (const auto & entry : *this) { - handler.setArrayIndex(index++); wasModified = checkAndRemove(*entry.second, entry.second->iterateNested(nested.next(), handler), wasModified, keysToRemove); @@ -483,7 +482,6 @@ MapFieldValue::iterateNestedImpl(PathRange nested, } else { PathRange next = nested.next(); for (const auto & entry : *this) { - handler.setArrayIndex(index++); LOG(spam, "key is '%s'", entry.first->toString().c_str()); handler.getVariables()[fpe.getVariableName()] = IndexValue(*entry.first); LOG(spam, "vars at this time = %s", handler.getVariables().toString().c_str()); @@ -497,7 +495,6 @@ MapFieldValue::iterateNestedImpl(PathRange nested, default: LOG(spam, "default"); for (const auto & entry : *this) { - handler.setArrayIndex(index++); if (isWSet) { handler.setWeight(static_cast<const IntFieldValue &>(*entry.second).getValue()); } @@ -525,7 +522,6 @@ MapFieldValue::iterateNestedImpl(PathRange nested, if (handler.handleComplex(complexFieldValue)) { LOG(spam, "calling handler.handleComplex for all map keys"); for (const auto & entry : *this) { - handler.setArrayIndex(index++); if (isWSet) { handler.setWeight(static_cast<const IntFieldValue &>(*entry.second).getValue()); } |