diff options
author | Arne H Juul <arnej@yahoo-inc.com> | 2017-02-23 14:51:07 +0100 |
---|---|---|
committer | Arne H Juul <arnej@yahoo-inc.com> | 2017-02-23 14:51:07 +0100 |
commit | efea8355c6314ad05d63b8bd688f2ded4470b08e (patch) | |
tree | f7056ff053912f94169dd8a306f06a4e3bcd6560 | |
parent | bc717833cccf027b017b2d901ffa9f0bf27eccdc (diff) |
resolve to Symbol outside loops
4 files changed, 22 insertions, 20 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/server/proton.cpp b/searchcore/src/vespa/searchcore/proton/server/proton.cpp index 0c3d32948ae..3baa0d94cef 100644 --- a/searchcore/src/vespa/searchcore/proton/server/proton.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/proton.cpp @@ -48,7 +48,6 @@ using vespalib::RWLockWriter; using vespalib::Slime; using vespalib::slime::ArrayInserter; using vespalib::slime::Cursor; -using vespalib::slime::ObjectInserter; using search::TuneFileDocumentDB; using search::index::Schema; diff --git a/searchsummary/src/vespa/searchsummary/docsummary/geoposdfw.cpp b/searchsummary/src/vespa/searchsummary/docsummary/geoposdfw.cpp index 0922b231b10..e2dda337e73 100644 --- a/searchsummary/src/vespa/searchsummary/docsummary/geoposdfw.cpp +++ b/searchsummary/src/vespa/searchsummary/docsummary/geoposdfw.cpp @@ -43,7 +43,8 @@ GeoPositionDFW::insertField(uint32_t docid, GeneralResult *, GetDocsumsState * d ResType, vespalib::slime::Inserter &target) { using vespalib::slime::Cursor; - using vespalib::slime::ObjectInserter; + using vespalib::slime::ObjectSymbolInserter; + using vespalib::slime::Symbol; using vespalib::slime::ArrayInserter; const IAttributeVector & attribute = vec(*dsState); @@ -51,14 +52,16 @@ GeoPositionDFW::insertField(uint32_t docid, GeneralResult *, GetDocsumsState * d uint32_t entries = attribute.getValueCount(docid); Cursor &arr = target.insertArray(); if (attribute.hasWeightedSetType()) { + Symbol isym = arr.resolve("item"); + Symbol wsym = arr.resolve("weight"); std::vector<IAttributeVector::WeightedInt> elements(entries); entries = attribute.get(docid, &elements[0], entries); for (uint32_t i = 0; i < entries; ++i) { Cursor &elem = arr.addObject(); int64_t pos = elements[i].getValue(); - ObjectInserter obj(elem, "item"); + ObjectSymbolInserter obj(elem, isym); fmtZcurve(pos, obj); - elem.setLong("weight", elements[i].getWeight()); + elem.setLong(wsym, elements[i].getWeight()); } } else { std::vector<IAttributeVector::largeint_t> elements(16); diff --git a/searchsummary/src/vespa/searchsummary/docsummary/summaryfieldconverter.cpp b/searchsummary/src/vespa/searchsummary/docsummary/summaryfieldconverter.cpp index 6f545dfe88e..ded7db38fed 100644 --- a/searchsummary/src/vespa/searchsummary/docsummary/summaryfieldconverter.cpp +++ b/searchsummary/src/vespa/searchsummary/docsummary/summaryfieldconverter.cpp @@ -357,12 +357,12 @@ class SlimeFiller : public ConstFieldValueVisitor { virtual void visit(const MapFieldValue & v) { Cursor &a = _inserter.insertArray(); - Memory keymem("key"); - Memory valmem("value"); + Symbol keysym = a.resolve("key"); + Symbol valsym = a.resolve("value"); for (const auto & entry : v) { Cursor &c = a.addObject(); - ObjectInserter ki(c, keymem); - ObjectInserter vi(c, valmem); + ObjectSymbolInserter ki(c, keysym); + ObjectSymbolInserter vi(c, valsym); SlimeFiller keyConv(ki, _tokenize); SlimeFiller valConv(vi, _tokenize); @@ -456,15 +456,15 @@ class SlimeFiller : public ConstFieldValueVisitor { virtual void visit(const WeightedSetFieldValue &value) { Cursor &a = _inserter.insertArray(); if (value.size() > 0) { - Memory imem("item"); - Memory wmem("weight"); + Symbol isym = a.resolve("item"); + Symbol wsym = a.resolve("weight"); for (const auto & entry : value) { Cursor &o = a.addObject(); - ObjectInserter ki(o, imem); + ObjectSymbolInserter ki(o, isym); SlimeFiller conv(ki, _tokenize); entry.first->accept(conv); int weight = static_cast<const IntFieldValue &>(*entry.second).getValue(); - o.setLong(wmem, weight); + o.setLong(wsym, weight); } } } diff --git a/vsm/src/vespa/vsm/vsm/slimefieldwriter.cpp b/vsm/src/vespa/vsm/vsm/slimefieldwriter.cpp index eb860315bf1..a0abf8b7a07 100644 --- a/vsm/src/vespa/vsm/vsm/slimefieldwriter.cpp +++ b/vsm/src/vespa/vsm/vsm/slimefieldwriter.cpp @@ -52,15 +52,15 @@ SlimeFieldWriter::traverseRecursive(const document::FieldValue & fv, } else if (cfv.inherits(document::WeightedSetFieldValue::classId)) { const document::WeightedSetFieldValue & wsfv = static_cast<const document::WeightedSetFieldValue &>(cfv); Cursor &a = inserter.insertArray(); - Memory imem("item"); - Memory wmem("weight"); + Symbol isym = a.resolve("item"); + Symbol wsym = a.resolve("weight"); for (const auto &entry : wsfv) { Cursor &o = a.addObject(); const document::FieldValue & nfv = *entry.first; - ObjectInserter oi(o, imem); + ObjectSymbolInserter oi(o, isym); traverseRecursive(nfv, oi); int weight = static_cast<const document::IntFieldValue &>(*entry.second).getValue(); - o.setLong(wmem, weight); + o.setLong(wsym, weight); } } else { LOG(warning, "traverseRecursive: Cannot handle collection field value of type '%s'", @@ -71,17 +71,17 @@ SlimeFieldWriter::traverseRecursive(const document::FieldValue & fv, const document::MapFieldValue & mfv = static_cast<const document::MapFieldValue &>(fv); const document::MapDataType& mapType = static_cast<const document::MapDataType &>(*mfv.getDataType()); Cursor &a = inserter.insertArray(); - Memory keymem("key"); - Memory valmem("value"); + Symbol keysym = a.resolve("key"); + Symbol valsym = a.resolve("value"); for (const auto &entry : mfv) { Cursor &o = a.addObject(); - ObjectInserter ki(o, keymem); + ObjectSymbolInserter ki(o, keysym); traverseRecursive(*entry.first, ki); document::FieldPathEntry valueEntry( mapType, mapType.getKeyType(), mapType.getValueType(), false, true); _currPath.push_back(valueEntry); - ObjectInserter vi(o, valmem); + ObjectSymbolInserter vi(o, valsym); traverseRecursive(*entry.second, vi); _currPath.pop_back(); } |