summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--searchcore/src/tests/proton/documentdb/configvalidator/configvalidator_test.cpp37
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/attribute_config_validator.cpp33
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/attribute_config_validator.h5
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/config_validator_result.h34
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/config_validator_result_type.h27
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/configvalidator.cpp4
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/configvalidator.h41
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/ddbstate.cpp13
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/ddbstate.h5
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/documentdb.cpp5
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/documentdb.h4
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/schema_config_validator.cpp102
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/schema_config_validator.h6
13 files changed, 184 insertions, 132 deletions
diff --git a/searchcore/src/tests/proton/documentdb/configvalidator/configvalidator_test.cpp b/searchcore/src/tests/proton/documentdb/configvalidator/configvalidator_test.cpp
index 70045537894..6ca02a7a4c5 100644
--- a/searchcore/src/tests/proton/documentdb/configvalidator/configvalidator_test.cpp
+++ b/searchcore/src/tests/proton/documentdb/configvalidator/configvalidator_test.cpp
@@ -12,16 +12,19 @@ typedef Schema::AttributeField AField;
typedef Schema::IndexField IField;
typedef Schema::SummaryField SField;
-const ConfigValidator::ResultType OK = ConfigValidator::OK;
-const ConfigValidator::ResultType DTC = ConfigValidator::DATA_TYPE_CHANGED;
-const ConfigValidator::ResultType CTC = ConfigValidator::COLLECTION_TYPE_CHANGED;
-const ConfigValidator::ResultType IAA = ConfigValidator::INDEX_ASPECT_ADDED;
-const ConfigValidator::ResultType IAR = ConfigValidator::INDEX_ASPECT_REMOVED;
-const ConfigValidator::ResultType AAA = ConfigValidator::ATTRIBUTE_ASPECT_ADDED;
-const ConfigValidator::ResultType AAR = ConfigValidator::ATTRIBUTE_ASPECT_REMOVED;
-const ConfigValidator::ResultType AFAA = ConfigValidator::ATTRIBUTE_FAST_ACCESS_ADDED;
-const ConfigValidator::ResultType AFAR = ConfigValidator::ATTRIBUTE_FAST_ACCESS_REMOVED;
-const ConfigValidator::ResultType ATTC = ConfigValidator::ATTRIBUTE_TENSOR_TYPE_CHANGED;
+using proton::configvalidator::ResultType;
+using proton::configvalidator::Result;
+
+const ResultType OK = ResultType::OK;
+const ResultType DTC = ResultType::DATA_TYPE_CHANGED;
+const ResultType CTC = ResultType::COLLECTION_TYPE_CHANGED;
+const ResultType IAA = ResultType::INDEX_ASPECT_ADDED;
+const ResultType IAR = ResultType::INDEX_ASPECT_REMOVED;
+const ResultType AAA = ResultType::ATTRIBUTE_ASPECT_ADDED;
+const ResultType AAR = ResultType::ATTRIBUTE_ASPECT_REMOVED;
+const ResultType AFAA = ResultType::ATTRIBUTE_FAST_ACCESS_ADDED;
+const ResultType AFAR = ResultType::ATTRIBUTE_FAST_ACCESS_REMOVED;
+const ResultType ATTC = ResultType::ATTRIBUTE_TENSOR_TYPE_CHANGED;
enum FType {
INDEX,
@@ -29,6 +32,16 @@ enum FType {
SUMMARY
};
+namespace std {
+
+std::ostream &operator<<(std::ostream &os, const ResultType &value)
+{
+ os << static_cast<int>(value);
+ return os;
+}
+
+}
+
struct SchemaBuilder
{
Schema _schema;
@@ -70,7 +83,7 @@ createc(FType ftype, schema::CollectionType ctype)
return create(ftype, schema::STRING, ctype);
}
-ConfigValidator::ResultType
+ResultType
checkSchema(const Schema &newSchema,
const Schema &oldSchema,
const Schema &oldHistory)
@@ -79,7 +92,7 @@ checkSchema(const Schema &newSchema,
ConfigValidator::Config(oldSchema, AttributesConfig()), oldHistory).type();
}
-ConfigValidator::ResultType
+ResultType
checkAttribute(const AttributesConfig &newCfg,
const AttributesConfig &oldCfg)
{
diff --git a/searchcore/src/vespa/searchcore/proton/server/attribute_config_validator.cpp b/searchcore/src/vespa/searchcore/proton/server/attribute_config_validator.cpp
index 39883168984..0c29d3436bc 100644
--- a/searchcore/src/vespa/searchcore/proton/server/attribute_config_validator.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/attribute_config_validator.cpp
@@ -7,51 +7,52 @@ LOG_SETUP(".proton.server.attribute_config_validator");
#include <vespa/eval/eval/value_type.h>
#include <vespa/vespalib/util/stringfmt.h>
+
using vespa::config::search::AttributesConfig;
using vespalib::make_string;
using vespalib::eval::ValueType;
+using proton::configvalidator::ResultType;
+using proton::configvalidator::Result;
namespace proton {
-typedef ConfigValidator CV;
-
namespace {
-CV::Result
+Result
checkFastAccess(const AttributesConfig &cfg1,
const AttributesConfig &cfg2,
- CV::ResultType type,
+ ResultType type,
const vespalib::string &typeStr)
{
for (const auto &attr1 : cfg1.attribute) {
if (attr1.fastaccess) {
for (const auto &attr2 : cfg2.attribute) {
if (attr1.name == attr2.name && !attr2.fastaccess) {
- return CV::Result(type,
+ return Result(type,
make_string("Trying to %s 'fast-access' to attribute '%s'",
typeStr.c_str(), attr1.name.c_str()));
}
}
}
}
- return CV::Result();
+ return Result();
}
-CV::Result
+Result
checkFastAccessAdded(const AttributesConfig &newCfg,
const AttributesConfig &oldCfg)
{
- return checkFastAccess(newCfg, oldCfg, CV::ATTRIBUTE_FAST_ACCESS_ADDED, "add");
+ return checkFastAccess(newCfg, oldCfg, ResultType::ATTRIBUTE_FAST_ACCESS_ADDED, "add");
}
-CV::Result
+Result
checkFastAccessRemoved(const AttributesConfig &newCfg,
const AttributesConfig &oldCfg)
{
- return checkFastAccess(oldCfg, newCfg, CV::ATTRIBUTE_FAST_ACCESS_REMOVED, "remove");
+ return checkFastAccess(oldCfg, newCfg, ResultType::ATTRIBUTE_FAST_ACCESS_REMOVED, "remove");
}
-CV::Result
+Result
checkTensorTypeChanged(const AttributesConfig &newCfg,
const AttributesConfig &oldCfg)
{
@@ -60,26 +61,26 @@ checkTensorTypeChanged(const AttributesConfig &newCfg,
if ((newAttr.name == oldAttr.name) &&
(ValueType::from_spec(newAttr.tensortype) != ValueType::from_spec(oldAttr.tensortype)))
{
- return CV::Result(CV::ATTRIBUTE_TENSOR_TYPE_CHANGED,
+ return Result(ResultType::ATTRIBUTE_TENSOR_TYPE_CHANGED,
make_string("Tensor type has changed from '%s' -> '%s' for attribute '%s'",
oldAttr.tensortype.c_str(), newAttr.tensortype.c_str(), newAttr.name.c_str()));
}
}
}
- return CV::Result();
+ return Result();
}
}
-CV::Result
+Result
AttributeConfigValidator::validate(const AttributesConfig &newCfg,
const AttributesConfig &oldCfg)
{
- CV::Result res;
+ Result res;
if (!(res = checkFastAccessAdded(newCfg, oldCfg)).ok()) return res;
if (!(res = checkFastAccessRemoved(newCfg, oldCfg)).ok()) return res;
if (!(res = checkTensorTypeChanged(newCfg, oldCfg)).ok()) return res;
- return CV::Result();
+ return Result();
}
} // namespace proton
diff --git a/searchcore/src/vespa/searchcore/proton/server/attribute_config_validator.h b/searchcore/src/vespa/searchcore/proton/server/attribute_config_validator.h
index dd4ccbc51e8..76cabf8c4b2 100644
--- a/searchcore/src/vespa/searchcore/proton/server/attribute_config_validator.h
+++ b/searchcore/src/vespa/searchcore/proton/server/attribute_config_validator.h
@@ -2,7 +2,8 @@
#pragma once
-#include "configvalidator.h"
+#include "config_validator_result.h"
+#include <vespa/config-attributes.h>
namespace proton {
@@ -11,7 +12,7 @@ namespace proton {
**/
struct AttributeConfigValidator
{
- static ConfigValidator::Result
+ static configvalidator::Result
validate(const vespa::config::search::AttributesConfig &newCfg,
const vespa::config::search::AttributesConfig &oldCfg);
};
diff --git a/searchcore/src/vespa/searchcore/proton/server/config_validator_result.h b/searchcore/src/vespa/searchcore/proton/server/config_validator_result.h
new file mode 100644
index 00000000000..0d362f7d97e
--- /dev/null
+++ b/searchcore/src/vespa/searchcore/proton/server/config_validator_result.h
@@ -0,0 +1,34 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#pragma once
+
+#include "config_validator_result_type.h"
+#include <vespa/vespalib/stllike/string.h>
+
+namespace proton {
+namespace configvalidator {
+
+/*
+ * The result of a schema check, with message string for more detailed info.
+ */
+class Result
+{
+private:
+ ResultType _type;
+ vespalib::string _what;
+public:
+ Result()
+ : _type(ResultType::OK),
+ _what("")
+ {}
+ Result(ResultType type_, const vespalib::string &what_)
+ : _type(type_),
+ _what(what_)
+ {}
+ ResultType type() const { return _type; }
+ const vespalib::string &what() const { return _what; }
+ bool ok() const { return type() == ResultType::OK; }
+};
+
+} // namespace proton::configvalidator
+} // namespace proton
diff --git a/searchcore/src/vespa/searchcore/proton/server/config_validator_result_type.h b/searchcore/src/vespa/searchcore/proton/server/config_validator_result_type.h
new file mode 100644
index 00000000000..b114735319a
--- /dev/null
+++ b/searchcore/src/vespa/searchcore/proton/server/config_validator_result_type.h
@@ -0,0 +1,27 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#pragma once
+
+namespace proton {
+namespace configvalidator {
+
+/**
+ * The various results of a schema check.
+ * All but OK means that the new schema should be rejected.
+ */
+enum class ResultType
+{
+ OK,
+ DATA_TYPE_CHANGED,
+ COLLECTION_TYPE_CHANGED,
+ INDEX_ASPECT_ADDED,
+ INDEX_ASPECT_REMOVED,
+ ATTRIBUTE_ASPECT_ADDED,
+ ATTRIBUTE_ASPECT_REMOVED,
+ ATTRIBUTE_FAST_ACCESS_ADDED,
+ ATTRIBUTE_FAST_ACCESS_REMOVED,
+ ATTRIBUTE_TENSOR_TYPE_CHANGED
+};
+
+} // namespace proton::configvalidator
+} // namespace proton
diff --git a/searchcore/src/vespa/searchcore/proton/server/configvalidator.cpp b/searchcore/src/vespa/searchcore/proton/server/configvalidator.cpp
index 430b11c18b8..d57e6e256e4 100644
--- a/searchcore/src/vespa/searchcore/proton/server/configvalidator.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/configvalidator.cpp
@@ -8,9 +8,11 @@ LOG_SETUP(".proton.server.configvalidator");
#include "schema_config_validator.h"
#include "attribute_config_validator.h"
+using proton::configvalidator::Result;
+
namespace proton {
-ConfigValidator::Result
+Result
ConfigValidator::validate(const ConfigValidator::Config &newCfg,
const ConfigValidator::Config &oldCfg,
const search::index::Schema &oldHistory)
diff --git a/searchcore/src/vespa/searchcore/proton/server/configvalidator.h b/searchcore/src/vespa/searchcore/proton/server/configvalidator.h
index c4a189dd756..d659317e6bb 100644
--- a/searchcore/src/vespa/searchcore/proton/server/configvalidator.h
+++ b/searchcore/src/vespa/searchcore/proton/server/configvalidator.h
@@ -2,6 +2,8 @@
#pragma once
+#include "config_validator_result_type.h"
+#include "config_validator_result.h"
#include <vespa/searchcommon/common/schema.h>
#include <vespa/config-attributes.h>
@@ -12,43 +14,6 @@ namespace proton {
**/
class ConfigValidator {
public:
- /**
- * The various results of a schema check.
- * All but OK means that the new schema should be rejected.
- */
- enum ResultType
- {
- OK,
- DATA_TYPE_CHANGED,
- COLLECTION_TYPE_CHANGED,
- INDEX_ASPECT_ADDED,
- INDEX_ASPECT_REMOVED,
- ATTRIBUTE_ASPECT_ADDED,
- ATTRIBUTE_ASPECT_REMOVED,
- ATTRIBUTE_FAST_ACCESS_ADDED,
- ATTRIBUTE_FAST_ACCESS_REMOVED,
- ATTRIBUTE_TENSOR_TYPE_CHANGED
- };
-
- class Result
- {
- private:
- ResultType _type;
- vespalib::string _what;
- public:
- Result()
- : _type(OK),
- _what("")
- {}
- Result(ResultType type_, const vespalib::string &what_)
- : _type(type_),
- _what(what_)
- {}
- ResultType type() const { return _type; }
- const vespalib::string &what() const { return _what; }
- bool ok() const { return type() == OK; }
- };
-
class Config
{
private:
@@ -71,7 +36,7 @@ public:
/**
* Check if new schema can be applied or not.
*/
- static Result
+ static configvalidator::Result
validate(const Config &newCfg,
const Config &oldCfg,
const search::index::Schema &oldHistory);
diff --git a/searchcore/src/vespa/searchcore/proton/server/ddbstate.cpp b/searchcore/src/vespa/searchcore/proton/server/ddbstate.cpp
index 8ffa2c88bab..b190d5e32dc 100644
--- a/searchcore/src/vespa/searchcore/proton/server/ddbstate.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/ddbstate.cpp
@@ -5,6 +5,7 @@
LOG_SETUP(".proton.server.ddbstate");
#include "ddbstate.h"
+using proton::configvalidator::ResultType;
namespace proton {
@@ -164,7 +165,7 @@ DDBState::clearRejectedConfig()
DDBState::ConfigState
-DDBState::calcConfigState(const ConfigValidator::ResultType &cvr)
+DDBState::calcConfigState(const ResultType &cvr)
{
if (_state < State::APPLY_LIVE_CONFIG) {
// Config has been accepted, placed in transaction log and
@@ -173,12 +174,12 @@ DDBState::calcConfigState(const ConfigValidator::ResultType &cvr)
return ConfigState::OK;
}
switch (cvr) {
- case ConfigValidator::ResultType::OK:
+ case ResultType::OK:
return ConfigState::OK;
- case ConfigValidator::ResultType::ATTRIBUTE_ASPECT_ADDED:
- case ConfigValidator::ResultType::ATTRIBUTE_FAST_ACCESS_ADDED:
- case ConfigValidator::ResultType::ATTRIBUTE_ASPECT_REMOVED:
- case ConfigValidator::ResultType::ATTRIBUTE_FAST_ACCESS_REMOVED:
+ case ResultType::ATTRIBUTE_ASPECT_ADDED:
+ case ResultType::ATTRIBUTE_FAST_ACCESS_ADDED:
+ case ResultType::ATTRIBUTE_ASPECT_REMOVED:
+ case ResultType::ATTRIBUTE_FAST_ACCESS_REMOVED:
if (_state == State::APPLY_LIVE_CONFIG) {
return ConfigState::OK;
}
diff --git a/searchcore/src/vespa/searchcore/proton/server/ddbstate.h b/searchcore/src/vespa/searchcore/proton/server/ddbstate.h
index 26cb85f3b39..4371e80ddcd 100644
--- a/searchcore/src/vespa/searchcore/proton/server/ddbstate.h
+++ b/searchcore/src/vespa/searchcore/proton/server/ddbstate.h
@@ -1,7 +1,8 @@
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
-#include "configvalidator.h"
+#include "config_validator_result_type.h"
+#include <vespa/vespalib/stllike/string.h>
#include <mutex>
#include <condition_variable>
@@ -159,7 +160,7 @@ public:
setConfigState(ConfigState newConfigState);
ConfigState
- calcConfigState(const ConfigValidator::ResultType &cvr);
+ calcConfigState(const configvalidator::ResultType &cvr);
void
waitForOnlineState();
diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp b/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp
index dfd337fc9fe..547c269dc68 100644
--- a/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp
@@ -10,6 +10,7 @@
#include "lid_space_compaction_handler.h"
#include "maintenance_jobs_injector.h"
#include "reconfig_params.h"
+#include "configvalidator.h"
#include <vespa/searchcommon/common/schemaconfigurer.h>
#include <vespa/searchcore/proton/attribute/attribute_writer.h>
#include <vespa/searchcore/proton/attribute/imported_attributes_repo.h>
@@ -389,7 +390,7 @@ DocumentDB::performReconfig(DocumentDBConfig::SP configSnapshot)
void
DocumentDB::handleRejectedConfig(DocumentDBConfig::SP &configSnapshot,
- const ConfigValidator::Result &cvr,
+ const configvalidator::Result &cvr,
const DDBState::ConfigState &cs)
{
_state.setConfigState(cs);
@@ -467,7 +468,7 @@ DocumentDB::applyConfig(DocumentDBConfig::SP configSnapshot,
}
} else {
oldSchema = _activeConfigSnapshot->getSchemaSP();
- ConfigValidator::Result cvr =
+ configvalidator::Result cvr =
ConfigValidator::validate(ConfigValidator::Config
(*configSnapshot->getSchemaSP(),
configSnapshot->getAttributesConfig()),
diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdb.h b/searchcore/src/vespa/searchcore/proton/server/documentdb.h
index 48fd3e66ed6..a4b2bfb3da5 100644
--- a/searchcore/src/vespa/searchcore/proton/server/documentdb.h
+++ b/searchcore/src/vespa/searchcore/proton/server/documentdb.h
@@ -61,6 +61,8 @@ namespace proton {
class MetricsWireService;
class IDocumentDBOwner;
+namespace configvalidator { class Result; }
+
/**
* The document database contains all the necessary structures required per
* document type. It has an internal single-threaded Executor to process input
@@ -165,7 +167,7 @@ private:
void
handleRejectedConfig(DocumentDBConfig::SP &configSnapshot,
- const ConfigValidator::Result &cvr,
+ const configvalidator::Result &cvr,
const DDBState::ConfigState &cs);
void applySubDBConfig(const DocumentDBConfig &newConfigSnapshot, SerialNum serialNum, const ReconfigParams &params);
void applyConfig(DocumentDBConfig::SP configSnapshot, SerialNum serialNum);
diff --git a/searchcore/src/vespa/searchcore/proton/server/schema_config_validator.cpp b/searchcore/src/vespa/searchcore/proton/server/schema_config_validator.cpp
index f970161bfdb..5d4beb8c045 100644
--- a/searchcore/src/vespa/searchcore/proton/server/schema_config_validator.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/schema_config_validator.cpp
@@ -3,12 +3,16 @@
#include <vespa/fastos/fastos.h>
#include "schema_config_validator.h"
#include <vespa/vespalib/util/stringfmt.h>
+#include <vespa/searchcommon/common/schema.h>
#include <vespa/log/log.h>
LOG_SETUP(".proton.server.schema_config_validator");
using namespace search::index;
using vespalib::make_string;
+using proton::configvalidator::ResultType;
+using proton::configvalidator::Result;
+
namespace proton {
namespace {
@@ -17,8 +21,6 @@ const vespalib::string INDEX_TYPE_NAME = "index";
const vespalib::string ATTRIBUTE_TYPE_NAME = "attribute";
const vespalib::string SUMMARY_TYPE_NAME = "summary";
-typedef ConfigValidator CV;
-
struct SchemaSpec
{
const Schema &_newSchema;
@@ -36,8 +38,8 @@ struct SchemaSpec
struct IndexChecker {
static vespalib::string TypeName;
- static CV::ResultType AspectAdded;
- static CV::ResultType AspectRemoved;
+ static ResultType AspectAdded;
+ static ResultType AspectRemoved;
static bool
inSchema(const vespalib::string &name,
@@ -59,13 +61,13 @@ struct IndexChecker {
}
};
vespalib::string IndexChecker::TypeName = INDEX_TYPE_NAME;
-CV::ResultType IndexChecker::AspectAdded = CV::INDEX_ASPECT_ADDED;
-CV::ResultType IndexChecker::AspectRemoved = CV::INDEX_ASPECT_REMOVED;
+ResultType IndexChecker::AspectAdded = ResultType::INDEX_ASPECT_ADDED;
+ResultType IndexChecker::AspectRemoved = ResultType::INDEX_ASPECT_REMOVED;
struct AttributeChecker {
static vespalib::string TypeName;
- static CV::ResultType AspectAdded;
- static CV::ResultType AspectRemoved;
+ static ResultType AspectAdded;
+ static ResultType AspectRemoved;
static bool
inSchema(const vespalib::string &name,
@@ -88,8 +90,8 @@ struct AttributeChecker {
}
};
vespalib::string AttributeChecker::TypeName = ATTRIBUTE_TYPE_NAME;
-CV::ResultType AttributeChecker::AspectAdded = CV::ATTRIBUTE_ASPECT_ADDED;
-CV::ResultType AttributeChecker::AspectRemoved = CV::ATTRIBUTE_ASPECT_REMOVED;
+ResultType AttributeChecker::AspectAdded = ResultType::ATTRIBUTE_ASPECT_ADDED;
+ResultType AttributeChecker::AspectRemoved = ResultType::ATTRIBUTE_ASPECT_REMOVED;
bool
unchangedAspects(const vespalib::string &fieldName,
@@ -110,37 +112,37 @@ unchangedAspects(const vespalib::string &fieldName,
}
template <typename Checker>
-CV::Result
+Result
checkAspectAdded(const Schema::Field &field,
const SchemaSpec &spec)
{
// Special check for undo scenarios.
if (unchangedAspects(field.getName(), spec._newSchema, spec._oldSchema, spec._oldHistory)) {
- return CV::Result();
+ return Result();
}
if (Checker::notInSchema(field.getName(), spec._oldSchema, spec._oldHistory)) {
- return CV::Result(Checker::AspectAdded,
+ return Result(Checker::AspectAdded,
make_string("Trying to add %s field `%s', but it has existed as a field before",
Checker::TypeName.c_str(), field.getName().c_str()));
}
- return CV::Result();
+ return Result();
}
template <typename Checker>
-CV::Result
+Result
checkAspectRemoved(const Schema::Field &field,
const SchemaSpec &spec)
{
// Special check for undo scenarios.
if (unchangedAspects(field.getName(), spec._newSchema, spec._oldSchema, spec._oldHistory)) {
- return CV::Result();
+ return Result();
}
if (Checker::inSchema(field.getName(), spec._oldSchema, spec._oldHistory)) {
- return CV::Result(Checker::AspectRemoved,
+ return Result(Checker::AspectRemoved,
make_string("Trying to remove %s field `%s', but it still exists as a field",
Checker::TypeName.c_str(), field.getName().c_str()));
}
- return CV::Result();
+ return Result();
}
struct IndexTraits
@@ -179,68 +181,68 @@ struct SummaryTraits
};
vespalib::string SummaryTraits::TypeName = SUMMARY_TYPE_NAME;
-CV::Result
+Result
checkDataTypeFunc(const Schema::Field &oldField,
const Schema::Field &newField,
const vespalib::string &fieldClass)
{
if (oldField.getDataType() != newField.getDataType()) {
- return CV::Result(CV::DATA_TYPE_CHANGED,
+ return Result(ResultType::DATA_TYPE_CHANGED,
make_string("Trying to add %s field `%s' of data type %s, "
"but it has been of of data type %s earlier",
fieldClass.c_str(), newField.getName().c_str(),
schema::getTypeName(newField.getDataType()).c_str(),
schema::getTypeName(oldField.getDataType()).c_str()));
}
- return CV::Result();
+ return Result();
}
-CV::Result
+Result
checkCollectionTypeFunc(const Schema::Field &oldField,
const Schema::Field &newField,
const vespalib::string &fieldClass)
{
if (oldField.getCollectionType() != newField.getCollectionType()) {
- return CV::Result(CV::COLLECTION_TYPE_CHANGED,
+ return Result(ResultType::COLLECTION_TYPE_CHANGED,
make_string("Trying to add %s field `%s' of collection type %s, "
"but it has been of of collection type %s earlier",
fieldClass.c_str(), newField.getName().c_str(),
schema::getTypeName(newField.getCollectionType()).c_str(),
schema::getTypeName(oldField.getCollectionType()).c_str()));
}
- return CV::Result();
+ return Result();
}
template <typename T, typename CheckFunc>
-CV::Result
+Result
checkType(const Schema::Field &field, const Schema &oldSchema, CheckFunc func)
{
uint32_t oFieldId = T::getFieldId(field.getName(), oldSchema);
if (oFieldId != Schema::UNKNOWN_FIELD_ID) {
const Schema::Field &oField = T::getField(oFieldId, oldSchema);
- CV::Result res = func(oField, field, T::TypeName);
+ Result res = func(oField, field, T::TypeName);
if (!res.ok()) {
return res;
}
}
- return CV::Result();
+ return Result();
}
template <typename T, typename CheckFunc>
-CV::Result
+Result
checkType(const Schema::Field &field, const SchemaSpec &spec, CheckFunc func)
{
- CV::Result res;
+ Result res;
if (!(res = checkType<T>(field, spec._oldSchema, func)).ok()) return res;
if (!(res = checkType<T>(field, spec._oldHistory, func)).ok()) return res;
- return CV::Result();
+ return Result();
}
template <typename CheckFunc>
-CV::Result
+Result
checkType(const SchemaSpec &spec, CheckFunc func)
{
- CV::Result res;
+ Result res;
for (const auto &f : spec._newSchema.getIndexFields()) {
if (!(res = checkType<IndexTraits>(f, spec, func)).ok()) return res;
}
@@ -250,35 +252,35 @@ checkType(const SchemaSpec &spec, CheckFunc func)
for (const auto &f : spec._newSchema.getSummaryFields()) {
if (!(res = checkType<SummaryTraits>(f, spec, func)).ok()) return res;
}
- return CV::Result();
+ return Result();
}
-CV::Result
+Result
checkDataType(const SchemaSpec &spec)
{
return checkType(spec, checkDataTypeFunc);
}
-CV::Result
+Result
checkCollectionType(const SchemaSpec &spec)
{
return checkType(spec, checkCollectionTypeFunc);
}
-CV::Result
+Result
checkIndexAspectAdded(const SchemaSpec &spec)
{
- CV::Result res;
+ Result res;
for (const auto &f : spec._newSchema.getIndexFields()) {
if (!(res = checkAspectAdded<IndexChecker>(f, spec)).ok()) return res;
}
- return CV::Result();
+ return Result();
}
-CV::Result
+Result
checkIndexAspectRemoved(const SchemaSpec &spec)
{
- CV::Result res;
+ Result res;
for (const auto &f : spec._newSchema.getAttributeFields()) {
if (!spec._newSchema.isIndexField(f.getName())) {
if (!(res = checkAspectRemoved<IndexChecker>(f, spec)).ok()) return res;
@@ -289,23 +291,23 @@ checkIndexAspectRemoved(const SchemaSpec &spec)
if (!(res = checkAspectRemoved<IndexChecker>(f, spec)).ok()) return res;
}
}
- return CV::Result();
+ return Result();
}
-CV::Result
+Result
checkAttributeAspectAdded(const SchemaSpec &spec)
{
- CV::Result res;
+ Result res;
for (const auto &f : spec._newSchema.getAttributeFields()) {
if (!(res = checkAspectAdded<AttributeChecker>(f, spec)).ok()) return res;
}
- return CV::Result();
+ return Result();
}
-CV::Result
+Result
checkAttributeAspectRemoved(const SchemaSpec &spec)
{
- CV::Result res;
+ Result res;
// Note: remove as attribute is allowed when still existing as index
// so no need to iterator all index fields.
@@ -317,19 +319,19 @@ checkAttributeAspectRemoved(const SchemaSpec &spec)
if (!(res = checkAspectRemoved<AttributeChecker>(f, spec)).ok()) return res;
}
}
- return CV::Result();
+ return Result();
}
}
-CV::Result
+Result
SchemaConfigValidator::validate(const Schema &newSchema,
const Schema &oldSchema,
const Schema &oldHistory)
{
LOG(debug, "validate(): newSchema='%s', oldSchema='%s', oldHistory='%s'",
newSchema.toString().c_str(), oldSchema.toString().c_str(), oldHistory.toString().c_str());
- CV::Result res;
+ Result res;
SchemaSpec spec(newSchema, oldSchema, oldHistory);
if (!(res = checkDataType(spec)).ok()) return res;
if (!(res = checkCollectionType(spec)).ok()) return res;
@@ -337,7 +339,7 @@ SchemaConfigValidator::validate(const Schema &newSchema,
if (!(res = checkIndexAspectRemoved(spec)).ok()) return res;
if (!(res = checkAttributeAspectRemoved(spec)).ok()) return res;
if (!(res = checkAttributeAspectAdded(spec)).ok()) return res;
- return CV::Result();
+ return Result();
}
} // namespace proton
diff --git a/searchcore/src/vespa/searchcore/proton/server/schema_config_validator.h b/searchcore/src/vespa/searchcore/proton/server/schema_config_validator.h
index 5b301fd93ba..a97cd612f30 100644
--- a/searchcore/src/vespa/searchcore/proton/server/schema_config_validator.h
+++ b/searchcore/src/vespa/searchcore/proton/server/schema_config_validator.h
@@ -2,7 +2,9 @@
#pragma once
-#include "configvalidator.h"
+#include "config_validator_result.h"
+
+namespace search { namespace index { class Schema; } }
namespace proton {
@@ -11,7 +13,7 @@ namespace proton {
**/
struct SchemaConfigValidator
{
- static ConfigValidator::Result
+ static configvalidator::Result
validate(const search::index::Schema &newSchema,
const search::index::Schema &oldSchema,
const search::index::Schema &oldHistory);