aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArne Juul <arnej@verizonmedia.com>2020-07-14 07:26:54 +0000
committerArne Juul <arnej@verizonmedia.com>2020-07-15 15:39:23 +0000
commitf941239c2d02fc07acc8f12ae8561c66c8de0c07 (patch)
treefb7b9df2d0307c17858838f82966c7d9101b55ea
parent9534d9ef4d74017ff4ef0849924f751403979cbb (diff)
fix bugs
-rw-r--r--searchlib/src/tests/common/location/location_test.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/common/geo_location.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/query/streaming/querynode.cpp7
-rw-r--r--searchlib/src/vespa/searchlib/query/tree/location.cpp32
-rw-r--r--searchlib/src/vespa/searchlib/query/tree/location.h2
-rw-r--r--searchlib/src/vespa/searchlib/query/tree/stackdumpquerycreator.h4
7 files changed, 37 insertions, 14 deletions
diff --git a/searchlib/src/tests/common/location/location_test.cpp b/searchlib/src/tests/common/location/location_test.cpp
index c25dce38a4a..aac772b7dd0 100644
--- a/searchlib/src/tests/common/location/location_test.cpp
+++ b/searchlib/src/tests/common/location/location_test.cpp
@@ -1,13 +1,11 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/testkit/test_kit.h>
#include <vespa/searchlib/common/location.h>
-#include <vespa/searchlib/common/geo_location_spec.h>
#include <vespa/searchlib/common/geo_location_parser.h>
#include <vespa/searchlib/attribute/attributeguard.h>
using search::common::Location;
using search::common::GeoLocationParser;
-using search::common::GeoLocationSpec;
Location parse(const char *str) {
GeoLocationParser parser;
diff --git a/searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp b/searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp
index a66873fb59a..78c37a03609 100644
--- a/searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp
@@ -255,7 +255,7 @@ public:
_location.setVec(attribute);
estHits = _attribute.getNumDocs();
}
- LOG(debug, "location %s in attribute with numdocs %u", loc.getDebugString().c_str(), estHits);
+ LOG(debug, "location %s in attribute with numdocs %u", loc.getOldFormatString().c_str(), estHits);
HitEstimate estimate(estHits, estHits == 0);
setEstimate(estimate);
}
diff --git a/searchlib/src/vespa/searchlib/common/geo_location.cpp b/searchlib/src/vespa/searchlib/common/geo_location.cpp
index f9fea1143a6..d7a0d7b8ef8 100644
--- a/searchlib/src/vespa/searchlib/common/geo_location.cpp
+++ b/searchlib/src/vespa/searchlib/common/geo_location.cpp
@@ -92,7 +92,7 @@ GeoLocation::GeoLocation(Point p, uint32_t r, Aspect xa)
: has_point(true),
point(p),
radius(r),
- x_aspect(),
+ x_aspect(xa),
bounding_box(adjust_bounding_box(no_box, p, r, xa)),
_sq_radius(uint64_t(r) * uint64_t(r)),
_z_bounding_box(to_z(bounding_box))
diff --git a/searchlib/src/vespa/searchlib/query/streaming/querynode.cpp b/searchlib/src/vespa/searchlib/query/streaming/querynode.cpp
index 44d8cbf88e6..66466b030d0 100644
--- a/searchlib/src/vespa/searchlib/query/streaming/querynode.cpp
+++ b/searchlib/src/vespa/searchlib/query/streaming/querynode.cpp
@@ -64,14 +64,11 @@ QueryNode::Build(const QueryNode * parent, const QueryNodeResultFactory & factor
}
break;
case ParseItem::ITEM_GEO_LOCATION_TERM:
- {
// TODO implement this:
// vespalib::string field = queryRep.getIndexName();
// vespalib::stringref location_term = queryRep.getTerm();
- // qn = std::make_unique<LocationQueryNode>
- qn.reset(new TrueNode());
- }
- break;
+ // qn = std::make_unique<LocationQueryNode> ...something ....
+ // break;
case ParseItem::ITEM_NUMTERM:
case ParseItem::ITEM_TERM:
case ParseItem::ITEM_PREFIXTERM:
diff --git a/searchlib/src/vespa/searchlib/query/tree/location.cpp b/searchlib/src/vespa/searchlib/query/tree/location.cpp
index bde62e20240..eb8685f2dc8 100644
--- a/searchlib/src/vespa/searchlib/query/tree/location.cpp
+++ b/searchlib/src/vespa/searchlib/query/tree/location.cpp
@@ -33,20 +33,43 @@ Location::Location(const Rectangle &rect)
bool
Location::operator==(const Location &other) const
{
- auto me = getDebugString();
- auto it = other.getDebugString();
+ auto me = getOldFormatString();
+ auto it = other.getOldFormatString();
if (me == it) {
return true;
} else {
// dump 'me' and 'it' here if unit tests fail
+ fprintf(stderr, "not equal: this('%s') and other('%s')\n",
+ me.c_str(), it.c_str());
return false;
}
}
std::string
-Location::getDebugString() const
+Location::getOldFormatString() const
{
+ // we need to product what search::common::GeoLocationParser can parse
vespalib::asciistream buf;
+#if 1
+ if (has_point) {
+ buf << "(2" // dimensionality
+ << "," << point.x
+ << "," << point.y
+ << "," << radius
+ << "," << "0" // table id.
+ << "," << "1" // rank multiplier.
+ << "," << "0" // rank only on distance.
+ << "," << x_aspect.multiplier // aspect multiplier
+ << ")";
+ }
+ if (bounding_box.active()) {
+ buf << "[2," << bounding_box.x.lo
+ << "," << bounding_box.y.lo
+ << "," << bounding_box.x.hi
+ << "," << bounding_box.y.hi
+ << "]" ;
+ }
+#else
buf << "query::Location{";
if (has_point) {
buf << "point=[" << point.x << "," << point.y << "]";
@@ -63,11 +86,12 @@ Location::getDebugString() const
buf << "bb.y=[" << bounding_box.y.lo << "," << bounding_box.y.hi << "]";
}
buf << "}";
+#endif
return buf.str();
}
vespalib::asciistream &operator<<(vespalib::asciistream &out, const Location &loc) {
- return out << loc.getDebugString();
+ return out << loc.getOldFormatString();
}
}
diff --git a/searchlib/src/vespa/searchlib/query/tree/location.h b/searchlib/src/vespa/searchlib/query/tree/location.h
index 89c35698262..6b8090f45e1 100644
--- a/searchlib/src/vespa/searchlib/query/tree/location.h
+++ b/searchlib/src/vespa/searchlib/query/tree/location.h
@@ -21,7 +21,7 @@ public:
Location(const Rectangle &rect, const Point &p, uint32_t dist, uint32_t x_asp);
bool operator==(const Location &other) const;
- std::string getDebugString() const;
+ std::string getOldFormatString() const;
};
vespalib::asciistream &operator<<(vespalib::asciistream &out, const Location &loc);
diff --git a/searchlib/src/vespa/searchlib/query/tree/stackdumpquerycreator.h b/searchlib/src/vespa/searchlib/query/tree/stackdumpquerycreator.h
index a7e00d41555..b4d04b3a104 100644
--- a/searchlib/src/vespa/searchlib/query/tree/stackdumpquerycreator.h
+++ b/searchlib/src/vespa/searchlib/query/tree/stackdumpquerycreator.h
@@ -146,6 +146,10 @@ private:
search::common::GeoLocationParser parser;
parser.parseOldFormat(term);
Location loc(parser.getGeoLocation());
+ if (! loc.valid()) {
+ vespalib::string tmp(term);
+ fprintf(stderr, "not valid location term: '%s'\n", tmp.c_str());
+ }
t = &builder.addLocationTerm(loc, view, id, weight);
} else if (type == ParseItem::ITEM_NUMTERM) {
if (term[0] == '[' || term[0] == '<' || term[0] == '>') {