summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--streamingvisitors/src/vespa/searchvisitor/searchenvironment.cpp15
-rw-r--r--streamingvisitors/src/vespa/searchvisitor/searchvisitor.cpp59
2 files changed, 37 insertions, 37 deletions
diff --git a/streamingvisitors/src/vespa/searchvisitor/searchenvironment.cpp b/streamingvisitors/src/vespa/searchvisitor/searchenvironment.cpp
index 64c2c9a6429..7ebb71f1855 100644
--- a/streamingvisitors/src/vespa/searchvisitor/searchenvironment.cpp
+++ b/streamingvisitors/src/vespa/searchvisitor/searchenvironment.cpp
@@ -15,9 +15,7 @@ __thread SearchEnvironment::EnvMap * SearchEnvironment::_localEnvMap=0;
SearchEnvironment::Env::Env(const vespalib::string & muffens, const config::ConfigUri & configUri, Fast_NormalizeWordFolder & wf) :
_configId(configUri.getConfigId()),
- _configurer(config::SimpleConfigRetriever::UP(
- new config::SimpleConfigRetriever(createKeySet(configUri.getConfigId()), configUri.getContext())),
- this),
+ _configurer(std::make_unique<config::SimpleConfigRetriever>(createKeySet(configUri.getConfigId()), configUri.getContext()), this),
_vsmAdapter(new VSMAdapter(muffens, _configId, wf)),
_rankManager(new RankManager(_vsmAdapter.get()))
{
@@ -63,13 +61,15 @@ SearchEnvironment::~SearchEnvironment()
_threadLocals.clear();
}
-SearchEnvironment::Env & SearchEnvironment::getEnv(const vespalib::string & searchCluster)
+SearchEnvironment::Env &
+SearchEnvironment::getEnv(const vespalib::string & searchCluster)
{
config::ConfigUri searchClusterUri(_configUri.createWithNewId(searchCluster));
if (_localEnvMap == NULL) {
- _localEnvMap = new EnvMap;
+ EnvMapUP envMap = std::make_unique<EnvMap>();
+ _localEnvMap = envMap.get();
vespalib::LockGuard guard(_lock);
- _threadLocals.push_back(EnvMapUP(_localEnvMap));
+ _threadLocals.emplace_back(std::move(envMap));
}
EnvMap::iterator localFound = _localEnvMap->find(searchCluster);
if (localFound == _localEnvMap->end()) {
@@ -77,7 +77,8 @@ SearchEnvironment::Env & SearchEnvironment::getEnv(const vespalib::string & sear
EnvMap::iterator found = _envMap.find(searchCluster);
if (found == _envMap.end()) {
LOG(debug, "Init VSMAdapter with config id = '%s'", searchCluster.c_str());
- _envMap[searchCluster].reset(new Env("*", searchClusterUri, _wordFolder));
+ Env::SP env = std::make_shared<Env>("*", searchClusterUri, _wordFolder);
+ _envMap[searchCluster] = std::move(env);
found = _envMap.find(searchCluster);
}
_localEnvMap->insert(*found);
diff --git a/streamingvisitors/src/vespa/searchvisitor/searchvisitor.cpp b/streamingvisitors/src/vespa/searchvisitor/searchvisitor.cpp
index 51c01a40fac..e3483e8beac 100644
--- a/streamingvisitors/src/vespa/searchvisitor/searchvisitor.cpp
+++ b/streamingvisitors/src/vespa/searchvisitor/searchvisitor.cpp
@@ -31,6 +31,8 @@ using search::attribute::IAttributeVector;
using search::aggregation::HitsAggregationResult;
using search::expression::ConfigureStaticParams;
using vdslib::Parameters;
+using document::PositionDataType;
+using document::DataType;
class ForceWordfolderInit
{
@@ -52,25 +54,25 @@ static ForceWordfolderInit _G_forceNormWordFolderInit;
AttributeVector::SP
createMultiValueAttribute(const vespalib::string & name, const document::FieldValue & fv, bool arrayType)
{
- const document::DataType * ndt = fv.getDataType();
+ const DataType * ndt = fv.getDataType();
if (ndt->inherits(document::CollectionDataType::classId)) {
ndt = &(static_cast<const document::CollectionDataType *>(ndt))->getNestedType();
}
LOG(debug, "Create %s attribute '%s' with data type '%s' (%s)",
arrayType ? "array" : "weighted set", name.c_str(), ndt->getName().c_str(), fv.getClass().name());
AttributeVector::SP attr;
- if (ndt->getId() == document::DataType::T_BYTE ||
- ndt->getId() == document::DataType::T_INT ||
- ndt->getId() == document::DataType::T_LONG)
+ if (ndt->getId() == DataType::T_BYTE ||
+ ndt->getId() == DataType::T_INT ||
+ ndt->getId() == DataType::T_LONG)
{
attr.reset(arrayType ? static_cast<AttributeVector *>(new search::MultiIntegerExtAttribute(name))
: static_cast<AttributeVector *>(new search::WeightedSetIntegerExtAttribute(name)));
- } else if (ndt->getId() == document::DataType::T_DOUBLE ||
- ndt->getId() == document::DataType::T_FLOAT)
+ } else if (ndt->getId() == DataType::T_DOUBLE ||
+ ndt->getId() == DataType::T_FLOAT)
{
attr.reset(arrayType ? static_cast<AttributeVector *>(new search::MultiFloatExtAttribute(name))
: static_cast<AttributeVector *>(new search::WeightedSetFloatExtAttribute(name)));
- } else if (ndt->getId() == document::DataType::T_STRING) {
+ } else if (ndt->getId() == DataType::T_STRING) {
attr.reset(arrayType ? static_cast<AttributeVector *>(new search::MultiStringExtAttribute(name))
: static_cast<AttributeVector *>(new search::WeightedSetStringExtAttribute(name)));
} else {
@@ -204,27 +206,26 @@ void SearchVisitor::init(const Parameters & params)
_attrMan.add(_rankAttributeBacking);
Parameters::ValueRef valueRef;
if ( params.get("summaryclass", valueRef) ) {
- _summaryClass = vespalib::string(static_cast<const char *>(valueRef.data()),
- static_cast<unsigned>(valueRef.size()));
+ _summaryClass = vespalib::string(valueRef.data(), valueRef.size());
LOG(debug, "Received summary class: %s", _summaryClass.c_str());
}
size_t wantedSummaryCount(10);
if (params.get("summarycount", valueRef) ) {
- vespalib::string tmp(static_cast<const char *>(valueRef.data()), valueRef.size());
+ vespalib::string tmp(valueRef.data(), valueRef.size());
wantedSummaryCount = strtoul(tmp.c_str(), NULL, 0);
LOG(debug, "Received summary count: %ld", wantedSummaryCount);
}
_queryResult->getSearchResult().setWantedHitCount(wantedSummaryCount);
if (params.get("rankprofile", valueRef) ) {
- vespalib::string tmp(static_cast<const char *>(valueRef.data()), valueRef.size());
+ vespalib::string tmp(valueRef.data(), valueRef.size());
_rankController.setRankProfile(tmp);
LOG(debug, "Received rank profile: %s", _rankController.getRankProfile().c_str());
}
if (params.get("queryflags", valueRef) ) {
- vespalib::string tmp(static_cast<const char *>(valueRef.data()), valueRef.size());
+ vespalib::string tmp(valueRef.data(), valueRef.size());
LOG(debug, "Received query flags: 0x%lx", strtoul(tmp.c_str(), NULL, 0));
uint32_t queryFlags = strtoul(tmp.c_str(), NULL, 0);
_rankController.setDumpFeatures((queryFlags & search::fs4transport::QFLAG_DUMP_FEATURES) != 0);
@@ -234,7 +235,7 @@ void SearchVisitor::init(const Parameters & params)
if (params.get("rankproperties", valueRef) && valueRef.size() > 0) {
LOG(spam, "Received rank properties of %zd bytes", valueRef.size());
uint32_t len = static_cast<uint32_t>(valueRef.size());
- char * data = const_cast<char *>(static_cast<const char *>(valueRef.data()));
+ char * data = const_cast<char *>(valueRef.data());
FNET_DataBuffer src(data, len);
uint32_t cnt = src.ReadInt32();
len -= sizeof(uint32_t);
@@ -259,7 +260,7 @@ void SearchVisitor::init(const Parameters & params)
}
if (params.get("rankprofile", valueRef)) {
- vespalib::string tmp(static_cast<const char *>(valueRef.data()), valueRef.size());
+ vespalib::string tmp(valueRef.data(), valueRef.size());
_summaryGenerator.getDocsumState()._args.SetRankProfile(tmp);
}
@@ -270,7 +271,7 @@ void SearchVisitor::init(const Parameters & params)
vespalib::string location;
if (params.get("location", valueRef)) {
- location = vespalib::string(static_cast<const char *>(valueRef.data()), valueRef.size());
+ location = vespalib::string(valueRef.data(), valueRef.size());
LOG(debug, "Location = '%s'", location.c_str());
_summaryGenerator.getDocsumState()._args.SetLocation(valueRef.size(), (const char*)valueRef.data());
}
@@ -278,14 +279,12 @@ void SearchVisitor::init(const Parameters & params)
Parameters::ValueRef searchClusterBlob;
if (params.get("searchcluster", searchClusterBlob)) {
LOG(spam, "Received searchcluster blob of %zd bytes", searchClusterBlob.size());
- vespalib::string searchCluster(static_cast<const char *>(searchClusterBlob.data()), searchClusterBlob.size());
+ vespalib::string searchCluster(searchClusterBlob.data(), searchClusterBlob.size());
_vsmAdapter = _env.getVSMAdapter(searchCluster);
if ( params.get("sort", valueRef) ) {
search::uca::UcaConverterFactory ucaFactory;
- _sortSpec = search::common::SortSpec(vespalib::string(static_cast<const char *>(valueRef.data()),
- static_cast<unsigned>(valueRef.size())),
- ucaFactory);
+ _sortSpec = search::common::SortSpec(vespalib::string(valueRef.data(), valueRef.size()), ucaFactory);
LOG(debug, "Received sort specification: '%s'", _sortSpec.getSpec().c_str());
}
@@ -388,16 +387,16 @@ SearchVisitor::AttributeInserter::onPrimitive(uint32_t, const Content & c)
}
}
-SearchVisitor::AttributeInserter::AttributeInserter(search::AttributeVector & attribute, search::AttributeVector::DocId docId) :
+SearchVisitor::AttributeInserter::AttributeInserter(AttributeVector & attribute, AttributeVector::DocId docId) :
_attribute(attribute),
_docId(docId)
{
}
-SearchVisitor::PositionInserter::PositionInserter(search::AttributeVector & attribute, search::AttributeVector::DocId docId) :
+SearchVisitor::PositionInserter::PositionInserter(AttributeVector & attribute, AttributeVector::DocId docId) :
AttributeInserter(attribute, docId),
- _fieldX(document::PositionDataType::getInstance().getField(document::PositionDataType::FIELD_X)),
- _fieldY(document::PositionDataType::getInstance().getField(document::PositionDataType::FIELD_Y))
+ _fieldX(PositionDataType::getInstance().getField(PositionDataType::FIELD_X)),
+ _fieldY(PositionDataType::getInstance().getField(PositionDataType::FIELD_Y))
{
}
@@ -605,7 +604,7 @@ void
SearchVisitor::SyntheticFieldsController::onDocumentMatch(StorageDocument & document,
const vespalib::string & documentId)
{
- document.setField(_documentIdFId, document::FieldValue::UP(new document::StringFieldValue(documentId)));
+ document.setField(_documentIdFId, std::make_unique<document::StringFieldValue>(documentId));
}
void
@@ -617,8 +616,8 @@ SearchVisitor::registerAdditionalFields(const std::vector<vsm::DocsumTools::Fiel
const std::vector<vespalib::string> & inputNames = spec.getInputNames();
for (size_t j = 0; j < inputNames.size(); ++j) {
fieldList.push_back(inputNames[j]);
- if (document::PositionDataType::isZCurveFieldName(inputNames[j])) {
- fieldList.push_back(document::PositionDataType::cutZCurveFieldName(inputNames[j]));
+ if (PositionDataType::isZCurveFieldName(inputNames[j])) {
+ fieldList.push_back(PositionDataType::cutZCurveFieldName(inputNames[j]));
}
}
}
@@ -991,16 +990,16 @@ SearchVisitor::fillAttributeVectors(const vespalib::string & documentId, const S
{
for (const AttrInfo & finfo : _attributeFields) {
const AttributeGuard &finfoGuard(*finfo._attr);
- bool isPosition = finfoGuard->getClass().inherits(search::IntegerAttribute::classId) && document::PositionDataType::isZCurveFieldName(finfoGuard->getName());
+ bool isPosition = finfoGuard->getClass().inherits(search::IntegerAttribute::classId) && PositionDataType::isZCurveFieldName(finfoGuard->getName());
LOG(debug, "Filling attribute '%s', isPosition='%s'", finfoGuard->getName().c_str(), isPosition ? "true" : "false");
uint32_t fieldId = finfo._field;
if (isPosition) {
- vespalib::stringref org = document::PositionDataType::cutZCurveFieldName(finfoGuard->getName());
+ vespalib::stringref org = PositionDataType::cutZCurveFieldName(finfoGuard->getName());
fieldId = _fieldsUnion.find(org)->second;
}
const StorageDocument::SubDocument & subDoc = document.getComplexField(fieldId);
- search::AttributeVector & attrV = const_cast<search::AttributeVector & >(*finfoGuard);
- search::AttributeVector::DocId docId(0);
+ AttributeVector & attrV = const_cast<AttributeVector & >(*finfoGuard);
+ AttributeVector::DocId docId(0);
attrV.addDoc(docId);
if (subDoc.getFieldValue() != NULL) {
LOG(debug, "value = '%s'", subDoc.getFieldValue()->toString().c_str());