summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2017-08-23 21:45:36 +0200
committerHenning Baldersheim <balder@yahoo-inc.com>2017-08-23 21:45:36 +0200
commitefa813a34dc4decad2b145002798b9207e9753b8 (patch)
tree191c95698244e817bd962d7c6509205e663d8c45 /searchlib
parentf1376511dc20469576c0e3b2bceac151f9946054 (diff)
All you need is make_string.
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/vespa/searchlib/features/foreachfeature.cpp11
-rw-r--r--searchlib/src/vespa/searchlib/fef/parametervalidator.cpp26
-rw-r--r--searchlib/src/vespa/searchlib/parsequery/simplequerystack.cpp36
-rw-r--r--searchlib/src/vespa/searchlib/transactionlog/common.h5
-rw-r--r--searchlib/src/vespa/searchlib/transactionlog/domain.cpp10
-rw-r--r--searchlib/src/vespa/searchlib/transactionlog/domainpart.cpp1
6 files changed, 36 insertions, 53 deletions
diff --git a/searchlib/src/vespa/searchlib/features/foreachfeature.cpp b/searchlib/src/vespa/searchlib/features/foreachfeature.cpp
index 3cef8c12c6c..a67d8001a36 100644
--- a/searchlib/src/vespa/searchlib/features/foreachfeature.cpp
+++ b/searchlib/src/vespa/searchlib/features/foreachfeature.cpp
@@ -4,18 +4,16 @@
#include "valuefeature.h"
#include "utils.h"
-#include <boost/algorithm/string/replace.hpp>
#include <vespa/searchlib/fef/properties.h>
#include <vespa/vespalib/util/stringfmt.h>
-#include <vespa/vespalib/util/vstringfmt.h>
+#include <boost/algorithm/string/replace.hpp>
#include <vespa/log/log.h>
LOG_SETUP(".features.foreachfeature");
using namespace search::fef;
-namespace search {
-namespace features {
+namespace search::features {
template <typename CO, typename OP>
ForeachExecutor<CO, OP>::ForeachExecutor(const CO & condition, uint32_t numInputs) :
@@ -149,7 +147,7 @@ ForeachBlueprint::setup(const IIndexEnvironment & env,
if (_dimension == TERMS) {
uint32_t maxTerms = util::strToNum<uint32_t>(env.getProperties().lookup(getBaseName(), "maxTerms").get("16"));
for (uint32_t i = 0; i < maxTerms; ++i) {
- defineInput(boost::algorithm::replace_all_copy(feature, variable, vespalib::make_vespa_string("%u", i)));
+ defineInput(boost::algorithm::replace_all_copy(feature, variable, vespalib::make_string("%u", i)));
++_num_inputs;
}
} else {
@@ -186,5 +184,4 @@ ForeachBlueprint::createExecutor(const IQueryEnvironment &, vespalib::Stash &sta
}
-} // namespace features
-} // namespace search
+}
diff --git a/searchlib/src/vespa/searchlib/fef/parametervalidator.cpp b/searchlib/src/vespa/searchlib/fef/parametervalidator.cpp
index f357df250b4..62c9efc6739 100644
--- a/searchlib/src/vespa/searchlib/fef/parametervalidator.cpp
+++ b/searchlib/src/vespa/searchlib/fef/parametervalidator.cpp
@@ -3,13 +3,12 @@
#include "parametervalidator.h"
#include "fieldtype.h"
#include "fieldinfo.h"
-#include <vespa/vespalib/util/vstringfmt.h>
+#include <vespa/vespalib/util/stringfmt.h>
#include <boost/lexical_cast.hpp>
-using vespalib::make_vespa_string;
+using vespalib::make_string;
-namespace search {
-namespace fef {
+namespace search::fef {
using CollectionType = FieldInfo::CollectionType;
@@ -56,27 +55,27 @@ ParameterValidator::validateField(ParameterType::Enum type, ParameterCollection:
{
const FieldInfo * field = _indexEnv.getFieldByName(_params[i]);
if (field == NULL) {
- throw ValidateException(make_vespa_string("Param[%zu]: Field '%s' was not found in the index environment",
+ throw ValidateException(make_string("Param[%zu]: Field '%s' was not found in the index environment",
i, _params[i].c_str()));
}
if (type == ParameterType::INDEX_FIELD) {
if (field->type() != FieldType::INDEX) {
- throw ValidateException(make_vespa_string("Param[%zu]: Expected field '%s' to be an index field, but it was not",
+ throw ValidateException(make_string("Param[%zu]: Expected field '%s' to be an index field, but it was not",
i, _params[i].c_str()));
}
} else if (type == ParameterType::ATTRIBUTE_FIELD) {
if (field->type() != FieldType::ATTRIBUTE) {
- throw ValidateException(make_vespa_string("Param[%zu]: Expected field '%s' to be an attribute field, but it was not",
+ throw ValidateException(make_string("Param[%zu]: Expected field '%s' to be an attribute field, but it was not",
i, _params[i].c_str()));
}
} else if (type == ParameterType::ATTRIBUTE) {
if (!field->hasAttribute()) {
- throw ValidateException(make_vespa_string("Param[%zu]: Expected field '%s' to support attribute lookup, but it does not",
+ throw ValidateException(make_string("Param[%zu]: Expected field '%s' to support attribute lookup, but it does not",
i, _params[i].c_str()));
}
}
if (!checkCollectionType(collection, field->collection())) {
- throw ValidateException(make_vespa_string("Param[%zu]: field '%s' has inappropriate collection type",
+ throw ValidateException(make_string("Param[%zu]: field '%s' has inappropriate collection type",
i, _params[i].c_str()));
}
result.addParameter(Parameter(type, _params[i]).setField(field));
@@ -90,7 +89,7 @@ ParameterValidator::validateNumber(ParameterType::Enum type, size_t i, Result &
int64_t intVal = static_cast<int64_t>(doubleVal);
result.addParameter(Parameter(type, _params[i]).setInteger(intVal).setDouble(doubleVal));
} catch (const boost::bad_lexical_cast &) {
- throw ValidateException(make_vespa_string("Param[%zu]: Could not convert '%s' to a number", i, _params[i].c_str()));
+ throw ValidateException(make_string("Param[%zu]: Could not convert '%s' to a number", i, _params[i].c_str()));
}
}
@@ -103,11 +102,11 @@ ParameterValidator::validate(const ParameterDescriptions::Description & desc)
if (minParams > _params.size() ||
((_params.size() - desc.getParams().size()) % desc.getRepeat() != 0))
{
- throw ValidateException(make_vespa_string("Expected %zd+%zdx parameter(s), but got %zd",
+ throw ValidateException(make_string("Expected %zd+%zdx parameter(s), but got %zd",
minParams, desc.getRepeat(), _params.size()));
}
} else if (desc.getParams().size() != _params.size()) {
- throw ValidateException(make_vespa_string("Expected %zd parameter(s), but got %zd", desc.getParams().size(), _params.size()));
+ throw ValidateException(make_string("Expected %zd parameter(s), but got %zd", desc.getParams().size(), _params.size()));
}
for (size_t i = 0; i < _params.size(); ++i) {
ParamDescItem param = desc.getParam(i);
@@ -160,5 +159,4 @@ ParameterValidator::validate()
return invalid;
}
-} // namespace fef
-} // namespace search
+}
diff --git a/searchlib/src/vespa/searchlib/parsequery/simplequerystack.cpp b/searchlib/src/vespa/searchlib/parsequery/simplequerystack.cpp
index cae3e769c5b..6274bd083de 100644
--- a/searchlib/src/vespa/searchlib/parsequery/simplequerystack.cpp
+++ b/searchlib/src/vespa/searchlib/parsequery/simplequerystack.cpp
@@ -8,14 +8,14 @@
* ALL RIGHTS RESERVED
*/
#include "simplequerystack.h"
-#include <vespa/vespalib/util/vstringfmt.h>
#include <vespa/vespalib/util/compress.h>
#include <vespa/vespalib/objects/nbo.h>
+#include <vespa/vespalib/util/stringfmt.h>
#include <vespa/log/log.h>
LOG_SETUP(".search.simplequerystack");
-using vespalib::make_vespa_string;
+using vespalib::make_string;
namespace search {
@@ -174,24 +174,24 @@ SimpleQueryStack::StackbufToString(const vespalib::stringref &theBuf)
int64_t tmpLong(0);
p += vespalib::compress::Integer::decompress(tmpLong, p);
metaStr.append("(w:");
- metaStr.append(make_vespa_string("%ld", tmpLong));
+ metaStr.append(make_string("%ld", tmpLong));
metaStr.append(")");
}
if (search::ParseItem::getFeature_UniqueId(rawtype)) {
p += vespalib::compress::Integer::decompressPositive(tmp, p);
metaStr.append("(u:");
- metaStr.append(make_vespa_string("%ld", tmp));
+ metaStr.append(make_string("%ld", tmp));
metaStr.append(")");
}
if (search::ParseItem::getFeature_Flags(rawtype)) {
flags = *p++;
metaStr.append("(f:");
- metaStr.append(make_vespa_string("%d", flags));
+ metaStr.append(make_string("%d", flags));
metaStr.append(")");
}
if (search::ParseItem::GetCreator(flags) != search::ParseItem::CREA_ORIG) {
metaStr.append("(c:");
- metaStr.append(make_vespa_string("%d", search::ParseItem::GetCreator(flags)));
+ metaStr.append(make_string("%d", search::ParseItem::GetCreator(flags)));
metaStr.append(")");
}
@@ -207,7 +207,7 @@ SimpleQueryStack::StackbufToString(const vespalib::stringref &theBuf)
case search::ParseItem::ITEM_ANY:
p += vespalib::compress::Integer::decompressPositive(tmp, p);
arity = tmp;
- result.append(make_vespa_string("%c/%d~", _G_ItemName[type], arity));
+ result.append(make_string("%c/%d~", _G_ItemName[type], arity));
break;
case search::ParseItem::ITEM_WEAK_AND:
case search::ParseItem::ITEM_NEAR:
@@ -221,9 +221,9 @@ SimpleQueryStack::StackbufToString(const vespalib::stringref &theBuf)
idxRefLen = tmp;
idxRef = p;
p += idxRefLen;
- result.append(make_vespa_string("%c/%d/%d/%d:%.*s~", _G_ItemName[type], arity, arg1, idxRefLen, idxRefLen, idxRef));
+ result.append(make_string("%c/%d/%d/%d:%.*s~", _G_ItemName[type], arity, arg1, idxRefLen, idxRefLen, idxRef));
} else {
- result.append(make_vespa_string("%c/%d/%d~", _G_ItemName[type], arity, arg1));
+ result.append(make_string("%c/%d/%d~", _G_ItemName[type], arity, arg1));
}
break;
@@ -242,7 +242,7 @@ SimpleQueryStack::StackbufToString(const vespalib::stringref &theBuf)
termRefLen = tmp;
termRef = p;
p += termRefLen;
- result.append(make_vespa_string("%c/%d:%.*s/%d:%.*s~", _G_ItemName[type],
+ result.append(make_string("%c/%d:%.*s/%d:%.*s~", _G_ItemName[type],
idxRefLen, idxRefLen, idxRef,
termRefLen, termRefLen, termRef));
break;
@@ -251,14 +251,14 @@ SimpleQueryStack::StackbufToString(const vespalib::stringref &theBuf)
termRefLen = tmp;
termRef = p;
p += termRefLen;
- result.append(make_vespa_string("%c/%d:%.*s~", _G_ItemName[type],
+ result.append(make_string("%c/%d:%.*s~", _G_ItemName[type],
termRefLen, termRefLen, termRef));
break;
case search::ParseItem::ITEM_PURE_WEIGHTED_LONG:
tmp = vespalib::nbo::n2h(*reinterpret_cast<const uint64_t *>(p));
p += sizeof(uint64_t);
- result.append(make_vespa_string("%c/%lu", _G_ItemName[type], tmp));
+ result.append(make_string("%c/%lu", _G_ItemName[type], tmp));
break;
case search::ParseItem::ITEM_PHRASE:
@@ -278,10 +278,10 @@ SimpleQueryStack::StackbufToString(const vespalib::stringref &theBuf)
p += sizeof(double);
double thresholdBoostFactor = vespalib::nbo::n2h(*reinterpret_cast<const double *>(p)); // thresholdBoostFactor
p += sizeof(double);
- result.append(make_vespa_string("%c/%d/%d:%.*s(%u,%f,%f)~", _G_ItemName[type], arity, idxRefLen,
+ result.append(make_string("%c/%d/%d:%.*s(%u,%f,%f)~", _G_ItemName[type], arity, idxRefLen,
idxRefLen, idxRef, targetNumHits, scoreThreshold, thresholdBoostFactor));
} else {
- result.append(make_vespa_string("%c/%d/%d:%.*s~", _G_ItemName[type], arity, idxRefLen,
+ result.append(make_string("%c/%d/%d:%.*s~", _G_ItemName[type], arity, idxRefLen,
idxRefLen, idxRef));
}
break;
@@ -292,25 +292,25 @@ SimpleQueryStack::StackbufToString(const vespalib::stringref &theBuf)
idxRef = p;
p += idxRefLen;
size_t feature_count = ReadCompressedPositiveInt(p);
- result.append(make_vespa_string(
+ result.append(make_string(
"%c/%d:%.*s/%zu(", _G_ItemName[type], idxRefLen, idxRefLen, idxRef, feature_count));
for (size_t i = 0; i < feature_count; ++i) {
vespalib::string key = ReadString(p);
vespalib::string value = ReadString(p);
uint64_t sub_queries = ReadUint64(p);
- result.append(make_vespa_string("%s:%s:%lx", key.c_str(), value.c_str(), sub_queries));
+ result.append(make_string("%s:%s:%lx", key.c_str(), value.c_str(), sub_queries));
if (i < feature_count - 1) {
result.append(',');
}
}
size_t range_feature_count = ReadCompressedPositiveInt(p);
- result.append(make_vespa_string(")/%zu(", range_feature_count));
+ result.append(make_string(")/%zu(", range_feature_count));
for (size_t i = 0; i < range_feature_count; ++i) {
vespalib::string key = ReadString(p);
uint64_t value = ReadUint64(p);
uint64_t sub_queries = ReadUint64(p);
- result.append(make_vespa_string("%s:%zu:%lx", key.c_str(), value, sub_queries));
+ result.append(make_string("%s:%zu:%lx", key.c_str(), value, sub_queries));
if (i < range_feature_count - 1) {
result.append(',');
}
diff --git a/searchlib/src/vespa/searchlib/transactionlog/common.h b/searchlib/src/vespa/searchlib/transactionlog/common.h
index 4b8e6575c4c..65ef8f363c0 100644
--- a/searchlib/src/vespa/searchlib/transactionlog/common.h
+++ b/searchlib/src/vespa/searchlib/transactionlog/common.h
@@ -5,8 +5,7 @@
#include <vespa/vespalib/objects/nbostream.h>
#include <vespa/vespalib/util/buffer.h>
-namespace search {
-namespace transactionlog {
+namespace search::transactionlog {
/// This represents a type of the entry. Fx update,remove
typedef uint32_t Type;
@@ -96,5 +95,3 @@ public:
};
}
-}
-
diff --git a/searchlib/src/vespa/searchlib/transactionlog/domain.cpp b/searchlib/src/vespa/searchlib/transactionlog/domain.cpp
index 82e700620e5..8477098ccc8 100644
--- a/searchlib/src/vespa/searchlib/transactionlog/domain.cpp
+++ b/searchlib/src/vespa/searchlib/transactionlog/domain.cpp
@@ -1,8 +1,6 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "domain.h"
-#include <limits>
-#include <vespa/vespalib/util/vstringfmt.h>
#include <vespa/vespalib/util/stringfmt.h>
#include <vespa/vespalib/util/closuretask.h>
@@ -11,7 +9,6 @@ LOG_SETUP(".transactionlog.domain");
using vespalib::string;
using vespalib::make_string;
-using vespalib::make_vespa_string;
using vespalib::LockGuard;
using vespalib::makeTask;
using vespalib::makeClosure;
@@ -20,11 +17,7 @@ using vespalib::MonitorGuard;
using search::common::FileHeaderContext;
using std::runtime_error;
-namespace search
-{
-
-namespace transactionlog
-{
+namespace search::transactionlog {
Domain::Domain(const string &domainName,
const string & baseDir,
@@ -420,4 +413,3 @@ Domain::scanDir()
}
}
-}
diff --git a/searchlib/src/vespa/searchlib/transactionlog/domainpart.cpp b/searchlib/src/vespa/searchlib/transactionlog/domainpart.cpp
index 03bb1c4e043..bd09371181b 100644
--- a/searchlib/src/vespa/searchlib/transactionlog/domainpart.cpp
+++ b/searchlib/src/vespa/searchlib/transactionlog/domainpart.cpp
@@ -3,7 +3,6 @@
#include "domainpart.h"
#include <vespa/vespalib/util/crc.h>
#include <vespa/vespalib/xxhash/xxhash.h>
-#include <vespa/vespalib/util/vstringfmt.h>
#include <vespa/vespalib/util/stringfmt.h>
#include <vespa/vespalib/data/fileheader.h>
#include <vespa/searchlib/common/fileheadercontext.h>