diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-02-05 13:11:04 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-05 13:11:04 +0100 |
commit | 0455780c0a1ddb6fad0f5ac1d5c94a6932450815 (patch) | |
tree | 2b07c8f142b434fca1f28fa85afdaa66c4a432a1 | |
parent | af9e7e997ebb0782a9feafdbaff5a7280b21e6c5 (diff) | |
parent | 724cc3927f470a683f63d45d7be96bbf938e2797 (diff) |
Merge pull request #21079 from vespa-engine/arnej/more-geo-rendering
Arnej/more geo rendering
5 files changed, 31 insertions, 3 deletions
diff --git a/searchsummary/src/vespa/searchsummary/docsummary/geoposdfw.cpp b/searchsummary/src/vespa/searchsummary/docsummary/geoposdfw.cpp index cfc492d50ee..8f627ac1b9a 100644 --- a/searchsummary/src/vespa/searchsummary/docsummary/geoposdfw.cpp +++ b/searchsummary/src/vespa/searchsummary/docsummary/geoposdfw.cpp @@ -64,6 +64,7 @@ GeoPositionDFW::insertField(uint32_t docid, GetDocsumsState * dsState, ResType, const auto& attribute = get_attribute(*dsState); if (attribute.hasMultiValue()) { uint32_t entries = attribute.getValueCount(docid); + if (entries == 0 && _useV8geoPositions) return; Cursor &arr = target.insertArray(); if (attribute.hasWeightedSetType()) { Symbol isym = arr.resolve("item"); diff --git a/searchsummary/src/vespa/searchsummary/docsummary/resultconfig.cpp b/searchsummary/src/vespa/searchsummary/docsummary/resultconfig.cpp index d3c0caeec48..02bb5d25ca4 100644 --- a/searchsummary/src/vespa/searchsummary/docsummary/resultconfig.cpp +++ b/searchsummary/src/vespa/searchsummary/docsummary/resultconfig.cpp @@ -3,6 +3,7 @@ #include "resultconfig.h" #include <vespa/vespalib/util/exceptions.h> #include <vespa/vespalib/stllike/hash_map.hpp> +#include <atomic> #include <vespa/log/log.h> LOG_SETUP(".searchlib.docsummary.resultconfig"); @@ -117,6 +118,13 @@ ResultConfig::CreateEnumMaps() } } +namespace { +std::atomic<bool> global_useV8geoPositions = false; +} + +bool ResultConfig::wantedV8geoPositions() { + return global_useV8geoPositions; +} bool ResultConfig::ReadConfig(const vespa::config::search::SummaryConfig &cfg, const char *configId) @@ -126,6 +134,7 @@ ResultConfig::ReadConfig(const vespa::config::search::SummaryConfig &cfg, const int maxclassID = 0x7fffffff; // avoid negative classids _defaultSummaryId = cfg.defaultsummaryid; _useV8geoPositions = cfg.usev8geopositions; + global_useV8geoPositions = cfg.usev8geopositions; for (uint32_t i = 0; rc && i < cfg.classes.size(); i++) { const auto& cfg_class = cfg.classes[i]; diff --git a/searchsummary/src/vespa/searchsummary/docsummary/resultconfig.h b/searchsummary/src/vespa/searchsummary/docsummary/resultconfig.h index 8a8bfabaaec..8c5895a779d 100644 --- a/searchsummary/src/vespa/searchsummary/docsummary/resultconfig.h +++ b/searchsummary/src/vespa/searchsummary/docsummary/resultconfig.h @@ -173,6 +173,8 @@ public: return false; } + // whether last config seen wanted useV8geoPositions = true + static bool wantedV8geoPositions(); /** * @return the name of the given result field type. diff --git a/searchsummary/src/vespa/searchsummary/docsummary/summaryfieldconverter.cpp b/searchsummary/src/vespa/searchsummary/docsummary/summaryfieldconverter.cpp index 31b953362dd..597cfe8eb40 100644 --- a/searchsummary/src/vespa/searchsummary/docsummary/summaryfieldconverter.cpp +++ b/searchsummary/src/vespa/searchsummary/docsummary/summaryfieldconverter.cpp @@ -2,12 +2,14 @@ #include "summaryfieldconverter.h" #include "linguisticsannotation.h" +#include "resultconfig.h" #include "searchdatatype.h" #include <vespa/document/annotation/alternatespanlist.h> #include <vespa/document/annotation/annotation.h> #include <vespa/document/annotation/spantree.h> #include <vespa/document/annotation/spantreevisitor.h> #include <vespa/document/datatype/documenttype.h> +#include <vespa/document/datatype/positiondatatype.h> #include <vespa/document/fieldvalue/arrayfieldvalue.h> #include <vespa/document/fieldvalue/boolfieldvalue.h> #include <vespa/document/fieldvalue/bytefieldvalue.h> @@ -472,6 +474,18 @@ private: } void visit(const StructFieldValue &value) override { + if (value.getDataType() == &document::PositionDataType::getInstance() + && ResultConfig::wantedV8geoPositions()) + { + auto xv = value.getValue("x"); + auto yv = value.getValue("y"); + if (xv && yv) { + Cursor &c = _inserter.insertObject(); + c.setDouble("lat", double(yv->getAsInt()) / 1.0e6); + c.setDouble("lng", double(xv->getAsInt()) / 1.0e6); + return; + } + } if (*value.getDataType() == *SearchDataType::URI) { FieldValue::UP uriAllValue = value.getValue("all"); if (uriAllValue && diff --git a/vsm/src/vespa/vsm/vsm/slimefieldwriter.cpp b/vsm/src/vespa/vsm/vsm/slimefieldwriter.cpp index 4a03c93127a..405f2292f5d 100644 --- a/vsm/src/vespa/vsm/vsm/slimefieldwriter.cpp +++ b/vsm/src/vespa/vsm/vsm/slimefieldwriter.cpp @@ -4,6 +4,8 @@ #include <vespa/searchlib/util/slime_output_raw_buf_adapter.h> #include <vespa/vespalib/stllike/asciistream.h> #include <vespa/vespalib/util/size_literals.h> +#include <vespa/searchsummary/docsummary/resultconfig.h> +#include <vespa/document/datatype/positiondatatype.h> #include <vespa/log/log.h> LOG_SETUP(".vsm.slimefieldwriter"); @@ -93,8 +95,9 @@ SlimeFieldWriter::traverseRecursive(const document::FieldValue & fv, Inserter &i } else if (clazz.inherits(document::StructuredFieldValue::classId)) { const document::StructuredFieldValue & sfv = static_cast<const document::StructuredFieldValue &>(fv); Cursor &o = inserter.insertObject(); -#ifdef USE_V8_GEO_POSITION_RENDERING - if (sfv.getDataType()->getName() == "position") { + if (sfv.getDataType() == &document::PositionDataType::getInstance() + && search::docsummary::ResultConfig::wantedV8geoPositions()) + { bool ok = true; try { int x = std::numeric_limits<int>::min(); @@ -121,7 +124,6 @@ SlimeFieldWriter::traverseRecursive(const document::FieldValue & fv, Inserter &i // fallback to code below } } -#endif for (const document::Field & entry : sfv) { if (explorePath(entry.getName())) { _currPath.push_back(entry.getName()); |