summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2020-03-05 14:18:42 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2020-03-05 14:18:42 +0000
commitea7621f3a4b46ff504bd9d24ee345e51046e5d39 (patch)
treec2c4b65a8434d77a3b2d9df032acaca673c35095 /searchlib
parent79eb4da646da25b9734a1ae8eb1222d44cc85061 (diff)
std::make_shared
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/vespa/searchlib/attribute/createsinglefastsearch.cpp33
-rw-r--r--searchlib/src/vespa/searchlib/attribute/createsinglestd.cpp49
-rw-r--r--searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.hpp12
-rw-r--r--searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.hpp2
4 files changed, 32 insertions, 64 deletions
diff --git a/searchlib/src/vespa/searchlib/attribute/createsinglefastsearch.cpp b/searchlib/src/vespa/searchlib/attribute/createsinglefastsearch.cpp
index cdb7e1807ba..0e1cfaa3c09 100644
--- a/searchlib/src/vespa/searchlib/attribute/createsinglefastsearch.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/createsinglefastsearch.cpp
@@ -5,15 +5,9 @@
#include "floatbase.h"
#include "defines.h"
#include "singlestringattribute.h"
+#include "singleboolattribute.h"
#include "singlestringpostattribute.hpp"
-#include "singlenumericenumattribute.hpp"
#include "singlenumericpostattribute.hpp"
-#include "enumstore.hpp"
-#include "enumattribute.hpp"
-#include "singleenumattribute.hpp"
-
-#include <vespa/log/log.h>
-LOG_SETUP(".searchlib.attribute.create_single_fast_search");
#define INTPOSTING(T) SingleValueNumericPostingAttribute< ENUM_ATTRIBUTE(IntegerAttributeTemplate<T>) >
#define FLOATPOSTING(T) SingleValueNumericPostingAttribute< ENUM_ATTRIBUTE(FloatingPointAttributeTemplate<T>) >
@@ -27,37 +21,30 @@ AttributeFactory::createSingleFastSearch(stringref name, const Config & info)
{
assert(info.collectionType().type() == attribute::CollectionType::SINGLE);
assert(info.fastSearch());
- AttributeVector::SP ret;
switch(info.basicType().type()) {
case BasicType::BOOL:
+ return std::make_shared<SingleBoolAttribute>(name, info.getGrowStrategy());
case BasicType::UINT2:
case BasicType::UINT4:
break;
case BasicType::INT8:
- ret.reset(new INTPOSTING(int8_t)(name, info));
- break;
+ return std::make_shared<INTPOSTING(int8_t)>(name, info);
case BasicType::INT16:
- ret.reset(new INTPOSTING(int16_t)(name, info));
- break;
+ return std::make_shared<INTPOSTING(int16_t)>(name, info);
case BasicType::INT32:
- ret.reset(new INTPOSTING(int32_t)(name, info));
- break;
+ return std::make_shared<INTPOSTING(int32_t)>(name, info);
case BasicType::INT64:
- ret.reset(new INTPOSTING(int64_t)(name, info));
- break;
+ return std::make_shared<INTPOSTING(int64_t)>(name, info);
case BasicType::FLOAT:
- ret.reset(new FLOATPOSTING(float)(name, info));
- break;
+ return std::make_shared<FLOATPOSTING(float)>(name, info);
case BasicType::DOUBLE:
- ret.reset(new FLOATPOSTING(double)(name, info));
- break;
+ return std::make_shared<FLOATPOSTING(double)>(name, info);
case BasicType::STRING:
- ret.reset(new SingleValueStringPostingAttribute(name, info));
- break;
+ return std::make_shared<SingleValueStringPostingAttribute>(name, info);
default:
break;
}
- return ret;
+ return AttributeVector::SP();
}
}
diff --git a/searchlib/src/vespa/searchlib/attribute/createsinglestd.cpp b/searchlib/src/vespa/searchlib/attribute/createsinglestd.cpp
index 7bd96b5cbb2..a0cf47f64e0 100644
--- a/searchlib/src/vespa/searchlib/attribute/createsinglestd.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/createsinglestd.cpp
@@ -4,16 +4,12 @@
#include "predicate_attribute.h"
#include "singlesmallnumericattribute.h"
#include "reference_attribute.h"
-#include "attributevector.hpp"
#include "singlenumericattribute.hpp"
#include "singlestringattribute.h"
#include "singleboolattribute.h"
#include <vespa/searchlib/tensor/generic_tensor_attribute.h>
#include <vespa/searchlib/tensor/dense_tensor_attribute.h>
-#include <vespa/log/log.h>
-LOG_SETUP(".searchlib.attribute.create_single_std");
-
namespace search {
using attribute::BasicType;
@@ -22,55 +18,42 @@ AttributeVector::SP
AttributeFactory::createSingleStd(stringref name, const Config & info)
{
assert(info.collectionType().type() == attribute::CollectionType::SINGLE);
- AttributeVector::SP ret;
switch(info.basicType().type()) {
case BasicType::BOOL:
- ret.reset(new SingleBoolAttribute(name, info.getGrowStrategy()));
- break;
+ return std::make_shared<SingleBoolAttribute>(name, info.getGrowStrategy());
case BasicType::UINT2:
- ret.reset(new SingleValueSemiNibbleNumericAttribute(name, info.getGrowStrategy()));
- break;
+ return std::make_shared<SingleValueSemiNibbleNumericAttribute>(name, info.getGrowStrategy());
case BasicType::UINT4:
- ret.reset(new SingleValueNibbleNumericAttribute(name, info.getGrowStrategy()));
- break;
+ return std::make_shared<SingleValueNibbleNumericAttribute>(name, info.getGrowStrategy());
case BasicType::INT8:
- ret.reset(new SingleValueNumericAttribute<IntegerAttributeTemplate<int8_t> >(name, info));
- break;
+ return std::make_shared<SingleValueNumericAttribute<IntegerAttributeTemplate<int8_t>>>(name, info);
case BasicType::INT16:
// XXX: Unneeded since we don't have short document fields in java.
- ret.reset(new SingleValueNumericAttribute<IntegerAttributeTemplate<int16_t> >(name, info));
- break;
+ return std::make_shared<SingleValueNumericAttribute<IntegerAttributeTemplate<int16_t>>>(name, info);
case BasicType::INT32:
- ret.reset(new SingleValueNumericAttribute<IntegerAttributeTemplate<int32_t> >(name, info));
- break;
+ return std::make_shared<SingleValueNumericAttribute<IntegerAttributeTemplate<int32_t>>>(name, info);
case BasicType::INT64:
- ret.reset(new SingleValueNumericAttribute<IntegerAttributeTemplate<int64_t> >(name, info));
- break;
+ return std::make_shared<SingleValueNumericAttribute<IntegerAttributeTemplate<int64_t>>>(name, info);
case BasicType::FLOAT:
- ret.reset(new SingleValueNumericAttribute<FloatingPointAttributeTemplate<float> >(name, info));
- break;
+ return std::make_shared<SingleValueNumericAttribute<FloatingPointAttributeTemplate<float>>>(name, info);
case BasicType::DOUBLE:
- ret.reset(new SingleValueNumericAttribute<FloatingPointAttributeTemplate<double> >(name, info));
- break;
+ return std::make_shared<SingleValueNumericAttribute<FloatingPointAttributeTemplate<double>>>(name, info);
case BasicType::STRING:
- ret.reset(new SingleValueStringAttribute(name, info));
- break;
+ return std::make_shared<SingleValueStringAttribute>(name, info);
case BasicType::PREDICATE:
- ret.reset(new PredicateAttribute(name, info));
- break;
+ return std::make_shared<PredicateAttribute>(name, info);
case BasicType::TENSOR:
if (info.tensorType().is_dense()) {
- ret.reset(new tensor::DenseTensorAttribute(name, info));
+ return std::make_shared<tensor::DenseTensorAttribute>(name, info);
} else {
- ret.reset(new tensor::GenericTensorAttribute(name, info));
+ return std::make_shared<tensor::GenericTensorAttribute>(name, info);
}
- break;
case BasicType::REFERENCE:
- ret = std::make_shared<attribute::ReferenceAttribute>(name, info);
- break;
+ return std::make_shared<attribute::ReferenceAttribute>(name, info);
default:
break;
}
- return ret;
+ return AttributeVector::SP();
}
+
} // namespace search
diff --git a/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.hpp b/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.hpp
index ca6b6caba32..b330be3a2bb 100644
--- a/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.hpp
@@ -2,10 +2,10 @@
#pragma once
-#include <vespa/searchlib/attribute/singlenumericpostattribute.h>
-#include <vespa/searchlib/attribute/enumstore.h>
-#include <vespa/searchlib/attribute/enumcomparator.h>
-#include <vespa/searchlib/attribute/singlenumericenumattribute.hpp>
+#include "singlenumericpostattribute.h"
+#include "enumstore.h"
+#include "enumcomparator.h"
+#include "singlenumericenumattribute.hpp"
namespace search {
@@ -141,9 +141,7 @@ AttributeVector::SearchContext::UP
SingleValueNumericPostingAttribute<B>::getSearch(QueryTermSimple::UP qTerm,
const attribute::SearchContextParams & params) const
{
- return std::make_unique<SinglePostingSearchContext>(std::move(qTerm),
- params,
- *this);
+ return std::make_unique<SinglePostingSearchContext>(std::move(qTerm), params, *this);
}
} // namespace search
diff --git a/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.hpp b/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.hpp
index 59a5a9b8cac..cdf1acedb24 100644
--- a/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.hpp
@@ -2,7 +2,7 @@
#pragma once
-#include <vespa/searchlib/attribute/singlestringpostattribute.h>
+#include "singlestringpostattribute.h"
#include <vespa/searchlib/query/query_term_ucs4.h>
namespace search {