aboutsummaryrefslogtreecommitdiffstats
path: root/streamingvisitors
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2020-03-09 14:20:42 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2020-03-09 14:20:42 +0000
commit62a75e6a91a54e351a9f46af353598a2b68a06a5 (patch)
tree624d0a1f67b5b5e4ae0a21683f68c6a480987c47 /streamingvisitors
parentd5a0a4fa7f5c48ca650579d79f1a459bc1d9828f (diff)
Use std::make_shared and remove cast not needed.
Diffstat (limited to 'streamingvisitors')
-rw-r--r--streamingvisitors/src/vespa/searchvisitor/searchvisitor.cpp21
1 files changed, 9 insertions, 12 deletions
diff --git a/streamingvisitors/src/vespa/searchvisitor/searchvisitor.cpp b/streamingvisitors/src/vespa/searchvisitor/searchvisitor.cpp
index 7c4e8834104..b220344edba 100644
--- a/streamingvisitors/src/vespa/searchvisitor/searchvisitor.cpp
+++ b/streamingvisitors/src/vespa/searchvisitor/searchvisitor.cpp
@@ -70,34 +70,31 @@ createMultiValueAttribute(const vespalib::string & name, const document::FieldVa
}
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() == 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)));
+ return arrayType ? std::make_shared<search::MultiIntegerExtAttribute>(name)
+ : std::make_shared<search::WeightedSetIntegerExtAttribute>(name));
} 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)));
+ return arrayType ? std::make_shared<search::MultiFloatExtAttribute>(name)
+ : std::make_shared<search::WeightedSetFloatExtAttribute>(name));
} else if (ndt->getId() == DataType::T_STRING) {
- attr.reset(arrayType ? static_cast<AttributeVector *>(new search::MultiStringExtAttribute(name))
- : static_cast<AttributeVector *>(new search::WeightedSetStringExtAttribute(name)));
+ return arrayType ? std::make_shared<search::MultiStringExtAttribute>(name)
+ : std:.make_shared<search::WeightedSetStringExtAttribute>(name));
} else {
LOG(debug, "Can not make an multivalue attribute out of %s with data type '%s' (%s)",
name.c_str(), ndt->getName().c_str(), fv.getClass().name());
}
- return attr;
+ return AttributeVector::SP();
}
AttributeVector::SP
createAttribute(const vespalib::string & name, const document::FieldValue & fv)
{
LOG(debug, "Create single value attribute '%s' with value type '%s'", name.c_str(), fv.getClass().name());
- AttributeVector::SP attr;
-
if (fv.inherits(document::ByteFieldValue::classId) || fv.inherits(document::IntFieldValue::classId) || fv.inherits(document::LongFieldValue::classId)) {
return std::make_shared<search::SingleIntegerExtAttribute>(name);
} else if (fv.inherits(document::DoubleFieldValue::classId) || fv.inherits(document::FloatFieldValue::classId)) {
@@ -107,7 +104,7 @@ createAttribute(const vespalib::string & name, const document::FieldValue & fv)
} else {
LOG(debug, "Can not make an attribute out of %s of type '%s'.", name.c_str(), fv.getClass().name());
}
- return attr;
+ return AttributeVector::SP();
}
SearchVisitor::SummaryGenerator::SummaryGenerator() :
@@ -242,7 +239,7 @@ void SearchVisitor::init(const Parameters & params)
if (params.lookup("rankproperties", valueRef) && ! valueRef.empty()) {
LOG(spam, "Received rank properties of %zd bytes", valueRef.size());
- uint32_t len = uint32_t(valueRef.size());
+ uint32_t len = valueRef.size();
char * data = const_cast<char *>(valueRef.data());
FNET_DataBuffer src(data, len);
uint32_t cnt = src.ReadInt32();