summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArne Juul <arnej@yahoo-inc.com>2018-12-18 08:59:24 +0000
committergjoranv <gv@oath.com>2019-01-21 15:09:29 +0100
commita18658fca16b994786f1b60d50f9d2f5f2ceb679 (patch)
tree9eda787fa9589c5c976abd1de7275af1692df5ce
parentc57b27a8def89067d3b488c0e3153d67878c483c (diff)
use IntegerContent to retrieve positions
-rw-r--r--searchsummary/src/vespa/searchsummary/docsummary/positionsdfw.cpp32
1 files changed, 11 insertions, 21 deletions
diff --git a/searchsummary/src/vespa/searchsummary/docsummary/positionsdfw.cpp b/searchsummary/src/vespa/searchsummary/docsummary/positionsdfw.cpp
index 607a4db9d13..c968158b9c2 100644
--- a/searchsummary/src/vespa/searchsummary/docsummary/positionsdfw.cpp
+++ b/searchsummary/src/vespa/searchsummary/docsummary/positionsdfw.cpp
@@ -3,6 +3,7 @@
#include "positionsdfw.h"
#include "docsumstate.h"
#include <vespa/searchlib/attribute/iattributemanager.h>
+#include <vespa/searchcommon/attribute/attributecontent.h>
#include <vespa/searchlib/common/location.h>
#include <vespa/vespalib/stllike/asciistream.h>
#include <vespa/vespalib/data/slime/cursor.h>
@@ -18,6 +19,7 @@ namespace search::docsummary {
using search::attribute::IAttributeContext;
using search::attribute::IAttributeVector;
using search::attribute::BasicType;
+using search::attribute::IntegerContent;
using search::common::Location;
AbsDistanceDFW::AbsDistanceDFW(const vespalib::string & attrName) :
@@ -33,13 +35,9 @@ AbsDistanceDFW::findMinDistance(uint32_t docid, GetDocsumsState *state)
uint64_t absdist = std::numeric_limits<int64_t>::max();
int32_t docx = 0;
int32_t docy = 0;
- std::vector<IAttributeVector::largeint_t> pos(16);
- uint32_t numValues = attribute.get(docid, &pos[0], pos.size());
- if (numValues > pos.size()) {
- pos.resize(numValues);
- numValues = attribute.get(docid, &pos[0], pos.size());
- assert(numValues <= pos.size());
- }
+ IntegerContent pos;
+ pos.fill(attribute, docid);
+ uint32_t numValues = pos.size();
for (uint32_t i = 0; i < numValues; i++) {
int64_t docxy(pos[i]);
vespalib::geo::ZCurve::decode(docxy, &docx, &docy);
@@ -154,13 +152,9 @@ insertPos(int64_t docxy, vespalib::slime::Inserter &target)
void
insertFromAttr(const attribute::IAttributeVector &attribute, uint32_t docid, vespalib::slime::Inserter &target)
{
- std::vector<IAttributeVector::largeint_t> pos(16);
- uint32_t numValues = attribute.get(docid, &pos[0], pos.size());
- if (numValues > pos.size()) {
- pos.resize(numValues);
- numValues = attribute.get(docid, &pos[0], pos.size());
- assert(numValues <= pos.size());
- }
+ IntegerContent pos;
+ pos.fill(attribute, docid);
+ uint32_t numValues = pos.size();
LOG(debug, "docid=%d, numValues=%d", docid, numValues);
if (numValues > 0) {
vespalib::slime::Cursor &arr = target.insertArray();
@@ -177,13 +171,9 @@ formatField(const attribute::IAttributeVector &attribute, uint32_t docid, ResTyp
int32_t docx = 0;
int32_t docy = 0;
- std::vector<IAttributeVector::largeint_t> pos(16);
- uint32_t numValues = attribute.get(docid, &pos[0], pos.size());
- if (numValues > pos.size()) {
- pos.resize(numValues);
- numValues = attribute.get(docid, &pos[0], pos.size());
- assert(numValues <= pos.size());
- }
+ IntegerContent pos;
+ pos.fill(attribute, docid);
+ uint32_t numValues = pos.size();
LOG(debug, "docid=%d, numValues=%d", docid, numValues);
bool isShort = !IDocsumFieldWriter::IsBinaryCompatible(type, RES_LONG_STRING);