summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-x[-rw-r--r--]bootstrap-cmake.sh11
-rw-r--r--build_settings.cmake2
-rw-r--r--config-model/src/main/java/com/yahoo/config/model/deploy/DeployState.java7
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/expressiontransforms/ConvertedModel.java (renamed from config-model/src/main/java/com/yahoo/searchdefinition/expressiontransforms/MLImportFeatureConverter.java)140
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/expressiontransforms/OnnxFeatureConverter.java39
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/expressiontransforms/TensorFlowFeatureConverter.java39
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionWithOnnxTestCase.java2
-rw-r--r--config/src/vespa/config/common/configkey.cpp16
-rw-r--r--config/src/vespa/config/common/configkey.h20
-rw-r--r--config/src/vespa/config/common/configparser.cpp10
-rw-r--r--config/src/vespa/config/common/configparser.h38
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java20
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/maintenance/FileDistributionMaintainer.java2
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/maintenance/SessionsMaintainer.java14
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ModelsBuilder.java9
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/session/RemoteSession.java1
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java11
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/JobType.java1
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/RunId.java2
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/stubs/MockTesterCloud.java14
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java40
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentSteps.java4
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java213
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java41
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/RunStatus.java1
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentExpirer.java2
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/JobRunner.java5
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java6
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java9
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTester.java19
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTester.java28
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunnerTest.java367
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ArtifactRepositoryMock.java6
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ConfigServerMock.java55
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/NodeRepositoryMock.java109
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/RoutingGeneratorMock.java36
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ApplicationOwnershipConfirmerTest.java4
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DnsMaintainerTest.java4
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/JobRunnerTest.java33
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/SystemUpgraderTest.java8
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java2
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiTest.java3
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/versions/VersionStatusTest.java5
-rw-r--r--dist/vespa.spec44
-rw-r--r--document/src/tests/documentselectparsertest.cpp4
-rw-r--r--document/src/vespa/document/annotation/spantree.h2
-rw-r--r--document/src/vespa/document/base/field.cpp4
-rw-r--r--document/src/vespa/document/base/field.h4
-rw-r--r--document/src/vespa/document/base/fieldpath.cpp2
-rw-r--r--document/src/vespa/document/base/fieldpath.h2
-rw-r--r--document/src/vespa/document/base/globalid.cpp2
-rw-r--r--document/src/vespa/document/base/globalid.h2
-rw-r--r--document/src/vespa/document/base/idstring.cpp42
-rw-r--r--document/src/vespa/document/base/idstring.h18
-rw-r--r--document/src/vespa/document/datatype/annotationreferencedatatype.cpp2
-rw-r--r--document/src/vespa/document/datatype/annotationreferencedatatype.h2
-rw-r--r--document/src/vespa/document/datatype/annotationtype.h2
-rw-r--r--document/src/vespa/document/datatype/arraydatatype.cpp2
-rw-r--r--document/src/vespa/document/datatype/arraydatatype.h2
-rw-r--r--document/src/vespa/document/datatype/collectiondatatype.cpp4
-rw-r--r--document/src/vespa/document/datatype/collectiondatatype.h4
-rw-r--r--document/src/vespa/document/datatype/datatype.cpp10
-rw-r--r--document/src/vespa/document/datatype/datatype.h8
-rw-r--r--document/src/vespa/document/datatype/documenttype.cpp12
-rw-r--r--document/src/vespa/document/datatype/documenttype.h12
-rw-r--r--document/src/vespa/document/datatype/mapdatatype.cpp4
-rw-r--r--document/src/vespa/document/datatype/mapdatatype.h4
-rw-r--r--document/src/vespa/document/datatype/primitivedatatype.cpp2
-rw-r--r--document/src/vespa/document/datatype/primitivedatatype.h2
-rw-r--r--document/src/vespa/document/datatype/referencedatatype.cpp2
-rw-r--r--document/src/vespa/document/datatype/referencedatatype.h2
-rw-r--r--document/src/vespa/document/datatype/structdatatype.cpp8
-rw-r--r--document/src/vespa/document/datatype/structdatatype.h8
-rw-r--r--document/src/vespa/document/datatype/structureddatatype.cpp10
-rw-r--r--document/src/vespa/document/datatype/structureddatatype.h12
-rw-r--r--document/src/vespa/document/datatype/weightedsetdatatype.cpp2
-rw-r--r--document/src/vespa/document/datatype/weightedsetdatatype.h2
-rw-r--r--document/src/vespa/document/fieldset/fieldsetrepo.cpp8
-rw-r--r--document/src/vespa/document/fieldset/fieldsetrepo.h2
-rw-r--r--document/src/vespa/document/fieldvalue/arrayfieldvalue.cpp2
-rw-r--r--document/src/vespa/document/fieldvalue/arrayfieldvalue.h2
-rw-r--r--document/src/vespa/document/fieldvalue/collectionfieldvalue.h6
-rw-r--r--document/src/vespa/document/fieldvalue/document.cpp4
-rw-r--r--document/src/vespa/document/fieldvalue/document.h4
-rw-r--r--document/src/vespa/document/fieldvalue/fieldvalue.cpp2
-rw-r--r--document/src/vespa/document/fieldvalue/fieldvalue.h2
-rw-r--r--document/src/vespa/document/fieldvalue/literalfieldvalue.cpp2
-rw-r--r--document/src/vespa/document/fieldvalue/literalfieldvalue.h8
-rw-r--r--document/src/vespa/document/fieldvalue/numericfieldvalue.h2
-rw-r--r--document/src/vespa/document/fieldvalue/numericfieldvalue.hpp2
-rw-r--r--document/src/vespa/document/fieldvalue/stringfieldvalue.cpp6
-rw-r--r--document/src/vespa/document/fieldvalue/stringfieldvalue.h4
-rw-r--r--document/src/vespa/document/fieldvalue/structfieldvalue.cpp4
-rw-r--r--document/src/vespa/document/fieldvalue/structfieldvalue.h4
-rw-r--r--document/src/vespa/document/fieldvalue/structuredfieldvalue.cpp12
-rw-r--r--document/src/vespa/document/fieldvalue/structuredfieldvalue.h14
-rw-r--r--document/src/vespa/document/fieldvalue/structuredfieldvalue.hpp2
-rw-r--r--document/src/vespa/document/fieldvalue/weightedsetfieldvalue.h8
-rw-r--r--document/src/vespa/document/repo/documenttyperepo.cpp8
-rw-r--r--document/src/vespa/document/repo/documenttyperepo.h4
-rw-r--r--document/src/vespa/document/select/branch.h2
-rw-r--r--document/src/vespa/document/select/doctype.cpp4
-rw-r--r--document/src/vespa/document/select/doctype.h2
-rw-r--r--document/src/vespa/document/select/invalidconstant.cpp2
-rw-r--r--document/src/vespa/document/select/invalidconstant.h2
-rw-r--r--document/src/vespa/document/select/node.h2
-rw-r--r--document/src/vespa/document/select/operator.cpp14
-rw-r--r--document/src/vespa/document/select/operator.h16
-rw-r--r--document/src/vespa/document/select/simpleparser.cpp10
-rw-r--r--document/src/vespa/document/select/simpleparser.h16
-rw-r--r--document/src/vespa/document/select/value.cpp2
-rw-r--r--document/src/vespa/document/select/value.h2
-rw-r--r--document/src/vespa/document/select/valuenodes.cpp12
-rw-r--r--document/src/vespa/document/select/valuenodes.h10
-rw-r--r--document/src/vespa/document/serialization/vespadocumentdeserializer.cpp2
-rw-r--r--document/src/vespa/document/util/stringutil.cpp2
-rw-r--r--document/src/vespa/document/util/stringutil.h2
-rw-r--r--documentapi/src/vespa/documentapi/messagebus/messages/getdocumentmessage.cpp2
-rw-r--r--documentapi/src/vespa/documentapi/messagebus/messages/getdocumentmessage.h2
-rw-r--r--documentapi/src/vespa/documentapi/messagebus/messages/visitor.h2
-rw-r--r--messagebus/src/vespa/messagebus/routing/errordirective.cpp2
-rw-r--r--messagebus/src/vespa/messagebus/routing/errordirective.h2
-rw-r--r--messagebus/src/vespa/messagebus/routing/policydirective.cpp2
-rw-r--r--messagebus/src/vespa/messagebus/routing/policydirective.h2
-rw-r--r--messagebus/src/vespa/messagebus/routing/routedirective.cpp2
-rw-r--r--messagebus/src/vespa/messagebus/routing/routedirective.h2
-rw-r--r--messagebus/src/vespa/messagebus/routing/routeparser.cpp12
-rw-r--r--messagebus/src/vespa/messagebus/routing/routeparser.h13
-rw-r--r--messagebus/src/vespa/messagebus/routing/tcpdirective.cpp2
-rw-r--r--messagebus/src/vespa/messagebus/routing/tcpdirective.h2
-rw-r--r--messagebus/src/vespa/messagebus/routing/verbatimdirective.cpp2
-rw-r--r--messagebus/src/vespa/messagebus/routing/verbatimdirective.h2
-rw-r--r--metrics/src/vespa/metrics/countmetric.h4
-rw-r--r--metrics/src/vespa/metrics/countmetricvalues.h4
-rw-r--r--metrics/src/vespa/metrics/countmetricvalues.hpp4
-rw-r--r--metrics/src/vespa/metrics/metric.h4
-rw-r--r--metrics/src/vespa/metrics/metricmanager.cpp2
-rw-r--r--metrics/src/vespa/metrics/metricset.cpp4
-rw-r--r--metrics/src/vespa/metrics/metricset.h4
-rw-r--r--metrics/src/vespa/metrics/metricvalueset.h4
-rw-r--r--metrics/src/vespa/metrics/summetric.h4
-rw-r--r--metrics/src/vespa/metrics/summetric.hpp4
-rw-r--r--metrics/src/vespa/metrics/valuemetric.h4
-rw-r--r--metrics/src/vespa/metrics/valuemetric.hpp4
-rw-r--r--metrics/src/vespa/metrics/valuemetricvalues.h6
-rw-r--r--metrics/src/vespa/metrics/valuemetricvalues.hpp6
-rw-r--r--node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperations.java3
-rw-r--r--node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImpl.java54
-rw-r--r--node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/maintenance/StorageMaintainer.java19
-rw-r--r--node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/maintenance/identity/AthenzCredentialsMaintainer.java98
-rw-r--r--node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/ContainerData.java20
-rw-r--r--node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentImpl.java17
-rw-r--r--node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImplTest.java45
-rw-r--r--node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/integrationTests/StorageMaintainerMock.java2
-rw-r--r--node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/StorageMaintainerTest.java31
-rw-r--r--node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentImplTest.java18
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/NodeRepository.java6
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/ApplicationMaintainer.java12
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/MetricsReporter.java9
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/NodeRepositoryMaintenance.java2
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/Status.java47
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/filter/NodeOsVersionFilter.java35
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDatabaseClient.java20
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/NodeSerializer.java5
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/OsVersions.java91
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodePatcher.java2
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodesApiHandler.java63
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodesResponse.java4
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/UpgradeResponse.java12
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/monitoring/MetricsReporterTest.java15
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/persistence/NodeTypeVersionsSerializerTest.java28
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/persistence/SerializationTest.java17
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/OsVersionsTest.java63
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/RestApiTest.java87
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/docker-node1-os-upgrade-complete.json72
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/docker-node1-os-upgrade.json71
-rw-r--r--searchcommon/src/vespa/searchcommon/common/datatype.cpp4
-rw-r--r--searchcommon/src/vespa/searchcommon/common/datatype.h4
-rw-r--r--searchcommon/src/vespa/searchcommon/common/schema.cpp24
-rw-r--r--searchcommon/src/vespa/searchcommon/common/schema.h30
-rw-r--r--searchcore/src/tests/proton/matching/matching_test.cpp101
-rw-r--r--searchcore/src/tests/proton/summaryengine/summaryengine.cpp4
-rw-r--r--searchcore/src/vespa/searchcore/fdispatch/search/query.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/fdispatch/search/query.h6
-rw-r--r--searchcore/src/vespa/searchcore/fdispatch/search/search_path.cpp6
-rw-r--r--searchcore/src/vespa/searchcore/fdispatch/search/search_path.h6
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/attribute_limiter.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/attribute_limiter.h2
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/match_tools.h2
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/query.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/query.h2
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/viewresolver.cpp6
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/viewresolver.h6
-rw-r--r--searchcorespi/src/vespa/searchcorespi/plugin/factoryloader.cpp10
-rw-r--r--searchcorespi/src/vespa/searchcorespi/plugin/factoryloader.h2
-rw-r--r--searchcorespi/src/vespa/searchcorespi/plugin/factoryregistry.cpp16
-rw-r--r--searchcorespi/src/vespa/searchcorespi/plugin/factoryregistry.h8
-rw-r--r--searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/integration/ml/TensorFlowImporter.java1
-rw-r--r--searchlib/src/tests/diskindex/bitvector/bitvector_test.cpp4
-rw-r--r--searchlib/src/tests/memoryindex/dictionary/dictionary_test.cpp4
-rw-r--r--searchlib/src/tests/memoryindex/document_remover/document_remover_test.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/attribute/attributevector.cpp14
-rw-r--r--searchlib/src/vespa/searchlib/attribute/attributevector.h20
-rw-r--r--searchlib/src/vespa/searchlib/bitcompression/compression.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/bitcompression/compression.h2
-rw-r--r--searchlib/src/vespa/searchlib/bitcompression/pagedict4.cpp30
-rw-r--r--searchlib/src/vespa/searchlib/bitcompression/pagedict4.h30
-rw-r--r--searchlib/src/vespa/searchlib/common/packets.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/common/packets.h30
-rw-r--r--searchlib/src/vespa/searchlib/diskindex/dictionarywordreader.h2
-rw-r--r--searchlib/src/vespa/searchlib/diskindex/diskindex.cpp4
-rw-r--r--searchlib/src/vespa/searchlib/diskindex/diskindex.h4
-rw-r--r--searchlib/src/vespa/searchlib/diskindex/fieldwriter.cpp4
-rw-r--r--searchlib/src/vespa/searchlib/diskindex/fieldwriter.h4
-rw-r--r--searchlib/src/vespa/searchlib/diskindex/indexbuilder.cpp14
-rw-r--r--searchlib/src/vespa/searchlib/diskindex/indexbuilder.h6
-rw-r--r--searchlib/src/vespa/searchlib/diskindex/pagedict4file.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/diskindex/pagedict4file.h2
-rw-r--r--searchlib/src/vespa/searchlib/diskindex/pagedict4randread.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/diskindex/pagedict4randread.h2
-rw-r--r--searchlib/src/vespa/searchlib/docstore/chunkformat.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/docstore/chunkformat.h2
-rw-r--r--searchlib/src/vespa/searchlib/docstore/summaryexceptions.cpp4
-rw-r--r--searchlib/src/vespa/searchlib/docstore/summaryexceptions.h2
-rw-r--r--searchlib/src/vespa/searchlib/engine/propertiesmap.cpp4
-rw-r--r--searchlib/src/vespa/searchlib/engine/propertiesmap.h4
-rw-r--r--searchlib/src/vespa/searchlib/engine/transportserver.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/engine/transportserver.h2
-rw-r--r--searchlib/src/vespa/searchlib/expression/attributenode.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/expression/attributenode.h2
-rw-r--r--searchlib/src/vespa/searchlib/expression/catserializer.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/expression/catserializer.h2
-rw-r--r--searchlib/src/vespa/searchlib/expression/documentfieldnode.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/expression/documentfieldnode.h2
-rw-r--r--searchlib/src/vespa/searchlib/expression/stringbucketresultnode.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/expression/stringbucketresultnode.h4
-rw-r--r--searchlib/src/vespa/searchlib/expression/stringresultnode.h4
-rw-r--r--searchlib/src/vespa/searchlib/features/attributefeature.cpp18
-rw-r--r--searchlib/src/vespa/searchlib/features/dotproductfeature.h6
-rw-r--r--searchlib/src/vespa/searchlib/features/tensor_from_weighted_set_feature.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/features/utils.h19
-rw-r--r--searchlib/src/vespa/searchlib/fef/blueprint.cpp8
-rw-r--r--searchlib/src/vespa/searchlib/fef/blueprint.h8
-rw-r--r--searchlib/src/vespa/searchlib/fef/blueprintresolver.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/fef/blueprintresolver.h2
-rw-r--r--searchlib/src/vespa/searchlib/fef/parametervalidator.h2
-rw-r--r--searchlib/src/vespa/searchlib/fef/properties.cpp28
-rw-r--r--searchlib/src/vespa/searchlib/fef/properties.h28
-rw-r--r--searchlib/src/vespa/searchlib/fef/test/ftlib.h2
-rw-r--r--searchlib/src/vespa/searchlib/index/dictionaryfile.h4
-rw-r--r--searchlib/src/vespa/searchlib/index/indexbuilder.h2
-rw-r--r--searchlib/src/vespa/searchlib/index/olddictionaryfile.h2
-rw-r--r--searchlib/src/vespa/searchlib/memoryindex/memoryfieldindex.h4
-rw-r--r--searchlib/src/vespa/searchlib/parsequery/parse.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/parsequery/parse.h2
-rw-r--r--searchlib/src/vespa/searchlib/parsequery/simplequerystack.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/parsequery/simplequerystack.h2
-rw-r--r--searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.h2
-rw-r--r--searchlib/src/vespa/searchlib/predicate/document_features_store.h2
-rw-r--r--searchlib/src/vespa/searchlib/query/queryterm.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/query/tree/querybuilder.h60
-rw-r--r--searchlib/src/vespa/searchlib/query/tree/simplequery.h30
-rw-r--r--searchlib/src/vespa/searchlib/query/tree/term.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/query/tree/term.h2
-rw-r--r--searchlib/src/vespa/searchlib/query/tree/termnodes.h16
-rw-r--r--searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.h2
-rw-r--r--searchlib/src/vespa/searchlib/tensor/generic_tensor_attribute.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/tensor/generic_tensor_attribute.h2
-rw-r--r--searchlib/src/vespa/searchlib/tensor/tensor_attribute.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/tensor/tensor_attribute.h2
-rw-r--r--searchlib/src/vespa/searchlib/transactionlog/translogserver.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/transactionlog/translogserver.h2
-rw-r--r--searchsummary/src/vespa/searchsummary/docsummary/dynamicteaserdfw.cpp2
-rw-r--r--searchsummary/src/vespa/searchsummary/docsummary/getdocsumargs.h2
-rw-r--r--searchsummary/src/vespa/searchsummary/docsummary/itokenizer.h4
-rw-r--r--searchsummary/src/vespa/searchsummary/docsummary/summaryfeaturesdfw.cpp2
-rw-r--r--searchsummary/src/vespa/searchsummary/docsummary/summaryfeaturesdfw.h2
-rw-r--r--slobrok/src/vespa/slobrok/sbregister.cpp6
-rw-r--r--slobrok/src/vespa/slobrok/sbregister.h4
-rw-r--r--staging_vespalib/src/vespa/vespalib/net/json_handler_repo.cpp8
-rw-r--r--staging_vespalib/src/vespa/vespalib/net/json_handler_repo.h10
-rw-r--r--staging_vespalib/src/vespa/vespalib/objects/asciiserializer.cpp2
-rw-r--r--staging_vespalib/src/vespa/vespalib/objects/asciiserializer.h2
-rw-r--r--staging_vespalib/src/vespa/vespalib/objects/nboserializer.cpp2
-rw-r--r--staging_vespalib/src/vespa/vespalib/objects/nboserializer.h2
-rw-r--r--staging_vespalib/src/vespa/vespalib/objects/serializer.h4
-rw-r--r--staging_vespalib/src/vespa/vespalib/objects/visit.h2
-rw-r--r--staging_vespalib/src/vespa/vespalib/util/growablebytebuffer.cpp2
-rw-r--r--staging_vespalib/src/vespa/vespalib/util/growablebytebuffer.h2
-rw-r--r--staging_vespalib/src/vespa/vespalib/util/jsonwriter.cpp6
-rw-r--r--staging_vespalib/src/vespa/vespalib/util/jsonwriter.h6
-rw-r--r--staging_vespalib/src/vespa/vespalib/util/librarypool.cpp6
-rw-r--r--staging_vespalib/src/vespa/vespalib/util/librarypool.h6
-rw-r--r--staging_vespalib/src/vespa/vespalib/util/xmlstream.cpp26
-rw-r--r--staging_vespalib/src/vespa/vespalib/util/xmlstream.h2
-rw-r--r--staging_vespalib/src/vespa/vespalib/util/xmlstream.hpp2
-rw-r--r--storage/src/tests/visiting/commandqueuetest.cpp2
-rw-r--r--storage/src/vespa/storage/common/hostreporter/kernelmetrictool.cpp6
-rw-r--r--storage/src/vespa/storage/common/hostreporter/kernelmetrictool.h6
-rw-r--r--storage/src/vespa/storage/config/distributorconfiguration.h4
-rw-r--r--storage/src/vespa/storage/storageserver/fnetlistener.cpp2
-rw-r--r--storage/src/vespa/storage/storageserver/fnetlistener.h2
-rw-r--r--storage/src/vespa/storage/visiting/visitorthread.cpp2
-rw-r--r--storage/src/vespa/storage/visiting/visitorthread.h2
-rw-r--r--storageapi/src/vespa/storageapi/message/bucket.cpp2
-rw-r--r--storageapi/src/vespa/storageapi/message/bucket.h2
-rw-r--r--storageapi/src/vespa/storageapi/message/persistence.cpp2
-rw-r--r--storageapi/src/vespa/storageapi/message/persistence.h4
-rw-r--r--storageapi/src/vespa/storageapi/message/removelocation.cpp2
-rw-r--r--storageapi/src/vespa/storageapi/message/removelocation.h2
-rw-r--r--storageapi/src/vespa/storageapi/message/stat.cpp4
-rw-r--r--storageapi/src/vespa/storageapi/message/stat.h6
-rw-r--r--storageapi/src/vespa/storageapi/message/visitor.cpp8
-rw-r--r--storageapi/src/vespa/storageapi/message/visitor.h16
-rw-r--r--storageapi/src/vespa/storageapi/messageapi/maintenancecommand.h2
-rw-r--r--storageapi/src/vespa/storageapi/messageapi/returncode.cpp2
-rw-r--r--storageapi/src/vespa/storageapi/messageapi/returncode.h4
-rw-r--r--storageapi/src/vespa/storageapi/messageapi/storagemessage.cpp6
-rw-r--r--storageapi/src/vespa/storageapi/messageapi/storagemessage.h4
-rw-r--r--streamingvisitors/src/vespa/searchvisitor/searchvisitor.cpp24
-rw-r--r--vdslib/src/vespa/vdslib/container/parameters.cpp28
-rw-r--r--vdslib/src/vespa/vdslib/container/parameters.h16
-rw-r--r--vdslib/src/vespa/vdslib/container/parameters.hpp6
-rw-r--r--vdslib/src/vespa/vdslib/state/clusterstate.h2
-rw-r--r--vdslib/src/vespa/vdslib/state/diskstate.cpp6
-rw-r--r--vdslib/src/vespa/vdslib/state/diskstate.h8
-rw-r--r--vdslib/src/vespa/vdslib/state/nodestate.cpp6
-rw-r--r--vdslib/src/vespa/vdslib/state/nodestate.h8
-rw-r--r--vdslib/src/vespa/vdslib/state/nodetype.cpp4
-rw-r--r--vdslib/src/vespa/vdslib/state/nodetype.h4
-rw-r--r--vdslib/src/vespa/vdslib/state/state.cpp4
-rw-r--r--vdslib/src/vespa/vdslib/state/state.h4
-rw-r--r--vespa-athenz/src/main/java/com/yahoo/vespa/athenz/identityprovider/api/EntityBindingsMapper.java7
-rw-r--r--vespalib/src/vespa/vespalib/component/version.cpp4
-rw-r--r--vespalib/src/vespa/vespalib/data/memory.h2
-rw-r--r--vespalib/src/vespa/vespalib/io/fileutil.h2
-rw-r--r--vespalib/src/vespa/vespalib/objects/nbostream.h2
-rw-r--r--vespalib/src/vespa/vespalib/stllike/asciistream.cpp6
-rw-r--r--vespalib/src/vespa/vespalib/stllike/asciistream.h24
-rw-r--r--vespalib/src/vespa/vespalib/stllike/hash_fun.h2
-rw-r--r--vespalib/src/vespa/vespalib/stllike/string.cpp30
-rw-r--r--vespalib/src/vespa/vespalib/stllike/string.h94
-rw-r--r--vespalib/src/vespa/vespalib/stllike/string.hpp30
-rw-r--r--vespalib/src/vespa/vespalib/text/lowercase.cpp2
-rw-r--r--vespalib/src/vespa/vespalib/text/lowercase.h2
-rw-r--r--vespalib/src/vespa/vespalib/text/stringtokenizer.cpp12
-rw-r--r--vespalib/src/vespa/vespalib/text/stringtokenizer.h6
-rw-r--r--vespalib/src/vespa/vespalib/text/utf8.h2
-rw-r--r--vespalib/src/vespa/vespalib/util/exception.cpp6
-rw-r--r--vespalib/src/vespa/vespalib/util/exception.h22
-rw-r--r--vespalib/src/vespa/vespalib/util/exceptions.cpp26
-rw-r--r--vespalib/src/vespa/vespalib/util/exceptions.h22
-rw-r--r--vespalib/src/vespa/vespalib/util/regexp.cpp20
-rw-r--r--vespalib/src/vespa/vespalib/util/regexp.h16
357 files changed, 2704 insertions, 1649 deletions
diff --git a/bootstrap-cmake.sh b/bootstrap-cmake.sh
index 739dc79f001..0c2d9553213 100644..100755
--- a/bootstrap-cmake.sh
+++ b/bootstrap-cmake.sh
@@ -20,11 +20,16 @@ else
exit 1
fi
+if [ -z "$VESPA_LLVM_VERSION" ]; then
+ VESPA_LLVM_VERSION=5.0
+fi
+
cmake3 \
-DCMAKE_INSTALL_PREFIX=/opt/vespa \
-DJAVA_HOME=/usr/lib/jvm/java-openjdk \
- -DEXTRA_LINK_DIRECTORY="/opt/vespa-gtest/lib;/opt/vespa-boost/lib;/opt/vespa-cppunit/lib;/usr/lib64/llvm3.9/lib" \
- -DEXTRA_INCLUDE_DIRECTORY="/opt/vespa-gtest/include;/opt/vespa-boost/include;/opt/vespa-cppunit/include;/usr/include/llvm3.9" \
- -DCMAKE_INSTALL_RPATH="/opt/vespa/lib64;/opt/vespa-gtest/lib;/opt/vespa-boost/lib;/opt/vespa-cppunit/lib;/usr/lib/jvm/java-1.8.0/jre/lib/amd64/server;/usr/lib64/llvm3.9/lib" \
+ -DEXTRA_LINK_DIRECTORY="/opt/vespa-gtest/lib;/opt/vespa-boost/lib;/opt/vespa-cppunit/lib;/usr/lib64/llvm$VESPA_LLVM_VERSION/lib" \
+ -DEXTRA_INCLUDE_DIRECTORY="/opt/vespa-gtest/include;/opt/vespa-boost/include;/opt/vespa-cppunit/include;/usr/include/llvm$VESPA_LLVM_VERSION" \
+ -DCMAKE_INSTALL_RPATH="/opt/vespa/lib64;/opt/vespa-gtest/lib;/opt/vespa-boost/lib;/opt/vespa-cppunit/lib;/usr/lib/jvm/java-1.8.0/jre/lib/amd64/server;/usr/lib64/llvm$VESPA_LLVM_VERSION/lib" \
${EXTRA_CMAKE_ARGS} \
+ -DVESPA_LLVM_VERSION=$VESPA_LLVM_VERSION \
"${SOURCE_DIR}"
diff --git a/build_settings.cmake b/build_settings.cmake
index a154559d1e0..1bb5ed8baa0 100644
--- a/build_settings.cmake
+++ b/build_settings.cmake
@@ -74,7 +74,7 @@ endif()
if(VESPA_LLVM_VERSION)
else()
-set (VESPA_LLVM_VERSION "3.9")
+set (VESPA_LLVM_VERSION "6.0")
endif()
if(VESPA_USER)
diff --git a/config-model/src/main/java/com/yahoo/config/model/deploy/DeployState.java b/config-model/src/main/java/com/yahoo/config/model/deploy/DeployState.java
index 8b0285ec2b4..ff6370f1738 100644
--- a/config-model/src/main/java/com/yahoo/config/model/deploy/DeployState.java
+++ b/config-model/src/main/java/com/yahoo/config/model/deploy/DeployState.java
@@ -1,6 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config.model.deploy;
+import com.google.common.collect.ImmutableMap;
import com.yahoo.component.Version;
import com.yahoo.component.Vtag;
import com.yahoo.config.application.api.ApplicationPackage;
@@ -22,6 +23,7 @@ import com.yahoo.io.reader.NamedReader;
import com.yahoo.searchdefinition.RankProfileRegistry;
import com.yahoo.searchdefinition.SearchBuilder;
import com.yahoo.searchdefinition.parser.ParseException;
+import com.yahoo.searchlib.rankingexpression.integration.ml.ImportedModel;
import com.yahoo.vespa.config.ConfigDefinition;
import com.yahoo.vespa.config.ConfigDefinitionBuilder;
import com.yahoo.vespa.config.ConfigDefinitionKey;
@@ -65,6 +67,7 @@ public class DeployState implements ConfigDefinitionStore {
private final Zone zone;
private final QueryProfiles queryProfiles;
private final SemanticRules semanticRules;
+ //private final ImmutableMap<String, ImportedModel> importedMlModels;
private final ValidationOverrides validationOverrides;
private final Version wantedNodeVespaVersion;
private final Instant now;
@@ -98,6 +101,7 @@ public class DeployState implements ConfigDefinitionStore {
this.zone = zone;
this.queryProfiles = queryProfiles; // TODO: Remove this by seeing how pagetemplates are propagated
this.semanticRules = semanticRules; // TODO: Remove this by seeing how pagetemplates are propagated
+
this.validationOverrides = applicationPackage.getValidationOverrides().map(ValidationOverrides::fromXml).orElse(ValidationOverrides.empty);
this.wantedNodeVespaVersion = wantedNodeVespaVersion;
this.now = now;
@@ -210,6 +214,9 @@ public class DeployState implements ConfigDefinitionStore {
public SemanticRules getSemanticRules() { return semanticRules; }
+ /** The (machine learned) models imported from the models/ directory, as an unmodifiable map indexed by model name */
+ //public Map<String, ImportedModel> importedMlModels() { return importedMlModels; }
+
public Version getWantedNodeVespaVersion() { return wantedNodeVespaVersion; }
public Instant now() { return now; }
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/expressiontransforms/MLImportFeatureConverter.java b/config-model/src/main/java/com/yahoo/searchdefinition/expressiontransforms/ConvertedModel.java
index effa261be3b..867740c7912 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/expressiontransforms/MLImportFeatureConverter.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/expressiontransforms/ConvertedModel.java
@@ -17,6 +17,7 @@ import com.yahoo.searchlib.rankingexpression.evaluation.DoubleValue;
import com.yahoo.searchlib.rankingexpression.evaluation.TensorValue;
import com.yahoo.searchlib.rankingexpression.evaluation.Value;
import com.yahoo.searchlib.rankingexpression.integration.ml.ImportedModel;
+import com.yahoo.searchlib.rankingexpression.integration.ml.ModelImporter;
import com.yahoo.searchlib.rankingexpression.parser.ParseException;
import com.yahoo.searchlib.rankingexpression.rule.Arguments;
import com.yahoo.searchlib.rankingexpression.rule.CompositeNode;
@@ -25,7 +26,6 @@ import com.yahoo.searchlib.rankingexpression.rule.ExpressionNode;
import com.yahoo.searchlib.rankingexpression.rule.GeneratorLambdaFunctionNode;
import com.yahoo.searchlib.rankingexpression.rule.ReferenceNode;
import com.yahoo.searchlib.rankingexpression.rule.TensorFunctionNode;
-import com.yahoo.searchlib.rankingexpression.transform.ExpressionTransformer;
import com.yahoo.tensor.Tensor;
import com.yahoo.tensor.TensorType;
import com.yahoo.tensor.evaluation.TypeContext;
@@ -46,28 +46,57 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
/**
- * Base class for replacing instances of a pseudofeature for imported ML
- * ranking models with native Vespa ranking expressions.
+ * A machine learned model imported from the models/ directory in the application package.
+ * This encapsulates the difference between reading a model
+ * - from a file application package, where it is represented by an ImportedModel, and
+ * - from a ZK application package, where the models/ directory is unavailable and models are read from
+ * generated files stored in file distribution or ZooKeeper.
*
* @author bratseth
- * @author lesters
*/
-abstract class MLImportFeatureConverter extends ExpressionTransformer<RankProfileTransformContext> {
+public class ConvertedModel {
- ExpressionNode transformFromImportedModel(ImportedModel model,
- ModelStore store,
- RankProfile profile,
- QueryProfileRegistry queryProfiles) {
+ private final ExpressionNode convertedExpression;
+
+ public ConvertedModel(FeatureArguments arguments,
+ RankProfileTransformContext context,
+ ModelImporter modelImporter,
+ Map<Path, ImportedModel> importedModels) {
+ ModelStore store = new ModelStore(context.rankProfile().getSearch().sourceApplication(), arguments);
+ if ( ! store.hasStoredModel()) // not converted yet - access from models/ directory
+ convertedExpression = importModel(store, context.rankProfile(), context.queryProfiles(), modelImporter, importedModels);
+ else
+ convertedExpression = transformFromStoredModel(store, context.rankProfile());
+ }
+
+ private ExpressionNode importModel(ModelStore store,
+ RankProfile profile,
+ QueryProfileRegistry queryProfiles,
+ ModelImporter modelImporter,
+ Map<Path, ImportedModel> importedModels) {
+ ImportedModel model = importedModels.computeIfAbsent(store.arguments().modelPath(),
+ k -> modelImporter.importModel(store.arguments().modelName(),
+ store.modelDir()));
+ return transformFromImportedModel(model, store, profile, queryProfiles);
+ }
+
+ public ExpressionNode expression() { return convertedExpression; }
+
+ private ExpressionNode transformFromImportedModel(ImportedModel model,
+ ModelStore store,
+ RankProfile profile,
+ QueryProfileRegistry queryProfiles) {
// Add constants
Set<String> constantsReplacedByMacros = new HashSet<>();
model.smallConstants().forEach((k, v) -> transformSmallConstant(store, profile, k, v));
model.largeConstants().forEach((k, v) -> transformLargeConstant(store, profile, queryProfiles,
- constantsReplacedByMacros, k, v));
+ constantsReplacedByMacros, k, v));
// Find the specified expression
ImportedModel.Signature signature = chooseSignature(model, store.arguments().signature());
@@ -121,16 +150,16 @@ abstract class MLImportFeatureConverter extends ExpressionTransformer<RankProfil
throw new IllegalArgumentException("No signatures are available");
if (importResult.signatures().size() > 1)
throw new IllegalArgumentException("Model has multiple signatures (" +
- Joiner.on(", ").join(importResult.signatures().keySet()) +
- "), one must be specified " +
- "as a second argument to tensorflow()");
+ Joiner.on(", ").join(importResult.signatures().keySet()) +
+ "), one must be specified " +
+ "as a second argument to tensorflow()");
return importResult.signatures().values().stream().findFirst().get();
}
else {
ImportedModel.Signature signature = importResult.signatures().get(signatureName.get());
if (signature == null)
throw new IllegalArgumentException("Model does not have the specified signature '" +
- signatureName.get() + "'");
+ signatureName.get() + "'");
return signature;
}
}
@@ -145,9 +174,9 @@ abstract class MLImportFeatureConverter extends ExpressionTransformer<RankProfil
throw new IllegalArgumentException("No outputs are available" + skippedOutputsDescription(signature));
if (signature.outputs().size() > 1)
throw new IllegalArgumentException(signature + " has multiple outputs (" +
- Joiner.on(", ").join(signature.outputs().keySet()) +
- "), one must be specified " +
- "as a third argument to tensorflow()");
+ Joiner.on(", ").join(signature.outputs().keySet()) +
+ "), one must be specified " +
+ "as a third argument to tensorflow()");
return signature.outputs().get(signature.outputs().keySet().stream().findFirst().get());
}
else {
@@ -155,10 +184,10 @@ abstract class MLImportFeatureConverter extends ExpressionTransformer<RankProfil
if (output == null) {
if (signature.skippedOutputs().containsKey(outputName.get()))
throw new IllegalArgumentException("Could not use output '" + outputName.get() + "': " +
- signature.skippedOutputs().get(outputName.get()));
+ signature.skippedOutputs().get(outputName.get()));
else
throw new IllegalArgumentException("Model does not have the specified output '" +
- outputName.get() + "'");
+ outputName.get() + "'");
}
return output;
}
@@ -177,14 +206,14 @@ abstract class MLImportFeatureConverter extends ExpressionTransformer<RankProfil
TensorType macroType = macroOverridingConstant.getRankingExpression().type(profile.typeContext(queryProfiles));
if ( ! macroType.equals(constantValue.type()))
throw new IllegalArgumentException("Macro '" + constantName + "' replaces the constant with this name. " +
- typeMismatchExplanation(constantValue.type(), macroType));
+ typeMismatchExplanation(constantValue.type(), macroType));
constantsReplacedByMacros.add(constantName); // will replace constant(constantName) by constantName later
}
else {
Path constantPath = store.writeLargeConstant(constantName, constantValue);
if ( ! profile.getSearch().getRankingConstants().containsKey(constantName)) {
profile.getSearch().addRankingConstant(new RankingConstant(constantName, constantValue.type(),
- constantPath.toString()));
+ constantPath.toString()));
}
}
}
@@ -229,8 +258,8 @@ abstract class MLImportFeatureConverter extends ExpressionTransformer<RankProfil
RankProfile.Macro macro = profile.getMacros().get(macroName);
if (macro == null)
throw new IllegalArgumentException("Model refers input '" + macroName +
- "' of type " + requiredType + " but this macro is not present in " +
- profile);
+ "' of type " + requiredType + " but this macro is not present in " +
+ profile);
// TODO: We should verify this in the (function reference(s) this is invoked (starting from first/second
// phase and summary features), as it may only resolve correctly given those bindings
// Or, probably better, annotate the macros with type constraints here and verify during general
@@ -238,20 +267,20 @@ abstract class MLImportFeatureConverter extends ExpressionTransformer<RankProfil
TensorType actualType = macro.getRankingExpression().getRoot().type(profile.typeContext(queryProfiles));
if ( actualType == null)
throw new IllegalArgumentException("Model refers input '" + macroName +
- "' of type " + requiredType +
- " which must be produced by a macro in the rank profile, but " +
- "this macro references a feature which is not declared");
+ "' of type " + requiredType +
+ " which must be produced by a macro in the rank profile, but " +
+ "this macro references a feature which is not declared");
if ( ! actualType.isAssignableTo(requiredType))
throw new IllegalArgumentException("Model refers input '" + macroName + "'. " +
- typeMismatchExplanation(requiredType, actualType));
+ typeMismatchExplanation(requiredType, actualType));
}
}
private String typeMismatchExplanation(TensorType requiredType, TensorType actualType) {
return "The required type of this is " + requiredType + ", but this macro returns " + actualType +
- (actualType.rank() == 0 ? ". This is often due to missing declaration of query tensor features " +
- "in query profile types - see the documentation."
- : "");
+ (actualType.rank() == 0 ? ". This is often due to missing declaration of query tensor features " +
+ "in query profile types - see the documentation."
+ : "");
}
/**
@@ -281,7 +310,7 @@ abstract class MLImportFeatureConverter extends ExpressionTransformer<RankProfil
RankProfile.Macro macro = profile.getMacros().get(macroName);
if (macro == null) {
throw new IllegalArgumentException("Model refers to generated macro '" + macroName +
- "but this macro is not present in " + profile);
+ "but this macro is not present in " + profile);
}
RankingExpression macroExpression = macro.getRankingExpression();
macroExpression.setRoot(reduceBatchDimensionsAtInput(macroExpression.getRoot(), model, typeContext));
@@ -362,9 +391,9 @@ abstract class MLImportFeatureConverter extends ExpressionTransformer<RankProfil
if (expandDimensionsType.dimensions().size() > 0) {
ExpressionNode generatedExpression = new ConstantNode(new DoubleValue(1.0));
Generate generatedFunction = new Generate(expandDimensionsType,
- new GeneratorLambdaFunctionNode(expandDimensionsType,
- generatedExpression)
- .asLongListToDoubleOperator());
+ new GeneratorLambdaFunctionNode(expandDimensionsType,
+ generatedExpression)
+ .asLongListToDoubleOperator());
Join expand = new Join(TensorFunctionNode.wrapArgument(node), generatedFunction, ScalarFunctions.multiply());
return new TensorFunctionNode(expand);
}
@@ -379,7 +408,7 @@ abstract class MLImportFeatureConverter extends ExpressionTransformer<RankProfil
Set<String> constantsReplacedByMacros) {
if (constantsReplacedByMacros.isEmpty()) return expression;
return new RankingExpression(expression.getName(),
- replaceConstantsByMacros(expression.getRoot(), constantsReplacedByMacros));
+ replaceConstantsByMacros(expression.getRoot(), constantsReplacedByMacros));
}
private ExpressionNode replaceConstantsByMacros(ExpressionNode node, Set<String> constantsReplacedByMacros) {
@@ -394,8 +423,8 @@ abstract class MLImportFeatureConverter extends ExpressionTransformer<RankProfil
if (node instanceof CompositeNode) { // not else: this matches some of the same nodes as the outer if above
CompositeNode composite = (CompositeNode)node;
return composite.setChildren(composite.children().stream()
- .map(child -> replaceConstantsByMacros(child, constantsReplacedByMacros))
- .collect(Collectors.toList()));
+ .map(child -> replaceConstantsByMacros(child, constantsReplacedByMacros))
+ .collect(Collectors.toList()));
}
return node;
}
@@ -459,7 +488,7 @@ abstract class MLImportFeatureConverter extends ExpressionTransformer<RankProfil
*/
void writeConverted(RankingExpression expression) {
application.getFile(arguments.expressionPath())
- .writeFile(new StringReader(expression.getRoot().toString()));
+ .writeFile(new StringReader(expression.getRoot().toString()));
}
/** Reads the previously stored ranking expression for these arguments */
@@ -478,7 +507,7 @@ abstract class MLImportFeatureConverter extends ExpressionTransformer<RankProfil
/** Adds this macro expression to the application package to it can be read later. */
void writeMacro(String name, RankingExpression expression) {
application.getFile(arguments.macrosPath()).appendFile(name + "\t" +
- expression.getRoot().toString() + "\n");
+ expression.getRoot().toString() + "\n");
}
/** Reads the previously stored macro expressions for these arguments */
@@ -540,7 +569,7 @@ abstract class MLImportFeatureConverter extends ExpressionTransformer<RankProfil
// Remember the constant in a file we replicate in ZooKeeper
application.getFile(arguments.largeConstantsPath().append(name + ".constant"))
- .writeFile(new StringReader(name + ":" + constant.type() + ":" + correct(constantPath)));
+ .writeFile(new StringReader(name + ":" + constant.type() + ":" + correct(constantPath)));
// Write content explicitly as a file on the file system as this is distributed using file distribution
createIfNeeded(constantsPath);
@@ -576,14 +605,14 @@ abstract class MLImportFeatureConverter extends ExpressionTransformer<RankProfil
public void writeSmallConstant(String name, Tensor constant) {
// Secret file format for remembering constants:
application.getFile(arguments.smallConstantsPath()).appendFile(name + "\t" +
- constant.type().toString() + "\t" +
- constant.toString() + "\n");
+ constant.type().toString() + "\t" +
+ constant.toString() + "\n");
}
/** Workaround for being constructed with the .preprocessed dir as root while later being used outside it */
private Path correct(Path path) {
if (application.getFileReference(Path.fromString("")).getAbsolutePath().endsWith(FilesApplicationPackage.preprocessed)
- && ! path.elements().contains(FilesApplicationPackage.preprocessed)) {
+ && ! path.elements().contains(FilesApplicationPackage.preprocessed)) {
return Path.fromString(FilesApplicationPackage.preprocessed).append(path);
}
else {
@@ -602,13 +631,25 @@ abstract class MLImportFeatureConverter extends ExpressionTransformer<RankProfil
}
/** Encapsulates the arguments to the import feature */
- static abstract class FeatureArguments {
+ static class FeatureArguments {
Path modelPath;
/** Optional arguments */
Optional<String> signature, output;
+ public FeatureArguments(Arguments arguments) {
+ this(Path.fromString(asString(arguments.expressions().get(0))),
+ optionalArgument(1, arguments),
+ optionalArgument(2, arguments));
+ }
+
+ public FeatureArguments(Path modelPath, Optional<String> signature, Optional<String> output) {
+ this.modelPath = modelPath;
+ this.signature = signature;
+ this.output = output;
+ }
+
/** Returns modelPath with slashes replaced by underscores */
public String modelName() { return modelPath.toString().replace('/', '_').replace('.', '_'); }
@@ -634,7 +675,7 @@ abstract class MLImportFeatureConverter extends ExpressionTransformer<RankProfil
public Path expressionPath() {
return ApplicationPackage.MODELS_GENERATED_REPLICATED_DIR
- .append(modelPath).append("expressions").append(expressionFileName());
+ .append(modelPath).append("expressions").append(expressionFileName());
}
private String expressionFileName() {
@@ -647,28 +688,29 @@ abstract class MLImportFeatureConverter extends ExpressionTransformer<RankProfil
return fileName.toString();
}
- Optional<String> optionalArgument(int argumentIndex, Arguments arguments) {
+ private static Optional<String> optionalArgument(int argumentIndex, Arguments arguments) {
if (argumentIndex >= arguments.expressions().size())
return Optional.empty();
return Optional.of(asString(arguments.expressions().get(argumentIndex)));
}
- String asString(ExpressionNode node) {
+ private static String asString(ExpressionNode node) {
if ( ! (node instanceof ConstantNode))
throw new IllegalArgumentException("Expected a constant string as argument, but got '" + node);
return stripQuotes(((ConstantNode)node).sourceString());
}
- private String stripQuotes(String s) {
+ private static String stripQuotes(String s) {
if ( ! isQuoteSign(s.codePointAt(0))) return s;
if ( ! isQuoteSign(s.codePointAt(s.length() - 1 )))
throw new IllegalArgumentException("argument [" + s + "] is missing endquote");
return s.substring(1, s.length()-1);
}
- private boolean isQuoteSign(int c) {
+ private static boolean isQuoteSign(int c) {
return c == '\'' || c == '"';
}
}
+
}
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/expressiontransforms/OnnxFeatureConverter.java b/config-model/src/main/java/com/yahoo/searchdefinition/expressiontransforms/OnnxFeatureConverter.java
index 44eeb364603..d31ffefde65 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/expressiontransforms/OnnxFeatureConverter.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/expressiontransforms/OnnxFeatureConverter.java
@@ -11,6 +11,7 @@ import com.yahoo.searchlib.rankingexpression.rule.Arguments;
import com.yahoo.searchlib.rankingexpression.rule.CompositeNode;
import com.yahoo.searchlib.rankingexpression.rule.ExpressionNode;
import com.yahoo.searchlib.rankingexpression.rule.ReferenceNode;
+import com.yahoo.searchlib.rankingexpression.transform.ExpressionTransformer;
import java.io.UncheckedIOException;
import java.util.HashMap;
@@ -25,7 +26,7 @@ import java.util.Optional;
* @author bratseth
* @author lesters
*/
-public class OnnxFeatureConverter extends MLImportFeatureConverter {
+public class OnnxFeatureConverter extends ExpressionTransformer<RankProfileTransformContext> {
private final OnnxImporter onnxImporter = new OnnxImporter();
@@ -46,39 +47,23 @@ public class OnnxFeatureConverter extends MLImportFeatureConverter {
if ( ! feature.getName().equals("onnx")) return feature;
try {
- FeatureArguments arguments = new OnnxFeatureArguments(feature.getArguments());
- ModelStore store = new ModelStore(context.rankProfile().getSearch().sourceApplication(), arguments);
- if ( ! store.hasStoredModel()) // not converted yet - access Onnx model files
- return transformFromOnnxModel(store, context.rankProfile(), context.queryProfiles());
- else
- return transformFromStoredModel(store, context.rankProfile());
+ ConvertedModel convertedModel = new ConvertedModel(asFeatureArguments(feature.getArguments()),
+ context, onnxImporter, importedModels);
+ return convertedModel.expression();
}
catch (IllegalArgumentException | UncheckedIOException e) {
throw new IllegalArgumentException("Could not use Onnx model from " + feature, e);
}
}
- private ExpressionNode transformFromOnnxModel(ModelStore store,
- RankProfile profile,
- QueryProfileRegistry queryProfiles) {
- ImportedModel model = importedModels.computeIfAbsent(store.arguments().modelPath(),
- k -> onnxImporter.importModel(store.arguments().modelName(),
- store.modelDir()));
- return transformFromImportedModel(model, store, profile, queryProfiles);
- }
-
- static class OnnxFeatureArguments extends FeatureArguments {
- public OnnxFeatureArguments(Arguments arguments) {
- if (arguments.isEmpty())
- throw new IllegalArgumentException("An onnx node must take an argument pointing to " +
- "the tensorflow model directory under [application]/models");
- if (arguments.expressions().size() > 3)
- throw new IllegalArgumentException("An onnx feature can have at most 2 arguments");
+ private ConvertedModel.FeatureArguments asFeatureArguments(Arguments arguments) {
+ if (arguments.isEmpty())
+ throw new IllegalArgumentException("An onnx node must take an argument pointing to " +
+ "the onnx model directory under [application]/models");
+ if (arguments.expressions().size() > 3)
+ throw new IllegalArgumentException("An onnx feature can have at most 2 arguments");
- modelPath = Path.fromString(asString(arguments.expressions().get(0)));
- output = optionalArgument(1, arguments);
- signature = Optional.of("default");
- }
+ return new ConvertedModel.FeatureArguments(arguments);
}
}
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/expressiontransforms/TensorFlowFeatureConverter.java b/config-model/src/main/java/com/yahoo/searchdefinition/expressiontransforms/TensorFlowFeatureConverter.java
index 27e1ad51b33..d28299b1d30 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/expressiontransforms/TensorFlowFeatureConverter.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/expressiontransforms/TensorFlowFeatureConverter.java
@@ -10,6 +10,7 @@ import com.yahoo.searchlib.rankingexpression.rule.Arguments;
import com.yahoo.searchlib.rankingexpression.rule.CompositeNode;
import com.yahoo.searchlib.rankingexpression.rule.ExpressionNode;
import com.yahoo.searchlib.rankingexpression.rule.ReferenceNode;
+import com.yahoo.searchlib.rankingexpression.transform.ExpressionTransformer;
import java.io.UncheckedIOException;
import java.util.HashMap;
@@ -22,7 +23,7 @@ import java.util.Map;
*
* @author bratseth
*/
-public class TensorFlowFeatureConverter extends MLImportFeatureConverter {
+public class TensorFlowFeatureConverter extends ExpressionTransformer<RankProfileTransformContext> {
private final TensorFlowImporter tensorFlowImporter = new TensorFlowImporter();
@@ -43,39 +44,23 @@ public class TensorFlowFeatureConverter extends MLImportFeatureConverter {
if ( ! feature.getName().equals("tensorflow")) return feature;
try {
- FeatureArguments arguments = new TensorFlowFeatureArguments(feature.getArguments());
- ModelStore store = new ModelStore(context.rankProfile().getSearch().sourceApplication(), arguments);
- if ( ! store.hasStoredModel()) // not converted yet - access TensorFlow model files
- return transformFromTensorFlowModel(store, context.rankProfile(), context.queryProfiles());
- else
- return transformFromStoredModel(store, context.rankProfile());
+ ConvertedModel convertedModel = new ConvertedModel(asFeatureArguments(feature.getArguments()),
+ context, tensorFlowImporter, importedModels);
+ return convertedModel.expression();
}
catch (IllegalArgumentException | UncheckedIOException e) {
throw new IllegalArgumentException("Could not use tensorflow model from " + feature, e);
}
}
- private ExpressionNode transformFromTensorFlowModel(ModelStore store,
- RankProfile profile,
- QueryProfileRegistry queryProfiles) {
- ImportedModel model = importedModels.computeIfAbsent(store.arguments().modelPath(),
- k -> tensorFlowImporter.importModel(store.arguments().modelName(),
- store.modelDir()));
- return transformFromImportedModel(model, store, profile, queryProfiles);
- }
-
- static class TensorFlowFeatureArguments extends FeatureArguments {
- public TensorFlowFeatureArguments(Arguments arguments) {
- if (arguments.isEmpty())
- throw new IllegalArgumentException("A tensorflow node must take an argument pointing to " +
- "the tensorflow model directory under [application]/models");
- if (arguments.expressions().size() > 3)
- throw new IllegalArgumentException("A tensorflow feature can have at most 3 arguments");
+ private ConvertedModel.FeatureArguments asFeatureArguments(Arguments arguments) {
+ if (arguments.isEmpty())
+ throw new IllegalArgumentException("A tensorflow node must take an argument pointing to " +
+ "the tensorflow model directory under [application]/models");
+ if (arguments.expressions().size() > 3)
+ throw new IllegalArgumentException("A tensorflow feature can have at most 3 arguments");
- modelPath = Path.fromString(asString(arguments.expressions().get(0)));
- signature = optionalArgument(1, arguments);
- output = optionalArgument(2, arguments);
- }
+ return new ConvertedModel.FeatureArguments(arguments);
}
}
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionWithOnnxTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionWithOnnxTestCase.java
index d9beab6e2f2..b2ef08dcc36 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionWithOnnxTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionWithOnnxTestCase.java
@@ -164,7 +164,7 @@ public class RankingExpressionWithOnnxTestCase {
catch (IllegalArgumentException expected) {
assertEquals("Rank profile 'my_profile' is invalid: Could not use Onnx model from " +
"onnx('mnist_softmax.onnx','y'): " +
- "Model does not have the specified output 'y'",
+ "Model does not have the specified signature 'y'",
Exceptions.toMessageString(expected));
}
}
diff --git a/config/src/vespa/config/common/configkey.cpp b/config/src/vespa/config/common/configkey.cpp
index 64eefe8339a..1b8460ea1f5 100644
--- a/config/src/vespa/config/common/configkey.cpp
+++ b/config/src/vespa/config/common/configkey.cpp
@@ -4,10 +4,10 @@
namespace config {
-ConfigKey::ConfigKey(const vespalib::stringref & configId,
- const vespalib::stringref & defName,
- const vespalib::stringref & defNamespace,
- const vespalib::stringref & defMd5)
+ConfigKey::ConfigKey(vespalib::stringref configId,
+ vespalib::stringref defName,
+ vespalib::stringref defNamespace,
+ vespalib::stringref defMd5)
: _configId(configId),
_defName(defName),
_defNamespace(defNamespace),
@@ -16,10 +16,10 @@ ConfigKey::ConfigKey(const vespalib::stringref & configId,
_key(_configId + _defName + _defNamespace)
{}
-ConfigKey::ConfigKey(const vespalib::stringref & configId,
- const vespalib::stringref & defName,
- const vespalib::stringref & defNamespace,
- const vespalib::stringref & defMd5,
+ConfigKey::ConfigKey(vespalib::stringref configId,
+ vespalib::stringref defName,
+ vespalib::stringref defNamespace,
+ vespalib::stringref defMd5,
const std::vector<vespalib::string> & defSchema)
: _configId(configId),
_defName(defName),
diff --git a/config/src/vespa/config/common/configkey.h b/config/src/vespa/config/common/configkey.h
index 1cde2433281..9f6eec99f63 100644
--- a/config/src/vespa/config/common/configkey.h
+++ b/config/src/vespa/config/common/configkey.h
@@ -8,15 +8,15 @@ namespace config {
class ConfigKey {
public:
- ConfigKey(const vespalib::stringref & configId,
- const vespalib::stringref & defName,
- const vespalib::stringref & defNamespace,
- const vespalib::stringref & defMd5);
-
- ConfigKey(const vespalib::stringref & configId,
- const vespalib::stringref & defName,
- const vespalib::stringref & defNamespace,
- const vespalib::stringref & defMd5,
+ ConfigKey(vespalib::stringref configId,
+ vespalib::stringref defName,
+ vespalib::stringref defNamespace,
+ vespalib::stringref defMd5);
+
+ ConfigKey(vespalib::stringref configId,
+ vespalib::stringref defName,
+ vespalib::stringref defNamespace,
+ vespalib::stringref defMd5,
const std::vector<vespalib::string> & defSchema);
ConfigKey(const ConfigKey &);
@@ -37,7 +37,7 @@ public:
const std::vector<vespalib::string> & getDefSchema() const;
template <typename ConfigType>
- static const ConfigKey create(const vespalib::stringref & configId)
+ static const ConfigKey create(vespalib::stringref configId)
{
return ConfigKey(configId, ConfigType::CONFIG_DEF_NAME,
ConfigType::CONFIG_DEF_NAMESPACE,
diff --git a/config/src/vespa/config/common/configparser.cpp b/config/src/vespa/config/common/configparser.cpp
index 4d9eac41af6..e6105486c0c 100644
--- a/config/src/vespa/config/common/configparser.cpp
+++ b/config/src/vespa/config/common/configparser.cpp
@@ -8,7 +8,7 @@
namespace config {
-void ConfigParser::throwNoDefaultValue(const vespalib::stringref & key) {
+void ConfigParser::throwNoDefaultValue(vespalib::stringref key) {
throw InvalidConfigException("Config parameter " + key + " has no "
"default value and is not specified in config", VESPA_STRLOC);
}
@@ -85,7 +85,7 @@ ConfigParser::deQuote(const vespalib::string & source)
namespace {
bool
-getValueForKey(const vespalib::stringref & key, const vespalib::stringref & line,
+getValueForKey(vespalib::stringref key, vespalib::stringref line,
vespalib::string& retval)
{
if (line.length() <= key.length()) {
@@ -124,7 +124,7 @@ getValueForKey(const vespalib::stringref & key, const vespalib::stringref & line
}
std::vector<vespalib::string>
-ConfigParser::getLinesForKey(const vespalib::stringref & key,
+ConfigParser::getLinesForKey(vespalib::stringref key,
const vsvector & lines)
{
vsvector retval;
@@ -141,7 +141,7 @@ ConfigParser::getLinesForKey(const vespalib::stringref & key,
}
void
-ConfigParser::stripLinesForKey(const vespalib::stringref & key,
+ConfigParser::stripLinesForKey(vespalib::stringref key,
std::set<vespalib::string>& config)
{
vespalib::string value;
@@ -228,7 +228,7 @@ ConfigParser::splitArray(const vsvector & config)
}
vespalib::string
-ConfigParser::stripWhitespace(const vespalib::stringref & source)
+ConfigParser::stripWhitespace(vespalib::stringref source)
{
// Remove leading spaces and return.
if (source.empty()) {
diff --git a/config/src/vespa/config/common/configparser.h b/config/src/vespa/config/common/configparser.h
index 77b5bf7ddaa..c70aeed4901 100644
--- a/config/src/vespa/config/common/configparser.h
+++ b/config/src/vespa/config/common/configparser.h
@@ -18,13 +18,13 @@ class ConfigParser {
public:
typedef std::vector<vespalib::string> vsvector;
private:
- static vsvector getLinesForKey( const vespalib::stringref & key, const vsvector & config);
+ static vsvector getLinesForKey(vespalib::stringref key, const vsvector & config);
static std::vector<vsvector> splitArray( const vsvector & config);
static std::map<vespalib::string, vsvector> splitMap( const vsvector & config);
static vespalib::string deQuote(const vespalib::string & source);
- static void throwNoDefaultValue(const vespalib::stringref & key);
+ static void throwNoDefaultValue(vespalib::stringref key);
template<typename T>
static T convert(const vsvector &);
@@ -32,43 +32,43 @@ private:
static vespalib::string arrayToString(const vsvector &);
template<typename T, typename V>
- static T parseInternal(const vespalib::stringref & key, const V & config);
+ static T parseInternal(vespalib::stringref key, const V & config);
template<typename T, typename V>
- static T parseInternal(const vespalib::stringref & key, const V & config, T defaultValue);
+ static T parseInternal(vespalib::stringref key, const V & config, T defaultValue);
template<typename T, typename V>
- static std::vector<T> parseArrayInternal(const vespalib::stringref & key, const V & config);
+ static std::vector<T> parseArrayInternal(vespalib::stringref key, const V & config);
template<typename T, typename V>
- static std::map<vespalib::string, T> parseMapInternal(const vespalib::stringref & key, const V & config);
+ static std::map<vespalib::string, T> parseMapInternal(vespalib::stringref key, const V & config);
template<typename T, typename V>
- static T parseStructInternal(const vespalib::stringref & key, const V & config);
+ static T parseStructInternal(vespalib::stringref key, const V & config);
public:
- static void stripLinesForKey(const vespalib::stringref & key,
+ static void stripLinesForKey(vespalib::stringref key,
std::set<vespalib::string>& config);
- static vespalib::string stripWhitespace(const vespalib::stringref & source);
+ static vespalib::string stripWhitespace(vespalib::stringref source);
template<typename T>
- static T parse(const vespalib::stringref & key, const vsvector & config) {
+ static T parse(vespalib::stringref key, const vsvector & config) {
return parseInternal<T, vsvector>(key, config);
}
template<typename T>
- static T parse(const vespalib::stringref & key, const vsvector & config, T defaultValue) {
+ static T parse(vespalib::stringref key, const vsvector & config, T defaultValue) {
return parseInternal(key, config, defaultValue);
}
template<typename T>
- static std::vector<T> parseArray(const vespalib::stringref & key, const vsvector & config) {
+ static std::vector<T> parseArray(vespalib::stringref key, const vsvector & config) {
return parseArrayInternal<T, vsvector>(key, config);
}
template<typename T>
- static std::map<vespalib::string, T> parseMap(const vespalib::stringref & key, const vsvector & config) {
+ static std::map<vespalib::string, T> parseMap(vespalib::stringref key, const vsvector & config) {
return parseMapInternal<T, vsvector>(key, config);
}
template<typename T>
- static T parseStruct(const vespalib::stringref & key, const vsvector & config) {
+ static T parseStruct(vespalib::stringref key, const vsvector & config) {
return parseStructInternal<T, vsvector>(key, config);
}
@@ -76,7 +76,7 @@ public:
template<typename T, typename V>
T
-ConfigParser::parseInternal(const vespalib::stringref & key, const V & config)
+ConfigParser::parseInternal(vespalib::stringref key, const V & config)
{
V lines = getLinesForKey(key, config);
@@ -88,7 +88,7 @@ ConfigParser::parseInternal(const vespalib::stringref & key, const V & config)
template<typename T, typename V>
T
-ConfigParser::parseInternal(const vespalib::stringref & key, const V & config, T defaultValue)
+ConfigParser::parseInternal(vespalib::stringref key, const V & config, T defaultValue)
{
V lines = getLinesForKey(key, config);
@@ -107,7 +107,7 @@ ConfigParser::convert(const vsvector & lines) {
template<typename T, typename V>
std::map<vespalib::string, T>
-ConfigParser::parseMapInternal(const vespalib::stringref & key, const V & config)
+ConfigParser::parseMapInternal(vespalib::stringref key, const V & config)
{
V lines = getLinesForKey(key, config);
typedef std::map<vespalib::string, V> SplittedMap;
@@ -121,7 +121,7 @@ ConfigParser::parseMapInternal(const vespalib::stringref & key, const V & config
template<typename T, typename V>
std::vector<T>
-ConfigParser::parseArrayInternal(const vespalib::stringref & key, const V & config)
+ConfigParser::parseArrayInternal(vespalib::stringref key, const V & config)
{
V lines = getLinesForKey(key, config);
std::vector<V> split = splitArray(lines);
@@ -136,7 +136,7 @@ ConfigParser::parseArrayInternal(const vespalib::stringref & key, const V & conf
template<typename T, typename V>
T
-ConfigParser::parseStructInternal(const vespalib::stringref & key, const V & config)
+ConfigParser::parseStructInternal(vespalib::stringref key, const V & config)
{
V lines = getLinesForKey(key, config);
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java b/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java
index 8a02383ad0b..6ace7a61f28 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java
@@ -283,14 +283,15 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
*/
public boolean delete(ApplicationId applicationId) {
List<String> hostedZonesToUseDeleteApplication =
- Arrays.asList("dev.us-east-1", "dev.corp-us-east-1", "test.us-east-1",
- "prod.corp-us-east-1", "prod.aws-us-east-1a", "prod.aws-us-west-1b");
- boolean useDeleteApplicationLegacyInThisZone = !hostedZonesToUseDeleteApplication.contains(zone().toString());
+ Arrays.asList("dev.us-east-1", "dev.corp-us-east-1",
+ "test.us-east-1", "staging.us-east-3",
+ "prod.aws-us-east-1a", "prod.aws-us-west-1b",
+ "prod.corp-us-east-1", "prod.us-central-1");
+ boolean useDeleteApplicationLegacy = !hostedZonesToUseDeleteApplication.contains(zone().toString());
// TODO: Use deleteApplication() in all zones
if (configserverConfig.deleteApplicationLegacy() ||
- (configserverConfig.hostedVespa() && zone().system() == SystemName.main &&
- useDeleteApplicationLegacyInThisZone)) {
+ (configserverConfig.hostedVespa() && zone().system() == SystemName.main && useDeleteApplicationLegacy)) {
return deleteApplicationLegacy(applicationId);
} else {
return deleteApplication(applicationId);
@@ -399,7 +400,7 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
return fileDistributionStatus.status(getApplication(applicationId), timeout);
}
- public Set<String> deleteUnusedFiledistributionReferences(File fileReferencesPath, boolean deleteFromDisk) {
+ public Set<String> deleteUnusedFiledistributionReferences(File fileReferencesPath) {
if (!fileReferencesPath.isDirectory()) throw new RuntimeException(fileReferencesPath + " is not a directory");
// Find all file references in use
@@ -424,7 +425,7 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
.filter(fileReference -> ! fileReferencesInUse.contains(fileReference))
.filter(fileReference -> isFileLastModifiedBefore(new File(fileReferencesPath, fileReference), instant))
.collect(Collectors.toSet());
- if (deleteFromDisk && fileReferencesToDelete.size() > 0) {
+ if (fileReferencesToDelete.size() > 0) {
log.log(LogLevel.INFO, "Will delete file references not in use: " + fileReferencesToDelete);
fileReferencesToDelete.forEach(fileReference -> {
File file = new File(fileReferencesPath, fileReference);
@@ -554,12 +555,11 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
listApplications().forEach(app -> tenantRepository.getTenant(app.tenant()).getLocalSessionRepo().purgeOldSessions());
}
- public int deleteExpiredRemoteSessions(Duration expiryTime) {
+ public int deleteExpiredRemoteSessions(Duration expiryTime, boolean deleteFromZooKeeper ) {
return listApplications()
.stream()
.map(app -> tenantRepository.getTenant(app.tenant()).getRemoteSessionRepo()
- // TODO: Delete in all zones
- .deleteExpiredSessions(expiryTime, zone().system() == SystemName.cd))
+ .deleteExpiredSessions(expiryTime, deleteFromZooKeeper))
.mapToInt(i -> i)
.sum();
}
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/maintenance/FileDistributionMaintainer.java b/configserver/src/main/java/com/yahoo/vespa/config/server/maintenance/FileDistributionMaintainer.java
index a5d4aa226a6..c6accd04896 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/maintenance/FileDistributionMaintainer.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/maintenance/FileDistributionMaintainer.java
@@ -32,6 +32,6 @@ public class FileDistributionMaintainer extends Maintainer {
@Override
protected void maintain() {
- applicationRepository.deleteUnusedFiledistributionReferences(fileReferencesDir, true /* delete files */);
+ applicationRepository.deleteUnusedFiledistributionReferences(fileReferencesDir);
}
}
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/maintenance/SessionsMaintainer.java b/configserver/src/main/java/com/yahoo/vespa/config/server/maintenance/SessionsMaintainer.java
index a0cbf4e4845..0631fca6a32 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/maintenance/SessionsMaintainer.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/maintenance/SessionsMaintainer.java
@@ -1,6 +1,8 @@
// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.server.maintenance;
+import com.yahoo.config.provision.SystemName;
+import com.yahoo.config.provision.Zone;
import com.yahoo.vespa.config.server.ApplicationRepository;
import com.yahoo.vespa.curator.Curator;
@@ -28,8 +30,14 @@ public class SessionsMaintainer extends Maintainer {
// Expired remote sessions are not expected to exist, they should have been deleted when
// a deployment happened or when the application was deleted. We still see them from time to time,
// probably due to some race or another bug
- Duration expiryTime = Duration.ofDays(30);
- if (hostedVespa)
- applicationRepository.deleteExpiredRemoteSessions(expiryTime);
+ if (hostedVespa) {
+ Duration expiryTime = Duration.ofDays(30);
+ Zone zone = applicationRepository.zone();
+ // TODO: Delete in all zones
+ boolean deleteFromZooKeeper = zone.system() == SystemName.cd ||
+ zone.environment().isTest() ||
+ zone.region().value().equals("us-central-1");
+ applicationRepository.deleteExpiredRemoteSessions(expiryTime, deleteFromZooKeeper);
+ }
}
}
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ModelsBuilder.java b/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ModelsBuilder.java
index 3eece4f5640..98e42b88e6d 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ModelsBuilder.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ModelsBuilder.java
@@ -9,9 +9,7 @@ import com.yahoo.config.model.api.ModelFactory;
import com.yahoo.config.provision.AllocatedHosts;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.ApplicationLockException;
-import com.yahoo.config.provision.Environment;
import com.yahoo.config.provision.OutOfCapacityException;
-import com.yahoo.config.provision.SystemName;
import com.yahoo.config.provision.Version;
import com.yahoo.config.provision.Zone;
import com.yahoo.lang.SettableOptional;
@@ -22,7 +20,6 @@ import com.yahoo.vespa.config.server.provision.StaticProvisioner;
import java.time.Instant;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
@@ -166,11 +163,7 @@ public abstract class ModelsBuilder<MODELRESULT extends ModelResult> {
}
private Set<Version> versionsToBuild(Set<Version> versions, com.yahoo.component.Version wantedVersion, AllocatedHosts allocatedHosts) {
- // TODO: Enable for all zones
- if (configserverConfig.buildMinimalSetOfConfigModels() &&
- (SystemName.from(configserverConfig.system()) == SystemName.cd ||
- Arrays.asList(Environment.dev, Environment.test, Environment.staging).contains(zone().environment()) ||
- Arrays.asList("corp-us-east-1", "ap-southeast-1", "us-central-1").contains(zone().region().value())))
+ if (configserverConfig.buildMinimalSetOfConfigModels())
versions = keepThoseUsedOn(allocatedHosts, versions);
// Make sure we build wanted version if we are building models for this major version and we are on hosted vespa
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/RemoteSession.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/RemoteSession.java
index dbccba395a2..b91627374e6 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/RemoteSession.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/RemoteSession.java
@@ -135,6 +135,7 @@ public class RemoteSession extends Session {
public void delete() {
Transaction transaction = zooKeeperClient.deleteTransaction();
transaction.commit();
+ transaction.close();
}
}
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java
index 6148c276088..4a279c68c70 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java
@@ -168,14 +168,7 @@ public class ApplicationRepositoryTest {
PrepareParams prepareParams = new PrepareParams.Builder().applicationId(applicationId()).ignoreValidationErrors(true).build();
deployApp(new File("src/test/apps/app"), prepareParams);
- boolean deleteFiles = false;
- Set<String> toBeDeleted = applicationRepository.deleteUnusedFiledistributionReferences(fileReferencesDir, deleteFiles);
- assertEquals(Collections.singleton("foo"), toBeDeleted);
- assertTrue(filereferenceDir.exists());
- assertTrue(filereferenceDir2.exists());
-
- deleteFiles = true;
- toBeDeleted = applicationRepository.deleteUnusedFiledistributionReferences(fileReferencesDir, deleteFiles);
+ Set<String> toBeDeleted = applicationRepository.deleteUnusedFiledistributionReferences(fileReferencesDir);
assertEquals(Collections.singleton("foo"), toBeDeleted);
assertFalse(filereferenceDir.exists());
assertTrue(filereferenceDir2.exists());
@@ -280,7 +273,7 @@ public class ApplicationRepositoryTest {
assertEquals(3, new ArrayList<>(sessions).get(0).getSessionId());
// There should be no expired remote sessions in the common case
- assertEquals(0, applicationRepository.deleteExpiredRemoteSessions(Duration.ofSeconds(0)));
+ assertEquals(0, applicationRepository.deleteExpiredRemoteSessions(Duration.ofSeconds(0), true));
}
private PrepareResult prepareAndActivateApp(File application) throws IOException {
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/JobType.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/JobType.java
index 38ee28a5b4d..a238facc983 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/JobType.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/JobType.java
@@ -6,7 +6,6 @@ import com.yahoo.config.provision.RegionName;
import com.yahoo.config.provision.SystemName;
import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId;
-import java.util.Objects;
import java.util.Optional;
import java.util.stream.Stream;
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/RunId.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/RunId.java
index a46cec1bb40..da1a3029619 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/RunId.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/RunId.java
@@ -48,7 +48,7 @@ public class RunId {
@Override
public String toString() {
- return "Run " + number + " of " + type + " for " + application;
+ return "run " + number + " of " + type + " for " + application;
}
}
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/stubs/MockTesterCloud.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/stubs/MockTesterCloud.java
index c2199c284f3..ff3f168a978 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/stubs/MockTesterCloud.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/stubs/MockTesterCloud.java
@@ -12,10 +12,14 @@ public class MockTesterCloud implements TesterCloud {
private byte[] logs = new byte[0];
private Status status = NOT_STARTED;
+ private byte[] config;
+ private URI testerUrl;
@Override
public void startTests(URI testerUrl, Suite suite, byte[] config) {
- status = RUNNING;
+ this.status = RUNNING;
+ this.config = config;
+ this.testerUrl = testerUrl;
}
@Override
@@ -33,4 +37,12 @@ public class MockTesterCloud implements TesterCloud {
this.status = status;
}
+ public byte[] config() {
+ return config;
+ }
+
+ public URI testerUrl() {
+ return testerUrl;
+ }
+
}
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java
index 66725d40b29..5e775ea6cd3 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java
@@ -306,18 +306,8 @@ public class ApplicationController {
validate(applicationPackage.deploymentSpec());
// Update application with information from application package
- if ( ! preferOldestVersion) {
- // Store information about application package
- application = application.with(applicationPackage.deploymentSpec());
- application = application.with(applicationPackage.validationOverrides());
-
- // Delete zones not listed in DeploymentSpec, if allowed
- // We do this at deployment time to be able to return a validation failure message when necessary
- application = deleteRemovedDeployments(application);
-
- // Clean up deployment jobs that are no longer referenced by deployment spec
- application = deleteUnreferencedDeploymentJobs(application);
-
+ if ( ! preferOldestVersion && ! application.get().deploymentJobs().builtInternally()) {
+ application = withUpdatedConfig(application, applicationPackage);
store(application); // store missing information even if we fail deployment below
}
@@ -341,6 +331,24 @@ public class ApplicationController {
}
}
+ /** Stores the deployment spec and validation overrides from the application package, and runs cleanup. */
+ public LockedApplication withUpdatedConfig(LockedApplication application, ApplicationPackage applicationPackage) {
+ // Store information about application package
+ application = application.with(applicationPackage.deploymentSpec());
+ application = application.with(applicationPackage.validationOverrides());
+
+ // Delete zones not listed in DeploymentSpec, if allowed
+ // We do this at deployment time for externally built applications, and at submission time
+ // for internally built ones, to be able to return a validation failure message when necessary
+ application = withoutDeletedDeployments(application);
+
+ // Clean up deployment jobs that are no longer referenced by deployment spec
+ application = withoutUnreferencedDeploymentJobs(application);
+
+ store(application);
+ return(application);
+ }
+
/** Deploy a system application to given zone */
public void deploy(SystemApplication application, ZoneId zone, Version version) {
if (application.hasApplicationPackage()) {
@@ -403,7 +411,7 @@ public class ApplicationController {
return new ActivateResult(new RevisionId("0"), prepareResponse, 0);
}
- private LockedApplication deleteRemovedDeployments(LockedApplication application) {
+ private LockedApplication withoutDeletedDeployments(LockedApplication application) {
List<Deployment> deploymentsToRemove = application.get().productionDeployments().values().stream()
.filter(deployment -> ! application.get().deploymentSpec().includes(deployment.zone().environment(),
Optional.of(deployment.zone().region())))
@@ -428,7 +436,7 @@ public class ApplicationController {
return applicationWithRemoval;
}
- private LockedApplication deleteUnreferencedDeploymentJobs(LockedApplication application) {
+ private LockedApplication withoutUnreferencedDeploymentJobs(LockedApplication application) {
for (JobType job : JobList.from(application.get()).production().mapToList(JobStatus::type)) {
ZoneId zone = job.zone(controller.system());
if (application.get().deploymentSpec().includes(zone.environment(), Optional.of(zone.region())))
@@ -571,8 +579,8 @@ public class ApplicationController {
}
/** Deactivate application in the given zone */
- public void deactivate(Application application, ZoneId zone) {
- lockOrThrow(application.id(), lockedApplication -> store(deactivate(lockedApplication, zone)));
+ public void deactivate(ApplicationId application, ZoneId zone) {
+ lockOrThrow(application, lockedApplication -> store(deactivate(lockedApplication, zone)));
}
/**
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentSteps.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentSteps.java
index 1d130ffbec2..925f3e5948a 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentSteps.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentSteps.java
@@ -44,7 +44,7 @@ public class DeploymentSteps {
}
/** Returns job status sorted according to deployment spec */
- public List<JobStatus> sortBy(Collection<JobStatus> jobStatus) {
+ public List<JobStatus> sortedJobs(Collection<JobStatus> jobStatus) {
List<JobType> sortedJobs = jobs();
return jobStatus.stream()
.sorted(comparingInt(job -> sortedJobs.indexOf(job.type())))
@@ -52,7 +52,7 @@ public class DeploymentSteps {
}
/** Returns deployments sorted according to declared zones */
- public List<Deployment> sortBy2(Collection<Deployment> deployments) {
+ public List<Deployment> sortedDeployments(Collection<Deployment> deployments) {
List<ZoneId> productionZones = spec.zones().stream()
.filter(z -> z.region().isPresent())
.map(z -> ZoneId.from(z.environment(), z.region().get()))
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java
index cc240353b02..e96f88e94ca 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java
@@ -14,7 +14,6 @@ import com.yahoo.vespa.hosted.controller.api.application.v4.model.DeployOptions;
import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId;
import com.yahoo.vespa.hosted.controller.api.identifiers.Hostname;
import com.yahoo.vespa.hosted.controller.api.integration.configserver.ConfigServerException;
-import com.yahoo.vespa.hosted.controller.api.integration.configserver.NoInstanceException;
import com.yahoo.vespa.hosted.controller.api.integration.configserver.Node;
import com.yahoo.vespa.hosted.controller.api.integration.configserver.PrepareResponse;
import com.yahoo.vespa.hosted.controller.api.integration.configserver.ServiceConvergence;
@@ -25,9 +24,7 @@ import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId;
import com.yahoo.vespa.hosted.controller.application.ApplicationPackage;
import com.yahoo.vespa.hosted.controller.application.ApplicationVersion;
import com.yahoo.vespa.hosted.controller.application.DeploymentJobs;
-import com.yahoo.vespa.hosted.controller.application.JobStatus;
import com.yahoo.vespa.hosted.controller.deployment.Step.Status;
-import com.yahoo.yolean.Exceptions;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -64,7 +61,7 @@ import static java.util.logging.Level.WARNING;
/**
* Runs steps of a deployment job against its provided controller.
*
- * A dual-purpose logger is set up for each thread that runs a step here:
+ * A dual-purpose logger is set up for each step run here:
* 1. all messages are logged to a buffer which is stored in an external log storage at the end of execution, and
* 2. all messages are also logged through the usual logging framework; by default, any messages of level
* {@code Level.INFO} or higher end up in the Vespa log, and all messages may be sent there by means of log-control.
@@ -85,7 +82,6 @@ public class InternalStepRunner implements StepRunner {
private final Controller controller;
private final TesterCloud testerCloud;
- private final ThreadLocal<ByteArrayLogger> logger = new ThreadLocal<>();
public InternalStepRunner(Controller controller, TesterCloud testerCloud) {
this.controller = controller;
@@ -94,80 +90,81 @@ public class InternalStepRunner implements StepRunner {
@Override
public Status run(LockedStep step, RunId id) {
+ ByteArrayLogger logger = ByteArrayLogger.of(id.application(), id.type(), step.get());
try {
- logger.set(ByteArrayLogger.of(id.application(), id.type(), step.get()));
switch (step.get()) {
- case deployInitialReal: return deployInitialReal(id);
- case installInitialReal: return installInitialReal(id);
- case deployReal: return deployReal(id);
- case deployTester: return deployTester(id);
- case installReal: return installReal(id);
- case installTester: return installTester(id);
- case startTests: return startTests(id);
- case endTests: return endTests(id);
- case deactivateReal: return deactivateReal(id);
- case deactivateTester: return deactivateTester(id);
+ case deployInitialReal: return deployInitialReal(id, logger);
+ case installInitialReal: return installInitialReal(id, logger);
+ case deployReal: return deployReal(id, logger);
+ case deployTester: return deployTester(id, logger);
+ case installReal: return installReal(id, logger);
+ case installTester: return installTester(id, logger);
+ case startTests: return startTests(id, logger);
+ case endTests: return endTests(id, logger);
+ case deactivateReal: return deactivateReal(id, logger);
+ case deactivateTester: return deactivateTester(id, logger);
case report: return report(id);
default: throw new AssertionError("Unknown step '" + step + "'!");
}
}
catch (RuntimeException e) {
- logger.get().log(INFO, "Unexpected exception: " + Exceptions.toMessageString(e));
+ logger.log(INFO, "Unexpected exception running " + id, e);
return failed;
}
finally {
- controller.jobController().log(id, step.get(), logger.get().getLog());
- logger.remove();
+ controller.jobController().log(id, step.get(), logger.getLog());
}
}
- private Status deployInitialReal(RunId id) {
- JobStatus.JobRun triggering = triggering(id.application(), id.type());
- logger.get().log("Deploying platform version " +
- triggering.sourcePlatform().orElse(triggering.platform()) +
- " and application version " +
- triggering.sourceApplication().orElse(triggering.application()) + " ...");
- return deployReal(id, true);
+ private Status deployInitialReal(RunId id, ByteArrayLogger logger) {
+ Versions versions = controller.jobController().run(id).get().versions();
+ logger.log("Deploying platform version " +
+ versions.sourcePlatform().orElse(versions.targetPlatform()) +
+ " and application version " +
+ versions.sourceApplication().orElse(versions.targetApplication()).id() + " ...");
+ return deployReal(id, true, logger);
}
- private Status deployReal(RunId id) {
- JobStatus.JobRun triggering = triggering(id.application(), id.type());
- logger.get().log("Deploying platform version " + triggering.platform() +
- " and application version " + triggering.application() + " ...");
- return deployReal(id, false);
+ private Status deployReal(RunId id, ByteArrayLogger logger) {
+ Versions versions = controller.jobController().run(id).get().versions();
+ logger.log("Deploying platform version " + versions.targetPlatform() +
+ " and application version " + versions.targetApplication().id() + " ...");
+ return deployReal(id, false, logger);
}
- private Status deployReal(RunId id, boolean setTheStage) {
+ private Status deployReal(RunId id, boolean setTheStage, ByteArrayLogger logger) {
return deploy(id.application(),
id.type(),
() -> controller.applications().deploy(id.application(),
- zone(id.type()),
+ id.type().zone(controller.system()),
Optional.empty(),
new DeployOptions(false,
Optional.empty(),
false,
- setTheStage)));
+ setTheStage)),
+ logger);
}
- private Status deployTester(RunId id) {
+ private Status deployTester(RunId id, ByteArrayLogger logger) {
// TODO jvenstad: Consider deploying old version of tester for initial staging feeding?
- logger.get().log("Deploying the tester container ...");
+ logger.log("Deploying the tester container ...");
return deploy(testerOf(id.application()),
id.type(),
() -> controller.applications().deployTester(testerOf(id.application()),
testerPackage(id),
- zone(id.type()),
+ id.type().zone(controller.system()),
new DeployOptions(true,
Optional.of(controller.systemVersion()),
false,
- false)));
+ false)),
+ logger);
}
- private Status deploy(ApplicationId id, JobType type, Supplier<ActivateResult> deployment) {
+ private Status deploy(ApplicationId id, JobType type, Supplier<ActivateResult> deployment, ByteArrayLogger logger) {
try {
PrepareResponse prepareResponse = deployment.get().prepareResponse();
if ( ! prepareResponse.configChangeActions.refeedActions.stream().allMatch(action -> action.allowed)) {
- logger.get().log("Deploy failed due to non-compatible changes that require re-feed. " +
+ logger.log("Deploy failed due to non-compatible changes that require re-feed. " +
"Your options are: \n" +
"1. Revert the incompatible changes.\n" +
"2. If you think it is safe in your case, you can override this validation, see\n" +
@@ -186,7 +183,7 @@ public class InternalStepRunner implements StepRunner {
}
if (prepareResponse.configChangeActions.restartActions.isEmpty())
- logger.get().log("No services requiring restart.");
+ logger.log("No services requiring restart.");
else
prepareResponse.configChangeActions.restartActions.stream()
.flatMap(action -> action.services.stream())
@@ -194,72 +191,72 @@ public class InternalStepRunner implements StepRunner {
.sorted().distinct()
.map(Hostname::new)
.forEach(hostname -> {
- controller.applications().restart(new DeploymentId(id, zone(type)), Optional.of(hostname));
- logger.get().log("Restarting services on host " + hostname.id() + ".");
+ controller.applications().restart(new DeploymentId(id, type.zone(controller.system())), Optional.of(hostname));
+ logger.log("Restarting services on host " + hostname.id() + ".");
});
- logger.get().log("Deployment successful.");
+ logger.log("Deployment successful.");
return succeeded;
}
catch (ConfigServerException e) {
if ( e.getErrorCode() == OUT_OF_CAPACITY && type.isTest()
|| e.getErrorCode() == ACTIVATION_CONFLICT
|| e.getErrorCode() == APPLICATION_LOCK_FAILURE) {
- logger.get().log("Will retry, because of '" + e.getErrorCode() + "' deploying:\n" + e.getMessage());
+ logger.log("Will retry, because of '" + e.getErrorCode() + "' deploying:\n" + e.getMessage());
return unfinished;
}
throw e;
}
}
- private Status installInitialReal(RunId id) {
- return installReal(id.application(), id.type(), true);
+ private Status installInitialReal(RunId id, ByteArrayLogger logger) {
+ return installReal(id, true, logger);
}
- private Status installReal(RunId id) {
- return installReal(id.application(), id.type(), false);
+ private Status installReal(RunId id, ByteArrayLogger logger) {
+ return installReal(id, false, logger);
}
- private Status installReal(ApplicationId id, JobType type, boolean setTheStage) {
- JobStatus.JobRun triggering = triggering(id, type);
- Version platform = setTheStage ? triggering.sourcePlatform().orElse(triggering.platform()) : triggering.platform();
- ApplicationVersion application = setTheStage ? triggering.sourceApplication().orElse(triggering.application()) : triggering.application();
- logger.get().log("Checking installation of " + platform + " and " + application + " ...");
+ private Status installReal(RunId id, boolean setTheStage, ByteArrayLogger logger) {
+ Versions versions = controller.jobController().run(id).get().versions();
+ Version platform = setTheStage ? versions.sourcePlatform().orElse(versions.targetPlatform()) : versions.targetPlatform();
+ ApplicationVersion application = setTheStage ? versions.sourceApplication().orElse(versions.targetApplication()) : versions.targetApplication();
+ logger.log("Checking installation of " + platform + " and " + application + " ...");
- if (nodesConverged(id, type, platform) && servicesConverged(id, type)) {
- logger.get().log("Installation succeeded!");
+ if (nodesConverged(id.application(), id.type(), platform, logger) && servicesConverged(id.application(), id.type())) {
+ logger.log("Installation succeeded!");
return succeeded;
}
- if (timedOut(id, type, installationTimeout)) {
- logger.get().log(INFO, "Installation failed to complete within " + installationTimeout.toMinutes() + " minutes!");
+ if (timedOut(id.application(), id.type(), installationTimeout)) {
+ logger.log(INFO, "Installation failed to complete within " + installationTimeout.toMinutes() + " minutes!");
return failed;
}
- logger.get().log("Installation not yet complete.");
+ logger.log("Installation not yet complete.");
return unfinished;
}
- private Status installTester(RunId id) {
- logger.get().log("Checking installation of tester container ...");
+ private Status installTester(RunId id, ByteArrayLogger logger) {
+ logger.log("Checking installation of tester container ...");
if (servicesConverged(testerOf(id.application()), id.type())) {
- logger.get().log("Tester container successfully installed!");
+ logger.log("Tester container successfully installed!");
return succeeded;
}
if (timedOut(id.application(), id.type(), installationTimeout)) {
- logger.get().log(WARNING, "Installation of tester failed to complete within " + installationTimeout.toMinutes() + " minutes of real deployment!");
+ logger.log(WARNING, "Installation of tester failed to complete within " + installationTimeout.toMinutes() + " minutes of real deployment!");
return failed;
}
- logger.get().log("Installation of tester not yet complete.");
+ logger.log("Installation of tester not yet complete.");
return unfinished;
}
- private boolean nodesConverged(ApplicationId id, JobType type, Version target) {
- List<Node> nodes = controller.configServer().nodeRepository().list(zone(type), id, Arrays.asList(active, reserved));
+ private boolean nodesConverged(ApplicationId id, JobType type, Version target, ByteArrayLogger logger) {
+ List<Node> nodes = controller.configServer().nodeRepository().list(type.zone(controller.system()), id, Arrays.asList(active, reserved));
for (Node node : nodes)
- logger.get().log(String.format("%70s: %-12s%-25s%-32s%s",
+ logger.log(String.format("%70s: %-16s%-25s%-32s%s",
node.hostname(),
node.serviceState(),
node.wantedVersion() + (node.currentVersion().equals(node.wantedVersion()) ? "" : " <-- " + node.currentVersion()),
@@ -275,49 +272,50 @@ public class InternalStepRunner implements StepRunner {
private boolean servicesConverged(ApplicationId id, JobType type) {
// TODO jvenstad: Print information for each host.
- return controller.configServer().serviceConvergence(new DeploymentId(id, zone(type)))
+ return controller.configServer().serviceConvergence(new DeploymentId(id, type.zone(controller.system())))
.map(ServiceConvergence::converged)
.orElse(false);
}
- private Status startTests(RunId id) {
- logger.get().log("Attempting to find endpoints ...");
+ private Status startTests(RunId id, ByteArrayLogger logger) {
+ logger.log("Attempting to find endpoints ...");
Map<ZoneId, List<URI>> endpoints = deploymentEndpoints(id.application());
- logger.get().log("Found endpoints:\n" +
+ logger.log("Found endpoints:\n" +
endpoints.entrySet().stream()
.map(zoneEndpoints -> "- " + zoneEndpoints.getKey() + ":\n" +
zoneEndpoints.getValue().stream()
.map(uri -> " |-- " + uri)
- .collect(Collectors.joining("\n"))));
- if ( ! endpoints.containsKey(zone(id.type()))) {
+ .collect(Collectors.joining("\n")))
+ .collect(Collectors.joining("\n")));
+ if ( ! endpoints.containsKey(id.type().zone(controller.system()))) {
if (timedOut(id.application(), id.type(), endpointTimeout)) {
- logger.get().log(WARNING, "Endpoints failed to show up within " + endpointTimeout.toMinutes() + " minutes!");
+ logger.log(WARNING, "Endpoints failed to show up within " + endpointTimeout.toMinutes() + " minutes!");
return failed;
}
- logger.get().log("Endpoints for the deployment to test are not yet ready.");
+ logger.log("Endpoints for the deployment to test are not yet ready.");
return unfinished;
}
Optional<URI> testerEndpoint = testerEndpoint(id);
if (testerEndpoint.isPresent()) {
- logger.get().log("Starting tests ...");
+ logger.log("Starting tests ...");
testerCloud.startTests(testerEndpoint.get(),
TesterCloud.Suite.of(id.type()),
- testConfig(id.application(), zone(id.type()), controller.system(), endpoints));
+ testConfig(id.application(), id.type().zone(controller.system()), controller.system(), endpoints));
return succeeded;
}
- if (timedOut(id.application(), id.type(), installationTimeout)) {
- logger.get().log(WARNING, "Endpoint for tester failed to show up within " + installationTimeout.toMinutes() + " minutes of real deployment!");
+ if (timedOut(id.application(), id.type(), endpointTimeout)) {
+ logger.log(WARNING, "Endpoint for tester failed to show up within " + endpointTimeout.toMinutes() + " minutes of real deployment!");
return failed;
}
- logger.get().log("Endpoints of tester container not yet available.");
+ logger.log("Endpoints of tester container not yet available.");
return unfinished;
}
- private Status endTests(RunId id) {
+ private Status endTests(RunId id, ByteArrayLogger logger) {
URI testerEndpoint = testerEndpoint(id)
.orElseThrow(() -> new NoSuchElementException("Endpoint for tester vanished again before tests were complete!"));
@@ -326,39 +324,33 @@ public class InternalStepRunner implements StepRunner {
case NOT_STARTED:
throw new IllegalStateException("Tester reports tests not started, even though they should have!");
case RUNNING:
- logger.get().log("Tests still running ...");
+ logger.log("Tests still running ...");
return unfinished;
case FAILURE:
- logger.get().log("Tests failed.");
+ logger.log("Tests failed.");
status = failed; break;
case ERROR:
- logger.get().log(INFO, "Tester failed running its tests!");
+ logger.log(INFO, "Tester failed running its tests!");
status = failed; break;
case SUCCESS:
- logger.get().log("Tests completed successfully.");
+ logger.log("Tests completed successfully.");
status = succeeded; break;
default:
throw new AssertionError("Unknown status!");
}
- logger.get().log(new String(testerCloud.getLogs(testerEndpoint))); // TODO jvenstad: Replace with something less hopeless!
+ logger.log(new String(testerCloud.getLogs(testerEndpoint))); // TODO jvenstad: Replace with something less hopeless!
return status;
}
- private Status deactivateReal(RunId id) {
- logger.get().log("Deactivating deployment of " + id.application() + " in " + zone(id.type()) + " ...");
- return deactivate(id.application(), id.type());
- }
-
- private Status deactivateTester(RunId id) {
- logger.get().log("Deactivating tester of " + id.application() + " in " + zone(id.type()) + " ...");
- return deactivate(testerOf(id.application()), id.type());
+ private Status deactivateReal(RunId id, ByteArrayLogger logger) {
+ logger.log("Deactivating deployment of " + id.application() + " in " + id.type().zone(controller.system()) + " ...");
+ controller.applications().deactivate(id.application(), id.type().zone(controller.system()));
+ return succeeded;
}
- private Status deactivate(ApplicationId id, JobType type) {
- try {
- controller.configServer().deactivate(new DeploymentId(id, zone(type)));
- }
- catch (NoInstanceException e) { }
+ private Status deactivateTester(RunId id, ByteArrayLogger logger) {
+ logger.log("Deactivating tester of " + id.application() + " in " + id.type().zone(controller.system()) + " ...");
+ controller.jobController().deactivateTester(id.application(), id.type());
return succeeded;
}
@@ -372,26 +364,16 @@ public class InternalStepRunner implements StepRunner {
return controller.applications().require(id);
}
- /** Returns the zone of the given job type. */
- private ZoneId zone(JobType type) {
- return type.zone(controller.system());
- }
-
- /** Returns the triggering of the currently running job, i.e., this job. */
- private JobStatus.JobRun triggering(ApplicationId id, JobType type) {
- return application(id).deploymentJobs().statusOf(type).get().lastTriggered().get();
- }
-
/** Returns whether the time elapsed since the last real deployment in the given zone is more than the given timeout. */
private boolean timedOut(ApplicationId id, JobType type, Duration timeout) {
- return application(id).deployments().get(zone(type)).at().isBefore(controller.clock().instant().minus(timeout));
+ return application(id).deployments().get(type.zone(controller.system())).at().isBefore(controller.clock().instant().minus(timeout));
}
/** Returns a generated job report for the given run. */
private DeploymentJobs.JobReport report(RunStatus run) {
return new DeploymentJobs.JobReport(run.id().application(),
run.id().type(),
- Long.MAX_VALUE,
+ 1,
run.id().number(),
Optional.empty(),
run.hasFailed() ? Optional.of(DeploymentJobs.JobError.unknown) : Optional.empty());
@@ -399,10 +381,7 @@ public class InternalStepRunner implements StepRunner {
/** Returns the application package for the tester application, assembled from a generated config, fat-jar and services.xml. */
private ApplicationPackage testerPackage(RunId id) {
- ApplicationVersion version = application(id.application()).deploymentJobs()
- .statusOf(id.type()).get()
- .lastTriggered().get()
- .application();
+ ApplicationVersion version = controller.jobController().run(id).get().versions().targetApplication();
byte[] testPackage = controller.applications().artifacts().getTesterPackage(testerOf(id.application()), version.id());
byte[] servicesXml = servicesXml(controller.system());
@@ -419,6 +398,7 @@ public class InternalStepRunner implements StepRunner {
ImmutableMap.Builder<ZoneId, List<URI>> deployments = ImmutableMap.builder();
application(id).deployments().keySet()
.forEach(zone -> controller.applications().getDeploymentEndpoints(new DeploymentId(id, zone))
+ .filter(endpoints -> ! endpoints.isEmpty())
.ifPresent(endpoints -> deployments.put(zone, endpoints)));
return deployments.build();
}
@@ -426,7 +406,7 @@ public class InternalStepRunner implements StepRunner {
/** Returns a URI of the tester endpoint retrieved from the routing generator, provided it matches an expected form. */
private Optional<URI> testerEndpoint(RunId id) {
ApplicationId tester = testerOf(id.application());
- return controller.applications().getDeploymentEndpoints(new DeploymentId(tester, zone(id.type())))
+ return controller.applications().getDeploymentEndpoints(new DeploymentId(tester, id.type().zone(controller.system())))
.flatMap(uris -> uris.stream()
.filter(uri -> uri.getHost().contains(String.format("%s--%s--%s.",
tester.instance().value(),
@@ -529,6 +509,7 @@ public class InternalStepRunner implements StepRunner {
for (String line : record.getMessage().split("\n"))
out.println(timestamp + ": " + line);
+ record.setSourceClassName(null); // Makes the root logger's ConsoleHandler use the logger name instead, when printing.
getParent().log(record);
}
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java
index cda226d0ded..c966492259f 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java
@@ -1,7 +1,6 @@
package com.yahoo.vespa.hosted.controller.deployment;
import com.google.common.collect.ImmutableMap;
-import com.yahoo.component.Version;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.vespa.curator.Lock;
import com.yahoo.vespa.hosted.controller.Application;
@@ -11,6 +10,7 @@ import com.yahoo.vespa.hosted.controller.api.integration.LogStore;
import com.yahoo.vespa.hosted.controller.api.integration.configserver.NoInstanceException;
import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType;
import com.yahoo.vespa.hosted.controller.api.integration.deployment.RunId;
+import com.yahoo.vespa.hosted.controller.application.ApplicationPackage;
import com.yahoo.vespa.hosted.controller.application.ApplicationVersion;
import com.yahoo.vespa.hosted.controller.application.DeploymentJobs;
import com.yahoo.vespa.hosted.controller.application.JobStatus;
@@ -36,9 +36,9 @@ import static com.yahoo.vespa.hosted.controller.deployment.InternalStepRunner.te
/**
* A singleton owned by the controller, which contains the state and methods for controlling deployment jobs.
*
- * Keys are the {@link ApplicationId} of the real application, for which the deployment job is run, and the
- * {@link JobType} of the real deployment to test.
- * Although the deployment jobs are themselves applications, their IDs are not to be referenced.
+ * Keys are the {@link ApplicationId} of the real application, for which the deployment job is run, the
+ * {@link JobType} to run, and the strictly increasing run number of this combination.
+ * The deployment jobs run tests using regular applications, but these tester application IDs are not to be used elsewhere.
*
* Jobs consist of sets of {@link Step}s, defined in {@link JobProfile}s.
* Each run is represented by a {@link RunStatus}, which holds the status of each step of the run, as well as
@@ -63,7 +63,7 @@ public class JobController {
public void updateStorage() {
for (ApplicationId id : applications())
for (JobType type : jobs(id)) {
- locked(id, type, runs -> {
+ locked(id, type, runs -> { // runs is unmodified, and written back as such.
curator.readLastRun(id, type).ifPresent(curator::writeLastRun);
});
}
@@ -91,14 +91,6 @@ public class JobController {
}
}
- // TODO jvenstad: Remove this, and let the DeploymentTrigger trigger directly with the correct BuildService.
- /** Returns whether the given application has registered with this build service. */
- public boolean builds(ApplicationId id) {
- return controller.applications().get(id)
- .map(application -> application.deploymentJobs().builtInternally())
- .orElse(false);
- }
-
/** Returns a list of all application which have registered. */
public List<ApplicationId> applications() {
return copyOf(controller.applications().asList().stream()
@@ -180,17 +172,21 @@ public class JobController {
byte[] applicationPackage, byte[] applicationTestPackage) {
AtomicReference<ApplicationVersion> version = new AtomicReference<>();
controller.applications().lockOrThrow(id, application -> {
- controller.applications().store(application.withBuiltInternally(true));
-
long run = nextBuild(id);
version.set(ApplicationVersion.from(revision, run));
- // TODO smorgrav: Store the pair.
-// controller.applications().artifacts().putApplicationPackage(id, version.toString(), applicationPackage);
-// controller.applications().artifacts().putTesterPackage(
-// InternalStepRunner.testerOf(id), version.toString(), applicationTestPackage);
-//
-// notifyOfNewSubmission(id, revision, run);
+ controller.applications().artifacts().putApplicationPackage(id,
+ version.toString(),
+ applicationPackage);
+ controller.applications().artifacts().putTesterPackage(InternalStepRunner.testerOf(id),
+ version.toString(),
+ applicationTestPackage);
+
+ application = application.withBuiltInternally(true);
+ controller.applications().store(controller.applications().withUpdatedConfig(application,
+ new ApplicationPackage(applicationPackage)));
+
+ notifyOfNewSubmission(id, revision, run);
});
return version.get();
}
@@ -246,13 +242,12 @@ public class JobController {
});
}
- // TODO jvenstad: Urgh, clean this up somehow?
public void deactivateTester(ApplicationId id, JobType type) {
try {
controller.configServer().deactivate(new DeploymentId(testerOf(id), type.zone(controller.system())));
}
catch (NoInstanceException ignored) {
- // ok; already gone
+ // Already gone -- great!
}
}
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/RunStatus.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/RunStatus.java
index 23b9624679d..504d8cfc88c 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/RunStatus.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/RunStatus.java
@@ -142,6 +142,7 @@ public class RunStatus {
public String toString() {
return "RunStatus{" +
"id=" + id +
+ ", versions=" + versions +
", start=" + start +
", end=" + end +
", aborted=" + aborted +
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentExpirer.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentExpirer.java
index 423f7f50aed..9133c8980ec 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentExpirer.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentExpirer.java
@@ -42,7 +42,7 @@ public class DeploymentExpirer extends Maintainer {
if (hasExpired(controller().zoneRegistry(), deployment, clock.instant())) {
try {
- controller().applications().deactivate(application, deployment.zone());
+ controller().applications().deactivate(application.id(), deployment.zone());
} catch (Exception e) {
log.log(Level.WARNING, "Could not expire " + deployment + " of " + application +
": " + Exceptions.toMessageString(e) + ". Retrying in " +
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/JobRunner.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/JobRunner.java
index 9fa67cb5f89..dd89644b580 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/JobRunner.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/JobRunner.java
@@ -25,6 +25,7 @@ import java.util.logging.Logger;
*/
public class JobRunner extends Maintainer {
+ static final Duration jobTimeout = Duration.ofDays(1);
private static final Logger log = Logger.getLogger(JobRunner.class.getName());
private final JobController jobs;
@@ -36,7 +37,7 @@ public class JobRunner extends Maintainer {
}
@TestOnly
- JobRunner(Controller controller, Duration duration, JobControl jobControl, ExecutorService executors, StepRunner runner) {
+ public JobRunner(Controller controller, Duration duration, JobControl jobControl, ExecutorService executors, StepRunner runner) {
super(controller, duration, jobControl);
this.jobs = controller.jobController();
this.executors = executors;
@@ -67,6 +68,8 @@ public class JobRunner extends Maintainer {
steps.forEach(step -> executors.execute(() -> advance(run.id(), step)));
if (steps.isEmpty())
jobs.finish(run.id());
+ else if (run.start().isBefore(controller().clock().instant().minus(jobTimeout)))
+ jobs.abort(run.id());
}
/** Attempts to advance the status of the given step, for the given run. */
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java
index 9e45526e5e4..34d2257c5f4 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java
@@ -370,7 +370,7 @@ public class ApplicationApiHandler extends LoggingRequestHandler {
// Jobs sorted according to deployment spec
List<JobStatus> jobStatus = controller.applications().deploymentTrigger()
.steps(application.deploymentSpec())
- .sortBy(application.deploymentJobs().jobStatus().values());
+ .sortedJobs(application.deploymentJobs().jobStatus().values());
Cursor deploymentsArray = object.setArray("deploymentJobs");
for (JobStatus job : jobStatus) {
@@ -411,7 +411,7 @@ public class ApplicationApiHandler extends LoggingRequestHandler {
// Deployments sorted according to deployment spec
List<Deployment> deployments = controller.applications().deploymentTrigger()
.steps(application.deploymentSpec())
- .sortBy2(application.deployments().values());
+ .sortedDeployments(application.deployments().values());
Cursor instancesArray = object.setArray("instances");
for (Deployment deployment : deployments) {
Cursor deploymentObject = instancesArray.addObject();
@@ -820,7 +820,7 @@ public class ApplicationApiHandler extends LoggingRequestHandler {
Application application = controller.applications().require(ApplicationId.from(tenantName, applicationName, instanceName));
// Attempt to deactivate application even if the deployment is not known by the controller
- controller.applications().deactivate(application, ZoneId.from(environment, region));
+ controller.applications().deactivate(application.id(), ZoneId.from(environment, region));
// TODO: Change to return JSON
return new StringResponse("Deactivated " + path(TenantResource.API_PATH, tenantName,
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java
index 6b5e5b0199c..635e0c1fb26 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java
@@ -12,11 +12,9 @@ import com.yahoo.config.provision.RegionName;
import com.yahoo.config.provision.SystemName;
import com.yahoo.config.provision.TenantName;
import com.yahoo.vespa.athenz.api.NToken;
-import com.yahoo.vespa.config.SlimeUtils;
import com.yahoo.vespa.hosted.controller.api.application.v4.model.DeployOptions;
import com.yahoo.vespa.hosted.controller.api.application.v4.model.EndpointStatus;
import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId;
-import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType;
import com.yahoo.vespa.hosted.controller.api.integration.dns.Record;
import com.yahoo.vespa.hosted.controller.api.integration.dns.RecordName;
import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId;
@@ -34,13 +32,10 @@ import com.yahoo.vespa.hosted.controller.rotation.RotationLock;
import org.junit.Test;
import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Paths;
import java.time.Duration;
import java.util.List;
import java.util.Map;
import java.util.Optional;
-import java.util.function.Supplier;
import static com.yahoo.config.provision.SystemName.main;
import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType.component;
@@ -310,8 +305,8 @@ public class ControllerTest {
.build();
tester.jobCompletion(component).application(app1).nextBuildNumber().uploadArtifact(applicationPackage).submit();
tester.deployAndNotify(app1, applicationPackage, true, systemTest);
- tester.applications().deactivate(app1, ZoneId.from(Environment.test, RegionName.from("us-east-1")));
- tester.applications().deactivate(app1, ZoneId.from(Environment.staging, RegionName.from("us-east-3")));
+ tester.applications().deactivate(app1.id(), ZoneId.from(Environment.test, RegionName.from("us-east-1")));
+ tester.applications().deactivate(app1.id(), ZoneId.from(Environment.staging, RegionName.from("us-east-3")));
tester.applications().deleteApplication(app1.id(), Optional.of(new NToken("ntoken")));
try (RotationLock lock = tester.applications().rotationRepository().lock()) {
assertTrue("Rotation is unassigned",
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTester.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTester.java
index 324ae4440cd..106cd280098 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTester.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTester.java
@@ -23,6 +23,7 @@ import com.yahoo.vespa.hosted.controller.api.integration.entity.MemoryEntityServ
import com.yahoo.vespa.hosted.controller.api.integration.github.GitHubMock;
import com.yahoo.vespa.hosted.controller.api.integration.organization.MockOrganization;
import com.yahoo.vespa.hosted.controller.api.integration.routing.MemoryGlobalRoutingService;
+import com.yahoo.vespa.hosted.controller.api.integration.routing.RoutingGenerator;
import com.yahoo.vespa.hosted.controller.api.integration.stubs.MockBuildService;
import com.yahoo.vespa.hosted.controller.api.integration.stubs.MockLogStore;
import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId;
@@ -69,6 +70,7 @@ public final class ControllerTester {
private final EntityService entityService;
private final MockBuildService buildService;
private final MetricsServiceMock metricsService;
+ private final RoutingGeneratorMock routingGenerator;
private Controller controller;
@@ -77,7 +79,7 @@ public final class ControllerTester {
this(new AthenzDbMock(), clock, new ConfigServerMock(new ZoneRegistryMock()),
new ZoneRegistryMock(), new GitHubMock(), curatorDb, rotationsConfig,
new MemoryNameService(), new ArtifactRepositoryMock(), new MemoryEntityService(), new MockBuildService(),
- metricsService);
+ metricsService, new RoutingGeneratorMock());
}
public ControllerTester(ManualClock clock) {
@@ -101,7 +103,7 @@ public final class ControllerTester {
GitHubMock gitHub, CuratorDb curator, RotationsConfig rotationsConfig,
MemoryNameService nameService, ArtifactRepositoryMock artifactRepository,
EntityService entityService, MockBuildService buildService,
- MetricsServiceMock metricsService) {
+ MetricsServiceMock metricsService, RoutingGeneratorMock routingGenerator) {
this.athenzDb = athenzDb;
this.clock = clock;
this.configServer = configServer;
@@ -114,9 +116,10 @@ public final class ControllerTester {
this.entityService = entityService;
this.buildService = buildService;
this.metricsService = metricsService;
+ this.routingGenerator = routingGenerator;
this.controller = createController(curator, rotationsConfig, configServer, clock, gitHub, zoneRegistry,
athenzDb, nameService, artifactRepository, entityService, buildService,
- metricsService);
+ metricsService, routingGenerator);
// Make root logger use time from manual clock
Logger.getLogger("").getHandlers()[0].setFilter(
@@ -150,10 +153,13 @@ public final class ControllerTester {
public MetricsServiceMock metricsService() { return metricsService; }
+ public RoutingGeneratorMock routingGenerator() { return routingGenerator; }
+
/** Create a new controller instance. Useful to verify that controller state is rebuilt from persistence */
public final void createNewController() {
controller = createController(curator, rotationsConfig, configServer, clock, gitHub, zoneRegistry, athenzDb,
- nameService, artifactRepository, entityService, buildService, metricsService);
+ nameService, artifactRepository, entityService, buildService, metricsService,
+ routingGenerator);
}
/** Creates the given tenant and application and deploys it */
@@ -267,7 +273,8 @@ public final class ControllerTester {
GitHubMock gitHub, ZoneRegistryMock zoneRegistryMock,
AthenzDbMock athensDb, MemoryNameService nameService,
ArtifactRepository artifactRepository, EntityService entityService,
- BuildService buildService, MetricsServiceMock metricsService) {
+ BuildService buildService, MetricsServiceMock metricsService,
+ RoutingGenerator routingGenerator) {
Controller controller = new Controller(curator,
rotationsConfig,
gitHub,
@@ -278,7 +285,7 @@ public final class ControllerTester {
configServer,
metricsService,
nameService,
- new RoutingGeneratorMock(),
+ routingGenerator,
new ChefMock(),
clock,
new AthenzClientFactoryMock(athensDb),
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTester.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTester.java
index a9682fc6e34..44af8edb96e 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTester.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTester.java
@@ -30,7 +30,6 @@ import java.time.Duration;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
-import java.util.stream.Collectors;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -181,25 +180,17 @@ public class DeploymentTester {
.buildNumber(buildNumber)
.uploadArtifact(applicationPackage)
.submit();
- completeDeployment(application, applicationPackage, Optional.of(failOnJob), true);
- assertTrue(applications().require(application.id()).change().isPresent());
+ completeDeployment(application, applicationPackage, Optional.ofNullable(failOnJob));
}
public void deployCompletely(Application application, ApplicationPackage applicationPackage, long buildNumber) {
- jobCompletion(JobType.component).application(application)
- .buildNumber(buildNumber)
- .uploadArtifact(applicationPackage)
- .submit();
- assertTrue(applications().require(application.id()).change().isPresent());
- completeDeployment(application, applicationPackage, Optional.empty(), true);
+ completeDeploymentWithError(application, applicationPackage, buildNumber, null);
}
- private void completeDeployment(Application application, ApplicationPackage applicationPackage,
- Optional<JobType> failOnJob, boolean includingProductionZones) {
+ private void completeDeployment(Application application, ApplicationPackage applicationPackage, Optional<JobType> failOnJob) {
+ assertTrue(applications().require(application.id()).change().isPresent());
DeploymentSteps steps = controller().applications().deploymentTrigger().steps(applicationPackage.deploymentSpec());
List<JobType> jobs = steps.jobs();
- if ( ! includingProductionZones)
- jobs = jobs.stream().filter(job -> ! job.isProduction()).collect(Collectors.toList());
for (JobType job : jobs) {
boolean failJob = failOnJob.map(j -> j.equals(job)).orElse(false);
deployAndNotify(application, applicationPackage, ! failJob, job);
@@ -210,12 +201,9 @@ public class DeploymentTester {
if (failOnJob.isPresent()) {
assertTrue(applications().require(application.id()).change().isPresent());
assertTrue(applications().require(application.id()).deploymentJobs().hasFailures());
- } else if (includingProductionZones) {
+ } else {
assertFalse(applications().require(application.id()).change().isPresent());
}
- else {
- assertTrue(applications().require(application.id()).change().isPresent());
- }
}
public void completeUpgrade(Application application, Version version, String upgradePolicy) {
@@ -225,7 +213,7 @@ public class DeploymentTester {
public void completeUpgrade(Application application, Version version, ApplicationPackage applicationPackage) {
assertTrue(application + " has a change", applications().require(application.id()).change().isPresent());
assertEquals(Change.of(version), applications().require(application.id()).change());
- completeDeployment(application, applicationPackage, Optional.empty(), true);
+ completeDeployment(application, applicationPackage, Optional.empty());
}
public void completeUpgradeWithError(Application application, Version version, String upgradePolicy, JobType failOnJob) {
@@ -239,7 +227,7 @@ public class DeploymentTester {
private void completeUpgradeWithError(Application application, Version version, ApplicationPackage applicationPackage, Optional<JobType> failOnJob) {
assertTrue(applications().require(application.id()).change().isPresent());
assertEquals(Change.of(version), applications().require(application.id()).change());
- completeDeployment(application, applicationPackage, failOnJob, true);
+ completeDeployment(application, applicationPackage, failOnJob);
}
public void deploy(JobType job, Application application, ApplicationPackage applicationPackage) {
@@ -278,7 +266,7 @@ public class DeploymentTester {
}
// Deactivate test deployments after deploy. This replicates the behaviour of the tenant pipeline
if (job.isTest()) {
- controller().applications().deactivate(application, job.zone(controller().system()));
+ controller().applications().deactivate(application.id(), job.zone(controller().system()));
}
jobCompletion(job).application(application).success(success).submit();
}
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunnerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunnerTest.java
index abff8fdbe42..d1c9b9f9b7e 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunnerTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunnerTest.java
@@ -1,22 +1,389 @@
// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.controller.deployment;
+import com.yahoo.component.Version;
+import com.yahoo.config.provision.ApplicationId;
+import com.yahoo.config.provision.Environment;
+import com.yahoo.config.provision.HostName;
import com.yahoo.config.provision.SystemName;
+import com.yahoo.slime.ArrayTraverser;
+import com.yahoo.slime.Inspector;
+import com.yahoo.vespa.config.SlimeUtils;
+import com.yahoo.vespa.hosted.controller.Application;
+import com.yahoo.vespa.hosted.controller.api.application.v4.model.configserverbindings.ConfigChangeActions;
+import com.yahoo.vespa.hosted.controller.api.application.v4.model.configserverbindings.RefeedAction;
+import com.yahoo.vespa.hosted.controller.api.application.v4.model.configserverbindings.RestartAction;
+import com.yahoo.vespa.hosted.controller.api.application.v4.model.configserverbindings.ServiceInfo;
+import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId;
+import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType;
+import com.yahoo.vespa.hosted.controller.api.integration.deployment.RunId;
+import com.yahoo.vespa.hosted.controller.api.integration.deployment.TesterCloud;
+import com.yahoo.vespa.hosted.controller.api.integration.routing.RoutingEndpoint;
+import com.yahoo.vespa.hosted.controller.api.integration.stubs.MockTesterCloud;
+import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId;
+import com.yahoo.vespa.hosted.controller.application.ApplicationPackage;
+import com.yahoo.vespa.hosted.controller.application.ApplicationVersion;
+import com.yahoo.vespa.hosted.controller.integration.RoutingGeneratorMock;
+import com.yahoo.vespa.hosted.controller.maintenance.JobControl;
+import com.yahoo.vespa.hosted.controller.maintenance.JobRunner;
+import com.yahoo.vespa.hosted.controller.maintenance.JobRunnerTest;
+import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
import java.io.UncheckedIOException;
+import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.time.Duration;
+import java.util.Collections;
+import java.util.Optional;
+import java.util.logging.Logger;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import static com.yahoo.log.LogLevel.DEBUG;
+import static com.yahoo.vespa.hosted.controller.deployment.InternalStepRunner.testerOf;
+import static com.yahoo.vespa.hosted.controller.deployment.Step.Status.failed;
+import static com.yahoo.vespa.hosted.controller.deployment.Step.Status.succeeded;
+import static com.yahoo.vespa.hosted.controller.deployment.Step.Status.unfinished;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
/**
+ * @author jonmv
* @author freva
*/
public class InternalStepRunnerTest {
+ private static final ApplicationPackage applicationPackage = new ApplicationPackageBuilder()
+ .upgradePolicy("default")
+ .environment(Environment.prod)
+ .region("us-west-1")
+ .build();
+ private static final ApplicationId appId = ApplicationId.from("tenant", "application", "default");
+
+ private DeploymentTester tester;
+ private JobController jobs;
+ private RoutingGeneratorMock routing;
+ private MockTesterCloud cloud;
+ private JobRunner runner;
+ private Application app() { return tester.application(appId); }
+
+ @Before
+ public void setup() {
+ tester = new DeploymentTester();
+ tester.createApplication(appId.application().value(), appId.tenant().value(), 1, 1L);
+ jobs = tester.controller().jobController();
+ routing = tester.controllerTester().routingGenerator();
+ cloud = new MockTesterCloud();
+ runner = new JobRunner(tester.controller(), Duration.ofDays(1), new JobControl(tester.controller().curator()),
+ JobRunnerTest.inThreadExecutor(), new InternalStepRunner(tester.controller(), cloud));
+ routing.putEndpoints(new DeploymentId(null, null), Collections.emptyList()); // Turn off default behaviour for the mock.
+
+ // Get deployment job logs to stderr.
+ Logger.getLogger(InternalStepRunner.class.getName()).setLevel(DEBUG);
+ Logger.getLogger("").setLevel(DEBUG);
+ Logger.getLogger("").getHandlers()[0].setLevel(DEBUG);
+ }
+
+ @Test
+ public void canRegisterAndRunDirectly() {
+ jobs.register(appId);
+
+ deployNewSubmission();
+
+ deployNewPlatform(new Version("7.1"));
+ }
+
+ @Test
+ public void canSwitchFromScrewdriver() {
+ // Deploys a default application package with default build number.
+ tester.deployCompletely(app(), applicationPackage);
+ setEndpoints(appId, JobType.productionUsWest1.zone(tester.controller().system()));
+
+ jobs.register(appId);
+
+ deployNewSubmission();
+
+ deployNewPlatform(new Version("7.1"));
+ }
+
+ /** Submits a new application, and returns the version of the new submission. */
+ private ApplicationVersion newSubmission(ApplicationId id) {
+ ApplicationVersion version = jobs.submit(id, BuildJob.defaultSourceRevision, applicationPackage.zippedContent(), new byte[0]);
+ tester.artifactRepository().putApplicationPackage(appId, version.id(), applicationPackage.zippedContent());
+ tester.artifactRepository().putTesterPackage(testerOf(appId), version.id(), new byte[0]);
+ return version;
+ }
+
+ /** Sets a single endpoint in the routing mock; this matches that required for the tester. */
+ private void setEndpoints(ApplicationId id, ZoneId zone) {
+ routing.putEndpoints(new DeploymentId(id, zone),
+ Collections.singletonList(new RoutingEndpoint(String.format("https://%s--%s--%s.%s.%s.vespa:43",
+ id.instance().value(),
+ id.application().value(),
+ id.tenant().value(),
+ zone.region().value(),
+ zone.environment().value()),
+ false)));
+ }
+
+ /** Completely deploys a new submission. */
+ private void deployNewSubmission() {
+ assertTrue(app().deploymentJobs().builtInternally());
+ ApplicationVersion applicationVersion = newSubmission(appId);
+
+ assertFalse(app().deployments().values().stream()
+ .anyMatch(deployment -> deployment.applicationVersion().equals(applicationVersion)));
+ assertEquals(applicationVersion, app().change().application().get());
+ assertFalse(app().change().platform().isPresent());
+
+ runJob(JobType.systemTest);
+ runJob(JobType.stagingTest);
+ runJob(JobType.productionUsWest1);
+ }
+
+ /** Completely deploys the given, new platform. */
+ private void deployNewPlatform(Version version) {
+ assertTrue(app().deploymentJobs().builtInternally());
+
+ tester.upgradeSystem(version);
+ assertFalse(app().deployments().values().stream()
+ .anyMatch(deployment -> deployment.version().equals(version)));
+ assertEquals(version, app().change().platform().get());
+ assertFalse(app().change().application().isPresent());
+
+ runJob(JobType.systemTest);
+ runJob(JobType.stagingTest);
+ runJob(JobType.productionUsWest1);
+ assertTrue(app().productionDeployments().values().stream()
+ .allMatch(deployment -> deployment.version().equals(version)));
+ assertTrue(tester.configServer().nodeRepository()
+ .list(JobType.productionUsWest1.zone(tester.controller().system()), appId).stream()
+ .allMatch(node -> node.currentVersion().equals(version)));
+ assertFalse(app().change().isPresent());
+ }
+
+ /** Runs the whole of the given job, successfully. */
+ private void runJob(JobType type) {
+ tester.readyJobTrigger().maintain();
+ RunStatus run = jobs.active().stream()
+ .filter(r -> r.id().type() == type)
+ .findAny()
+ .orElseThrow(() -> new AssertionError(type + " is not among the active: " + jobs.active()));
+ assertFalse(run.hasFailed());
+ assertFalse(run.isAborted());
+
+ ZoneId zone = type.zone(tester.controller().system());
+ DeploymentId deployment = new DeploymentId(appId, zone);
+
+ // First steps are always deployments.
+ runner.run();
+
+ if (type == JobType.stagingTest) { // Do the initial deployment and installation of the real application.
+ assertEquals(unfinished, jobs.active(run.id()).get().steps().get(Step.installInitialReal));
+ tester.configServer().convergeServices(appId, zone);
+ run.versions().sourcePlatform().ifPresent(version -> tester.configServer().nodeRepository().doUpgrade(deployment, Optional.empty(), version));
+ runner.run();
+ assertEquals(Step.Status.succeeded, jobs.active(run.id()).get().steps().get(Step.installInitialReal));
+ }
+
+ assertEquals(unfinished, jobs.active(run.id()).get().steps().get(Step.installReal));
+ tester.configServer().nodeRepository().doUpgrade(deployment, Optional.empty(), run.versions().targetPlatform());
+ runner.run();
+ assertEquals(unfinished, jobs.active(run.id()).get().steps().get(Step.installReal));
+ tester.configServer().convergeServices(appId, zone);
+ runner.run();
+ assertEquals(Step.Status.succeeded, jobs.active(run.id()).get().steps().get(Step.installReal));
+
+ assertEquals(unfinished, jobs.active(run.id()).get().steps().get(Step.installTester));
+ tester.configServer().convergeServices(testerOf(appId), zone);
+ runner.run();
+ assertEquals(Step.Status.succeeded, jobs.active(run.id()).get().steps().get(Step.installTester));
+
+ // All installation is complete. We now need endpoints, and the tests will then run, and cleanup finish.
+ assertEquals(unfinished, jobs.active(run.id()).get().steps().get(Step.startTests));
+ setEndpoints(testerOf(appId), zone);
+ runner.run();
+ if ( ! run.versions().sourceApplication().isPresent() || ! type.isProduction()) {
+ assertEquals(unfinished, jobs.active(run.id()).get().steps().get(Step.startTests));
+ setEndpoints(appId, zone);
+ }
+ runner.run();
+ assertEquals(Step.Status.succeeded, jobs.active(run.id()).get().steps().get(Step.startTests));
+
+ assertEquals(unfinished, jobs.active(run.id()).get().steps().get(Step.endTests));
+ cloud.set("Awesome!".getBytes(), TesterCloud.Status.SUCCESS);
+ runner.run();
+ assertTrue(jobs.run(run.id()).get().hasEnded());
+ assertFalse(jobs.run(run.id()).get().hasFailed());
+ assertEquals(type.isProduction(), app().deployments().containsKey(zone));
+ assertTrue(tester.configServer().nodeRepository().list(zone, testerOf(appId)).isEmpty());
+
+ if ( ! app().deployments().containsKey(zone))
+ routing.removeEndpoints(deployment);
+ routing.removeEndpoints(new DeploymentId(testerOf(appId), zone));
+ }
+
+ @Test
+ public void refeedRequirementBlocksDeployment() {
+ RunId id = newRun(JobType.productionUsWest1);
+ tester.configServer().setConfigChangeActions(new ConfigChangeActions(Collections.emptyList(),
+ Collections.singletonList(new RefeedAction("Refeed",
+ false,
+ "doctype",
+ "cluster",
+ Collections.emptyList(),
+ Collections.singletonList("Refeed it!")))));
+ runner.run();
+
+ assertEquals(failed, jobs.run(id).get().steps().get(Step.deployReal));
+ }
+
+ @Test
+ public void restartsServicesAndWaitsForRestartAndReboot() {
+ RunId id = newRun(JobType.productionUsWest1);
+ ZoneId zone = id.type().zone(tester.controller().system());
+ HostName host = tester.configServer().hostFor(appId, zone);
+ tester.configServer().setConfigChangeActions(new ConfigChangeActions(Collections.singletonList(new RestartAction("cluster",
+ "container",
+ "search",
+ Collections.singletonList(new ServiceInfo("queries",
+ "search",
+ "config",
+ host.value())),
+ Collections.singletonList("Restart it!"))),
+ Collections.emptyList()));
+ runner.run();
+ assertEquals(succeeded, jobs.run(id).get().steps().get(Step.deployReal));
+
+ tester.configServer().convergeServices(appId, zone);
+ assertEquals(unfinished, jobs.run(id).get().steps().get(Step.installReal));
+
+ tester.configServer().nodeRepository().doRestart(new DeploymentId(appId, zone), Optional.of(host));
+ tester.configServer().nodeRepository().requestReboot(new DeploymentId(appId, zone), Optional.of(host));
+ runner.run();
+ assertEquals(unfinished, jobs.run(id).get().steps().get(Step.installReal));
+
+ tester.clock().advance(InternalStepRunner.installationTimeout.plus(Duration.ofSeconds(1)));
+ runner.run();
+ assertEquals(failed, jobs.run(id).get().steps().get(Step.installReal));
+ }
+
+ @Test
+ public void waitsForEndpointsAndTimesOut() {
+ newRun(JobType.systemTest);
+
+ runner.run();
+ tester.configServer().convergeServices(appId, JobType.stagingTest.zone(tester.controller().system()));
+ runner.run();
+ tester.configServer().convergeServices(appId, JobType.systemTest.zone(tester.controller().system()));
+ tester.configServer().convergeServices(testerOf(appId), JobType.systemTest.zone(tester.controller().system()));
+ tester.configServer().convergeServices(appId, JobType.stagingTest.zone(tester.controller().system()));
+ tester.configServer().convergeServices(testerOf(appId), JobType.stagingTest.zone(tester.controller().system()));
+ runner.run();
+
+ // Tester fails to show up for system tests, and the real deployment for staging tests.
+ setEndpoints(appId, JobType.systemTest.zone(tester.controller().system()));
+ setEndpoints(testerOf(appId), JobType.stagingTest.zone(tester.controller().system()));
+
+ tester.clock().advance(InternalStepRunner.endpointTimeout.plus(Duration.ofSeconds(1)));
+ runner.run();
+ assertEquals(failed, jobs.last(appId, JobType.systemTest).get().steps().get(Step.startTests));
+ assertEquals(failed, jobs.last(appId, JobType.stagingTest).get().steps().get(Step.startTests));
+ }
+
+ @Test
+ public void testsFailIfEndpointsAreGone() {
+ RunId id = startSystemTestTests();
+ cloud.set(new byte[0], TesterCloud.Status.NOT_STARTED);
+ runner.run();
+ assertEquals(failed, jobs.run(id).get().steps().get(Step.endTests));
+ }
+
+ @Test
+ public void testsFailIfTestsFailRemotely() {
+ RunId id = startSystemTestTests();
+ cloud.set("Failure!".getBytes(), TesterCloud.Status.FAILURE);
+ runner.run();
+ assertEquals(failed, jobs.run(id).get().steps().get(Step.endTests));
+ assertLogMessages(id, Step.endTests, "Tests still running ...", "Tests failed.", "Failure!");
+ }
+
+ @Test
+ public void testsFailIfTestsErr() {
+ RunId id = startSystemTestTests();
+ cloud.set("Error!".getBytes(), TesterCloud.Status.ERROR);
+ runner.run();
+ assertEquals(failed, jobs.run(id).get().steps().get(Step.endTests));
+ assertLogMessages(id, Step.endTests, "Tests still running ...", "Tester failed running its tests!", "Error!");
+ }
+
+ @Test
+ public void testsSucceedWhenTheyDoRemotely() {
+ RunId id = startSystemTestTests();
+ runner.run();
+ assertEquals(unfinished, jobs.run(id).get().steps().get(Step.endTests));
+ assertEquals(URI.create(routing.endpoints(new DeploymentId(testerOf(appId), JobType.systemTest.zone(tester.controller().system()))).get(0).getEndpoint()),
+ cloud.testerUrl());
+ Inspector configObject = SlimeUtils.jsonToSlime(cloud.config()).get();
+ assertEquals(appId.serializedForm(), configObject.field("application").asString());
+ assertEquals(JobType.systemTest.zone(tester.controller().system()).value(), configObject.field("zone").asString());
+ assertEquals(tester.controller().system().name(), configObject.field("system").asString());
+ assertEquals(1, configObject.field("endpoints").children());
+ assertEquals(1, configObject.field("endpoints").field(JobType.systemTest.zone(tester.controller().system()).value()).entries());
+ configObject.field("endpoints").field(JobType.systemTest.zone(tester.controller().system()).value()).traverse((ArrayTraverser) (__, endpoint) ->
+ assertEquals(routing.endpoints(new DeploymentId(appId, JobType.systemTest.zone(tester.controller().system()))).get(0).getEndpoint(), endpoint.asString()));
+
+ cloud.set("Success!".getBytes(), TesterCloud.Status.SUCCESS);
+ runner.run();
+ assertEquals(succeeded, jobs.run(id).get().steps().get(Step.endTests));
+ assertLogMessages(id, Step.endTests, "Tests still running ...", "Tests still running ...", "Tests completed successfully.", "Success!");
+ }
+
+ private void assertLogMessages(RunId id, Step step, String... messages) {
+ String pattern = Stream.of(messages)
+ .map(message -> "\\[[^]]*] : " + message + "\n")
+ .collect(Collectors.joining());
+ String logs = new String(jobs.details(id).get().get(step).get());
+ if ( ! logs.matches(pattern))
+ throw new AssertionError("Expected a match for\n'''\n" + pattern + "\n'''\nbut got\n'''\n" + logs + "\n'''");
+ }
+
+ private RunId startSystemTestTests() {
+ RunId id = newRun(JobType.systemTest);
+ runner.run();
+ tester.configServer().convergeServices(appId, JobType.systemTest.zone(tester.controller().system()));
+ tester.configServer().convergeServices(testerOf(appId), JobType.systemTest.zone(tester.controller().system()));
+ setEndpoints(appId, JobType.systemTest.zone(tester.controller().system()));
+ setEndpoints(testerOf(appId), JobType.systemTest.zone(tester.controller().system()));
+ runner.run();
+ assertEquals(unfinished, jobs.run(id).get().steps().get(Step.endTests));
+ return id;
+ }
+
+ private RunId newRun(JobType type) {
+ assertFalse(app().deploymentJobs().builtInternally()); // Use this only once per test.
+ jobs.register(appId);
+ newSubmission(appId);
+ tester.readyJobTrigger().maintain();
+
+ if (type.isProduction()) {
+ runJob(JobType.systemTest);
+ runJob(JobType.stagingTest);
+ tester.readyJobTrigger().maintain();
+ }
+
+ RunStatus run = jobs.active().stream()
+ .filter(r -> r.id().type() == type)
+ .findAny()
+ .orElseThrow(() -> new AssertionError(type + " is not among the active: " + jobs.active()));
+ return run.id();
+ }
+
@Test
public void generates_correct_services_xml_test() {
assertFile("test_runner_services.xml-cd", new String(InternalStepRunner.servicesXml(SystemName.cd)));
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ArtifactRepositoryMock.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ArtifactRepositoryMock.java
index 3f800ad9a56..955980e89d6 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ArtifactRepositoryMock.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ArtifactRepositoryMock.java
@@ -48,17 +48,17 @@ public class ArtifactRepositoryMock extends AbstractComponent implements Artifac
@Override
public void putApplicationPackage(ApplicationId application, String applicationVersion, byte[] applicationPackage) {
- throw new AssertionError();
+ repository.put(artifactHash(application, applicationVersion), new Artifact(applicationPackage));
}
@Override
public byte[] getTesterPackage(ApplicationId tester, String applicationVersion) {
- throw new AssertionError();
+ return getApplicationPackage(tester, applicationVersion);
}
@Override
public void putTesterPackage(ApplicationId tester, String applicationVersion, byte[] testerPackage) {
- throw new AssertionError();
+ putApplicationPackage(tester, applicationVersion, testerPackage);
}
@Override
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ConfigServerMock.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ConfigServerMock.java
index 354f736202a..422e1b41de3 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ConfigServerMock.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ConfigServerMock.java
@@ -6,11 +6,13 @@ import com.yahoo.component.AbstractComponent;
import com.yahoo.component.Version;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.HostName;
+import com.yahoo.config.provision.NodeType;
import com.yahoo.vespa.hosted.controller.api.application.v4.model.DeployOptions;
import com.yahoo.vespa.hosted.controller.api.application.v4.model.EndpointStatus;
import com.yahoo.vespa.hosted.controller.api.application.v4.model.configserverbindings.ConfigChangeActions;
import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId;
import com.yahoo.vespa.hosted.controller.api.identifiers.Hostname;
+import com.yahoo.vespa.hosted.controller.api.identifiers.Identifier;
import com.yahoo.vespa.hosted.controller.api.identifiers.TenantId;
import com.yahoo.vespa.hosted.controller.api.integration.configserver.ConfigServer;
import com.yahoo.vespa.hosted.controller.api.integration.configserver.Log;
@@ -38,6 +40,7 @@ import java.util.stream.IntStream;
/**
* @author mortent
+ * @author jonmv
*/
public class ConfigServerMock extends AbstractComponent implements ConfigServer {
@@ -50,12 +53,32 @@ public class ConfigServerMock extends AbstractComponent implements ConfigServer
private Version lastPrepareVersion = null;
private RuntimeException prepareException = null;
+ private ConfigChangeActions configChangeActions = null;
@Inject
public ConfigServerMock(ZoneRegistryMock zoneRegistry) {
bootstrap(zoneRegistry.zones().all().ids(), SystemApplication.all());
}
+ /** Sets the ConfigChangeActions that will be returned on next deployment. */
+ public void setConfigChangeActions(ConfigChangeActions configChangeActions) {
+ this.configChangeActions = configChangeActions;
+ }
+
+ /** Assigns a reserved tenant node to the given deployment, with initial versions. */
+ public void provision(ZoneId zone, ApplicationId application) {
+ nodeRepository().putByHostname(zone, new Node(hostFor(application, zone),
+ Node.State.reserved,
+ NodeType.tenant,
+ Optional.of(application),
+ initialVersion,
+ initialVersion));
+ }
+
+ public HostName hostFor(ApplicationId application, ZoneId zone) {
+ return HostName.from("host-" + application.serializedForm() + "-" + zone.value());
+ }
+
public void bootstrap(List<ZoneId> zones, SystemApplication... applications) {
bootstrap(zones, Arrays.asList(applications));
}
@@ -74,7 +97,7 @@ public class ConfigServerMock extends AbstractComponent implements ConfigServer
initialVersion
))
.collect(Collectors.toList());
- nodeRepository().add(zone, nodes);
+ nodeRepository().putByHostname(zone, nodes);
convergeServices(application.id(), zone);
}
}
@@ -95,11 +118,11 @@ public class ConfigServerMock extends AbstractComponent implements ConfigServer
this.prepareException = prepareException;
}
- /** Set version for system applications in given zone */
+ /** Set version for an application in a given zone */
public void setVersion(ApplicationId application, ZoneId zone, Version version) {
for (Node node : nodeRepository().list(zone, application)) {
- nodeRepository().add(zone, new Node(node.hostname(), node.state(), node.type(), node.owner(),
- version, version));
+ nodeRepository().putByHostname(zone, new Node(node.hostname(), node.state(), node.type(), node.owner(),
+ version, version));
}
}
@@ -134,6 +157,9 @@ public class ConfigServerMock extends AbstractComponent implements ConfigServer
}
applications.put(deployment.applicationId(), new Application(deployment.applicationId(), lastPrepareVersion));
+ if (nodeRepository().list(deployment.zoneId(), deployment.applicationId()).isEmpty())
+ provision(deployment.zoneId(), deployment.applicationId());
+
return new PreparedApplication() {
@Override
@@ -159,19 +185,23 @@ public class ConfigServerMock extends AbstractComponent implements ConfigServer
Application application = applications.get(deployment.applicationId());
application.activate();
for (Node node : nodeRepository.list(deployment.zoneId(), deployment.applicationId())) {
- nodeRepository.add(deployment.zoneId(), new Node(node.hostname(),
- node.state(), node.type(),
- node.owner(),
- node.currentVersion(),
- application.version().get()));
+ nodeRepository.putByHostname(deployment.zoneId(), new Node(node.hostname(),
+ node.state(), node.type(),
+ node.owner(),
+ node.currentVersion(),
+ application.version().get()));
}
serviceStatus.remove(deployment); // Deployment is no longer converging after new deployment
PrepareResponse prepareResponse = new PrepareResponse();
prepareResponse.message = "foo";
- prepareResponse.configChangeActions = new ConfigChangeActions(Collections.emptyList(),
- Collections.emptyList());
+ prepareResponse.configChangeActions = configChangeActions != null
+ ? configChangeActions
+ : new ConfigChangeActions(Collections.emptyList(),
+ Collections.emptyList());
+ setConfigChangeActions(null);
prepareResponse.tenant = new TenantId("tenant");
+ prepareResponse.log = Collections.emptyList();
return prepareResponse;
}
@@ -180,11 +210,14 @@ public class ConfigServerMock extends AbstractComponent implements ConfigServer
@Override
public void restart(DeploymentId deployment, Optional<Hostname> hostname) {
+ nodeRepository().requestRestart(deployment, hostname.map(Identifier::id).map(HostName::from));
}
@Override
public void deactivate(DeploymentId deployment) {
applications.remove(deployment.applicationId());
+ nodeRepository().removeByHostname(deployment.zoneId(),
+ nodeRepository().list(deployment.zoneId(), deployment.applicationId()));
}
// Returns a canned example response
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/NodeRepositoryMock.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/NodeRepositoryMock.java
index 9ca9802eac8..49d47156c1d 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/NodeRepositoryMock.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/NodeRepositoryMock.java
@@ -5,6 +5,7 @@ import com.yahoo.component.Version;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.HostName;
import com.yahoo.config.provision.NodeType;
+import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId;
import com.yahoo.vespa.hosted.controller.api.integration.configserver.Node;
import com.yahoo.vespa.hosted.controller.api.integration.configserver.NodeRepository;
import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId;
@@ -13,35 +14,46 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.function.UnaryOperator;
import java.util.stream.Collectors;
/**
* @author mpolden
+ * @author jonmv
*/
public class NodeRepositoryMock implements NodeRepository {
private final Map<ZoneId, Map<HostName, Node>> nodeRepository = new HashMap<>();
- public void add(ZoneId zone, List<Node> nodes) {
- nodeRepository.compute(zone, (k, v) -> {
- if (v == null) {
- v = new HashMap<>();
- }
- for (Node node : nodes) {
- v.put(node.hostname(), node);
- }
- return v;
- });
+ public void putByHostname(ZoneId zone, List<Node> nodes) {
+ nodeRepository.putIfAbsent(zone, new HashMap<>());
+ nodeRepository.get(zone).putAll(nodes.stream().collect(Collectors.toMap(node -> node.hostname(),
+ node -> node)));
+ }
+
+ public void putByHostname(ZoneId zone, Node node) {
+ putByHostname(zone, Collections.singletonList(node));
}
- public void add(ZoneId zone, Node node) {
- add(zone, Collections.singletonList(node));
+ public void removeByHostname(ZoneId zone, List<Node> nodes) {
+ nodes.forEach(node -> nodeRepository.get(zone).remove(node.hostname()));
}
public void clear() {
nodeRepository.clear();
}
+ public Node require(HostName hostName) {
+ return nodeRepository.values().stream()
+ .map(zoneNodes -> zoneNodes.get(hostName))
+ .filter(Objects::nonNull)
+ .findFirst()
+ .orElseThrow(() -> new NoSuchElementException("No node with the hostname " + hostName + " is known."));
+ }
+
@Override
public List<Node> list(ZoneId zone, ApplicationId application) {
return nodeRepository.getOrDefault(zone, Collections.emptyMap()).values().stream()
@@ -56,7 +68,78 @@ public class NodeRepositoryMock implements NodeRepository {
.filter(node -> node.type() == type)
.map(node -> new Node(node.hostname(), node.state(), node.type(), node.owner(),
node.currentVersion(), version))
- .forEach(node -> add(zone, node));
+ .forEach(node -> putByHostname(zone, node));
+ }
+
+ public void doUpgrade(DeploymentId deployment, Optional<HostName> hostName, Version version) {
+ modifyNodes(deployment, hostName, node -> {
+ assert node.wantedVersion().equals(version);
+ return new Node(node.hostname(), node.state(), node.type(), node.owner(), version, version);
+ });
+ }
+
+ public void modifyNodes(DeploymentId deployment, Optional<HostName> hostname, UnaryOperator<Node> modification) {
+ List<Node> nodes = hostname.map(host -> require(host))
+ .map(Collections::singletonList)
+ .orElse(list(deployment.zoneId(), deployment.applicationId()));
+ putByHostname(deployment.zoneId(),
+ nodes.stream().map(modification).collect(Collectors.toList()));
+ }
+
+ public void requestRestart(DeploymentId deployment, Optional<HostName> hostname) {
+ modifyNodes(deployment, hostname, node -> new Node(node.hostname(),
+ node.state(),
+ node.type(),
+ node.owner(),
+ node.currentVersion(),
+ node.wantedVersion(),
+ node.serviceState(),
+ node.restartGeneration(),
+ node.wantedRestartGeneration() + 1,
+ node.rebootGeneration(),
+ node.wantedRebootGeneration()));
+ }
+
+ public void doRestart(DeploymentId deployment, Optional<HostName> hostname) {
+ modifyNodes(deployment, hostname, node -> new Node(node.hostname(),
+ node.state(),
+ node.type(),
+ node.owner(),
+ node.currentVersion(),
+ node.wantedVersion(),
+ node.serviceState(),
+ node.restartGeneration() + 1,
+ node.wantedRestartGeneration(),
+ node.rebootGeneration(),
+ node.wantedRebootGeneration()));
+ }
+
+ public void requestReboot(DeploymentId deployment, Optional<HostName> hostname) {
+ modifyNodes(deployment, hostname, node -> new Node(node.hostname(),
+ node.state(),
+ node.type(),
+ node.owner(),
+ node.currentVersion(),
+ node.wantedVersion(),
+ node.serviceState(),
+ node.restartGeneration(),
+ node.wantedRestartGeneration(),
+ node.rebootGeneration(),
+ node.wantedRebootGeneration() + 1));
+ }
+
+ public void doReboot(DeploymentId deployment, Optional<HostName> hostname) {
+ modifyNodes(deployment, hostname, node -> new Node(node.hostname(),
+ node.state(),
+ node.type(),
+ node.owner(),
+ node.currentVersion(),
+ node.wantedVersion(),
+ node.serviceState(),
+ node.restartGeneration(),
+ node.wantedRestartGeneration(),
+ node.rebootGeneration() + 1,
+ node.wantedRebootGeneration()));
}
}
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/RoutingGeneratorMock.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/RoutingGeneratorMock.java
index bfc50a5a93b..46e41eea6e1 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/RoutingGeneratorMock.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/RoutingGeneratorMock.java
@@ -1,28 +1,46 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.controller.integration;
+import com.yahoo.component.AbstractComponent;
import com.yahoo.vespa.hosted.controller.api.integration.routing.RoutingEndpoint;
import com.yahoo.vespa.hosted.controller.api.integration.routing.RoutingGenerator;
import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId;
-import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
/**
+ * Returns a default set of endpoints on every query if it has no mappings, or those added by the user, otherwise.
+ *
* @author bratseth
+ * @author jonmv
*/
public class RoutingGeneratorMock implements RoutingGenerator {
+ private final Map<DeploymentId, List<RoutingEndpoint>> allEndpoints = new ConcurrentHashMap<>();
+ private static final List<RoutingEndpoint> defaultEndpoints =
+ Arrays.asList(new RoutingEndpoint("http://old-endpoint.vespa.yahooapis.com:4080", false),
+ new RoutingEndpoint("http://qrs-endpoint.vespa.yahooapis.com:4080", "host1", false),
+ new RoutingEndpoint("http://feeding-endpoint.vespa.yahooapis.com:4080", "host2", false),
+ new RoutingEndpoint("http://global-endpoint.vespa.yahooapis.com:4080", "host1", true),
+ new RoutingEndpoint("http://alias-endpoint.vespa.yahooapis.com:4080", "host1", true));
+
@Override
public List<RoutingEndpoint> endpoints(DeploymentId deployment) {
- List<RoutingEndpoint> endpoints = new ArrayList<>();
- // TODO: TLS: Update to HTTPS when ready.
- endpoints.add(new RoutingEndpoint("http://old-endpoint.vespa.yahooapis.com:4080", false));
- endpoints.add(new RoutingEndpoint("http://qrs-endpoint.vespa.yahooapis.com:4080", "host1", false));
- endpoints.add(new RoutingEndpoint("http://feeding-endpoint.vespa.yahooapis.com:4080", "host2", false));
- endpoints.add(new RoutingEndpoint("http://global-endpoint.vespa.yahooapis.com:4080", "host1", true));
- endpoints.add(new RoutingEndpoint("http://alias-endpoint.vespa.yahooapis.com:4080", "host1", true));
- return endpoints;
+ return allEndpoints.isEmpty()
+ ? defaultEndpoints
+ : allEndpoints.getOrDefault(deployment, Collections.emptyList());
+ }
+
+ public void putEndpoints(DeploymentId deployment, List<RoutingEndpoint> endpoints) {
+ allEndpoints.put(deployment, endpoints);
+ }
+
+ public void removeEndpoints(DeploymentId deployment) {
+ allEndpoints.remove(deployment);
}
}
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ApplicationOwnershipConfirmerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ApplicationOwnershipConfirmerTest.java
index 703d65c8f9d..555fdb338e8 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ApplicationOwnershipConfirmerTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ApplicationOwnershipConfirmerTest.java
@@ -73,8 +73,8 @@ public class ApplicationOwnershipConfirmerTest {
// The user deletes all production deployments — see that the issue is forgotten.
assertEquals("Confirmation issue for user is sitll open.", issueId, userApp.get().ownershipIssueId());
- tester.controller().applications().deactivate(userApp.get(), userApp.get().productionDeployments().keySet().stream().findAny().get());
- tester.controller().applications().deactivate(userApp.get(), userApp.get().productionDeployments().keySet().stream().findAny().get());
+ tester.controller().applications().deactivate(userApp.get().id(), userApp.get().productionDeployments().keySet().stream().findAny().get());
+ tester.controller().applications().deactivate(userApp.get().id(), userApp.get().productionDeployments().keySet().stream().findAny().get());
assertTrue("No production deployments are listed for user.", userApp.get().productionDeployments().isEmpty());
confirmer.maintain();
confirmer.maintain();
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DnsMaintainerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DnsMaintainerTest.java
index 1bedb29ec97..b950e969300 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DnsMaintainerTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DnsMaintainerTest.java
@@ -86,8 +86,8 @@ public class DnsMaintainerTest {
tester.jobCompletion(component).application(application).nextBuildNumber().uploadArtifact(applicationPackage).submit();
tester.deployAndNotify(application, applicationPackage, true, systemTest);
- tester.applications().deactivate(application, ZoneId.from(Environment.test, RegionName.from("us-east-1")));
- tester.applications().deactivate(application, ZoneId.from(Environment.staging, RegionName.from("us-east-3")));
+ tester.applications().deactivate(application.id(), ZoneId.from(Environment.test, RegionName.from("us-east-1")));
+ tester.applications().deactivate(application.id(), ZoneId.from(Environment.staging, RegionName.from("us-east-3")));
tester.applications().deleteApplication(application.id(), Optional.of(new NToken("ntoken")));
// DnsMaintainer removes records
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/JobRunnerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/JobRunnerTest.java
index e5416672bb7..1ec07025812 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/JobRunnerTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/JobRunnerTest.java
@@ -58,13 +58,13 @@ import static org.junit.Assert.fail;
*/
public class JobRunnerTest {
- static final Versions versions = new Versions(Version.fromString("1.2.3"),
- ApplicationVersion.from(new SourceRevision("repo",
- "branch",
- "bada55"),
- 321),
- Optional.empty(),
- Optional.empty());
+ private static final Versions versions = new Versions(Version.fromString("1.2.3"),
+ ApplicationVersion.from(new SourceRevision("repo",
+ "branch",
+ "bada55"),
+ 321),
+ Optional.empty(),
+ Optional.empty());
@Test
public void multiThreadedExecutionFinishes() throws InterruptedException {
@@ -226,7 +226,24 @@ public class JobRunnerTest {
assertEquals(Optional.empty(), jobs.last(id, systemTest));
}
- private static ExecutorService inThreadExecutor() {
+ @Test
+ public void timeout() {
+ DeploymentTester tester = new DeploymentTester();
+ JobController jobs = tester.controller().jobController();
+ Map<Step, Status> outcomes = new EnumMap<>(Step.class);
+ JobRunner runner = new JobRunner(tester.controller(), Duration.ofDays(1), new JobControl(tester.controller().curator()),
+ inThreadExecutor(), mappedRunner(outcomes));
+
+ ApplicationId id = tester.createApplication("real", "tenant", 1, 1L).id();
+ jobs.submit(id, versions.targetApplication().source().get(), new byte[0], new byte[0]);
+
+ jobs.start(id, systemTest, versions);
+ tester.clock().advance(JobRunner.jobTimeout.plus(Duration.ofSeconds(1)));
+ runner.run();
+ assertTrue(jobs.last(id, systemTest).get().isAborted());
+ }
+
+ public static ExecutorService inThreadExecutor() {
return new AbstractExecutorService() {
AtomicBoolean shutDown = new AtomicBoolean(false);
@Override public void shutdown() { shutDown.set(true); }
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/SystemUpgraderTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/SystemUpgraderTest.java
index 35393302459..167f91cce59 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/SystemUpgraderTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/SystemUpgraderTest.java
@@ -245,8 +245,8 @@ public class SystemUpgraderTest {
assertWantedVersion(application, version, zones);
for (ZoneId zone : zones) {
for (Node node : nodeRepository().list(zone, application.id(), SystemApplication.activeStates())) {
- nodeRepository().add(zone, new Node(node.hostname(), node.state(), node.type(), node.owner(),
- node.wantedVersion(), node.wantedVersion()));
+ nodeRepository().putByHostname(zone, new Node(node.hostname(), node.state(), node.type(), node.owner(),
+ node.wantedVersion(), node.wantedVersion()));
}
assertCurrentVersion(application, version, zone);
@@ -269,8 +269,8 @@ public class SystemUpgraderTest {
throw new IllegalArgumentException("No nodes allocated to " + application.id());
}
Node node = nodes.get(0);
- nodeRepository().add(zone, new Node(node.hostname(), Node.State.failed, node.type(), node.owner(),
- node.currentVersion(), node.wantedVersion()));
+ nodeRepository().putByHostname(zone, new Node(node.hostname(), Node.State.failed, node.type(), node.owner(),
+ node.currentVersion(), node.wantedVersion()));
}
private void assertSystemVersion(Version version) {
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java
index 45513c2294f..4ab42248b6d 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java
@@ -338,7 +338,7 @@ public class ApplicationApiTest extends ControllerContainerTest {
// POST a 'restart application' command with a host filter (other filters not supported yet)
tester.assertResponse(request("/application/v4/tenant/tenant1/application/application1/environment/prod/region/corp-us-east-1/instance/default/restart?hostname=host1", POST)
.screwdriverIdentity(SCREWDRIVER_ID),
- "Requested restart of tenant/tenant1/application/application1/environment/prod/region/corp-us-east-1/instance/default");
+ "{\"error-code\":\"INTERNAL_SERVER_ERROR\",\"message\":\"No node with the hostname host1 is known.\"}", 500);
// GET services
tester.assertResponse(request("/application/v4/tenant/tenant1/application/application1/environment/prod/region/corp-us-east-1/instance/default/service", GET)
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiTest.java
index 1ed2af1f7b9..c284b120e33 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiTest.java
@@ -61,8 +61,7 @@ public class DeploymentApiTest extends ControllerContainerTest {
// Deploy once so that job information is stored, then remove the deployment
deployCompletely(applicationWithoutDeployment, applicationPackage, 3L, true);
- tester.controller().applications().deactivate(applicationWithoutDeployment,
- ZoneId.from("prod", "corp-us-east-1"));
+ tester.controller().applications().deactivate(applicationWithoutDeployment.id(), ZoneId.from("prod", "corp-us-east-1"));
// New version released
version = Version.fromString("5.1");
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/versions/VersionStatusTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/versions/VersionStatusTest.java
index 291e6899a7a..41f59b4e63d 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/versions/VersionStatusTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/versions/VersionStatusTest.java
@@ -6,7 +6,6 @@ import com.yahoo.component.Version;
import com.yahoo.component.Vtag;
import com.yahoo.config.provision.Environment;
import com.yahoo.config.provision.HostName;
-import com.yahoo.config.provision.TenantName;
import com.yahoo.vespa.hosted.controller.Application;
import com.yahoo.vespa.hosted.controller.Controller;
import com.yahoo.vespa.hosted.controller.ControllerTester;
@@ -61,8 +60,8 @@ public class VersionStatusTest {
Version oldest = new Version(5);
for (ZoneId zone : tester.zoneRegistry().zones().all().ids()) {
for (Node node : tester.configServer().nodeRepository().list(zone, SystemApplication.configServer.id())) {
- tester.configServer().nodeRepository().add(zone, new Node(node.hostname(), node.state(), node.type(),
- node.owner(), oldest, node.wantedVersion()));
+ tester.configServer().nodeRepository().putByHostname(zone, new Node(node.hostname(), node.state(), node.type(),
+ node.owner(), oldest, node.wantedVersion()));
break;
}
}
diff --git a/dist/vespa.spec b/dist/vespa.spec
index bd2bf798e58..1a0a51b88fc 100644
--- a/dist/vespa.spec
+++ b/dist/vespa.spec
@@ -32,31 +32,26 @@ BuildRequires: libatomic
BuildRequires: Judy-devel
%if 0%{?centos}
BuildRequires: cmake3
-BuildRequires: llvm3.9-devel
+BuildRequires: llvm5.0-devel
BuildRequires: vespa-boost-devel >= 1.59.0-6
BuildRequires: vespa-gtest >= 1.8.0-1
%endif
%if 0%{?fedora}
BuildRequires: cmake >= 3.9.1
BuildRequires: maven
-%if 0%{?fc26}
-BuildRequires: llvm-devel >= 4.0
-BuildRequires: boost-devel >= 1.63
-BuildRequires: vespa-gtest >= 1.8.0-2
-%endif
%if 0%{?fc27}
-BuildRequires: llvm4.0-devel >= 4.0
+BuildRequires: llvm-devel >= 5.0.2
BuildRequires: boost-devel >= 1.64
BuildRequires: vespa-gtest >= 1.8.0-2
%endif
%if 0%{?fc28}
-BuildRequires: llvm4.0-devel >= 4.0
+BuildRequires: llvm-devel >= 6.0.1
BuildRequires: boost-devel >= 1.66
BuildRequires: gtest-devel
BuildRequires: gmock-devel
%endif
%if 0%{?fc29}
-BuildRequires: llvm3.9-devel >= 3.9.1
+BuildRequires: llvm-devel >= 6.0.1
BuildRequires: boost-devel >= 1.66
BuildRequires: gtest-devel
BuildRequires: gmock-devel
@@ -104,36 +99,25 @@ Requires: perf
Requires: gdb
Requires: net-tools
%if 0%{?centos}
-Requires: llvm3.9
-%define _extra_link_directory /usr/lib64/llvm3.9/lib;/opt/vespa-gtest/lib;/opt/vespa-cppunit/lib
-%define _extra_include_directory /usr/include/llvm3.9;/opt/vespa-boost/include;/opt/vespa-gtest/include;/opt/vespa-cppunit/include
+Requires: llvm5.0
+%define _vespa_llvm_version 5.0
+%define _extra_link_directory /usr/lib64/llvm5.0/lib;/opt/vespa-gtest/lib;/opt/vespa-cppunit/lib
+%define _extra_include_directory /usr/include/llvm5.0;/opt/vespa-boost/include;/opt/vespa-gtest/include;/opt/vespa-cppunit/include
%endif
%if 0%{?fedora}
-%if 0%{?fc26}
-Requires: llvm-libs >= 4.0
-%define _vespa_llvm_version 4.0
-%define _vespa_gtest_link_directory /opt/vespa-gtest/lib
-%define _vespa_gtest_include_directory /opt/vespa-gtest/include
-%endif
%if 0%{?fc27}
-Requires: llvm4.0-libs >= 4.0
-%define _vespa_llvm_version 4.0
-%define _vespa_llvm_link_directory /usr/lib64/llvm4.0/lib
-%define _vespa_llvm_include_directory /usr/include/llvm4.0
+Requires: llvm-libs >= 5.0.2
+%define _vespa_llvm_version 5.0
%define _vespa_gtest_link_directory /opt/vespa-gtest/lib
%define _vespa_gtest_include_directory /opt/vespa-gtest/include
%endif
%if 0%{?fc28}
-Requires: llvm4.0-libs >= 4.0
-%define _vespa_llvm_version 4.0
-%define _vespa_llvm_link_directory /usr/lib64/llvm4.0/lib
-%define _vespa_llvm_include_directory /usr/include/llvm4.0
+Requires: llvm-libs >= 6.0.1
+%define _vespa_llvm_version 6.0
%endif
%if 0%{?fc29}
-Requires: llvm3.9-libs >= 3.9.1
-%define _vespa_llvm_version 3.9
-%define _vespa_llvm_link_directory /usr/lib64/llvm3.9/lib
-%define _vespa_llvm_include_directory /usr/include/llvm3.9
+Requires: llvm-libs >= 6.0.1
+%define _vespa_llvm_version 6.0
%endif
%define _extra_link_directory /opt/vespa-cppunit/lib%{?_vespa_llvm_link_directory:;%{_vespa_llvm_link_directory}}%{?_vespa_gtest_link_directory:;%{_vespa_gtest_link_directory}}
%define _extra_include_directory /opt/vespa-cppunit/include%{?_vespa_llvm_include_directory:;%{_vespa_llvm_include_directory}}%{?_vespa_gtest_include_directory:;%{_vespa_gtest_include_directory}}
diff --git a/document/src/tests/documentselectparsertest.cpp b/document/src/tests/documentselectparsertest.cpp
index 2433bfecdab..2e4f66cebd0 100644
--- a/document/src/tests/documentselectparsertest.cpp
+++ b/document/src/tests/documentselectparsertest.cpp
@@ -67,7 +67,7 @@ class DocumentSelectParserTest : public CppUnit::TestFixture {
parseFieldValue(const std::string& expression);
template <typename ContainsType>
- select::ResultList doParse(const vespalib::stringref& expr,
+ select::ResultList doParse(vespalib::stringref expr,
const ContainsType& t);
std::string parse_to_tree(const std::string& str);
@@ -526,7 +526,7 @@ void DocumentSelectParserTest::testParseBranches()
template <typename ContainsType>
select::ResultList
-DocumentSelectParserTest::doParse(const vespalib::stringref& expr,
+DocumentSelectParserTest::doParse(vespalib::stringref expr,
const ContainsType& t)
{
std::unique_ptr<select::Node> root(_parser->parse(expr));
diff --git a/document/src/vespa/document/annotation/spantree.h b/document/src/vespa/document/annotation/spantree.h
index e2839c4793b..4acd39b4793 100644
--- a/document/src/vespa/document/annotation/spantree.h
+++ b/document/src/vespa/document/annotation/spantree.h
@@ -21,7 +21,7 @@ public:
typedef AnnotationVector::const_iterator const_iterator;
template <typename T>
- SpanTree(const vespalib::stringref &name, std::unique_ptr<T> root)
+ SpanTree(vespalib::stringref name, std::unique_ptr<T> root)
: _name(name),
_root(std::move(root)) {
assert(_root.get());
diff --git a/document/src/vespa/document/base/field.cpp b/document/src/vespa/document/base/field.cpp
index 578294df7b0..be5d94ce7f0 100644
--- a/document/src/vespa/document/base/field.cpp
+++ b/document/src/vespa/document/base/field.cpp
@@ -11,7 +11,7 @@ namespace document {
Field::Field() : Field("", 0, *DataType::INT, false) { }
-Field::Field(const vespalib::stringref & name, int fieldId,
+Field::Field(vespalib::stringref name, int fieldId,
const DataType& dataType, bool headerField)
: FieldBase(name),
_dataType(&dataType),
@@ -19,7 +19,7 @@ Field::Field(const vespalib::stringref & name, int fieldId,
_isHeaderField(headerField)
{ }
-Field::Field(const vespalib::stringref & name,
+Field::Field(vespalib::stringref name,
const DataType& dataType, bool headerField)
: FieldBase(name),
_dataType(&dataType),
diff --git a/document/src/vespa/document/base/field.h b/document/src/vespa/document/base/field.h
index cb16538c4f1..f17a0a41703 100644
--- a/document/src/vespa/document/base/field.h
+++ b/document/src/vespa/document/base/field.h
@@ -48,7 +48,7 @@ public:
* @param type The datatype of the field.
* @param headerField Whether or not this is a "header" field.
*/
- Field(const vespalib::stringref & name, int fieldId,
+ Field(vespalib::stringref name, int fieldId,
const DataType &type, bool headerField);
Field();
@@ -61,7 +61,7 @@ public:
* @param dataType The datatype of the field.
* @param headerField Whether or not this is a "header" field.
*/
- Field(const vespalib::stringref & name, const DataType &dataType, bool headerField);
+ Field(vespalib::stringref name, const DataType &dataType, bool headerField);
Field* clone() const override { return new Field(*this); }
std::unique_ptr<FieldValue> createValue() const;
diff --git a/document/src/vespa/document/base/fieldpath.cpp b/document/src/vespa/document/base/fieldpath.cpp
index d1603ca5c09..2606aa269ed 100644
--- a/document/src/vespa/document/base/fieldpath.cpp
+++ b/document/src/vespa/document/base/fieldpath.cpp
@@ -100,7 +100,7 @@ FieldPathEntry::FieldPathEntry(const DataType&, const DataType& keyType,
setFillValue(*_dataType);
}
-FieldPathEntry::FieldPathEntry(const DataType & dataType, const vespalib::stringref & variableName) :
+FieldPathEntry::FieldPathEntry(const DataType & dataType, vespalib::stringref variableName) :
_type(VARIABLE),
_name(""),
_field(),
diff --git a/document/src/vespa/document/base/fieldpath.h b/document/src/vespa/document/base/fieldpath.h
index 42248bf2595..576c534e3db 100644
--- a/document/src/vespa/document/base/fieldpath.h
+++ b/document/src/vespa/document/base/fieldpath.h
@@ -64,7 +64,7 @@ public:
/**
Creates a field entry for an array, map or wset traversal using a variable.
*/
- FieldPathEntry(const DataType & dataType, const vespalib::stringref & variableName);
+ FieldPathEntry(const DataType & dataType, vespalib::stringref variableName);
FieldPathEntry * clone() const { return new FieldPathEntry(*this); }
diff --git a/document/src/vespa/document/base/globalid.cpp b/document/src/vespa/document/base/globalid.cpp
index 5211647e848..bdf81d1c3c8 100644
--- a/document/src/vespa/document/base/globalid.cpp
+++ b/document/src/vespa/document/base/globalid.cpp
@@ -85,7 +85,7 @@ vespalib::string GlobalId::toString() const {
}
GlobalId
-GlobalId::parse(const vespalib::stringref & source)
+GlobalId::parse(vespalib::stringref source)
{
if (source.substr(0, 6) != "gid(0x") {
throw vespalib::IllegalArgumentException(
diff --git a/document/src/vespa/document/base/globalid.h b/document/src/vespa/document/base/globalid.h
index 6c8d0123a95..dd1d061dbf7 100644
--- a/document/src/vespa/document/base/globalid.h
+++ b/document/src/vespa/document/base/globalid.h
@@ -159,7 +159,7 @@ public:
* @param str The string to parse.
* @throws vespalib::IllegalArgumentException Thrown if input is not in GID format.
*/
- static GlobalId parse(const vespalib::stringref &str);
+ static GlobalId parse(vespalib::stringref str);
/**
* Returns the most specified bucket id to which this global id belongs.
diff --git a/document/src/vespa/document/base/idstring.cpp b/document/src/vespa/document/base/idstring.cpp
index 175fb653542..eee8d3c38a2 100644
--- a/document/src/vespa/document/base/idstring.cpp
+++ b/document/src/vespa/document/base/idstring.cpp
@@ -49,8 +49,8 @@ IdString::toString() const
namespace {
void reportError(const char* part) __attribute__((noinline));
-void reportError(const stringref & s) __attribute__((noinline));
-void reportError(const stringref & s, const char* part) __attribute__((noinline));
+void reportError(stringref s) __attribute__((noinline));
+void reportError(stringref s, const char* part) __attribute__((noinline));
void reportTooShortDocId(const char * id, size_t sz) __attribute__((noinline));
void reportNoSchemeSeparator(const char * id) __attribute__((noinline));
@@ -58,13 +58,12 @@ void reportError(const char* part)
{
throw IdParseException(make_string("Unparseable id: No %s separator ':' found", part), VESPA_STRLOC);
}
-void reportError(const stringref & s, const char* part)
+void reportError(stringref s, const char* part)
{
- throw IdParseException(make_string("Unparseable %s '%s': Not an unsigned 64-bit number", part,
- string(s).c_str()), VESPA_STRLOC);
+ throw IdParseException(make_string("Unparseable %s '%s': Not an unsigned 64-bit number", part, string(s).c_str()), VESPA_STRLOC);
}
-void reportError(const stringref & s)
+void reportError(stringref s)
{
throw IdParseException(make_string("Unparseable order doc scheme '%s': Scheme must contain parameters on the form (width, division)",
string(s).c_str()), VESPA_STRLOC);
@@ -76,13 +75,10 @@ void reportNoSchemeSeparator(const char * id)
void reportTooShortDocId(const char * id, size_t sz)
{
- throw IdParseException(
- make_string(
- "Unparseable id '%s': It is too short(%li) "
- "to make any sense", id, sz), VESPA_STRLOC);
+ throw IdParseException( make_string( "Unparseable id '%s': It is too short(%li) " "to make any sense", id, sz), VESPA_STRLOC);
}
-uint64_t getAsNumber(const stringref & s, const char* part) {
+uint64_t getAsNumber(stringref s, const char* part) {
char* errPos = NULL;
uint64_t value = strtoull(s.data(), &errPos, 10);
@@ -93,7 +89,7 @@ uint64_t getAsNumber(const stringref & s, const char* part) {
}
void
-getOrderDocBits(const stringref& scheme, uint16_t & widthBits, uint16_t & divisionBits)
+getOrderDocBits(stringref scheme, uint16_t & widthBits, uint16_t & divisionBits)
{
const char* parenPos = reinterpret_cast<const char*>(
memchr(scheme.data(), '(', scheme.size()));
@@ -194,7 +190,7 @@ fmemchr(const char * s, const char * e)
} // namespace
-IdString::Offsets::Offsets(uint32_t maxComponents, uint32_t namespaceOffset, const stringref & id)
+IdString::Offsets::Offsets(uint32_t maxComponents, uint32_t namespaceOffset, stringref id)
{
_offsets[0] = namespaceOffset;
size_t index(1);
@@ -213,7 +209,7 @@ IdString::Offsets::Offsets(uint32_t maxComponents, uint32_t namespaceOffset, con
_offsets[maxComponents] = id.size() + 1; // 1 is added due to the implicitt accounting for ':'
}
-IdString::IdString(uint32_t maxComponents, uint32_t namespaceOffset, const stringref & rawId) :
+IdString::IdString(uint32_t maxComponents, uint32_t namespaceOffset, stringref rawId) :
_offsets(maxComponents, namespaceOffset, rawId),
_rawId(rawId)
{
@@ -274,13 +270,13 @@ union LocationUnion {
IdString::LocationType _location[2];
};
-IdString::LocationType makeLocation(const stringref &s) {
+IdString::LocationType makeLocation(stringref s) {
LocationUnion location;
fastc_md5sum(reinterpret_cast<const unsigned char*>(s.data()), s.size(), location._key);
return location._location[0];
}
-uint64_t parseNumber(const stringref &number) {
+uint64_t parseNumber(stringref number) {
char* errPos = NULL;
errno = 0;
uint64_t n = strtoul(number.data(), &errPos, 10);
@@ -297,7 +293,7 @@ uint64_t parseNumber(const stringref &number) {
}
void setLocation(IdString::LocationType &loc, IdString::LocationType val,
- bool &has_set_location, const stringref &key_values) {
+ bool &has_set_location, stringref key_values) {
if (has_set_location) {
throw IdParseException("Illegal key combination in "
+ key_values);
@@ -309,7 +305,7 @@ void setLocation(IdString::LocationType &loc, IdString::LocationType val,
} // namespace
-IdIdString::IdIdString(const stringref & id)
+IdIdString::IdIdString(stringref id)
: IdString(4, 3, id),
_location(0),
_groupOffset(0),
@@ -364,26 +360,26 @@ GroupDocIdString::getLocation() const
return makeLocation(getGroup());
}
-DocIdString::DocIdString(const stringref & ns, const stringref & id) :
+DocIdString::DocIdString(stringref ns, stringref id) :
IdString(2, 4, "doc:" + ns + ":" + id)
{
validate();
}
-DocIdString::DocIdString(const stringref & rawId) :
+DocIdString::DocIdString(stringref rawId) :
IdString(2, 4, rawId)
{
validate();
}
-UserDocIdString::UserDocIdString(const stringref & rawId) :
+UserDocIdString::UserDocIdString(stringref rawId) :
IdString(3, 8, rawId),
_userId(getAsNumber(rawId.substr(offset(1), offset(2) - offset(1) - 1), "userid"))
{
validate();
}
-GroupDocIdString::GroupDocIdString(const stringref & rawId) :
+GroupDocIdString::GroupDocIdString(stringref rawId) :
IdString(3, 9, rawId)
{
validate();
@@ -395,7 +391,7 @@ GroupDocIdString::locationFromGroupName(vespalib::stringref name)
return makeLocation(name);
}
-OrderDocIdString::OrderDocIdString(const stringref & rawId) :
+OrderDocIdString::OrderDocIdString(stringref rawId) :
IdString(4, static_cast<const char *>(memchr(rawId.data(), ':', rawId.size())) - rawId.data() + 1, rawId),
_widthBits(0),
_divisionBits(0),
diff --git a/document/src/vespa/document/base/idstring.h b/document/src/vespa/document/base/idstring.h
index b1a14cfec94..583e502e7ab 100644
--- a/document/src/vespa/document/base/idstring.h
+++ b/document/src/vespa/document/base/idstring.h
@@ -24,7 +24,7 @@ public:
static const vespalib::string & getTypeName(Type t);
/** @throws document::IdParseException If parsing of id scheme failed. */
- static IdString::UP createIdString(const vespalib::stringref & id) { return createIdString(id.data(), id.size()); }
+ static IdString::UP createIdString(vespalib::stringref id) { return createIdString(id.data(), id.size()); }
static IdString::UP createIdString(const char *id, size_t sz);
~IdString() {}
@@ -48,7 +48,7 @@ public:
const vespalib::string & toString() const;
protected:
- IdString(uint32_t maxComponents, uint32_t namespaceOffset, const vespalib::stringref & rawId);
+ IdString(uint32_t maxComponents, uint32_t namespaceOffset, vespalib::stringref rawId);
virtual vespalib::string getSchemeName() const;
size_t offset(size_t index) const { return _offsets[index]; }
size_t size(size_t index) const { return _offsets[index+1] - _offsets[index] - 1; }
@@ -60,7 +60,7 @@ protected:
private:
class Offsets {
public:
- Offsets(uint32_t maxComponents, uint32_t first, const vespalib::stringref & id);
+ Offsets(uint32_t maxComponents, uint32_t first, vespalib::stringref id);
uint16_t first() const { return _offsets[0]; }
uint16_t operator [] (size_t i) const { return _offsets[i]; }
size_t numComponents() const { return _numComponents; }
@@ -100,7 +100,7 @@ class IdIdString final : public IdString {
bool _has_number;
public:
- IdIdString(const vespalib::stringref &ns);
+ IdIdString(vespalib::stringref ns);
bool hasDocType() const override { return true; }
vespalib::stringref getDocType() const override { return getComponent(1); }
@@ -129,8 +129,8 @@ private:
*/
class DocIdString final : public IdString {
public:
- DocIdString(const vespalib::stringref & ns, const vespalib::stringref & id);
- DocIdString(const vespalib::stringref & rawId);
+ DocIdString(vespalib::stringref ns, vespalib::stringref id);
+ DocIdString(vespalib::stringref rawId);
private:
DocIdString* clone() const override { return new DocIdString(*this); }
Type getType() const override { return DOC; }
@@ -150,7 +150,7 @@ private:
*/
class UserDocIdString final : public IdString {
public:
- UserDocIdString(const vespalib::stringref & rawId);
+ UserDocIdString(vespalib::stringref rawId);
virtual int64_t getUserId() const { return _userId; }
bool hasNumber() const override { return true; }
@@ -172,7 +172,7 @@ private:
*/
class OrderDocIdString final : public IdString {
public:
- OrderDocIdString(const vespalib::stringref& rawId);
+ OrderDocIdString(vespalib::stringref rawId);
int64_t getUserId() const { return _location; }
uint16_t getWidthBits() const { return _widthBits; }
@@ -207,7 +207,7 @@ private:
*/
class GroupDocIdString : public IdString {
public:
- GroupDocIdString(const vespalib::stringref & rawId);
+ GroupDocIdString(vespalib::stringref rawId);
bool hasGroup() const override { return true; }
vespalib::stringref getGroup() const override { return getComponent(1); }
LocationType getLocation() const override;
diff --git a/document/src/vespa/document/datatype/annotationreferencedatatype.cpp b/document/src/vespa/document/datatype/annotationreferencedatatype.cpp
index 9a787f943a5..758972d3944 100644
--- a/document/src/vespa/document/datatype/annotationreferencedatatype.cpp
+++ b/document/src/vespa/document/datatype/annotationreferencedatatype.cpp
@@ -37,7 +37,7 @@ unique_ptr<FieldValue> AnnotationReferenceDataType::createFieldValue() const {
return FieldValue::UP(new AnnotationReferenceFieldValue(*this, 0));
}
-void AnnotationReferenceDataType::onBuildFieldPath(FieldPath &, const vespalib::stringref &) const { }
+void AnnotationReferenceDataType::onBuildFieldPath(FieldPath &, vespalib::stringref) const { }
} // namespace document
diff --git a/document/src/vespa/document/datatype/annotationreferencedatatype.h b/document/src/vespa/document/datatype/annotationreferencedatatype.h
index 424d1e19736..2184a2873a2 100644
--- a/document/src/vespa/document/datatype/annotationreferencedatatype.h
+++ b/document/src/vespa/document/datatype/annotationreferencedatatype.h
@@ -20,7 +20,7 @@ public:
void print(std::ostream &out, bool verbose, const std::string &indent) const override;
AnnotationReferenceDataType *clone() const override;
std::unique_ptr<FieldValue> createFieldValue() const override;
- void onBuildFieldPath(FieldPath & path, const vespalib::stringref &remainFieldName) const override;
+ void onBuildFieldPath(FieldPath & path, vespalib::stringref remainFieldName) const override;
DECLARE_IDENTIFIABLE(AnnotationReferenceDataType);
};
diff --git a/document/src/vespa/document/datatype/annotationtype.h b/document/src/vespa/document/datatype/annotationtype.h
index 355da3fe85f..00d48d6e384 100644
--- a/document/src/vespa/document/datatype/annotationtype.h
+++ b/document/src/vespa/document/datatype/annotationtype.h
@@ -19,7 +19,7 @@ public:
typedef std::unique_ptr<AnnotationType> UP;
typedef std::shared_ptr<AnnotationType> SP;
- AnnotationType(int id, const vespalib::stringref &name)
+ AnnotationType(int id, vespalib::stringref name)
: _id(id), _name(name), _type(0) {}
void setDataType(const DataType &type) { _type = &type; }
diff --git a/document/src/vespa/document/datatype/arraydatatype.cpp b/document/src/vespa/document/datatype/arraydatatype.cpp
index b49599ac620..8eb6a6ac875 100644
--- a/document/src/vespa/document/datatype/arraydatatype.cpp
+++ b/document/src/vespa/document/datatype/arraydatatype.cpp
@@ -43,7 +43,7 @@ ArrayDataType::operator==(const DataType& other) const
}
void
-ArrayDataType::onBuildFieldPath(FieldPath & path, const vespalib::stringref & remainFieldName) const
+ArrayDataType::onBuildFieldPath(FieldPath & path, vespalib::stringref remainFieldName) const
{
if (remainFieldName[0] == '[') {
size_t endPos = remainFieldName.find(']');
diff --git a/document/src/vespa/document/datatype/arraydatatype.h b/document/src/vespa/document/datatype/arraydatatype.h
index 6be50302c3d..55b5af184dd 100644
--- a/document/src/vespa/document/datatype/arraydatatype.h
+++ b/document/src/vespa/document/datatype/arraydatatype.h
@@ -27,7 +27,7 @@ public:
void print(std::ostream&, bool verbose, const std::string& indent) const override;
bool operator==(const DataType& other) const override;
ArrayDataType* clone() const override { return new ArrayDataType(*this); }
- void onBuildFieldPath(FieldPath & path, const vespalib::stringref & remainFieldName) const override;
+ void onBuildFieldPath(FieldPath & path, vespalib::stringref remainFieldName) const override;
DECLARE_IDENTIFIABLE(ArrayDataType);
};
diff --git a/document/src/vespa/document/datatype/collectiondatatype.cpp b/document/src/vespa/document/datatype/collectiondatatype.cpp
index f09aebb0be5..3678989adfa 100644
--- a/document/src/vespa/document/datatype/collectiondatatype.cpp
+++ b/document/src/vespa/document/datatype/collectiondatatype.cpp
@@ -24,13 +24,13 @@ CollectionDataType::operator=(const CollectionDataType& other)
return *this;
}
-CollectionDataType::CollectionDataType(const vespalib::stringref& name,
+CollectionDataType::CollectionDataType(vespalib::stringref name,
const DataType& nestedType)
: DataType(name),
_nestedType(&nestedType) {
}
-CollectionDataType::CollectionDataType(const vespalib::stringref& name,
+CollectionDataType::CollectionDataType(vespalib::stringref name,
const DataType& nestedType,
int32_t id)
: DataType(name, id),
diff --git a/document/src/vespa/document/datatype/collectiondatatype.h b/document/src/vespa/document/datatype/collectiondatatype.h
index 0e258e3e0cf..10cf636e70f 100644
--- a/document/src/vespa/document/datatype/collectiondatatype.h
+++ b/document/src/vespa/document/datatype/collectiondatatype.h
@@ -20,9 +20,9 @@ protected:
CollectionDataType() : _nestedType(0) {}
CollectionDataType(const CollectionDataType&);
CollectionDataType& operator=(const CollectionDataType&);
- CollectionDataType(const vespalib::stringref & name,
+ CollectionDataType(vespalib::stringref name,
const DataType &nestedType);
- CollectionDataType(const vespalib::stringref & name,
+ CollectionDataType(vespalib::stringref name,
const DataType &nestedType, int32_t id);
public:
diff --git a/document/src/vespa/document/datatype/datatype.cpp b/document/src/vespa/document/datatype/datatype.cpp
index 3b56942b61e..aef155999a4 100644
--- a/document/src/vespa/document/datatype/datatype.cpp
+++ b/document/src/vespa/document/datatype/datatype.cpp
@@ -118,7 +118,7 @@ namespace {
// ASCII characters. Probably screwed up otherwise, but generated ids
// should only be used in testing anyways. In production this will be
// set from the document manager config.
-uint32_t crappyJavaStringHash(const vespalib::stringref & value) {
+uint32_t crappyJavaStringHash(vespalib::stringref value) {
uint32_t h = 0;
for (uint32_t i = 0; i < value.size(); ++i) {
h = 31 * h + value[i];
@@ -126,7 +126,7 @@ uint32_t crappyJavaStringHash(const vespalib::stringref & value) {
return h;
}
-int32_t createId(const vespalib::stringref & name)
+int32_t createId(vespalib::stringref name)
{
if (name == "Tag") {
return DataType::T_TAG;
@@ -142,13 +142,13 @@ DataType::DataType()
{
}
-DataType::DataType(const vespalib::stringref & name, int dataTypeId)
+DataType::DataType(vespalib::stringref name, int dataTypeId)
: _dataTypeId(dataTypeId),
_name(name)
{
}
-DataType::DataType(const vespalib::stringref & name)
+DataType::DataType(vespalib::stringref name)
: _dataTypeId(createId(name)),
_name(name)
{
@@ -170,7 +170,7 @@ DataType::operator<(const DataType& other) const
}
void
-DataType::buildFieldPath(FieldPath & path, const vespalib::stringref & remainFieldName) const
+DataType::buildFieldPath(FieldPath & path, vespalib::stringref remainFieldName) const
{
if ( !remainFieldName.empty() ) {
path.reserve(4); // Optimize for short paths
diff --git a/document/src/vespa/document/datatype/datatype.h b/document/src/vespa/document/datatype/datatype.h
index 5857157c218..0e444ce8d3b 100644
--- a/document/src/vespa/document/datatype/datatype.h
+++ b/document/src/vespa/document/datatype/datatype.h
@@ -38,12 +38,12 @@ protected:
* everyone to be able to use them. Only tests and the type manager reading
* config should need to create datatypes.
*/
- DataType(const vespalib::stringref& name, int dataTypeId);
+ DataType(vespalib::stringref name, int dataTypeId);
/**
* Creates a datatype using the hash of name as the id.
*/
- explicit DataType(const vespalib::stringref& name);
+ explicit DataType(vespalib::stringref name);
public:
virtual ~DataType();
@@ -128,14 +128,14 @@ public:
* MUST be null-terminated.
* @return pointer to field path or null if an error occured
*/
- void buildFieldPath(FieldPath & fieldPath, const vespalib::stringref & remainFieldName) const;
+ void buildFieldPath(FieldPath & fieldPath, vespalib::stringref remainFieldName) const;
/** @throws FieldNotFoundException if field does not exist. */
virtual const Field& getField(int fieldId) const;
DECLARE_IDENTIFIABLE_ABSTRACT(DataType);
private:
- virtual void onBuildFieldPath(FieldPath & fieldPath, const vespalib::stringref & remainFieldName) const = 0;
+ virtual void onBuildFieldPath(FieldPath & fieldPath, vespalib::stringref remainFieldName) const = 0;
};
} // document
diff --git a/document/src/vespa/document/datatype/documenttype.cpp b/document/src/vespa/document/datatype/documenttype.cpp
index 2be5acaf3db..8198abfc7b1 100644
--- a/document/src/vespa/document/datatype/documenttype.cpp
+++ b/document/src/vespa/document/datatype/documenttype.cpp
@@ -22,7 +22,7 @@ DocumentType::DocumentType()
{
}
-DocumentType::DocumentType(const stringref& name, int32_t id)
+DocumentType::DocumentType(stringref name, int32_t id)
: StructuredDataType(name, id),
_inheritedTypes(),
_ownedFields(new StructDataType(name + ".header")),
@@ -34,7 +34,7 @@ DocumentType::DocumentType(const stringref& name, int32_t id)
}
}
-DocumentType::DocumentType(const stringref& name, int32_t id, const StructDataType& fields)
+DocumentType::DocumentType(stringref name, int32_t id, const StructDataType& fields)
: StructuredDataType(name, id),
_inheritedTypes(),
_fields(&fields),
@@ -45,7 +45,7 @@ DocumentType::DocumentType(const stringref& name, int32_t id, const StructDataTy
}
}
-DocumentType::DocumentType(const stringref& name)
+DocumentType::DocumentType(stringref name)
: StructuredDataType(name),
_inheritedTypes(),
_ownedFields(new StructDataType(name + ".header")),
@@ -57,7 +57,7 @@ DocumentType::DocumentType(const stringref& name)
}
}
-DocumentType::DocumentType(const stringref& name, const StructDataType& fields)
+DocumentType::DocumentType(stringref name, const StructDataType& fields)
: StructuredDataType(name),
_inheritedTypes(),
_fields(&fields),
@@ -210,7 +210,7 @@ DocumentType::operator==(const DataType& other) const
}
const Field&
-DocumentType::getField(const stringref& name) const
+DocumentType::getField(stringref name) const
{
return _fields->getField(name);
}
@@ -221,7 +221,7 @@ DocumentType::getField(int fieldId) const
return _fields->getField(fieldId);
}
-bool DocumentType::hasField(const stringref &name) const {
+bool DocumentType::hasField(stringref name) const {
return _fields->hasField(name);
}
diff --git a/document/src/vespa/document/datatype/documenttype.h b/document/src/vespa/document/datatype/documenttype.h
index 89034a86810..7fcf5dfa237 100644
--- a/document/src/vespa/document/datatype/documenttype.h
+++ b/document/src/vespa/document/datatype/documenttype.h
@@ -50,12 +50,12 @@ public:
typedef std::shared_ptr<DocumentType> SP;
DocumentType();
- DocumentType(const vespalib::stringref &name, int32_t id);
- DocumentType(const vespalib::stringref &name, int32_t id,
+ DocumentType(vespalib::stringref name, int32_t id);
+ DocumentType(vespalib::stringref name, int32_t id,
const StructDataType& fields);
- DocumentType(const vespalib::stringref &name);
- DocumentType(const vespalib::stringref &name,
+ DocumentType(vespalib::stringref name);
+ DocumentType(vespalib::stringref name,
const StructDataType& fields);
~DocumentType();
@@ -82,9 +82,9 @@ public:
uint32_t getFieldCount() const override {
return _fields->getFieldCount();
}
- const Field & getField(const vespalib::stringref & name) const override;
+ const Field & getField(vespalib::stringref name) const override;
const Field & getField(int fieldId) const override;
- bool hasField(const vespalib::stringref &name) const override;
+ bool hasField(vespalib::stringref name) const override;
bool hasField(int fieldId) const override;
Field::Set getFieldSet() const override;
DocumentType* clone() const override;
diff --git a/document/src/vespa/document/datatype/mapdatatype.cpp b/document/src/vespa/document/datatype/mapdatatype.cpp
index 4598b96d970..01a0f44c457 100644
--- a/document/src/vespa/document/datatype/mapdatatype.cpp
+++ b/document/src/vespa/document/datatype/mapdatatype.cpp
@@ -57,7 +57,7 @@ MapDataType::operator==(const DataType& other) const
void
MapDataType::buildFieldPathImpl(FieldPath & path, const DataType &dataType,
- const vespalib::stringref &remainFieldName,
+ vespalib::stringref remainFieldName,
const DataType &keyType, const DataType &valueType)
{
if (!remainFieldName.empty() && remainFieldName[0] == '{') {
@@ -97,7 +97,7 @@ MapDataType::buildFieldPathImpl(FieldPath & path, const DataType &dataType,
}
void
-MapDataType::onBuildFieldPath(FieldPath & fieldPath, const vespalib::stringref &remainFieldName) const
+MapDataType::onBuildFieldPath(FieldPath & fieldPath, vespalib::stringref remainFieldName) const
{
buildFieldPathImpl(fieldPath, *this, remainFieldName, getKeyType(), getValueType());
}
diff --git a/document/src/vespa/document/datatype/mapdatatype.h b/document/src/vespa/document/datatype/mapdatatype.h
index 9e7a32e29c0..a7f2cef8b68 100644
--- a/document/src/vespa/document/datatype/mapdatatype.h
+++ b/document/src/vespa/document/datatype/mapdatatype.h
@@ -28,9 +28,9 @@ public:
bool operator==(const DataType& other) const override;
MapDataType* clone() const override { return new MapDataType(*this); }
- void onBuildFieldPath(FieldPath & path, const vespalib::stringref &remainFieldName) const override;
+ void onBuildFieldPath(FieldPath & path, vespalib::stringref remainFieldName) const override;
static void buildFieldPathImpl(FieldPath & path, const DataType& dataType,
- const vespalib::stringref &remainFieldName,
+ vespalib::stringref remainFieldName,
const DataType &keyType, const DataType &valueType);
DECLARE_IDENTIFIABLE(MapDataType);
diff --git a/document/src/vespa/document/datatype/primitivedatatype.cpp b/document/src/vespa/document/datatype/primitivedatatype.cpp
index 3755ebc370e..e48e4464acf 100644
--- a/document/src/vespa/document/datatype/primitivedatatype.cpp
+++ b/document/src/vespa/document/datatype/primitivedatatype.cpp
@@ -79,7 +79,7 @@ PrimitiveDataType::print(std::ostream& out, bool verbose, const std::string& ind
}
void
-PrimitiveDataType::onBuildFieldPath(FieldPath &, const vespalib::stringref & rest) const
+PrimitiveDataType::onBuildFieldPath(FieldPath &, vespalib::stringref rest) const
{
if ( ! rest.empty()) {
std::ostringstream ost;
diff --git a/document/src/vespa/document/datatype/primitivedatatype.h b/document/src/vespa/document/datatype/primitivedatatype.h
index 0d7e5c0c826..95e817f5692 100644
--- a/document/src/vespa/document/datatype/primitivedatatype.h
+++ b/document/src/vespa/document/datatype/primitivedatatype.h
@@ -20,7 +20,7 @@
namespace document {
class PrimitiveDataType : public DataType {
- void onBuildFieldPath(FieldPath & path, const vespalib::stringref & remainFieldName) const override;
+ void onBuildFieldPath(FieldPath & path, vespalib::stringref remainFieldName) const override;
public:
PrimitiveDataType(Type _type);
diff --git a/document/src/vespa/document/datatype/referencedatatype.cpp b/document/src/vespa/document/datatype/referencedatatype.cpp
index 8f0c6a0a4c3..6792d95909c 100644
--- a/document/src/vespa/document/datatype/referencedatatype.cpp
+++ b/document/src/vespa/document/datatype/referencedatatype.cpp
@@ -33,7 +33,7 @@ ReferenceDataType* ReferenceDataType::clone() const {
return new ReferenceDataType(_targetDocType, getId());
}
-void ReferenceDataType::onBuildFieldPath(FieldPath &, const vespalib::stringref& remainingFieldName) const {
+void ReferenceDataType::onBuildFieldPath(FieldPath &, vespalib::stringref remainingFieldName) const {
if ( ! remainingFieldName.empty() ) {
throw IllegalArgumentException(make_string("Reference data type does not support further field recursion: '%s'",
vespalib::string(remainingFieldName).c_str()), VESPA_STRLOC);
diff --git a/document/src/vespa/document/datatype/referencedatatype.h b/document/src/vespa/document/datatype/referencedatatype.h
index f3e385c1614..d5804d09835 100644
--- a/document/src/vespa/document/datatype/referencedatatype.h
+++ b/document/src/vespa/document/datatype/referencedatatype.h
@@ -23,7 +23,7 @@ public:
std::unique_ptr<FieldValue> createFieldValue() const override;
void print(std::ostream&, bool verbose, const std::string& indent) const override;
ReferenceDataType* clone() const override;
- void onBuildFieldPath(FieldPath & path, const vespalib::stringref& remainingFieldName) const override;
+ void onBuildFieldPath(FieldPath & path, vespalib::stringref remainingFieldName) const override;
};
} // document
diff --git a/document/src/vespa/document/datatype/structdatatype.cpp b/document/src/vespa/document/datatype/structdatatype.cpp
index 9ff0b7e0b0a..3ccb08c32be 100644
--- a/document/src/vespa/document/datatype/structdatatype.cpp
+++ b/document/src/vespa/document/datatype/structdatatype.cpp
@@ -26,14 +26,14 @@ StructDataType::StructDataType() :
_compressionConfig()
{ }
-StructDataType::StructDataType(const vespalib::stringref &name)
+StructDataType::StructDataType(vespalib::stringref name)
: StructuredDataType(name),
_nameFieldMap(),
_idFieldMap(),
_compressionConfig()
{ }
-StructDataType::StructDataType(const vespalib::stringref & name, int32_t dataTypeId)
+StructDataType::StructDataType(vespalib::stringref name, int32_t dataTypeId)
: StructuredDataType(name, dataTypeId),
_nameFieldMap(),
_idFieldMap(),
@@ -122,7 +122,7 @@ StructDataType::createFieldValue() const
}
const Field&
-StructDataType::getField(const vespalib::stringref & name) const
+StructDataType::getField(vespalib::stringref name) const
{
StringFieldMap::const_iterator it(_nameFieldMap.find(name));
if (it == _nameFieldMap.end()) {
@@ -153,7 +153,7 @@ StructDataType::getField(int32_t fieldId) const
return *it->second;
}
-bool StructDataType::hasField(const vespalib::stringref &name) const {
+bool StructDataType::hasField(vespalib::stringref name) const {
return _nameFieldMap.find(name) != _nameFieldMap.end();
}
diff --git a/document/src/vespa/document/datatype/structdatatype.h b/document/src/vespa/document/datatype/structdatatype.h
index 0f1c58316c9..4491ed68e01 100644
--- a/document/src/vespa/document/datatype/structdatatype.h
+++ b/document/src/vespa/document/datatype/structdatatype.h
@@ -23,8 +23,8 @@ public:
using CompressionConfig = vespalib::compression::CompressionConfig;
StructDataType();
- StructDataType(const vespalib::stringref &name);
- StructDataType(const vespalib::stringref &name, int32_t id);
+ StructDataType(vespalib::stringref name);
+ StructDataType(vespalib::stringref name, int32_t id);
~StructDataType();
/**
@@ -48,7 +48,7 @@ public:
void print(std::ostream&, bool verbose, const std::string& indent) const override;
uint32_t getFieldCount() const override { return _idFieldMap.size(); }
- const Field& getField(const vespalib::stringref & name) const override;
+ const Field& getField(vespalib::stringref name) const override;
/**
* Retrieves a field based on its ID. To determine which ID to use, we also
@@ -56,7 +56,7 @@ public:
*/
const Field& getField(int32_t fieldId) const override;
- bool hasField(const vespalib::stringref &name) const override;
+ bool hasField(vespalib::stringref name) const override;
bool hasField(int32_t fieldId) const override;
bool hasField(const Field& f) const {
return hasField(f.getId());
diff --git a/document/src/vespa/document/datatype/structureddatatype.cpp b/document/src/vespa/document/datatype/structureddatatype.cpp
index 604b4cad045..6553f450134 100644
--- a/document/src/vespa/document/datatype/structureddatatype.cpp
+++ b/document/src/vespa/document/datatype/structureddatatype.cpp
@@ -13,12 +13,12 @@ IMPLEMENT_IDENTIFIABLE_ABSTRACT(StructuredDataType, DataType);
StructuredDataType::StructuredDataType() = default;
-StructuredDataType::StructuredDataType(const vespalib::stringref &name)
+StructuredDataType::StructuredDataType(vespalib::stringref name)
: DataType(name, createId(name))
{
}
-StructuredDataType::StructuredDataType(const vespalib::stringref &name, int dataTypeId)
+StructuredDataType::StructuredDataType(vespalib::stringref name, int dataTypeId)
: DataType(name, dataTypeId)
{
}
@@ -30,7 +30,7 @@ bool StructuredDataType::operator==(const DataType& type) const
}
namespace {
-uint32_t crappyJavaStringHash(const vespalib::stringref &value) {
+uint32_t crappyJavaStringHash(vespalib::stringref value) {
uint32_t h = 0;
for (uint32_t i = 0; i < value.size(); ++i) {
h = 31 * h + value[i];
@@ -39,7 +39,7 @@ uint32_t crappyJavaStringHash(const vespalib::stringref &value) {
}
} // namespace
-int32_t StructuredDataType::createId(const vespalib::stringref &name)
+int32_t StructuredDataType::createId(vespalib::stringref name)
{
if (name == "document") {
return 8;
@@ -54,7 +54,7 @@ int32_t StructuredDataType::createId(const vespalib::stringref &name)
}
void
-StructuredDataType::onBuildFieldPath(FieldPath & path, const vespalib::stringref & remainFieldName) const
+StructuredDataType::onBuildFieldPath(FieldPath & path, vespalib::stringref remainFieldName) const
{
vespalib::stringref currFieldName(remainFieldName);
vespalib::stringref subFieldName;
diff --git a/document/src/vespa/document/datatype/structureddatatype.h b/document/src/vespa/document/datatype/structureddatatype.h
index 31de0d93680..e940629553f 100644
--- a/document/src/vespa/document/datatype/structureddatatype.h
+++ b/document/src/vespa/document/datatype/structureddatatype.h
@@ -16,21 +16,21 @@
namespace document {
class StructuredDataType : public DataType {
- void onBuildFieldPath(FieldPath & path, const vespalib::stringref & remainFieldName) const override;
+ void onBuildFieldPath(FieldPath & path, vespalib::stringref remainFieldName) const override;
protected:
StructuredDataType();
- StructuredDataType(const vespalib::stringref & name);
- StructuredDataType(const vespalib::stringref & name, int32_t dataTypeId);
+ StructuredDataType(vespalib::stringref name);
+ StructuredDataType(vespalib::stringref name, int32_t dataTypeId);
public:
virtual uint32_t getFieldCount() const = 0;
/** @throws FieldNotFoundException if field does not exist. */
- virtual const Field& getField(const vespalib::stringref & name) const = 0;
+ virtual const Field& getField(vespalib::stringref name) const = 0;
- virtual bool hasField(const vespalib::stringref & name) const = 0;
+ virtual bool hasField(vespalib::stringref name) const = 0;
virtual bool hasField(int32_t fieldId) const = 0;
virtual Field::Set getFieldSet() const = 0;
@@ -38,7 +38,7 @@ public:
virtual StructuredDataType* clone() const override = 0;
bool operator==(const DataType& type) const override;
- static int32_t createId(const vespalib::stringref &name);
+ static int32_t createId(vespalib::stringref name);
DECLARE_IDENTIFIABLE_ABSTRACT(StructuredDataType);
diff --git a/document/src/vespa/document/datatype/weightedsetdatatype.cpp b/document/src/vespa/document/datatype/weightedsetdatatype.cpp
index c2726ec6f5a..02e60cce88b 100644
--- a/document/src/vespa/document/datatype/weightedsetdatatype.cpp
+++ b/document/src/vespa/document/datatype/weightedsetdatatype.cpp
@@ -83,7 +83,7 @@ WeightedSetDataType::operator==(const DataType& other) const
}
void
-WeightedSetDataType::onBuildFieldPath(FieldPath & path, const vespalib::stringref & remainFieldName) const
+WeightedSetDataType::onBuildFieldPath(FieldPath & path, vespalib::stringref remainFieldName) const
{
MapDataType::buildFieldPathImpl(path, *this, remainFieldName, getNestedType(), *DataType::INT);
}
diff --git a/document/src/vespa/document/datatype/weightedsetdatatype.h b/document/src/vespa/document/datatype/weightedsetdatatype.h
index 91917ec990f..15d979a02bb 100644
--- a/document/src/vespa/document/datatype/weightedsetdatatype.h
+++ b/document/src/vespa/document/datatype/weightedsetdatatype.h
@@ -40,7 +40,7 @@ public:
void print(std::ostream&, bool verbose, const std::string& indent) const override;
bool operator==(const DataType& other) const override;
WeightedSetDataType* clone() const override { return new WeightedSetDataType(*this); }
- void onBuildFieldPath(FieldPath & path, const vespalib::stringref &remainFieldName) const override;
+ void onBuildFieldPath(FieldPath & path, vespalib::stringref remainFieldName) const override;
DECLARE_IDENTIFIABLE(WeightedSetDataType);
};
diff --git a/document/src/vespa/document/fieldset/fieldsetrepo.cpp b/document/src/vespa/document/fieldset/fieldsetrepo.cpp
index e1e2ed35ca6..aa14cfc2b80 100644
--- a/document/src/vespa/document/fieldset/fieldsetrepo.cpp
+++ b/document/src/vespa/document/fieldset/fieldsetrepo.cpp
@@ -13,7 +13,7 @@ namespace document {
namespace {
FieldSet::UP
-parseSpecialValues(const vespalib::stringref & name)
+parseSpecialValues(vespalib::stringref name)
{
FieldSet::UP fs;
if ((name.size() == 4) && (name[1] == 'i') && (name[2] == 'd') && (name[3] == ']')) {
@@ -38,8 +38,8 @@ parseSpecialValues(const vespalib::stringref & name)
FieldSet::UP
parseFieldCollection(const DocumentTypeRepo& repo,
- const vespalib::stringref & docType,
- const vespalib::stringref & fieldNames)
+ vespalib::stringref docType,
+ vespalib::stringref fieldNames)
{
const DocumentType* typePtr = repo.getDocumentType(docType);
if (!typePtr) {
@@ -68,7 +68,7 @@ parseFieldCollection(const DocumentTypeRepo& repo,
}
FieldSet::UP
-FieldSetRepo::parse(const DocumentTypeRepo& repo, const vespalib::stringref & str)
+FieldSetRepo::parse(const DocumentTypeRepo& repo, vespalib::stringref str)
{
if (str[0] == '[') {
return parseSpecialValues(str);
diff --git a/document/src/vespa/document/fieldset/fieldsetrepo.h b/document/src/vespa/document/fieldset/fieldsetrepo.h
index d0bff0d60c8..a744aa572e5 100644
--- a/document/src/vespa/document/fieldset/fieldsetrepo.h
+++ b/document/src/vespa/document/fieldset/fieldsetrepo.h
@@ -17,7 +17,7 @@ class FieldSetRepo
{
public:
static FieldSet::UP parse(const DocumentTypeRepo& repo,
- const vespalib::stringref & fieldSetString);
+ vespalib::stringref fieldSetString);
static vespalib::string serialize(const FieldSet& fs);
};
diff --git a/document/src/vespa/document/fieldvalue/arrayfieldvalue.cpp b/document/src/vespa/document/fieldvalue/arrayfieldvalue.cpp
index a09d5a25dd2..5ec4535ce68 100644
--- a/document/src/vespa/document/fieldvalue/arrayfieldvalue.cpp
+++ b/document/src/vespa/document/fieldvalue/arrayfieldvalue.cpp
@@ -180,7 +180,7 @@ ArrayFieldValue::hasChanged() const
fieldvalue::ModificationStatus
ArrayFieldValue::iterateSubset(int startPos, int endPos,
- const vespalib::stringref & variable,
+ vespalib::stringref variable,
PathRange nested,
fieldvalue::IteratorHandler& handler) const
{
diff --git a/document/src/vespa/document/fieldvalue/arrayfieldvalue.h b/document/src/vespa/document/fieldvalue/arrayfieldvalue.h
index bf7075ce349..4d36d4f0176 100644
--- a/document/src/vespa/document/fieldvalue/arrayfieldvalue.h
+++ b/document/src/vespa/document/fieldvalue/arrayfieldvalue.h
@@ -27,7 +27,7 @@ private:
bool containsValue(const FieldValue& val) const override;
bool removeValue(const FieldValue& val) override;
fieldvalue::ModificationStatus iterateSubset(
- int startPos, int endPos, const vespalib::stringref & variable,
+ int startPos, int endPos, vespalib::stringref variable,
PathRange nested,
fieldvalue::IteratorHandler& handler) const;
fieldvalue::ModificationStatus onIterateNested(PathRange nested, fieldvalue::IteratorHandler & handler) const override;
diff --git a/document/src/vespa/document/fieldvalue/collectionfieldvalue.h b/document/src/vespa/document/fieldvalue/collectionfieldvalue.h
index a94fe89e549..050708475dd 100644
--- a/document/src/vespa/document/fieldvalue/collectionfieldvalue.h
+++ b/document/src/vespa/document/fieldvalue/collectionfieldvalue.h
@@ -64,7 +64,7 @@ public:
// Convenience functions for using primitives directly
- bool add(const vespalib::stringref & val)
+ bool add(vespalib::stringref val)
{ return addValue(*createNested() = val); }
bool add(int32_t val)
{ return addValue(*createNested() = val); }
@@ -75,7 +75,7 @@ public:
bool add(double val)
{ return addValue(*createNested() = val); }
- bool contains(const vespalib::stringref & val)
+ bool contains(vespalib::stringref val)
{ return containsValue(*createNested() = val); }
bool contains(int32_t val)
{ return containsValue(*createNested() = val); }
@@ -86,7 +86,7 @@ public:
bool contains(double val)
{ return containsValue(*createNested() = val); }
- bool remove(const vespalib::stringref & val)
+ bool remove(vespalib::stringref val)
{ return removeValue(*createNested() = val); }
bool remove(int32_t val)
{ return removeValue(*createNested() = val); }
diff --git a/document/src/vespa/document/fieldvalue/document.cpp b/document/src/vespa/document/fieldvalue/document.cpp
index 51ba135b826..7acc7e97be9 100644
--- a/document/src/vespa/document/fieldvalue/document.cpp
+++ b/document/src/vespa/document/fieldvalue/document.cpp
@@ -28,10 +28,10 @@ bool isLegalVersion(uint16_t version) {
return (6 <= version) && (version <= 8);
}
-void documentTypeError(const vespalib::stringref & name) __attribute__((noinline));
+void documentTypeError(vespalib::stringref name) __attribute__((noinline));
void throwTypeMismatch(vespalib::stringref type, vespalib::stringref docidType) __attribute__((noinline));
-void documentTypeError(const vespalib::stringref & name) {
+void documentTypeError(vespalib::stringref name) {
throw IllegalArgumentException(make_string("Cannot generate a document with non-document type %s.",
vespalib::string(name).c_str()), VESPA_STRLOC);
}
diff --git a/document/src/vespa/document/fieldvalue/document.h b/document/src/vespa/document/fieldvalue/document.h
index e0a35411f9b..ebbe01958b8 100644
--- a/document/src/vespa/document/fieldvalue/document.h
+++ b/document/src/vespa/document/fieldvalue/document.h
@@ -79,8 +79,8 @@ public:
const StructFieldValue& getFields() const { return _fields; }
StructFieldValue& getFields() { return _fields; }
- const Field& getField(const vespalib::stringref & name) const override { return _fields.getField(name); }
- bool hasField(const vespalib::stringref & name) const override { return _fields.hasField(name); }
+ const Field& getField(vespalib::stringref name) const override { return _fields.getField(name); }
+ bool hasField(vespalib::stringref name) const override { return _fields.hasField(name); }
void clear() override;
diff --git a/document/src/vespa/document/fieldvalue/fieldvalue.cpp b/document/src/vespa/document/fieldvalue/fieldvalue.cpp
index 44de51e7fe1..037baaffe5f 100644
--- a/document/src/vespa/document/fieldvalue/fieldvalue.cpp
+++ b/document/src/vespa/document/fieldvalue/fieldvalue.cpp
@@ -106,7 +106,7 @@ FieldValue::toXml(const std::string& indent) const
// Subtypes should implement the conversion functions that make sense
-FieldValue& FieldValue::operator=(const vespalib::stringref &)
+FieldValue& FieldValue::operator=(vespalib::stringref)
{
throw vespalib::IllegalArgumentException(
"Cannot assign string to datatype " + getDataType()->toString(),
diff --git a/document/src/vespa/document/fieldvalue/fieldvalue.h b/document/src/vespa/document/fieldvalue/fieldvalue.h
index 0f7e1fb432c..bfdc907e871 100644
--- a/document/src/vespa/document/fieldvalue/fieldvalue.h
+++ b/document/src/vespa/document/fieldvalue/fieldvalue.h
@@ -113,7 +113,7 @@ public:
virtual std::string toXml(const std::string& indent = "") const;
// Utility functions to set commonly used value types.
- virtual FieldValue& operator=(const vespalib::stringref &);
+ virtual FieldValue& operator=(vespalib::stringref);
virtual FieldValue& operator=(int32_t);
virtual FieldValue& operator=(int64_t);
virtual FieldValue& operator=(float);
diff --git a/document/src/vespa/document/fieldvalue/literalfieldvalue.cpp b/document/src/vespa/document/fieldvalue/literalfieldvalue.cpp
index 5614330a495..c1c11df30f3 100644
--- a/document/src/vespa/document/fieldvalue/literalfieldvalue.cpp
+++ b/document/src/vespa/document/fieldvalue/literalfieldvalue.cpp
@@ -91,7 +91,7 @@ print(std::ostream& out, bool, const std::string&) const
}
FieldValue&
-LiteralFieldValueB::operator=(const vespalib::stringref & value)
+LiteralFieldValueB::operator=(vespalib::stringref value)
{
setValue(value);
return *this;
diff --git a/document/src/vespa/document/fieldvalue/literalfieldvalue.h b/document/src/vespa/document/fieldvalue/literalfieldvalue.h
index 2f9050eb13c..7134172caeb 100644
--- a/document/src/vespa/document/fieldvalue/literalfieldvalue.h
+++ b/document/src/vespa/document/fieldvalue/literalfieldvalue.h
@@ -14,8 +14,8 @@
*/
#pragma once
+#include "fieldvalue.h"
#include <vespa/document/datatype/primitivedatatype.h>
-#include <vespa/document/fieldvalue/fieldvalue.h>
#include <vespa/vespalib/stllike/hash_fun.h>
namespace document {
@@ -44,12 +44,12 @@ public:
LiteralFieldValueB & operator=(const LiteralFieldValueB &);
- void setValueRef(const stringref & value) {
+ void setValueRef(stringref value) {
_value = value;
_altered = true;
}
- void setValue(const stringref & value) {
+ void setValue(stringref value) {
_backing = value;
_value = _backing;
_altered = true;
@@ -68,7 +68,7 @@ public:
FieldValue& assign(const FieldValue&) override;
bool hasChanged() const override{ return _altered; }
- FieldValue& operator=(const vespalib::stringref &) override;
+ FieldValue& operator=(vespalib::stringref) override;
FieldValue& operator=(int32_t) override;
FieldValue& operator=(int64_t) override;
FieldValue& operator=(float) override;
diff --git a/document/src/vespa/document/fieldvalue/numericfieldvalue.h b/document/src/vespa/document/fieldvalue/numericfieldvalue.h
index 2f44153c09c..36f4f65765b 100644
--- a/document/src/vespa/document/fieldvalue/numericfieldvalue.h
+++ b/document/src/vespa/document/fieldvalue/numericfieldvalue.h
@@ -40,7 +40,7 @@ public:
int compare(const FieldValue& other) const override;
int fastCompare(const FieldValue& other) const override final;
- FieldValue& operator=(const vespalib::stringref &) override;
+ FieldValue& operator=(vespalib::stringref) override;
FieldValue& operator=(int32_t) override;
FieldValue& operator=(int64_t) override;
FieldValue& operator=(float) override;
diff --git a/document/src/vespa/document/fieldvalue/numericfieldvalue.hpp b/document/src/vespa/document/fieldvalue/numericfieldvalue.hpp
index c3ef6781706..90c93e7a944 100644
--- a/document/src/vespa/document/fieldvalue/numericfieldvalue.hpp
+++ b/document/src/vespa/document/fieldvalue/numericfieldvalue.hpp
@@ -78,7 +78,7 @@ NumericFieldValue<Number>::print(std::ostream& out, bool, const std::string&) co
template<typename Number>
FieldValue&
-NumericFieldValue<Number>::operator=(const vespalib::stringref & value)
+NumericFieldValue<Number>::operator=(vespalib::stringref value)
{
// Lexical cast doesn't allow hex syntax we use in XML,
// so detect these in front.
diff --git a/document/src/vespa/document/fieldvalue/stringfieldvalue.cpp b/document/src/vespa/document/fieldvalue/stringfieldvalue.cpp
index 5ee0acfb6f9..d79535d54cd 100644
--- a/document/src/vespa/document/fieldvalue/stringfieldvalue.cpp
+++ b/document/src/vespa/document/fieldvalue/stringfieldvalue.cpp
@@ -87,7 +87,7 @@ StringFieldValue::doClearSpanTrees() {
_annotationData.reset();
}
-const SpanTree * StringFieldValue::findTree(const SpanTrees & trees, const stringref & name)
+const SpanTree * StringFieldValue::findTree(const SpanTrees & trees, stringref name)
{
for(const auto & tree : trees) {
if (tree->getName() == name) {
@@ -97,7 +97,7 @@ const SpanTree * StringFieldValue::findTree(const SpanTrees & trees, const strin
return nullptr;
}
-StringFieldValue &StringFieldValue::operator=(const stringref& value)
+StringFieldValue &StringFieldValue::operator=(stringref value)
{
setValue(value);
_annotationData.reset();
@@ -109,7 +109,7 @@ FieldValue & StringFieldValue::assign(const FieldValue & rhs)
if (rhs.inherits(StringFieldValue::classId)) {
*this = static_cast<const StringFieldValue &>(rhs);
} else {
- *this = static_cast<const stringref &>(rhs.getAsString());
+ *this = rhs.getAsString().operator stringref();
}
return *this;
}
diff --git a/document/src/vespa/document/fieldvalue/stringfieldvalue.h b/document/src/vespa/document/fieldvalue/stringfieldvalue.h
index 14b67838787..015fcd5ba22 100644
--- a/document/src/vespa/document/fieldvalue/stringfieldvalue.h
+++ b/document/src/vespa/document/fieldvalue/stringfieldvalue.h
@@ -30,7 +30,7 @@ public:
StringFieldValue(const StringFieldValue &rhs);
StringFieldValue &operator=(const StringFieldValue &rhs);
- StringFieldValue &operator=(const vespalib::stringref &value) override;
+ StringFieldValue &operator=(vespalib::stringref value) override;
~StringFieldValue();
FieldValue &assign(const FieldValue &) override;
@@ -48,7 +48,7 @@ public:
return _annotationData ? _annotationData->getSerializedAnnotations() : vespalib::ConstBufferRef();
}
bool hasSpanTrees() const { return _annotationData ? _annotationData->hasSpanTrees() : false; }
- static const SpanTree *findTree(const SpanTrees &trees, const vespalib::stringref &name);
+ static const SpanTree *findTree(const SpanTrees &trees, vespalib::stringref name);
void clearSpanTrees() {
if (_annotationData) {
doClearSpanTrees();
diff --git a/document/src/vespa/document/fieldvalue/structfieldvalue.cpp b/document/src/vespa/document/fieldvalue/structfieldvalue.cpp
index 7f88229e1ba..f2e2896d9c3 100644
--- a/document/src/vespa/document/fieldvalue/structfieldvalue.cpp
+++ b/document/src/vespa/document/fieldvalue/structfieldvalue.cpp
@@ -159,13 +159,13 @@ StructFieldValue::getRawFieldIds(vector<int> &raw_ids,
}
bool
-StructFieldValue::hasField(const vespalib::stringref & name) const
+StructFieldValue::hasField(vespalib::stringref name) const
{
return getStructType().hasField(name);
}
const Field&
-StructFieldValue::getField(const vespalib::stringref & name) const
+StructFieldValue::getField(vespalib::stringref name) const
{
return getStructType().getField(name);
}
diff --git a/document/src/vespa/document/fieldvalue/structfieldvalue.h b/document/src/vespa/document/fieldvalue/structfieldvalue.h
index bb6956cf012..8025365be26 100644
--- a/document/src/vespa/document/fieldvalue/structfieldvalue.h
+++ b/document/src/vespa/document/fieldvalue/structfieldvalue.h
@@ -83,8 +83,8 @@ public:
void accept(FieldValueVisitor &visitor) override { visitor.visit(*this); }
void accept(ConstFieldValueVisitor &visitor) const override { visitor.visit(*this); }
- bool hasField(const vespalib::stringref & name) const override;
- const Field& getField(const vespalib::stringref & name) const override;
+ bool hasField(vespalib::stringref name) const override;
+ const Field& getField(vespalib::stringref name) const override;
void clear() override;
const CompressionConfig &getCompressionConfig() const;
diff --git a/document/src/vespa/document/fieldvalue/structuredfieldvalue.cpp b/document/src/vespa/document/fieldvalue/structuredfieldvalue.cpp
index c193b0919ea..273c0290684 100644
--- a/document/src/vespa/document/fieldvalue/structuredfieldvalue.cpp
+++ b/document/src/vespa/document/fieldvalue/structuredfieldvalue.cpp
@@ -244,12 +244,12 @@ StructuredFieldValue::commitTransaction() {
}
using ConstCharP = const char *;
-template void StructuredFieldValue::set(const vespalib::stringref & field, int32_t value);
-template void StructuredFieldValue::set(const vespalib::stringref & field, int64_t value);
-template void StructuredFieldValue::set(const vespalib::stringref & field, double value);
-template void StructuredFieldValue::set(const vespalib::stringref & field, ConstCharP value);
-template void StructuredFieldValue::set(const vespalib::stringref & field, vespalib::stringref value);
-template void StructuredFieldValue::set(const vespalib::stringref & field, vespalib::string value);
+template void StructuredFieldValue::set(vespalib::stringref field, int32_t value);
+template void StructuredFieldValue::set(vespalib::stringref field, int64_t value);
+template void StructuredFieldValue::set(vespalib::stringref field, double value);
+template void StructuredFieldValue::set(vespalib::stringref field, ConstCharP value);
+template void StructuredFieldValue::set(vespalib::stringref field, vespalib::stringref value);
+template void StructuredFieldValue::set(vespalib::stringref field, vespalib::string value);
template std::unique_ptr<MapFieldValue> StructuredFieldValue::getAs<MapFieldValue>(const Field &field) const;
template std::unique_ptr<ArrayFieldValue> StructuredFieldValue::getAs<ArrayFieldValue>(const Field &field) const;
diff --git a/document/src/vespa/document/fieldvalue/structuredfieldvalue.h b/document/src/vespa/document/fieldvalue/structuredfieldvalue.h
index d93bee9b093..b179c701816 100644
--- a/document/src/vespa/document/fieldvalue/structuredfieldvalue.h
+++ b/document/src/vespa/document/fieldvalue/structuredfieldvalue.h
@@ -112,12 +112,12 @@ public:
const DataType *getDataType() const override { return _type; }
/** Wrapper for DataType's hasField() function. */
- virtual bool hasField(const vespalib::stringref & name) const = 0;
+ virtual bool hasField(vespalib::stringref name) const = 0;
/**
* Wrapper for DataType's getField() function.
* @throws FieldNotFoundException If no field with given name exist.
*/
- virtual const Field& getField(const vespalib::stringref & name) const = 0;
+ virtual const Field& getField(vespalib::stringref name) const = 0;
void beginTransaction();
void commitTransaction();
@@ -136,7 +136,7 @@ public:
return getFieldValue(field);
}
/** @return Retrieve value of given field. Null pointer if not set. */
- FieldValue::UP getValue(const vespalib::stringref & name) const {
+ FieldValue::UP getValue(vespalib::stringref name) const {
return getFieldValue(getField(name));
}
/** @return True if value is set. */
@@ -159,16 +159,16 @@ public:
virtual void clear() = 0;
// Utility functions for easy but less efficient access
- bool hasValue(const vespalib::stringref & fieldName) const
+ bool hasValue(vespalib::stringref fieldName) const
{ return hasFieldValue(getField(fieldName)); }
- void remove(const vespalib::stringref & fieldName)
+ void remove(vespalib::stringref fieldName)
{ removeFieldValue(getField(fieldName)); }
- void setValue(const vespalib::stringref & fieldName, const FieldValue& value)
+ void setValue(vespalib::stringref fieldName, const FieldValue& value)
{ setFieldValue(getField(fieldName), value); }
template<typename PrimitiveType>
void set(const Field& field, PrimitiveType value);
template<typename PrimitiveType>
- void set(const vespalib::stringref & fieldName, PrimitiveType value);
+ void set(vespalib::stringref fieldName, PrimitiveType value);
size_t getSetFieldCount() const {
size_t count = 0;
diff --git a/document/src/vespa/document/fieldvalue/structuredfieldvalue.hpp b/document/src/vespa/document/fieldvalue/structuredfieldvalue.hpp
index 3e23619be60..41b285728b4 100644
--- a/document/src/vespa/document/fieldvalue/structuredfieldvalue.hpp
+++ b/document/src/vespa/document/fieldvalue/structuredfieldvalue.hpp
@@ -31,7 +31,7 @@ StructuredFieldValue::set(const Field& field, PrimitiveType value)
template<typename PrimitiveType>
void
-StructuredFieldValue::set(const vespalib::stringref & fieldName, PrimitiveType value)
+StructuredFieldValue::set(vespalib::stringref fieldName, PrimitiveType value)
{
set(getField(fieldName), value);
}
diff --git a/document/src/vespa/document/fieldvalue/weightedsetfieldvalue.h b/document/src/vespa/document/fieldvalue/weightedsetfieldvalue.h
index 0f73e2602d3..7865cd7e9fd 100644
--- a/document/src/vespa/document/fieldvalue/weightedsetfieldvalue.h
+++ b/document/src/vespa/document/fieldvalue/weightedsetfieldvalue.h
@@ -97,7 +97,7 @@ public:
// Utility functions for easy use of weighted sets of primitives
- bool add(const vespalib::stringref & val, int32_t weight = 1)
+ bool add(vespalib::stringref val, int32_t weight = 1)
{ return add(*createNested() = val, weight); }
bool add(int32_t val, int32_t weight = 1)
{ return add(*createNested() = val, weight); }
@@ -108,7 +108,7 @@ public:
bool add(double val, int32_t weight = 1)
{ return add(*createNested() = val, weight); }
- int32_t get(const vespalib::stringref & val) const
+ int32_t get(vespalib::stringref val) const
{ return get(*createNested() = val); }
int32_t get(int32_t val) const
{ return get(*createNested() = val); }
@@ -119,7 +119,7 @@ public:
int32_t get(double val) const
{ return get(*createNested() = val); }
- void increment(const vespalib::stringref & val, int32_t weight = 1)
+ void increment(vespalib::stringref val, int32_t weight = 1)
{ increment(*createNested() = val, weight); }
void increment(int32_t val, int32_t weight = 1)
{ increment(*createNested() = val, weight); }
@@ -130,7 +130,7 @@ public:
void increment(double val, int32_t weight = 1)
{ increment(*createNested() = val, weight); }
- void decrement(const vespalib::stringref & val, int32_t weight = 1)
+ void decrement(vespalib::stringref val, int32_t weight = 1)
{ decrement(*createNested() = val, weight); }
void decrement(int32_t val, int32_t weight = 1)
{ decrement(*createNested() = val, weight); }
diff --git a/document/src/vespa/document/repo/documenttyperepo.cpp b/document/src/vespa/document/repo/documenttyperepo.cpp
index a2f5aeb8f0b..03b7660efbe 100644
--- a/document/src/vespa/document/repo/documenttyperepo.cpp
+++ b/document/src/vespa/document/repo/documenttyperepo.cpp
@@ -76,7 +76,7 @@ public:
template <typename T> void addDataType(unique_ptr<T> type);
const DataType *lookup(int32_t id) const;
- const DataType *lookup(const stringref &name) const;
+ const DataType *lookup(stringref name) const;
const DataType &findOrThrow(int32_t id) const;
};
@@ -127,7 +127,7 @@ const DataType *Repo::lookup(int32_t id) const {
return FindPtr(_types, id);
}
-const DataType *Repo::lookup(const stringref &n) const {
+const DataType *Repo::lookup(stringref n) const {
return FindPtr(_name_map, n);
}
@@ -523,7 +523,7 @@ DocumentTypeRepo::getDocumentType(int32_t type_id) const {
}
const DocumentType *
-DocumentTypeRepo::getDocumentType(const stringref &name) const {
+DocumentTypeRepo::getDocumentType(stringref name) const {
DocumentTypeMap::const_iterator it = _doc_types->find(DocumentType::createId(name));
if (it != _doc_types->end() && it->second->doc_type->getName() == name) {
@@ -544,7 +544,7 @@ DocumentTypeRepo::getDataType(const DocumentType &doc_type, int32_t id) const {
}
const DataType *
-DocumentTypeRepo::getDataType(const DocumentType &doc_type, const stringref &name) const {
+DocumentTypeRepo::getDataType(const DocumentType &doc_type, stringref name) const {
const DataTypeRepo *dt_repo = FindPtr(*_doc_types, doc_type.getId());
return dt_repo ? dt_repo->repo.lookup(name) : nullptr;
}
diff --git a/document/src/vespa/document/repo/documenttyperepo.h b/document/src/vespa/document/repo/documenttyperepo.h
index c1c25204b3f..68e4087ca49 100644
--- a/document/src/vespa/document/repo/documenttyperepo.h
+++ b/document/src/vespa/document/repo/documenttyperepo.h
@@ -35,9 +35,9 @@ public:
~DocumentTypeRepo();
const DocumentType *getDocumentType(int32_t doc_type_id) const;
- const DocumentType *getDocumentType(const vespalib::stringref &name) const;
+ const DocumentType *getDocumentType(vespalib::stringref name) const;
const DataType *getDataType(const DocumentType &doc_type, int32_t id) const;
- const DataType *getDataType(const DocumentType &doc_type, const vespalib::stringref &name) const;
+ const DataType *getDataType(const DocumentType &doc_type, vespalib::stringref name) const;
const AnnotationType *getAnnotationType(const DocumentType &doc_type, int32_t id) const;
void forEachDocumentType(vespalib::Closure1<const DocumentType &> &c) const;
const DocumentType *getDefaultDocType() const { return _default; }
diff --git a/document/src/vespa/document/select/branch.h b/document/src/vespa/document/select/branch.h
index 5c010dfde8c..a750c2512f9 100644
--- a/document/src/vespa/document/select/branch.h
+++ b/document/src/vespa/document/select/branch.h
@@ -22,7 +22,7 @@ namespace select {
class Branch : public Node
{
public:
- Branch(const vespalib::stringref & name) : Node(name) {}
+ Branch(vespalib::stringref name) : Node(name) {}
bool isLeafNode() const override { return false; }
};
diff --git a/document/src/vespa/document/select/doctype.cpp b/document/src/vespa/document/select/doctype.cpp
index 4ecb388f60d..ba0338b9b61 100644
--- a/document/src/vespa/document/select/doctype.cpp
+++ b/document/src/vespa/document/select/doctype.cpp
@@ -11,7 +11,7 @@ namespace document::select {
namespace {
bool documentTypeEqualsName(const DocumentType& type,
- const vespalib::stringref& name)
+ vespalib::stringref name)
{
if (type.getName() == name) return true;
for (std::vector<const DocumentType *>::const_iterator it
@@ -24,7 +24,7 @@ namespace {
}
}
-DocType::DocType(const vespalib::stringref& doctype)
+DocType::DocType(vespalib::stringref doctype)
: Node("DocType"),
_doctype(doctype)
{
diff --git a/document/src/vespa/document/select/doctype.h b/document/src/vespa/document/select/doctype.h
index c53794aba15..e72f4c3b56d 100644
--- a/document/src/vespa/document/select/doctype.h
+++ b/document/src/vespa/document/select/doctype.h
@@ -23,7 +23,7 @@ private:
vespalib::string _doctype;
public:
- DocType(const vespalib::stringref& doctype);
+ DocType(vespalib::stringref doctype);
ResultList contains(const Context&) const override;
ResultList trace(const Context&, std::ostream& trace) const override;
diff --git a/document/src/vespa/document/select/invalidconstant.cpp b/document/src/vespa/document/select/invalidconstant.cpp
index 06271efe8bf..9327f7d1e87 100644
--- a/document/src/vespa/document/select/invalidconstant.cpp
+++ b/document/src/vespa/document/select/invalidconstant.cpp
@@ -6,7 +6,7 @@
namespace document::select {
-InvalidConstant::InvalidConstant(const vespalib::stringref & value)
+InvalidConstant::InvalidConstant(vespalib::stringref value)
: Node(value)
{ }
diff --git a/document/src/vespa/document/select/invalidconstant.h b/document/src/vespa/document/select/invalidconstant.h
index 75a0ca7235b..b99d0f5a066 100644
--- a/document/src/vespa/document/select/invalidconstant.h
+++ b/document/src/vespa/document/select/invalidconstant.h
@@ -20,7 +20,7 @@ namespace select {
class InvalidConstant : public Node
{
public:
- explicit InvalidConstant(const vespalib::stringref &value);
+ explicit InvalidConstant(vespalib::stringref value);
ResultList contains(const Context&) const override { return ResultList(Result::Invalid); }
ResultList trace(const Context&, std::ostream& trace) const override;
diff --git a/document/src/vespa/document/select/node.h b/document/src/vespa/document/select/node.h
index 83e2ea3542d..1f5c78785d1 100644
--- a/document/src/vespa/document/select/node.h
+++ b/document/src/vespa/document/select/node.h
@@ -30,7 +30,7 @@ public:
typedef std::unique_ptr<Node> UP;
typedef std::shared_ptr<Node> SP;
- Node(const vespalib::stringref & name) : _name(name), _parentheses(false) {}
+ Node(vespalib::stringref name) : _name(name), _parentheses(false) {}
~Node() override {}
void setParentheses() { _parentheses = true; }
diff --git a/document/src/vespa/document/select/operator.cpp b/document/src/vespa/document/select/operator.cpp
index b2e7ddd82b8..1b97a375a5f 100644
--- a/document/src/vespa/document/select/operator.cpp
+++ b/document/src/vespa/document/select/operator.cpp
@@ -13,7 +13,7 @@ namespace document::select {
Operator::OperatorMap Operator::_operators;
-Operator::Operator(const vespalib::stringref & name)
+Operator::Operator(vespalib::stringref name)
: _name(name)
{
OperatorMap::iterator it = _operators.find(name);
@@ -24,7 +24,7 @@ Operator::Operator(const vespalib::stringref & name)
}
const Operator&
-Operator::get(const vespalib::stringref & name)
+Operator::get(vespalib::stringref name)
{
OperatorMap::iterator it = _operators.find(name);
if (it == _operators.end()) {
@@ -75,7 +75,7 @@ FunctionOperator::LT("<", &Value::operator<);
const FunctionOperator
FunctionOperator::NE("!=", &Value::operator!=);
-RegexOperator::RegexOperator(const vespalib::stringref & name)
+RegexOperator::RegexOperator(vespalib::stringref name)
: Operator(name)
{
}
@@ -123,7 +123,7 @@ RegexOperator::traceImpl(const Value& a, const Value& b, std::ostream& out) cons
}
ResultList
-RegexOperator::match(const vespalib::string& val, const vespalib::stringref & expr) const
+RegexOperator::match(const vespalib::string& val, vespalib::stringref expr) const
{
// Should we catch this in parsing?
if (expr.size() == 0) return ResultList(Result::True);
@@ -133,7 +133,7 @@ RegexOperator::match(const vespalib::string& val, const vespalib::stringref & ex
const RegexOperator RegexOperator::REGEX("=~");
-GlobOperator::GlobOperator(const vespalib::stringref & name)
+GlobOperator::GlobOperator(vespalib::stringref name)
: RegexOperator(name)
{
}
@@ -187,7 +187,7 @@ GlobOperator::traceImpl(const Value& a, const Value& b, std::ostream& ost) const
}
vespalib::string
-GlobOperator::convertToRegex(const vespalib::stringref & globpattern) const
+GlobOperator::convertToRegex(vespalib::stringref globpattern) const
{
vespalib::asciistream ost;
ost << '^';
@@ -219,7 +219,7 @@ GlobOperator::convertToRegex(const vespalib::stringref & globpattern) const
}
bool
-GlobOperator::containsVariables(const vespalib::stringref & expression)
+GlobOperator::containsVariables(vespalib::stringref expression)
{
for (size_t i=0, n=expression.size(); i<n; ++i) {
if (expression[i] == '*' || expression[i] == '?') {
diff --git a/document/src/vespa/document/select/operator.h b/document/src/vespa/document/select/operator.h
index e4a696c523c..54ef82b01b2 100644
--- a/document/src/vespa/document/select/operator.h
+++ b/document/src/vespa/document/select/operator.h
@@ -25,7 +25,7 @@ private:
vespalib::string _name;
public:
- Operator(const vespalib::stringref & name);
+ Operator(vespalib::stringref name);
virtual ~Operator() {}
virtual ResultList compare(const Value&, const Value&) const = 0;
@@ -33,7 +33,7 @@ public:
std::ostream& trace) const = 0;
const vespalib::string& getName() const { return _name; }
- static const Operator& get(const vespalib::stringref & name);
+ static const Operator& get(vespalib::stringref name);
bool operator==(const Operator& op) const
{ return (_name == op._name); }
@@ -48,7 +48,7 @@ private:
ResultList (Value::*_comparator)(const Value&) const;
public:
- FunctionOperator(const vespalib::stringref & name,
+ FunctionOperator(vespalib::stringref name,
ResultList (Value::*comparator)(const Value&) const)
: Operator(name), _comparator(comparator) {}
@@ -65,12 +65,12 @@ public:
class RegexOperator : public Operator {
public:
- RegexOperator(const vespalib::stringref & name);
+ RegexOperator(vespalib::stringref name);
// Delegates to Value::regexCompare
ResultList compare(const Value& a, const Value& b) const override;
ResultList trace(const Value&, const Value&, std::ostream& trace) const override;
- ResultList match(const vespalib::string & val, const vespalib::stringref & expr) const;
+ ResultList match(const vespalib::string & val, vespalib::stringref expr) const;
static const RegexOperator REGEX;
@@ -84,13 +84,13 @@ private:
class GlobOperator : public RegexOperator {
public:
- GlobOperator(const vespalib::stringref & name);
+ GlobOperator(vespalib::stringref name);
// Delegates to Value::globCompare
ResultList compare(const Value& a, const Value& b) const override;
ResultList trace(const Value&, const Value&, std::ostream& trace) const override;
- vespalib::string convertToRegex(const vespalib::stringref & globpattern) const;
- static bool containsVariables(const vespalib::stringref & expression);
+ vespalib::string convertToRegex(vespalib::stringref globpattern) const;
+ static bool containsVariables(vespalib::stringref expression);
static const GlobOperator GLOB;
private:
diff --git a/document/src/vespa/document/select/simpleparser.cpp b/document/src/vespa/document/select/simpleparser.cpp
index 349c1c17362..a19d6086abe 100644
--- a/document/src/vespa/document/select/simpleparser.cpp
+++ b/document/src/vespa/document/select/simpleparser.cpp
@@ -21,7 +21,7 @@ bool icmp(char c, char l)
return tolower(c) == l;
}
-bool IdSpecParser::parse(const vespalib::stringref & s)
+bool IdSpecParser::parse(vespalib::stringref s)
{
bool retval(false);
size_t pos(eatWhite(s.data(), s.size()));
@@ -74,7 +74,7 @@ bool IdSpecParser::parse(const vespalib::stringref & s)
return retval;
}
-bool OperatorParser::parse(const vespalib::stringref & s)
+bool OperatorParser::parse(vespalib::stringref s)
{
bool retval(false);
size_t pos(eatWhite(s.data(), s.size()));
@@ -118,7 +118,7 @@ bool OperatorParser::parse(const vespalib::stringref & s)
return retval;
}
-bool StringParser::parse(const vespalib::stringref & s)
+bool StringParser::parse(vespalib::stringref s)
{
bool retval(false);
setRemaining(s);
@@ -143,7 +143,7 @@ bool StringParser::parse(const vespalib::stringref & s)
return retval;
}
-bool IntegerParser::parse(const vespalib::stringref & s)
+bool IntegerParser::parse(vespalib::stringref s)
{
bool retval(false);
size_t pos(eatWhite(s.data(), s.size()));
@@ -165,7 +165,7 @@ bool IntegerParser::parse(const vespalib::stringref & s)
return retval;
}
-bool SelectionParser::parse(const vespalib::stringref & s)
+bool SelectionParser::parse(vespalib::stringref s)
{
bool retval(false);
IdSpecParser id(_bucketIdFactory);
diff --git a/document/src/vespa/document/select/simpleparser.h b/document/src/vespa/document/select/simpleparser.h
index 28406f0a6ab..97264106913 100644
--- a/document/src/vespa/document/select/simpleparser.h
+++ b/document/src/vespa/document/select/simpleparser.h
@@ -11,10 +11,10 @@ namespace document::select::simple {
class Parser {
public:
virtual ~Parser() { }
- virtual bool parse(const vespalib::stringref & s) = 0;
- const vespalib::stringref & getRemaining() const { return _remaining; }
+ virtual bool parse(vespalib::stringref s) = 0;
+ vespalib::stringref getRemaining() const { return _remaining; }
protected:
- void setRemaining(const vespalib::stringref & s) { _remaining = s; }
+ void setRemaining(vespalib::stringref s) { _remaining = s; }
private:
vespalib::stringref _remaining;
};
@@ -44,7 +44,7 @@ public:
IdSpecParser(const BucketIdFactory& bucketIdFactory) :
_bucketIdFactory(bucketIdFactory)
{}
- bool parse(const vespalib::stringref & s) override;
+ bool parse(vespalib::stringref s) override;
const IdValueNode & getId() const { return static_cast<const IdValueNode &>(getValue()); }
bool isUserSpec() const { return getId().getType() == IdValueNode::USER; }
private:
@@ -54,7 +54,7 @@ private:
class OperatorParser : public Parser
{
public:
- bool parse(const vespalib::stringref & s) override;
+ bool parse(vespalib::stringref s) override;
const Operator * getOperator() const { return _operator; }
private:
const Operator *_operator;
@@ -63,13 +63,13 @@ private:
class StringParser : public Parser, public ValueResult
{
public:
- bool parse(const vespalib::stringref & s) override;
+ bool parse(vespalib::stringref s) override;
};
class IntegerParser : public Parser, public ValueResult
{
public:
- bool parse(const vespalib::stringref & s) override;
+ bool parse(vespalib::stringref s) override;
};
class SelectionParser : public Parser, public NodeResult
@@ -78,7 +78,7 @@ public:
SelectionParser(const BucketIdFactory& bucketIdFactory) :
_bucketIdFactory(bucketIdFactory)
{}
- bool parse(const vespalib::stringref & s) override;
+ bool parse(vespalib::stringref s) override;
private:
const BucketIdFactory & _bucketIdFactory;
};
diff --git a/document/src/vespa/document/select/value.cpp b/document/src/vespa/document/select/value.cpp
index e20d6859c18..6b4bf15fc3b 100644
--- a/document/src/vespa/document/select/value.cpp
+++ b/document/src/vespa/document/select/value.cpp
@@ -96,7 +96,7 @@ NullValue::print(std::ostream& out, bool verbose,
out << "nil";
}
-StringValue::StringValue(const vespalib::stringref & val)
+StringValue::StringValue(vespalib::stringref val)
: Value(String),
_value(val)
{
diff --git a/document/src/vespa/document/select/value.h b/document/src/vespa/document/select/value.h
index 6976bc40d63..2951117302e 100644
--- a/document/src/vespa/document/select/value.h
+++ b/document/src/vespa/document/select/value.h
@@ -91,7 +91,7 @@ class StringValue : public Value
vespalib::string _value;
public:
- StringValue(const vespalib::stringref & val);
+ StringValue(vespalib::stringref val);
const vespalib::string& getValue() const { return _value; }
ResultList operator<(const Value& value) const override;
diff --git a/document/src/vespa/document/select/valuenodes.cpp b/document/src/vespa/document/select/valuenodes.cpp
index f9cf3472110..452d277874c 100644
--- a/document/src/vespa/document/select/valuenodes.cpp
+++ b/document/src/vespa/document/select/valuenodes.cpp
@@ -25,7 +25,7 @@ namespace {
}
namespace {
- bool documentTypeEqualsName(const DocumentType& type, const vespalib::stringref& name)
+ bool documentTypeEqualsName(const DocumentType& type, vespalib::stringref name)
{
if (type.getName() == name) return true;
for (std::vector<const DocumentType *>::const_iterator it
@@ -38,7 +38,7 @@ namespace {
}
}
-InvalidValueNode::InvalidValueNode(const vespalib::stringref & name)
+InvalidValueNode::InvalidValueNode(vespalib::stringref name)
: _name(name)
{ }
@@ -79,7 +79,7 @@ NullValueNode::print(std::ostream& out, bool verbose,
if (hadParentheses()) out << ')';
}
-StringValueNode::StringValueNode(const vespalib::stringref & val)
+StringValueNode::StringValueNode(vespalib::stringref val)
: _value(val)
{
}
@@ -434,7 +434,7 @@ FieldValueNode::traceValue(const Context &context, std::ostream& out) const
}
IdValueNode::IdValueNode(const BucketIdFactory& bucketIdFactory,
- const vespalib::stringref & name, const vespalib::stringref & type,
+ vespalib::stringref name, vespalib::stringref type,
int widthBits, int divisionBits)
: _bucketIdFactory(bucketIdFactory),
_id(name),
@@ -686,7 +686,7 @@ namespace {
}
}
-FunctionValueNode::FunctionValueNode(const vespalib::stringref & name,
+FunctionValueNode::FunctionValueNode(vespalib::stringref name,
std::unique_ptr<ValueNode> src)
: _function(),
_funcname(name),
@@ -857,7 +857,7 @@ FunctionValueNode::print(std::ostream& out, bool verbose,
}
ArithmeticValueNode::ArithmeticValueNode(
- std::unique_ptr<ValueNode> left, const vespalib::stringref & op,
+ std::unique_ptr<ValueNode> left, vespalib::stringref op,
std::unique_ptr<ValueNode> right)
: _operator(),
_left(std::move(left)),
diff --git a/document/src/vespa/document/select/valuenodes.h b/document/src/vespa/document/select/valuenodes.h
index bc1ec0e01e8..0b7d23e1e30 100644
--- a/document/src/vespa/document/select/valuenodes.h
+++ b/document/src/vespa/document/select/valuenodes.h
@@ -19,7 +19,7 @@ class InvalidValueNode : public ValueNode
{
vespalib::string _name;
public:
- InvalidValueNode(const vespalib::stringref & name);
+ InvalidValueNode(vespalib::stringref name);
std::unique_ptr<Value> getValue(const Context&) const override {
return std::unique_ptr<Value>(new InvalidValue());
@@ -55,7 +55,7 @@ class StringValueNode : public ValueNode
{
vespalib::string _value;
public:
- explicit StringValueNode(const vespalib::stringref & val);
+ explicit StringValueNode(vespalib::stringref val);
const vespalib::string& getValue() const { return _value; }
@@ -242,7 +242,7 @@ public:
enum Type { SCHEME, NS, TYPE, USER, GROUP, GID, SPEC, BUCKET, ORDER, ALL };
IdValueNode(const BucketIdFactory& bucketIdFactory,
- const vespalib::stringref & name, const vespalib::stringref & type,
+ vespalib::stringref name, vespalib::stringref type,
int widthBits = -1, int divisionBits = -1);
Type getType() const { return _type; }
@@ -280,7 +280,7 @@ class FunctionValueNode : public ValueNode
public:
enum Function { LOWERCASE, HASH, ABS };
- FunctionValueNode(const vespalib::stringref & name, std::unique_ptr<ValueNode> src);
+ FunctionValueNode(vespalib::stringref name, std::unique_ptr<ValueNode> src);
Function getFunction() const { return _function; }
const vespalib::string &getFunctionName(void) const { return _funcname; }
@@ -318,7 +318,7 @@ public:
enum Operator { ADD, SUB, MUL, DIV, MOD };
ArithmeticValueNode(std::unique_ptr<ValueNode> left,
- const vespalib::stringref & op,
+ vespalib::stringref op,
std::unique_ptr<ValueNode> right);
Operator getOperator() const { return _operator; }
diff --git a/document/src/vespa/document/serialization/vespadocumentdeserializer.cpp b/document/src/vespa/document/serialization/vespadocumentdeserializer.cpp
index 399cadb4c7d..4f30851ac4c 100644
--- a/document/src/vespa/document/serialization/vespadocumentdeserializer.cpp
+++ b/document/src/vespa/document/serialization/vespadocumentdeserializer.cpp
@@ -249,7 +249,7 @@ void VespaDocumentDeserializer::read(PredicateFieldValue &value) {
namespace {
template <typename FV>
-void setValue(FV &field_value, const stringref &val, bool use_ref) {
+void setValue(FV &field_value, stringref val, bool use_ref) {
if (use_ref) {
field_value.setValueRef(val);
} else {
diff --git a/document/src/vespa/document/util/stringutil.cpp b/document/src/vespa/document/util/stringutil.cpp
index a80f3ead21e..e281a05c7e4 100644
--- a/document/src/vespa/document/util/stringutil.cpp
+++ b/document/src/vespa/document/util/stringutil.cpp
@@ -127,7 +127,7 @@ const vespalib::string & StringUtil::escape(const vespalib::string & source, ves
return source;
}
-vespalib::string StringUtil::unescape(const vespalib::stringref & source)
+vespalib::string StringUtil::unescape(vespalib::stringref source)
{
vespalib::asciistream ost;
for (unsigned int i=0; i<source.size(); ++i) {
diff --git a/document/src/vespa/document/util/stringutil.h b/document/src/vespa/document/util/stringutil.h
index 9fc136f0ce2..999dd20cdc3 100644
--- a/document/src/vespa/document/util/stringutil.h
+++ b/document/src/vespa/document/util/stringutil.h
@@ -35,7 +35,7 @@ public:
* Unescape a string, replacing \\\\ \\n \\t \\f \\r or \\x## with their
* ascii value counterparts.
*/
- static vespalib::string unescape(const vespalib::stringref & source);
+ static vespalib::string unescape(vespalib::stringref source);
/**
* Print whatever source points to in a readable format.
diff --git a/documentapi/src/vespa/documentapi/messagebus/messages/getdocumentmessage.cpp b/documentapi/src/vespa/documentapi/messagebus/messages/getdocumentmessage.cpp
index 53b1abc8dcb..821af8e256b 100644
--- a/documentapi/src/vespa/documentapi/messagebus/messages/getdocumentmessage.cpp
+++ b/documentapi/src/vespa/documentapi/messagebus/messages/getdocumentmessage.cpp
@@ -20,7 +20,7 @@ GetDocumentMessage::GetDocumentMessage(const document::DocumentId &documentId, i
}
GetDocumentMessage::GetDocumentMessage(const document::DocumentId &documentId,
- const vespalib::stringref & fieldSet) :
+ vespalib::stringref fieldSet) :
DocumentMessage(),
_documentId(documentId),
_fieldSet(fieldSet)
diff --git a/documentapi/src/vespa/documentapi/messagebus/messages/getdocumentmessage.h b/documentapi/src/vespa/documentapi/messagebus/messages/getdocumentmessage.h
index 09ba8306b61..619367faf4d 100644
--- a/documentapi/src/vespa/documentapi/messagebus/messages/getdocumentmessage.h
+++ b/documentapi/src/vespa/documentapi/messagebus/messages/getdocumentmessage.h
@@ -46,7 +46,7 @@ public:
* @param fieldSet The fields to retrieve (comma-separated)
*/
GetDocumentMessage(const document::DocumentId &documentId,
- const vespalib::stringref & fieldSet);
+ vespalib::stringref fieldSet);
~GetDocumentMessage();
diff --git a/documentapi/src/vespa/documentapi/messagebus/messages/visitor.h b/documentapi/src/vespa/documentapi/messagebus/messages/visitor.h
index 80b13bc2b9d..2e6f094bf47 100644
--- a/documentapi/src/vespa/documentapi/messagebus/messages/visitor.h
+++ b/documentapi/src/vespa/documentapi/messagebus/messages/visitor.h
@@ -98,7 +98,7 @@ public:
}
const string & getFieldSet() const { return _fieldSet; }
- void setFieldSet(const vespalib::stringref & fieldSet) { _fieldSet = fieldSet; }
+ void setFieldSet(vespalib::stringref fieldSet) { _fieldSet = fieldSet; }
bool visitInconsistentBuckets() const { return _visitInconsistentBuckets; }
void setVisitInconsistentBuckets(bool val) { _visitInconsistentBuckets = val; }
diff --git a/messagebus/src/vespa/messagebus/routing/errordirective.cpp b/messagebus/src/vespa/messagebus/routing/errordirective.cpp
index c26a76d10c7..76263afe914 100644
--- a/messagebus/src/vespa/messagebus/routing/errordirective.cpp
+++ b/messagebus/src/vespa/messagebus/routing/errordirective.cpp
@@ -6,7 +6,7 @@ using vespalib::make_string;
namespace mbus {
-ErrorDirective::ErrorDirective(const vespalib::stringref &msg) :
+ErrorDirective::ErrorDirective(vespalib::stringref msg) :
_msg(msg)
{ }
diff --git a/messagebus/src/vespa/messagebus/routing/errordirective.h b/messagebus/src/vespa/messagebus/routing/errordirective.h
index 715c6f9327c..32648d0b223 100644
--- a/messagebus/src/vespa/messagebus/routing/errordirective.h
+++ b/messagebus/src/vespa/messagebus/routing/errordirective.h
@@ -22,7 +22,7 @@ public:
*
* @param msg The error message.
*/
- ErrorDirective(const vespalib::stringref &msg);
+ ErrorDirective(vespalib::stringref msg);
/**
* Returns the error string that is to be assigned to the reply.
diff --git a/messagebus/src/vespa/messagebus/routing/policydirective.cpp b/messagebus/src/vespa/messagebus/routing/policydirective.cpp
index 3a95520a18b..64041aa1cbc 100644
--- a/messagebus/src/vespa/messagebus/routing/policydirective.cpp
+++ b/messagebus/src/vespa/messagebus/routing/policydirective.cpp
@@ -6,7 +6,7 @@ using vespalib::make_string;
namespace mbus {
-PolicyDirective::PolicyDirective(const vespalib::stringref &name, const vespalib::stringref &param) :
+PolicyDirective::PolicyDirective(vespalib::stringref name, vespalib::stringref param) :
_name(name),
_param(param)
{ }
diff --git a/messagebus/src/vespa/messagebus/routing/policydirective.h b/messagebus/src/vespa/messagebus/routing/policydirective.h
index 23c53c58121..d4471b5e219 100644
--- a/messagebus/src/vespa/messagebus/routing/policydirective.h
+++ b/messagebus/src/vespa/messagebus/routing/policydirective.h
@@ -25,7 +25,7 @@ public:
* @param name The name of the policy to invoke.
* @param param The parameter to pass to the name constructor.
*/
- PolicyDirective(const vespalib::stringref &name, const vespalib::stringref &param);
+ PolicyDirective(vespalib::stringref name, vespalib::stringref param);
~PolicyDirective();
/**
diff --git a/messagebus/src/vespa/messagebus/routing/routedirective.cpp b/messagebus/src/vespa/messagebus/routing/routedirective.cpp
index dc84f8c0711..ae40cb88a32 100644
--- a/messagebus/src/vespa/messagebus/routing/routedirective.cpp
+++ b/messagebus/src/vespa/messagebus/routing/routedirective.cpp
@@ -6,7 +6,7 @@ using vespalib::make_string;
namespace mbus {
-RouteDirective::RouteDirective(const vespalib::stringref & name) :
+RouteDirective::RouteDirective(vespalib::stringref name) :
_name(name)
{
// empty
diff --git a/messagebus/src/vespa/messagebus/routing/routedirective.h b/messagebus/src/vespa/messagebus/routing/routedirective.h
index 63661a3a61c..5923699e599 100644
--- a/messagebus/src/vespa/messagebus/routing/routedirective.h
+++ b/messagebus/src/vespa/messagebus/routing/routedirective.h
@@ -23,7 +23,7 @@ public:
*
* @param name The name of the route to insert.
*/
- RouteDirective(const vespalib::stringref &name);
+ RouteDirective(vespalib::stringref name);
/**
* Returns the name of the route to insert.
diff --git a/messagebus/src/vespa/messagebus/routing/routeparser.cpp b/messagebus/src/vespa/messagebus/routing/routeparser.cpp
index 0fb90f0d585..88d5d6e4a0f 100644
--- a/messagebus/src/vespa/messagebus/routing/routeparser.cpp
+++ b/messagebus/src/vespa/messagebus/routing/routeparser.cpp
@@ -18,13 +18,13 @@ RouteParser::isWhitespace(char c)
}
IHopDirective::SP
-RouteParser::createRouteDirective(const stringref &str)
+RouteParser::createRouteDirective(stringref str)
{
return IHopDirective::SP(new RouteDirective(str));
}
IHopDirective::SP
-RouteParser::createTcpDirective(const stringref &str)
+RouteParser::createTcpDirective(stringref str)
{
size_t posP = str.find(":");
if (posP == string::npos || posP == 0) {
@@ -41,7 +41,7 @@ RouteParser::createTcpDirective(const stringref &str)
}
IHopDirective::SP
-RouteParser::createPolicyDirective(const stringref &str)
+RouteParser::createPolicyDirective(stringref str)
{
size_t pos = str.find(":");
if (pos == string::npos) {
@@ -51,19 +51,19 @@ RouteParser::createPolicyDirective(const stringref &str)
}
IHopDirective::SP
-RouteParser::createVerbatimDirective(const stringref &str)
+RouteParser::createVerbatimDirective(stringref str)
{
return IHopDirective::SP(new VerbatimDirective(str));
}
IHopDirective::SP
-RouteParser::createErrorDirective(const stringref &str)
+RouteParser::createErrorDirective(stringref str)
{
return IHopDirective::SP(new ErrorDirective(str));
}
IHopDirective::SP
-RouteParser::createDirective(const stringref &str)
+RouteParser::createDirective(stringref str)
{
if (str.size() > 2 && str[0] == '[') {
return createPolicyDirective(str.substr(1, str.size() - 2));
diff --git a/messagebus/src/vespa/messagebus/routing/routeparser.h b/messagebus/src/vespa/messagebus/routing/routeparser.h
index 8ffba3f6e11..7a0c5a7f14a 100644
--- a/messagebus/src/vespa/messagebus/routing/routeparser.h
+++ b/messagebus/src/vespa/messagebus/routing/routeparser.h
@@ -1,7 +1,6 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
-#include <vespa/vespalib/util/sync.h>
#include "hop.h"
#include "route.h"
@@ -15,12 +14,12 @@ namespace mbus {
class RouteParser {
private:
static bool isWhitespace(char c);
- static IHopDirective::SP createDirective(const vespalib::stringref &str);
- static IHopDirective::SP createErrorDirective(const vespalib::stringref &str);
- static IHopDirective::SP createPolicyDirective(const vespalib::stringref &str);
- static IHopDirective::SP createRouteDirective(const vespalib::stringref &str);
- static IHopDirective::SP createTcpDirective(const vespalib::stringref &str);
- static IHopDirective::SP createVerbatimDirective(const vespalib::stringref &str);
+ static IHopDirective::SP createDirective(vespalib::stringref str);
+ static IHopDirective::SP createErrorDirective(vespalib::stringref str);
+ static IHopDirective::SP createPolicyDirective(vespalib::stringref str);
+ static IHopDirective::SP createRouteDirective(vespalib::stringref str);
+ static IHopDirective::SP createTcpDirective(vespalib::stringref str);
+ static IHopDirective::SP createVerbatimDirective(vespalib::stringref str);
public:
/**
diff --git a/messagebus/src/vespa/messagebus/routing/tcpdirective.cpp b/messagebus/src/vespa/messagebus/routing/tcpdirective.cpp
index 2b6774a9412..764f26c24da 100644
--- a/messagebus/src/vespa/messagebus/routing/tcpdirective.cpp
+++ b/messagebus/src/vespa/messagebus/routing/tcpdirective.cpp
@@ -5,7 +5,7 @@
namespace mbus {
-TcpDirective::TcpDirective(const vespalib::stringref &host, uint32_t port, const vespalib::stringref &session) :
+TcpDirective::TcpDirective(vespalib::stringref host, uint32_t port, vespalib::stringref session) :
_host(host),
_port(port),
_session(session)
diff --git a/messagebus/src/vespa/messagebus/routing/tcpdirective.h b/messagebus/src/vespa/messagebus/routing/tcpdirective.h
index 8687298049f..3fbd933c775 100644
--- a/messagebus/src/vespa/messagebus/routing/tcpdirective.h
+++ b/messagebus/src/vespa/messagebus/routing/tcpdirective.h
@@ -26,7 +26,7 @@ public:
* @param port The port to connect to.
* @param session The session to route to.
*/
- TcpDirective(const vespalib::stringref &host, uint32_t port, const vespalib::stringref &session);
+ TcpDirective(vespalib::stringref host, uint32_t port, vespalib::stringref session);
/**
* Returns the host to connect to. This may be an ip address or a name.
diff --git a/messagebus/src/vespa/messagebus/routing/verbatimdirective.cpp b/messagebus/src/vespa/messagebus/routing/verbatimdirective.cpp
index 86f50d897a5..f4c768bfd59 100644
--- a/messagebus/src/vespa/messagebus/routing/verbatimdirective.cpp
+++ b/messagebus/src/vespa/messagebus/routing/verbatimdirective.cpp
@@ -4,7 +4,7 @@
namespace mbus {
-VerbatimDirective::VerbatimDirective(const vespalib::stringref &image) :
+VerbatimDirective::VerbatimDirective(vespalib::stringref image) :
_image(image)
{
// empty
diff --git a/messagebus/src/vespa/messagebus/routing/verbatimdirective.h b/messagebus/src/vespa/messagebus/routing/verbatimdirective.h
index 5745937380e..fe42c35505c 100644
--- a/messagebus/src/vespa/messagebus/routing/verbatimdirective.h
+++ b/messagebus/src/vespa/messagebus/routing/verbatimdirective.h
@@ -22,7 +22,7 @@ public:
*
* @param image The image to assign to this.
*/
- VerbatimDirective(const vespalib::stringref &image);
+ VerbatimDirective(vespalib::stringref image);
/**
* Returns the image to which this is a verbatim match.
diff --git a/metrics/src/vespa/metrics/countmetric.h b/metrics/src/vespa/metrics/countmetric.h
index 4de1674c5ed..dd4c9e6fc92 100644
--- a/metrics/src/vespa/metrics/countmetric.h
+++ b/metrics/src/vespa/metrics/countmetric.h
@@ -111,11 +111,11 @@ public:
const std::string& indent, uint64_t secondsPassed) const override;
// Only one metric in valuemetric, so return it on any id.
- int64_t getLongValue(const stringref & id) const override {
+ int64_t getLongValue(stringref id) const override {
(void) id;
return static_cast<int64_t>(getValue());
}
- double getDoubleValue(const stringref & id) const override {
+ double getDoubleValue(stringref id) const override {
(void) id;
return static_cast<double>(getValue());
}
diff --git a/metrics/src/vespa/metrics/countmetricvalues.h b/metrics/src/vespa/metrics/countmetricvalues.h
index 226d1a53ddb..17e6d89df5a 100644
--- a/metrics/src/vespa/metrics/countmetricvalues.h
+++ b/metrics/src/vespa/metrics/countmetricvalues.h
@@ -37,8 +37,8 @@ struct CountMetricValues : public MetricValueClass {
CountMetricValues() : _value(0) {}
std::string toString() const;
- double getDoubleValue(const stringref &) const override;
- uint64_t getLongValue(const stringref &) const override;
+ double getDoubleValue(stringref) const override;
+ uint64_t getLongValue(stringref) const override;
void output(const std::string&, std::ostream& out) const override;
void output(const std::string&, vespalib::JsonStream& stream) const override;
bool inUse() const { return (_value != 0); }
diff --git a/metrics/src/vespa/metrics/countmetricvalues.hpp b/metrics/src/vespa/metrics/countmetricvalues.hpp
index 15732a7c1d5..3f0f1ea4b49 100644
--- a/metrics/src/vespa/metrics/countmetricvalues.hpp
+++ b/metrics/src/vespa/metrics/countmetricvalues.hpp
@@ -15,12 +15,12 @@ CountMetricValues<T>::toString() const {
}
template <typename T>
double
-CountMetricValues<T>::getDoubleValue(const stringref &) const {
+CountMetricValues<T>::getDoubleValue(stringref) const {
return static_cast<double>(_value);
}
template <typename T>
uint64_t
-CountMetricValues<T>::getLongValue(const stringref &) const {
+CountMetricValues<T>::getLongValue(stringref) const {
return static_cast<uint64_t>(_value);
}
template <typename T>
diff --git a/metrics/src/vespa/metrics/metric.h b/metrics/src/vespa/metrics/metric.h
index 1b97dcb7d27..5b617e68a7f 100644
--- a/metrics/src/vespa/metrics/metric.h
+++ b/metrics/src/vespa/metrics/metric.h
@@ -180,8 +180,8 @@ public:
* @param id The part of the metric to extract. For instance, an average
* metric have average,
*/
- virtual int64_t getLongValue(const stringref & id) const = 0;
- virtual double getDoubleValue(const stringref & id) const = 0;
+ virtual int64_t getLongValue(stringref id) const = 0;
+ virtual double getDoubleValue(stringref id) const = 0;
/**
* When snapshotting we need to be able to add data from one set of metrics
diff --git a/metrics/src/vespa/metrics/metricmanager.cpp b/metrics/src/vespa/metrics/metricmanager.cpp
index 39a9fdefc39..b8255a6532f 100644
--- a/metrics/src/vespa/metrics/metricmanager.cpp
+++ b/metrics/src/vespa/metrics/metricmanager.cpp
@@ -189,7 +189,7 @@ namespace {
struct Path {
vespalib::StringTokenizer _path;
- Path(const vespalib::stringref & fullpath) : _path(fullpath, ".") { }
+ Path(vespalib::stringref fullpath) : _path(fullpath, ".") { }
vespalib::string toString() const {
vespalib::asciistream ost;
diff --git a/metrics/src/vespa/metrics/metricset.cpp b/metrics/src/vespa/metrics/metricset.cpp
index 6ac27ba38c9..2e708e17504 100644
--- a/metrics/src/vespa/metrics/metricset.cpp
+++ b/metrics/src/vespa/metrics/metricset.cpp
@@ -76,11 +76,11 @@ MetricSet::getMetricInternal(const String& name) const
return 0;
}
-int64_t MetricSet::getLongValue(const stringref &) const {
+int64_t MetricSet::getLongValue(stringref) const {
assert(false);
return 0;
}
-double MetricSet::getDoubleValue(const stringref &) const {
+double MetricSet::getDoubleValue(stringref) const {
assert(false);
return 0;
}
diff --git a/metrics/src/vespa/metrics/metricset.h b/metrics/src/vespa/metrics/metricset.h
index e6f7cfc0deb..9671aaffbfc 100644
--- a/metrics/src/vespa/metrics/metricset.h
+++ b/metrics/src/vespa/metrics/metricset.h
@@ -63,8 +63,8 @@ public:
void print(std::ostream&, bool verbose, const std::string& indent, uint64_t secondsPassed) const override;
// These should never be called on metrics set.
- int64_t getLongValue(const stringref & id) const override;
- double getDoubleValue(const stringref & id) const override;
+ int64_t getLongValue(stringref id) const override;
+ double getDoubleValue(stringref id) const override;
const Metric* getMetric(const String& name) const;
Metric* getMetric(const String& name) {
diff --git a/metrics/src/vespa/metrics/metricvalueset.h b/metrics/src/vespa/metrics/metricvalueset.h
index 41498b6503c..2463990378e 100644
--- a/metrics/src/vespa/metrics/metricvalueset.h
+++ b/metrics/src/vespa/metrics/metricvalueset.h
@@ -39,8 +39,8 @@ struct MetricValueClass {
using stringref = vespalib::stringref;
virtual ~MetricValueClass() {}
- virtual double getDoubleValue(const stringref & id) const = 0;
- virtual uint64_t getLongValue(const stringref & id) const = 0;
+ virtual double getDoubleValue(stringref id) const = 0;
+ virtual uint64_t getLongValue(stringref id) const = 0;
virtual void output(const std::string& id, std::ostream&) const = 0;
virtual void output(const std::string& id, vespalib::JsonStream&) const = 0;
std::string toString(const std::string& id);
diff --git a/metrics/src/vespa/metrics/summetric.h b/metrics/src/vespa/metrics/summetric.h
index 784ae1f20e7..3dc58d32bef 100644
--- a/metrics/src/vespa/metrics/summetric.h
+++ b/metrics/src/vespa/metrics/summetric.h
@@ -61,8 +61,8 @@ public:
bool logEvent(const String& fullName) const override;
void print(std::ostream&, bool verbose, const std::string& indent, uint64_t secondsPassed) const override;
- int64_t getLongValue(const stringref & id) const override;
- double getDoubleValue(const stringref & id) const override;
+ int64_t getLongValue(stringref id) const override;
+ double getDoubleValue(stringref id) const override;
void reset() override {}
bool visit(MetricVisitor& visitor, bool tagAsAutoGenerated = false) const override;
bool used() const override;
diff --git a/metrics/src/vespa/metrics/summetric.hpp b/metrics/src/vespa/metrics/summetric.hpp
index 761b369fb57..8e558eb94ee 100644
--- a/metrics/src/vespa/metrics/summetric.hpp
+++ b/metrics/src/vespa/metrics/summetric.hpp
@@ -234,7 +234,7 @@ SumMetric<AddendMetric>::generateSum() const
template<typename AddendMetric>
int64_t
-SumMetric<AddendMetric>::getLongValue(const stringref & id) const
+SumMetric<AddendMetric>::getLongValue(stringref id) const
{
std::pair<std::vector<Metric::UP>, Metric::UP> sum(generateSum());
if (sum.second.get() == 0) return 0;
@@ -243,7 +243,7 @@ SumMetric<AddendMetric>::getLongValue(const stringref & id) const
template<typename AddendMetric>
double
-SumMetric<AddendMetric>::getDoubleValue(const stringref & id) const
+SumMetric<AddendMetric>::getDoubleValue(stringref id) const
{
std::pair<std::vector<Metric::UP>, Metric::UP> sum(generateSum());
if (sum.second.get() == 0) return 0.0;
diff --git a/metrics/src/vespa/metrics/valuemetric.h b/metrics/src/vespa/metrics/valuemetric.h
index 0c40a0fa5ea..57baa36c26a 100644
--- a/metrics/src/vespa/metrics/valuemetric.h
+++ b/metrics/src/vespa/metrics/valuemetric.h
@@ -147,8 +147,8 @@ public:
void print(std::ostream&, bool verbose,
const std::string& indent, uint64_t secondsPassed) const override;
- int64_t getLongValue(const stringref & id) const override;
- double getDoubleValue(const stringref & id) const override;
+ int64_t getLongValue(stringref id) const override;
+ double getDoubleValue(stringref id) const override;
bool inUse(const MetricValueClass& v) const override {
const Values& values(static_cast<const Values&>(v));
diff --git a/metrics/src/vespa/metrics/valuemetric.hpp b/metrics/src/vespa/metrics/valuemetric.hpp
index f8b4d1626ab..60ed219edec 100644
--- a/metrics/src/vespa/metrics/valuemetric.hpp
+++ b/metrics/src/vespa/metrics/valuemetric.hpp
@@ -226,7 +226,7 @@ ValueMetric<AvgVal, TotVal, SumOnAdd>::print(
template<typename AvgVal, typename TotVal, bool SumOnAdd>
int64_t
-ValueMetric<AvgVal, TotVal, SumOnAdd>::getLongValue(const stringref & id) const
+ValueMetric<AvgVal, TotVal, SumOnAdd>::getLongValue(stringref id) const
{
Values values(_values.getValues());
if (id == "last" || (SumOnAdd && id == "value"))
@@ -245,7 +245,7 @@ ValueMetric<AvgVal, TotVal, SumOnAdd>::getLongValue(const stringref & id) const
template<typename AvgVal, typename TotVal, bool SumOnAdd>
double
-ValueMetric<AvgVal, TotVal, SumOnAdd>::getDoubleValue(const stringref & id) const
+ValueMetric<AvgVal, TotVal, SumOnAdd>::getDoubleValue(stringref id) const
{
Values values(_values.getValues());
if (id == "last" || (SumOnAdd && id == "value"))
diff --git a/metrics/src/vespa/metrics/valuemetricvalues.h b/metrics/src/vespa/metrics/valuemetricvalues.h
index 391b9c9d588..567f0d0ae0f 100644
--- a/metrics/src/vespa/metrics/valuemetricvalues.h
+++ b/metrics/src/vespa/metrics/valuemetricvalues.h
@@ -37,9 +37,9 @@ struct ValueMetricValues : MetricValueClass {
void relaxedLoadFrom(const AtomicImpl& source) noexcept;
template<typename T>
- T getValue(const stringref & id) const;
- double getDoubleValue(const stringref & id) const override;
- uint64_t getLongValue(const stringref & id) const override;
+ T getValue(stringref id) const;
+ double getDoubleValue(stringref id) const override;
+ uint64_t getLongValue(stringref id) const override;
void output(const std::string& id, std::ostream& out) const override;
void output(const std::string& id, vespalib::JsonStream& stream) const override;
template<typename A, typename T>
diff --git a/metrics/src/vespa/metrics/valuemetricvalues.hpp b/metrics/src/vespa/metrics/valuemetricvalues.hpp
index 9f63898d4f3..b33e636b120 100644
--- a/metrics/src/vespa/metrics/valuemetricvalues.hpp
+++ b/metrics/src/vespa/metrics/valuemetricvalues.hpp
@@ -48,7 +48,7 @@ void ValueMetricValues<AvgVal, TotVal>::relaxedLoadFrom(const AtomicImpl& source
template<typename AvgVal, typename TotVal>
template<typename T>
-T ValueMetricValues<AvgVal, TotVal>::getValue(const stringref & id) const {
+T ValueMetricValues<AvgVal, TotVal>::getValue(stringref id) const {
if (id == "last") return static_cast<T>(_last);
if (id == "count") return static_cast<T>(_count);
if (id == "total") return static_cast<T>(_total);
@@ -58,11 +58,11 @@ T ValueMetricValues<AvgVal, TotVal>::getValue(const stringref & id) const {
}
template<typename AvgVal, typename TotVal>
-double ValueMetricValues<AvgVal, TotVal>::getDoubleValue(const stringref & id) const {
+double ValueMetricValues<AvgVal, TotVal>::getDoubleValue(stringref id) const {
return getValue<double>(id);
}
template<typename AvgVal, typename TotVal>
-uint64_t ValueMetricValues<AvgVal, TotVal>::getLongValue(const stringref & id) const {
+uint64_t ValueMetricValues<AvgVal, TotVal>::getLongValue(stringref id) const {
return getValue<uint64_t>(id);
}
template<typename AvgVal, typename TotVal>
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperations.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperations.java
index 955dd116f89..baf1be41c36 100644
--- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperations.java
+++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperations.java
@@ -7,13 +7,14 @@ import com.yahoo.vespa.hosted.dockerapi.Docker;
import com.yahoo.vespa.hosted.dockerapi.DockerImage;
import com.yahoo.vespa.hosted.dockerapi.ProcessResult;
import com.yahoo.vespa.hosted.node.admin.configserver.noderepository.NodeSpec;
+import com.yahoo.vespa.hosted.node.admin.nodeagent.ContainerData;
import java.util.List;
import java.util.Optional;
public interface DockerOperations {
- void createContainer(ContainerName containerName, NodeSpec node);
+ void createContainer(ContainerName containerName, NodeSpec node, ContainerData containerData);
void startContainer(ContainerName containerName, NodeSpec node);
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImpl.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImpl.java
index 43fb11497c0..1e7df09dbce 100644
--- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImpl.java
+++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImpl.java
@@ -12,13 +12,13 @@ import com.yahoo.vespa.hosted.dockerapi.DockerImage;
import com.yahoo.vespa.hosted.dockerapi.DockerImpl;
import com.yahoo.vespa.hosted.dockerapi.DockerNetworkCreator;
import com.yahoo.vespa.hosted.dockerapi.ProcessResult;
-import com.yahoo.vespa.hosted.node.admin.configserver.noderepository.NodeSpec;
import com.yahoo.vespa.hosted.node.admin.component.Environment;
+import com.yahoo.vespa.hosted.node.admin.configserver.noderepository.NodeSpec;
+import com.yahoo.vespa.hosted.node.admin.nodeagent.ContainerData;
import com.yahoo.vespa.hosted.node.admin.task.util.network.IPAddresses;
import com.yahoo.vespa.hosted.node.admin.util.PrefixLogger;
import java.io.IOException;
-import java.net.Inet4Address;
import java.net.Inet6Address;
import java.net.InetAddress;
import java.nio.file.Path;
@@ -31,6 +31,8 @@ import java.util.Map;
import java.util.Optional;
import java.util.stream.Stream;
+import static com.yahoo.yolean.Exceptions.uncheck;
+
/**
* Class that wraps the Docker class and have some tools related to running programs in docker.
*
@@ -62,7 +64,7 @@ public class DockerOperationsImpl implements DockerOperations {
}
@Override
- public void createContainer(ContainerName containerName, final NodeSpec node) {
+ public void createContainer(ContainerName containerName, final NodeSpec node, ContainerData containerData) {
PrefixLogger logger = PrefixLogger.getNodeAgentLogger(DockerOperationsImpl.class, containerName);
logger.info("Creating container " + containerName);
try {
@@ -105,7 +107,7 @@ public class DockerOperationsImpl implements DockerOperations {
if (!docker.networkNATed()) {
command.withIpAddress(nodeInetAddress);
command.withNetworkMode(DockerImpl.DOCKER_CUSTOM_MACVLAN_NETWORK_NAME);
- command.withVolume("/etc/hosts", "/etc/hosts"); // TODO This is probably not necessary - review later
+ command.withVolume("/etc/hosts", "/etc/hosts");
} else {
// IPv6 - Assume always valid
Inet6Address ipV6Address = this.retriever.getIPv6Address(node.getHostname()).orElseThrow(
@@ -115,12 +117,14 @@ public class DockerOperationsImpl implements DockerOperations {
command.withIpAddress(ipV6Local);
// IPv4 - Only present for some containers
- Optional<Inet4Address> ipV4Address = this.retriever.getIPv4Address(node.getHostname());
- if (ipV4Address.isPresent()) {
- InetAddress ipV4Prefix = InetAddress.getByName(IPV4_NPT_PREFIX);
- InetAddress ipV4Local = IPAddresses.prefixTranslate(ipV4Address.get(), ipV4Prefix, 2);
- command.withIpAddress(ipV4Local);
- }
+ Optional<InetAddress> ipV4Local = this.retriever.getIPv4Address(node.getHostname())
+ .map(ipV4Address -> {
+ InetAddress ipV4Prefix = uncheck(() -> InetAddress.getByName(IPV4_NPT_PREFIX));
+ return IPAddresses.prefixTranslate(ipV4Address, ipV4Prefix, 2);
+ });
+ ipV4Local.ifPresent(command::withIpAddress);
+
+ addEtcHosts(containerData, node.getHostname(), ipV4Local, ipV6Local);
command.withNetworkMode(DOCKER_CUSTOM_BRIDGE_NETWORK_NAME);
}
@@ -147,6 +151,36 @@ public class DockerOperationsImpl implements DockerOperations {
}
}
+ void addEtcHosts(ContainerData containerData,
+ String hostname,
+ Optional<InetAddress> ipV4Local,
+ InetAddress ipV6Local) {
+ // The default /etc/hosts in a Docker container contains one entry for the host,
+ // mapping the hostname to the Docker-assigned IPv4 address.
+ //
+ // When e.g. the cluster controller's ZooKeeper server starts, it binds the election
+ // port to the localhost's IP address as returned by InetAddress.getByName, backed by
+ // getaddrinfo(2), backed by that one entry in /etc/hosts. If the Docker container does
+ // not have a public IPv4 address, then other members of the ZooKeeper ensemble will not
+ // be able to connect.
+ //
+ // We will therefore explicitly manage the /etc/hosts file ourselves. Because of NPT,
+ // the IP addresses needs to be local.
+
+ StringBuilder etcHosts = new StringBuilder(
+ "# This file was generated by " + DockerOperationsImpl.class.getName() + "\n" +
+ "127.0.0.1\tlocalhost\n" +
+ "::1\tlocalhost ip6-localhost ip6-loopback\n" +
+ "fe00::0\tip6-localnet\n" +
+ "ff00::0\tip6-mcastprefix\n" +
+ "ff02::1\tip6-allnodes\n" +
+ "ff02::2\tip6-allrouters\n" +
+ ipV6Local.getHostAddress() + '\t' + hostname + '\n');
+ ipV4Local.ifPresent(ipv4 -> etcHosts.append(ipv4.getHostAddress() + '\t' + hostname + '\n'));
+
+ containerData.addFile(Paths.get("/etc/hosts"), etcHosts.toString());
+ }
+
@Override
public void startContainer(ContainerName containerName, final NodeSpec node) {
PrefixLogger logger = PrefixLogger.getNodeAgentLogger(DockerOperationsImpl.class, containerName);
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/maintenance/StorageMaintainer.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/maintenance/StorageMaintainer.java
index c83b454db15..7d3c6eb5a95 100644
--- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/maintenance/StorageMaintainer.java
+++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/maintenance/StorageMaintainer.java
@@ -291,10 +291,8 @@ public class StorageMaintainer {
/**
* Checks if container has any new coredumps, reports and archives them if so
- *
- * @param force Set to true to bypass throttling
*/
- public void handleCoreDumpsForContainer(ContainerName containerName, NodeSpec node, boolean force) {
+ public void handleCoreDumpsForContainer(ContainerName containerName, NodeSpec node) {
// Sample number of coredumps on the host
try (Stream<Path> files = Files.list(environment.pathInNodeAdminToDoneCoredumps())) {
numberOfCoredumpsOnHost.sample(files.count());
@@ -302,14 +300,9 @@ public class StorageMaintainer {
// Ignore for now - this is either test or a misconfiguration
}
- // Return early if throttled
- if (! getMaintenanceThrottlerFor(containerName).shouldHandleCoredumpsNow() && !force) return;
-
MaintainerExecutor maintainerExecutor = new MaintainerExecutor();
addHandleCoredumpsCommand(maintainerExecutor, containerName, node);
maintainerExecutor.execute();
-
- getMaintenanceThrottlerFor(containerName).updateNextHandleCoredumpsTime();
}
/**
@@ -513,7 +506,6 @@ public class StorageMaintainer {
private class MaintenanceThrottler {
private Instant nextRemoveOldFilesAt = Instant.EPOCH;
- private Instant nextHandleOldCoredumpsAt = Instant.EPOCH;
void updateNextRemoveOldFilesTime() {
nextRemoveOldFilesAt = clock.instant().plus(Duration.ofHours(1));
@@ -523,17 +515,8 @@ public class StorageMaintainer {
return !nextRemoveOldFilesAt.isAfter(clock.instant());
}
- void updateNextHandleCoredumpsTime() {
- nextHandleOldCoredumpsAt = clock.instant().plus(Duration.ofMinutes(5));
- }
-
- boolean shouldHandleCoredumpsNow() {
- return !nextHandleOldCoredumpsAt.isAfter(clock.instant());
- }
-
void reset() {
nextRemoveOldFilesAt = Instant.EPOCH;
- nextHandleOldCoredumpsAt = Instant.EPOCH;
}
}
}
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/maintenance/identity/AthenzCredentialsMaintainer.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/maintenance/identity/AthenzCredentialsMaintainer.java
index a8403b8b10d..f82047d885c 100644
--- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/maintenance/identity/AthenzCredentialsMaintainer.java
+++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/maintenance/identity/AthenzCredentialsMaintainer.java
@@ -1,8 +1,6 @@
// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.node.admin.maintenance.identity;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.yahoo.vespa.athenz.api.AthenzService;
import com.yahoo.vespa.athenz.client.zts.DefaultZtsClient;
import com.yahoo.vespa.athenz.client.zts.InstanceIdentity;
@@ -12,7 +10,6 @@ import com.yahoo.vespa.athenz.identity.ServiceIdentityProvider;
import com.yahoo.vespa.athenz.identityprovider.api.EntityBindingsMapper;
import com.yahoo.vespa.athenz.identityprovider.api.IdentityDocumentClient;
import com.yahoo.vespa.athenz.identityprovider.api.SignedIdentityDocument;
-import com.yahoo.vespa.athenz.identityprovider.api.bindings.SignedIdentityDocumentEntity;
import com.yahoo.vespa.athenz.identityprovider.client.DefaultIdentityDocumentClient;
import com.yahoo.vespa.athenz.identityprovider.client.InstanceCsrGenerator;
import com.yahoo.vespa.athenz.tls.AthenzIdentityVerifier;
@@ -53,9 +50,9 @@ public class AthenzCredentialsMaintainer {
private static final Duration EXPIRY_MARGIN = Duration.ofDays(1);
private static final Duration REFRESH_PERIOD = Duration.ofDays(1);
- private static final Path CONTAINER_SIA_DIRECTORY = Paths.get("/var/lib/sia");
+ private static final Duration REFRESH_BACKOFF = Duration.ofHours(1); // Backoff when refresh fails to ensure ZTS is not DDoS'ed.
- private static final ObjectMapper mapper = new ObjectMapper().registerModule(new JavaTimeModule());
+ private static final Path CONTAINER_SIA_DIRECTORY = Paths.get("/var/lib/sia");
private final boolean enabled;
private final PrefixLogger log;
@@ -72,6 +69,8 @@ public class AthenzCredentialsMaintainer {
private final InstanceCsrGenerator csrGenerator;
private final AthenzService configserverIdentity;
+ private Instant lastRefreshAttempt = Instant.EPOCH; // Used as an optimization to ensure ZTS is not DDoS'ed on continuously failing refresh attempts
+
public AthenzCredentialsMaintainer(String hostname,
Environment environment,
ServiceIdentityProvider hostIdentityProvider) {
@@ -97,14 +96,11 @@ public class AthenzCredentialsMaintainer {
this.clock = Clock.systemUTC();
}
- /**
- * @return Returns true if credentials were updated
- */
- public boolean converge() {
+ public void converge() {
try {
if (!enabled) {
log.debug("Feature disabled on this host - not fetching certificate");
- return false;
+ return;
}
log.debug("Checking certificate");
Instant now = clock.instant();
@@ -114,23 +110,29 @@ public class AthenzCredentialsMaintainer {
Files.createDirectories(certificateFile.getParent());
Files.createDirectories(identityDocumentFile.getParent());
registerIdentity();
- return true;
+ return;
}
X509Certificate certificate = readCertificateFromFile();
Instant expiry = certificate.getNotAfter().toInstant();
if (isCertificateExpired(expiry, now)) {
log.info(String.format("Certificate has expired (expiry=%s)", expiry.toString()));
registerIdentity();
- return true;
+ return;
}
Duration age = Duration.between(certificate.getNotBefore().toInstant(), now);
if (shouldRefreshCredentials(age)) {
log.info(String.format("Certificate is ready to be refreshed (age=%s)", age.toString()));
- refreshIdentity();
- return true;
+ if (shouldThrottleRefreshAttempts(now)) {
+ log.warning(String.format("Skipping refresh attempt as last refresh was on %s (less than %s ago)",
+ lastRefreshAttempt.toString(), REFRESH_BACKOFF.toString()));
+ return;
+ } else {
+ lastRefreshAttempt = now;
+ refreshIdentity();
+ return;
+ }
}
log.debug("Certificate is still valid");
- return false;
} catch (IOException e) {
throw new UncheckedIOException(e);
}
@@ -154,6 +156,10 @@ public class AthenzCredentialsMaintainer {
return age.compareTo(REFRESH_PERIOD) >= 0;
}
+ private boolean shouldThrottleRefreshAttempts(Instant now) {
+ return REFRESH_BACKOFF.compareTo(Duration.between(lastRefreshAttempt, now)) > 0;
+ }
+
private X509Certificate readCertificateFromFile() throws IOException {
String pemEncodedCertificate = new String(Files.readAllBytes(certificateFile));
return X509CertificateUtils.fromPem(pemEncodedCertificate);
@@ -177,7 +183,7 @@ public class AthenzCredentialsMaintainer {
EntityBindingsMapper.toAttestationData(signedIdentityDocument),
false,
csr);
- writeIdentityDocument(signedIdentityDocument);
+ EntityBindingsMapper.writeSignedIdentityDocumentToFile(identityDocumentFile, signedIdentityDocument);
writePrivateKeyAndCertificate(keyPair.getPrivate(), instanceIdentity.certificate());
log.info("Instance successfully registered and credentials written to file");
} catch (IOException e) {
@@ -186,7 +192,7 @@ public class AthenzCredentialsMaintainer {
}
private void refreshIdentity() {
- SignedIdentityDocument identityDocument = readIdentityDocument();
+ SignedIdentityDocument identityDocument = EntityBindingsMapper.readSignedIdentityDocumentFromFile(identityDocumentFile);
KeyPair keyPair = KeyUtils.generateKeypair(KeyAlgorithm.RSA);
Pkcs10Csr csr = csrGenerator.generateCsr(containerIdentity, identityDocument.providerUniqueId(), identityDocument.ipAddresses(), keyPair);
SSLContext containerIdentitySslContext =
@@ -194,45 +200,27 @@ public class AthenzCredentialsMaintainer {
.withKeyStore(privateKeyFile.toFile(), certificateFile.toFile())
.withTrustStore(trustStorePath.toFile(), KeyStoreType.JKS)
.build();
- try (ZtsClient ztsClient = new DefaultZtsClient(ztsEndpoint, containerIdentity, containerIdentitySslContext)) {
- InstanceIdentity instanceIdentity =
- ztsClient.refreshInstance(
- configserverIdentity,
- containerIdentity,
- identityDocument.providerUniqueId().asDottedString(),
- false,
- csr);
- writePrivateKeyAndCertificate(keyPair.getPrivate(), instanceIdentity.certificate());
- log.info("Instance successfully refreshed and credentials written to file");
- } catch (ZtsClientException e) {
- // TODO Find out why certificate was revoked and hopefully remove this workaround
- if (e.getErrorCode() == 403 && e.getDescription().startsWith("Certificate revoked")) {
- log.error("Certificate cannot be refreshed as it is revoked by ZTS - re-registering the instance now", e);
- registerIdentity();
- }
- } catch (IOException e) {
- throw new UncheckedIOException(e);
- }
- }
-
- private SignedIdentityDocument readIdentityDocument() {
try {
- SignedIdentityDocumentEntity entity = mapper.readValue(identityDocumentFile.toFile(), SignedIdentityDocumentEntity.class);
- return EntityBindingsMapper.toSignedIdentityDocument(entity);
- } catch (IOException e) {
- throw new UncheckedIOException(e);
- }
- }
-
- private void writeIdentityDocument(SignedIdentityDocument signedIdentityDocument) {
- try {
- SignedIdentityDocumentEntity entity =
- EntityBindingsMapper.toSignedIdentityDocumentEntity(signedIdentityDocument);
- Path tempIdentityDocumentFile = toTempPath(identityDocumentFile);
- mapper.writeValue(tempIdentityDocumentFile.toFile(), entity);
- Files.move(tempIdentityDocumentFile, identityDocumentFile, StandardCopyOption.ATOMIC_MOVE);
- } catch (IOException e) {
- throw new UncheckedIOException(e);
+ try (ZtsClient ztsClient = new DefaultZtsClient(ztsEndpoint, containerIdentity, containerIdentitySslContext)) {
+ InstanceIdentity instanceIdentity =
+ ztsClient.refreshInstance(
+ configserverIdentity,
+ containerIdentity,
+ identityDocument.providerUniqueId().asDottedString(),
+ false,
+ csr);
+ writePrivateKeyAndCertificate(keyPair.getPrivate(), instanceIdentity.certificate());
+ log.info("Instance successfully refreshed and credentials written to file");
+ } catch (ZtsClientException e) {
+ if (e.getErrorCode() == 403 && e.getDescription().startsWith("Certificate revoked")) {
+ log.error("Certificate cannot be refreshed as it is revoked by ZTS - re-registering the instance now", e);
+ registerIdentity();
+ } else {
+ throw e;
+ }
+ }
+ } catch (Exception e) {
+ log.error("Certificate refresh failed: " + e.getMessage(), e);
}
}
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/ContainerData.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/ContainerData.java
new file mode 100644
index 00000000000..ab5795f17c2
--- /dev/null
+++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/ContainerData.java
@@ -0,0 +1,20 @@
+// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.vespa.hosted.node.admin.nodeagent;
+
+import java.nio.file.Path;
+
+/**
+ * Utility for manipulating the initial file system the Docker container will start with.
+ *
+ * @author hakon
+ */
+public interface ContainerData {
+ /**
+ * Add or overwrite file in container at path.
+ *
+ * @param pathInContainer The path to the file inside the container, absolute or relative root /.
+ * @param data The content of the file.
+ */
+ void addFile(Path pathInContainer, String data);
+}
+
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentImpl.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentImpl.java
index 5f1b7aefcfe..c84fe157cd3 100644
--- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentImpl.java
+++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentImpl.java
@@ -26,6 +26,7 @@ import com.yahoo.vespa.hosted.node.admin.maintenance.identity.AthenzCredentialsM
import com.yahoo.vespa.hosted.node.admin.util.PrefixLogger;
import com.yahoo.vespa.hosted.provision.Node;
+import java.nio.file.Path;
import java.text.SimpleDateFormat;
import java.time.Clock;
import java.time.Duration;
@@ -273,8 +274,8 @@ public class NodeAgentImpl implements NodeAgent {
}
private void startContainer(NodeSpec node) {
- createContainerData(environment, node);
- dockerOperations.createContainer(containerName, node);
+ ContainerData containerData = createContainerData(environment, node);
+ dockerOperations.createContainer(containerName, node, containerData);
dockerOperations.startContainer(containerName, node);
lastCpuMetric = new CpuUsageReporter();
@@ -475,7 +476,7 @@ public class NodeAgentImpl implements NodeAgent {
updateNodeRepoWithCurrentAttributes(node);
break;
case active:
- storageMaintainer.handleCoreDumpsForContainer(containerName, node, false);
+ storageMaintainer.handleCoreDumpsForContainer(containerName, node);
storageMaintainer.getDiskUsageFor(containerName)
.map(diskUsage -> (double) diskUsage / BYTES_IN_GB / node.getMinDiskAvailableGb())
@@ -489,7 +490,6 @@ public class NodeAgentImpl implements NodeAgent {
}
container = removeContainerIfNeededUpdateContainerState(node, container);
if (! container.isPresent()) {
- storageMaintainer.handleCoreDumpsForContainer(containerName, node, false);
containerState = STARTING;
startContainer(node);
containerState = UNKNOWN;
@@ -737,5 +737,12 @@ public class NodeAgentImpl implements NodeAgent {
orchestrator.suspend(hostname);
}
- protected void createContainerData(Environment environment, NodeSpec node) { }
+ protected ContainerData createContainerData(Environment environment, NodeSpec node) {
+ return new ContainerData() {
+ @Override
+ public void addFile(Path pathInContainer, String data) {
+ throw new UnsupportedOperationException("addFile not implemented");
+ }
+ };
+ }
}
diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImplTest.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImplTest.java
index 4526891d24a..bb349ac0c49 100644
--- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImplTest.java
+++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImplTest.java
@@ -10,11 +10,15 @@ import com.yahoo.vespa.hosted.dockerapi.DockerImage;
import com.yahoo.vespa.hosted.dockerapi.ProcessResult;
import com.yahoo.vespa.hosted.node.admin.component.Environment;
import com.yahoo.vespa.hosted.node.admin.config.ConfigServerConfig;
+import com.yahoo.vespa.hosted.node.admin.nodeagent.ContainerData;
import com.yahoo.vespa.hosted.node.admin.task.util.network.IPAddressesMock;
import org.junit.Test;
import org.mockito.InOrder;
import java.io.IOException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.nio.file.Paths;
import java.util.Optional;
import static org.hamcrest.core.Is.is;
@@ -26,6 +30,7 @@ import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
public class DockerOperationsImplTest {
@@ -96,4 +101,44 @@ public class DockerOperationsImplTest {
when(docker.getContainer(eq(container.name))).thenReturn(Optional.of(container));
return container;
}
+
+ @Test
+ public void verifyEtcHosts() throws UnknownHostException {
+ ContainerData containerData = mock(ContainerData.class);
+ String hostname = "hostname";
+ InetAddress ipV6Local = InetAddress.getByName("::1");
+ InetAddress ipV4Local = InetAddress.getByName("127.0.0.1");
+
+ DockerOperationsImpl dockerOperations = new DockerOperationsImpl(
+ docker,
+ environment,
+ processExecuter,
+ addressesMock);
+ dockerOperations.addEtcHosts(containerData, hostname, Optional.empty(), ipV6Local);
+
+ verify(containerData, times(1)).addFile(
+ Paths.get("/etc/hosts"),
+ "# This file was generated by com.yahoo.vespa.hosted.node.admin.docker.DockerOperationsImpl\n" +
+ "127.0.0.1 localhost\n" +
+ "::1 localhost ip6-localhost ip6-loopback\n" +
+ "fe00::0 ip6-localnet\n" +
+ "ff00::0 ip6-mcastprefix\n" +
+ "ff02::1 ip6-allnodes\n" +
+ "ff02::2 ip6-allrouters\n" +
+ "0:0:0:0:0:0:0:1 hostname\n");
+
+ dockerOperations.addEtcHosts(containerData, hostname, Optional.of(ipV4Local), ipV6Local);
+
+ verify(containerData, times(1)).addFile(
+ Paths.get("/etc/hosts"),
+ "# This file was generated by com.yahoo.vespa.hosted.node.admin.docker.DockerOperationsImpl\n" +
+ "127.0.0.1 localhost\n" +
+ "::1 localhost ip6-localhost ip6-loopback\n" +
+ "fe00::0 ip6-localnet\n" +
+ "ff00::0 ip6-mcastprefix\n" +
+ "ff02::1 ip6-allnodes\n" +
+ "ff02::2 ip6-allrouters\n" +
+ "0:0:0:0:0:0:0:1 hostname\n" +
+ "127.0.0.1 hostname\n");
+ }
}
diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/integrationTests/StorageMaintainerMock.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/integrationTests/StorageMaintainerMock.java
index 1f4cd02f443..6b7d545c286 100644
--- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/integrationTests/StorageMaintainerMock.java
+++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/integrationTests/StorageMaintainerMock.java
@@ -30,7 +30,7 @@ public class StorageMaintainerMock extends StorageMaintainer {
}
@Override
- public void handleCoreDumpsForContainer(ContainerName containerName, NodeSpec node, boolean force) {
+ public void handleCoreDumpsForContainer(ContainerName containerName, NodeSpec node) {
}
@Override
diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/StorageMaintainerTest.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/StorageMaintainerTest.java
index 7e6cc6b773f..627517b824e 100644
--- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/StorageMaintainerTest.java
+++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/StorageMaintainerTest.java
@@ -92,39 +92,22 @@ public class StorageMaintainerTest {
storageMaintainer.removeOldFilesFromNode(containerName);
verifyProcessExecuterCalled(1);
- // Coredump handler has its own throttler
- storageMaintainer.handleCoreDumpsForContainer(containerName, node, false);
- verifyProcessExecuterCalled(2);
-
-
clock.advance(Duration.ofMinutes(61));
storageMaintainer.removeOldFilesFromNode(containerName);
- verifyProcessExecuterCalled(3);
+ verifyProcessExecuterCalled(2);
- storageMaintainer.handleCoreDumpsForContainer(containerName, node, false);
- verifyProcessExecuterCalled(4);
+ // Coredump handling is unthrottled
+ storageMaintainer.handleCoreDumpsForContainer(containerName, node);
+ verifyProcessExecuterCalled(3);
- storageMaintainer.handleCoreDumpsForContainer(containerName, node, false);
+ storageMaintainer.handleCoreDumpsForContainer(containerName, node);
verifyProcessExecuterCalled(4);
- storageMaintainer.handleCoreDumpsForContainer(containerName, node, true);
- verifyProcessExecuterCalled(5);
-
- storageMaintainer.handleCoreDumpsForContainer(containerName, node, true);
- verifyProcessExecuterCalled(6);
-
- storageMaintainer.handleCoreDumpsForContainer(containerName, node, false);
- verifyProcessExecuterCalled(6);
-
-
// cleanupNodeStorage is unthrottled and it should reset previous times
storageMaintainer.cleanupNodeStorage(containerName, node);
- verifyProcessExecuterCalled(7);
+ verifyProcessExecuterCalled(5);
storageMaintainer.cleanupNodeStorage(containerName, node);
- verifyProcessExecuterCalled(8);
-
- storageMaintainer.handleCoreDumpsForContainer(containerName, node, false);
- verifyProcessExecuterCalled(9);
+ verifyProcessExecuterCalled(6);
}
@Test
diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentImplTest.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentImplTest.java
index 543a2da5448..6e05fd2a03c 100644
--- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentImplTest.java
+++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentImplTest.java
@@ -189,7 +189,7 @@ public class NodeAgentImplTest {
final InOrder inOrder = inOrder(dockerOperations, orchestrator, nodeRepository, aclMaintainer);
inOrder.verify(dockerOperations, times(1)).pullImageAsyncIfNeeded(eq(dockerImage));
- inOrder.verify(dockerOperations, times(1)).createContainer(eq(containerName), eq(node));
+ inOrder.verify(dockerOperations, times(1)).createContainer(eq(containerName), eq(node), any());
inOrder.verify(dockerOperations, times(1)).startContainer(eq(containerName), eq(node));
inOrder.verify(aclMaintainer, times(1)).run();
inOrder.verify(dockerOperations, times(1)).resumeNode(eq(containerName));
@@ -267,7 +267,7 @@ public class NodeAgentImplTest {
inOrder.verify(orchestrator).resume(any(String.class));
inOrder.verify(orchestrator).suspend(any(String.class));
inOrder.verify(dockerOperations).removeContainer(any(), any());
- inOrder.verify(dockerOperations, times(1)).createContainer(eq(containerName), eq(thirdSpec));
+ inOrder.verify(dockerOperations, times(1)).createContainer(eq(containerName), eq(thirdSpec), any());
inOrder.verify(dockerOperations).startContainer(eq(containerName), eq(thirdSpec));
inOrder.verify(orchestrator).resume(any(String.class));
}
@@ -293,7 +293,7 @@ public class NodeAgentImplTest {
fail("Expected to throw an exception");
} catch (Exception ignored) { }
- verify(dockerOperations, never()).createContainer(eq(containerName), eq(node));
+ verify(dockerOperations, never()).createContainer(eq(containerName), eq(node), any());
verify(dockerOperations, never()).startContainer(eq(containerName), eq(node));
verify(orchestrator, never()).resume(any(String.class));
verify(nodeRepository, never()).updateNodeAttributes(any(String.class), any(NodeAttributes.class));
@@ -345,7 +345,7 @@ public class NodeAgentImplTest {
// Should only be called once, when we initialize
verify(dockerOperations, times(1)).getContainer(eq(containerName));
verify(dockerOperations, never()).removeContainer(any(), any());
- verify(dockerOperations, never()).createContainer(eq(containerName), eq(node));
+ verify(dockerOperations, never()).createContainer(eq(containerName), eq(node), any());
verify(dockerOperations, never()).startContainer(eq(containerName), eq(node));
verify(orchestrator, never()).resume(any(String.class));
verify(nodeRepository, never()).updateNodeAttributes(eq(hostName), any());
@@ -425,7 +425,7 @@ public class NodeAgentImplTest {
inOrder.verify(storageMaintainer, times(1)).cleanupNodeStorage(eq(containerName), eq(node));
inOrder.verify(nodeRepository, times(1)).setNodeState(eq(hostName), eq(Node.State.ready));
- verify(dockerOperations, never()).createContainer(eq(containerName), any());
+ verify(dockerOperations, never()).createContainer(eq(containerName), any(), any());
verify(dockerOperations, never()).startContainer(eq(containerName), any());
verify(orchestrator, never()).resume(any(String.class));
verify(orchestrator, never()).suspend(any(String.class));
@@ -480,7 +480,7 @@ public class NodeAgentImplTest {
nodeAgent.tick();
verify(dockerOperations, times(1)).removeContainer(any(), any());
- verify(dockerOperations, times(1)).createContainer(eq(containerName), eq(node));
+ verify(dockerOperations, times(1)).createContainer(eq(containerName), eq(node), any());
verify(dockerOperations, times(1)).startContainer(eq(containerName), eq(node));
}
@@ -578,7 +578,7 @@ public class NodeAgentImplTest {
} catch (DockerException ignored) { }
verify(dockerOperations, never()).removeContainer(any(), any());
- verify(dockerOperations, times(1)).createContainer(eq(containerName), eq(node));
+ verify(dockerOperations, times(1)).createContainer(eq(containerName), eq(node), any());
verify(dockerOperations, times(1)).startContainer(eq(containerName), eq(node));
verify(nodeAgent, never()).runLocalResumeScriptIfNeeded(any());
@@ -588,7 +588,7 @@ public class NodeAgentImplTest {
nodeAgent.converge();
verify(dockerOperations, times(1)).removeContainer(any(), eq(node));
- verify(dockerOperations, times(2)).createContainer(eq(containerName), eq(node));
+ verify(dockerOperations, times(2)).createContainer(eq(containerName), eq(node), any());
verify(dockerOperations, times(2)).startContainer(eq(containerName), eq(node));
verify(nodeAgent, times(1)).runLocalResumeScriptIfNeeded(any());
}
@@ -702,7 +702,7 @@ public class NodeAgentImplTest {
final InOrder inOrder = inOrder(dockerOperations, orchestrator, nodeRepository, aclMaintainer);
inOrder.verify(dockerOperations, times(1)).pullImageAsyncIfNeeded(eq(dockerImage));
- inOrder.verify(dockerOperations, times(1)).createContainer(eq(containerName), eq(node));
+ inOrder.verify(dockerOperations, times(1)).createContainer(eq(containerName), eq(node), any());
inOrder.verify(dockerOperations, times(1)).startContainer(eq(containerName), eq(node));
inOrder.verify(aclMaintainer, times(1)).run();
inOrder.verify(dockerOperations, times(1)).resumeNode(eq(containerName));
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/NodeRepository.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/NodeRepository.java
index 5db79beac3c..69b31f506e5 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/NodeRepository.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/NodeRepository.java
@@ -24,6 +24,7 @@ import com.yahoo.vespa.hosted.provision.node.filter.StateFilter;
import com.yahoo.vespa.hosted.provision.persistence.CuratorDatabaseClient;
import com.yahoo.vespa.hosted.provision.persistence.DnsNameResolver;
import com.yahoo.vespa.hosted.provision.persistence.NameResolver;
+import com.yahoo.vespa.hosted.provision.provisioning.OsVersions;
import com.yahoo.vespa.hosted.provision.restapi.v2.NotFoundException;
import java.time.Clock;
@@ -78,6 +79,7 @@ public class NodeRepository extends AbstractComponent {
private final NodeFlavors flavors;
private final NameResolver nameResolver;
private final DockerImage dockerImage;
+ private final OsVersions osVersions;
/**
* Creates a node repository from a zookeeper provider.
@@ -100,6 +102,7 @@ public class NodeRepository extends AbstractComponent {
this.flavors = flavors;
this.nameResolver = nameResolver;
this.dockerImage = dockerImage;
+ this.osVersions = new OsVersions(this.db);
// read and write all nodes to make sure they are stored in the latest version of the serialized format
for (Node.State state : Node.State.values())
@@ -115,6 +118,9 @@ public class NodeRepository extends AbstractComponent {
/** @return The name resolver used to resolve hostname and ip addresses */
public NameResolver nameResolver() { return nameResolver; }
+ /** Returns the OS versions to use for nodes in this */
+ public OsVersions osVersions() { return osVersions; }
+
// ---------------- Query API ----------------------------------------------------------------
/**
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/ApplicationMaintainer.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/ApplicationMaintainer.java
index e3df6199d06..f729c30de20 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/ApplicationMaintainer.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/ApplicationMaintainer.java
@@ -29,7 +29,7 @@ import java.util.stream.Collectors;
public abstract class ApplicationMaintainer extends Maintainer {
private final Deployer deployer;
- private final List<ApplicationId> pendingDeployments = new CopyOnWriteArrayList<>();
+ private final CopyOnWriteArrayList<ApplicationId> pendingDeployments = new CopyOnWriteArrayList<>();
// Use a fixed thread pool to avoid overload on config servers. Resource usage when deploying varies
// a lot between applications, so doing one by one avoids issues where one or more resource-demanding
@@ -66,13 +66,11 @@ public abstract class ApplicationMaintainer extends Maintainer {
* even when deployments are slow.
*/
protected void deploy(ApplicationId application) {
- if (pendingDeployments.contains(application)) {
- return;// Avoid queuing multiple deployments for same application
+ if (pendingDeployments.addIfAbsent(application)) { // Avoid queuing multiple deployments for same application
+ log.log(LogLevel.INFO, application + " will be deployed, last deploy time " +
+ getLastDeployTime(application));
+ deploymentExecutor.execute(() -> deployWithLock(application));
}
- log.log(LogLevel.INFO, application + " will be deployed, last deploy time " +
- getLastDeployTime(application));
- pendingDeployments.add(application);
- deploymentExecutor.execute(() -> deployWithLock(application));
}
protected Deployer deployer() { return deployer; }
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/MetricsReporter.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/MetricsReporter.java
index aeb30320bda..e387fb2d0ed 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/MetricsReporter.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/MetricsReporter.java
@@ -25,6 +25,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
+import java.util.function.Supplier;
import java.util.stream.Collectors;
/**
@@ -36,17 +37,20 @@ public class MetricsReporter extends Maintainer {
private final Orchestrator orchestrator;
private final ServiceMonitor serviceMonitor;
private final Map<Map<String, String>, Metric.Context> contextMap = new HashMap<>();
+ private final Supplier<Integer> pendingRedeploymentsSupplier;
public MetricsReporter(NodeRepository nodeRepository,
Metric metric,
Orchestrator orchestrator,
ServiceMonitor serviceMonitor,
+ Supplier<Integer> pendingRedeploymentsSupplier,
Duration interval,
JobControl jobControl) {
super(nodeRepository, interval, jobControl);
this.metric = metric;
this.orchestrator = orchestrator;
this.serviceMonitor = serviceMonitor;
+ this.pendingRedeploymentsSupplier = pendingRedeploymentsSupplier;
}
@Override
@@ -58,9 +62,14 @@ public class MetricsReporter extends Maintainer {
nodes.forEach(node -> updateNodeMetrics(node, servicesByHost));
updateStateMetrics(nodes);
+ updateMaintenanceMetrics();
updateDockerMetrics(nodes);
}
+ private void updateMaintenanceMetrics() {
+ metric.set("hostedVespa.pendingRedeployments", pendingRedeploymentsSupplier.get(), null);
+ }
+
private void updateNodeMetrics(Node node, Map<HostName, List<ServiceInstance>> servicesByHost) {
Metric.Context context;
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/NodeRepositoryMaintenance.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/NodeRepositoryMaintenance.java
index 6985206b78e..454ede61243 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/NodeRepositoryMaintenance.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/NodeRepositoryMaintenance.java
@@ -80,7 +80,7 @@ public class NodeRepositoryMaintenance extends AbstractComponent {
dirtyExpirer = new DirtyExpirer(nodeRepository, clock, durationFromEnv("dirty_expiry").orElse(defaults.dirtyExpiry), jobControl);
provisionedExpirer = new ProvisionedExpirer(nodeRepository, clock, durationFromEnv("provisioned_expiry").orElse(defaults.provisionedExpiry), jobControl);
nodeRebooter = new NodeRebooter(nodeRepository, clock, durationFromEnv("reboot_interval").orElse(defaults.rebootInterval), jobControl);
- metricsReporter = new MetricsReporter(nodeRepository, metric, orchestrator, serviceMonitor, durationFromEnv("metrics_interval").orElse(defaults.metricsInterval), jobControl);
+ metricsReporter = new MetricsReporter(nodeRepository, metric, orchestrator, serviceMonitor, periodicApplicationMaintainer::pendingDeployments, durationFromEnv("metrics_interval").orElse(defaults.metricsInterval), jobControl);
infrastructureProvisioner = new InfrastructureProvisioner(provisioner, nodeRepository, infrastructureVersions, durationFromEnv("infrastructure_provision_interval").orElse(defaults.infrastructureProvisionInterval), jobControl);
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/Status.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/Status.java
index 19e34ccb169..feaa4d8241d 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/Status.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/Status.java
@@ -22,6 +22,7 @@ public class Status {
private final boolean wantToRetire;
private final boolean wantToDeprovision;
private final Optional<String> hardwareDivergence;
+ private final Optional<Version> osVersion;
public Status(Generation generation,
Optional<Version> vespaVersion,
@@ -29,50 +30,49 @@ public class Status {
Optional<String> hardwareFailureDescription,
boolean wantToRetire,
boolean wantToDeprovision,
- Optional<String> hardwareDivergence) {
- Objects.requireNonNull(generation, "Generation must be non-null");
- Objects.requireNonNull(vespaVersion, "Vespa version must be non-null");
- Objects.requireNonNull(hardwareFailureDescription, "Hardware failure description must be non-null");
+ Optional<String> hardwareDivergence,
+ Optional<Version> osVersion) {
Objects.requireNonNull(hardwareDivergence, "Hardware divergence must be non-null");
hardwareDivergence.ifPresent(s -> requireNonEmptyString(s, "Hardware divergence must be non-empty"));
- this.reboot = generation;
- this.vespaVersion = vespaVersion;
+ this.reboot = Objects.requireNonNull(generation, "Generation must be non-null");
+ this.vespaVersion = Objects.requireNonNull(vespaVersion, "Vespa version must be non-null");
this.failCount = failCount;
- this.hardwareFailureDescription = hardwareFailureDescription;
+ this.hardwareFailureDescription = Objects.requireNonNull(hardwareFailureDescription, "Hardware failure description must be non-null");
this.wantToRetire = wantToRetire;
this.wantToDeprovision = wantToDeprovision;
this.hardwareDivergence = hardwareDivergence;
+ this.osVersion = Objects.requireNonNull(osVersion, "OS version must be non-null");
}
/** Returns a copy of this with the reboot generation changed */
- public Status withReboot(Generation reboot) { return new Status(reboot, vespaVersion, failCount, hardwareFailureDescription, wantToRetire, wantToDeprovision, hardwareDivergence); }
+ public Status withReboot(Generation reboot) { return new Status(reboot, vespaVersion, failCount, hardwareFailureDescription, wantToRetire, wantToDeprovision, hardwareDivergence, osVersion); }
/** Returns the reboot generation of this node */
public Generation reboot() { return reboot; }
/** Returns a copy of this with the vespa version changed */
- public Status withVespaVersion(Version version) { return new Status(reboot, Optional.of(version), failCount, hardwareFailureDescription, wantToRetire, wantToDeprovision, hardwareDivergence); }
+ public Status withVespaVersion(Version version) { return new Status(reboot, Optional.of(version), failCount, hardwareFailureDescription, wantToRetire, wantToDeprovision, hardwareDivergence, osVersion); }
/** Returns the Vespa version installed on the node, if known */
public Optional<Version> vespaVersion() { return vespaVersion; }
- public Status withIncreasedFailCount() { return new Status(reboot, vespaVersion, failCount + 1, hardwareFailureDescription, wantToRetire, wantToDeprovision, hardwareDivergence); }
+ public Status withIncreasedFailCount() { return new Status(reboot, vespaVersion, failCount + 1, hardwareFailureDescription, wantToRetire, wantToDeprovision, hardwareDivergence, osVersion); }
- public Status withDecreasedFailCount() { return new Status(reboot, vespaVersion, failCount - 1, hardwareFailureDescription, wantToRetire, wantToDeprovision, hardwareDivergence); }
+ public Status withDecreasedFailCount() { return new Status(reboot, vespaVersion, failCount - 1, hardwareFailureDescription, wantToRetire, wantToDeprovision, hardwareDivergence, osVersion); }
- public Status setFailCount(Integer value) { return new Status(reboot, vespaVersion, value, hardwareFailureDescription, wantToRetire, wantToDeprovision, hardwareDivergence); }
+ public Status setFailCount(Integer value) { return new Status(reboot, vespaVersion, value, hardwareFailureDescription, wantToRetire, wantToDeprovision, hardwareDivergence, osVersion); }
/** Returns how many times this node has been moved to the failed state. */
public int failCount() { return failCount; }
- public Status withHardwareFailureDescription(Optional<String> hardwareFailureDescription) { return new Status(reboot, vespaVersion, failCount, hardwareFailureDescription, wantToRetire, wantToDeprovision, hardwareDivergence); }
+ public Status withHardwareFailureDescription(Optional<String> hardwareFailureDescription) { return new Status(reboot, vespaVersion, failCount, hardwareFailureDescription, wantToRetire, wantToDeprovision, hardwareDivergence, osVersion); }
/** Returns the type of the last hardware failure detected on this node, or empty if none */
public Optional<String> hardwareFailureDescription() { return hardwareFailureDescription; }
/** Returns a copy of this with the want to retire flag changed */
public Status withWantToRetire(boolean wantToRetire) {
- return new Status(reboot, vespaVersion, failCount, hardwareFailureDescription, wantToRetire, wantToDeprovision, hardwareDivergence);
+ return new Status(reboot, vespaVersion, failCount, hardwareFailureDescription, wantToRetire, wantToDeprovision, hardwareDivergence, osVersion);
}
/**
@@ -85,7 +85,7 @@ public class Status {
/** Returns a copy of this with the want to de-provision flag changed */
public Status withWantToDeprovision(boolean wantToDeprovision) {
- return new Status(reboot, vespaVersion, failCount, hardwareFailureDescription, wantToRetire, wantToDeprovision, hardwareDivergence);
+ return new Status(reboot, vespaVersion, failCount, hardwareFailureDescription, wantToRetire, wantToDeprovision, hardwareDivergence, osVersion);
}
/**
@@ -96,14 +96,27 @@ public class Status {
}
public Status withHardwareDivergence(Optional<String> hardwareDivergence) {
- return new Status(reboot, vespaVersion, failCount, hardwareFailureDescription, wantToRetire, wantToDeprovision, hardwareDivergence);
+ return new Status(reboot, vespaVersion, failCount, hardwareFailureDescription, wantToRetire, wantToDeprovision, hardwareDivergence, osVersion);
}
/** Returns hardware divergence report as JSON string, if any */
public Optional<String> hardwareDivergence() { return hardwareDivergence; }
+ /** Returns a copy of this with the current OS version set to version */
+ public Status withOsVersion(Version version) {
+ return new Status(reboot, vespaVersion, failCount, hardwareFailureDescription, wantToRetire, wantToDeprovision, hardwareDivergence, Optional.of(version));
+ }
+
+ /** Returns the current OS version of this node, if any */
+ public Optional<Version> osVersion() {
+ return osVersion;
+ }
+
/** Returns the initial status of a newly provisioned node */
- public static Status initial() { return new Status(Generation.inital(), Optional.empty(), 0, Optional.empty(), false, false, Optional.empty()); }
+ public static Status initial() {
+ return new Status(Generation.inital(), Optional.empty(), 0, Optional.empty(), false,
+ false, Optional.empty(), Optional.empty());
+ }
private void requireNonEmptyString(String value, String message) {
Objects.requireNonNull(value, message);
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/filter/NodeOsVersionFilter.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/filter/NodeOsVersionFilter.java
new file mode 100644
index 00000000000..f7083a6398f
--- /dev/null
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/filter/NodeOsVersionFilter.java
@@ -0,0 +1,35 @@
+// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.vespa.hosted.provision.node.filter;
+
+import com.yahoo.component.Version;
+import com.yahoo.vespa.hosted.provision.Node;
+
+import java.util.Objects;
+
+/**
+ * Filter nodes by their OS version.
+ *
+ * @author mpolden
+ */
+public class NodeOsVersionFilter extends NodeFilter {
+
+ private final Version version;
+
+ private NodeOsVersionFilter(Version version, NodeFilter next) {
+ super(next);
+ this.version = Objects.requireNonNull(version, "version cannot be null");
+ }
+
+ @Override
+ public boolean matches(Node node) {
+ if (!version.isEmpty() && !node.status().osVersion().filter(v -> v.equals(version)).isPresent()) {
+ return false;
+ }
+ return nextMatches(node);
+ }
+
+ public static NodeOsVersionFilter from(String version, NodeFilter filter) {
+ return new NodeOsVersionFilter(Version.fromString(version), filter);
+ }
+
+}
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDatabaseClient.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDatabaseClient.java
index f559ec0037b..a5dfc616302 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDatabaseClient.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDatabaseClient.java
@@ -71,6 +71,7 @@ public class CuratorDatabaseClient {
curatorDatabase.create(toPath(state));
curatorDatabase.create(inactiveJobsPath());
curatorDatabase.create(infrastructureVersionsPath());
+ curatorDatabase.create(osVersionsPath());
}
/**
@@ -374,4 +375,23 @@ public class CuratorDatabaseClient {
return root.append("infrastructureVersions");
}
+ public Map<NodeType, Version> readOsVersions() {
+ return read(osVersionsPath(), NodeTypeVersionsSerializer::fromJson).orElseGet(TreeMap::new);
+ }
+
+ public void writeOsVersions(Map<NodeType, Version> versions) {
+ NestedTransaction transaction = new NestedTransaction();
+ CuratorTransaction curatorTransaction = curatorDatabase.newCuratorTransactionIn(transaction);
+ curatorTransaction.add(CuratorOperations.setData(osVersionsPath().getAbsolute(),
+ NodeTypeVersionsSerializer.toJson(versions)));
+ transaction.commit();
+ }
+
+ public Lock lockOsVersions() {
+ return lock(lockRoot.append("osVersionsLock"), defaultLockTimeout);
+ }
+
+ private Path osVersionsPath() {
+ return root.append("osVersions");
+ }
}
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/NodeSerializer.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/NodeSerializer.java
index 669f2063ee6..dbe6589dd7f 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/NodeSerializer.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/NodeSerializer.java
@@ -58,6 +58,7 @@ public class NodeSerializer {
private static final String wantToRetireKey = "wantToRetire";
private static final String wantToDeprovisionKey = "wantToDeprovision";
private static final String hardwareDivergenceKey = "hardwareDivergence";
+ private static final String osVersionKey = "osVersion";
// Configuration fields
private static final String flavorKey = "flavor";
@@ -114,6 +115,7 @@ public class NodeSerializer {
object.setString(nodeTypeKey, toString(node.type()));
node.status().hardwareDivergence().ifPresent(hardwareDivergence -> object.setString(hardwareDivergenceKey,
hardwareDivergence));
+ node.status().osVersion().ifPresent(version -> object.setString(osVersionKey, version.toString()));
}
private void toSlime(Allocation allocation, Cursor object) {
@@ -169,7 +171,8 @@ public class NodeSerializer {
hardwareFailureDescriptionFromSlime(object),
object.field(wantToRetireKey).asBool(),
object.field(wantToDeprovisionKey).asBool(),
- removeQuotedNulls(hardwareDivergenceFromSlime(object)));
+ removeQuotedNulls(hardwareDivergenceFromSlime(object)),
+ versionFromSlime(object.field(osVersionKey)));
}
private Flavor flavorFromSlime(Inspector object) {
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/OsVersions.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/OsVersions.java
new file mode 100644
index 00000000000..7e941d58a62
--- /dev/null
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/OsVersions.java
@@ -0,0 +1,91 @@
+// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.vespa.hosted.provision.provisioning;
+
+import com.google.common.base.Supplier;
+import com.google.common.base.Suppliers;
+import com.google.common.collect.ImmutableMap;
+import com.yahoo.component.Version;
+import com.yahoo.config.provision.NodeType;
+import com.yahoo.vespa.curator.Lock;
+import com.yahoo.vespa.hosted.provision.persistence.CuratorDatabaseClient;
+
+import java.time.Duration;
+import java.util.Map;
+import java.util.Optional;
+import java.util.concurrent.TimeUnit;
+import java.util.logging.Logger;
+
+/**
+ * Thread-safe class that manages target OS versions for nodes in this repository.
+ *
+ * The target OS version for each node type is set through the /nodes/v2/upgrade REST API.
+ *
+ * @author mpolden
+ */
+public class OsVersions {
+
+ private static final Duration defaultCacheTtl = Duration.ofMinutes(1);
+ private static final Logger log = Logger.getLogger(OsVersions.class.getName());
+
+ private final CuratorDatabaseClient db;
+ private final Duration cacheTtl;
+
+ /**
+ * Target OS version is read on every request to /nodes/v2/node/[fqdn]. Cache current targets to avoid
+ * unnecessary ZK reads. When targets change, some nodes may need to wait for TTL until they see the new target,
+ * this is fine.
+ */
+ private volatile Supplier<Map<NodeType, Version>> currentTargets;
+
+ public OsVersions(CuratorDatabaseClient db) {
+ this(db, defaultCacheTtl);
+ }
+
+ OsVersions(CuratorDatabaseClient db, Duration cacheTtl) {
+ this.db = db;
+ this.cacheTtl = cacheTtl;
+ createCache();
+ }
+
+ private void createCache() {
+ this.currentTargets = Suppliers.memoizeWithExpiration(() -> ImmutableMap.copyOf(db.readOsVersions()),
+ cacheTtl.toMillis(), TimeUnit.MILLISECONDS);
+ }
+
+ /** Returns the current target versions for each node type */
+ public Map<NodeType, Version> targets() {
+ return currentTargets.get();
+ }
+
+ /** Returns the current target version for given node type, if any */
+ public Optional<Version> targetFor(NodeType type) {
+ return Optional.ofNullable(targets().get(type));
+ }
+
+ /** Set the target OS version for nodes of given type */
+ public void setTarget(NodeType nodeType, Version newTarget, boolean force) {
+ if (!nodeType.isDockerHost()) {
+ throw new IllegalArgumentException("Setting target OS version for " + nodeType + " nodes is unsupported");
+ }
+ try (Lock lock = db.lockOsVersions()) {
+ Map<NodeType, Version> osVersions = db.readOsVersions();
+ Optional<Version> oldTarget = Optional.ofNullable(osVersions.get(nodeType));
+
+ if (oldTarget.filter(v -> v.equals(newTarget)).isPresent()) {
+ return; // Old target matches new target, nothing to do
+ }
+
+ if (!force && oldTarget.filter(v -> v.isAfter(newTarget)).isPresent()) {
+ throw new IllegalArgumentException("Cannot set target OS version to " + newTarget +
+ " without setting 'force', as it's lower than the current version: "
+ + oldTarget.get());
+ }
+
+ osVersions.put(nodeType, newTarget);
+ db.writeOsVersions(osVersions);
+ createCache(); // Throw away current cache
+ log.info("Set OS target version for " + nodeType + " nodes to " + newTarget.toFullString());
+ }
+ }
+
+}
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodePatcher.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodePatcher.java
index 31d9a606d91..910da4e90bf 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodePatcher.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodePatcher.java
@@ -114,6 +114,8 @@ public class NodePatcher {
case "vespaVersion" :
case "currentVespaVersion" :
return node.with(node.status().withVespaVersion(Version.fromString(asString(value))));
+ case "currentOsVersion" :
+ return node.with(node.status().withOsVersion(Version.fromString(asString(value))));
case "failCount" :
return node.with(node.status().setFailCount(asLong(value).intValue()));
case "flavor" :
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodesApiHandler.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodesApiHandler.java
index 54202a15971..c282993a466 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodesApiHandler.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodesApiHandler.java
@@ -3,6 +3,7 @@ package com.yahoo.vespa.hosted.provision.restapi.v2;
import com.yahoo.component.Version;
import com.yahoo.config.provision.HostFilter;
+import com.yahoo.config.provision.NodeFlavors;
import com.yahoo.config.provision.NodeType;
import com.yahoo.container.jdisc.HttpRequest;
import com.yahoo.container.jdisc.HttpResponse;
@@ -15,12 +16,12 @@ import com.yahoo.vespa.config.SlimeUtils;
import com.yahoo.vespa.hosted.provision.NoSuchNodeException;
import com.yahoo.vespa.hosted.provision.Node;
import com.yahoo.vespa.hosted.provision.NodeRepository;
-import com.yahoo.config.provision.NodeFlavors;
import com.yahoo.vespa.hosted.provision.maintenance.NodeRepositoryMaintenance;
import com.yahoo.vespa.hosted.provision.node.Agent;
import com.yahoo.vespa.hosted.provision.node.filter.ApplicationFilter;
import com.yahoo.vespa.hosted.provision.node.filter.NodeFilter;
import com.yahoo.vespa.hosted.provision.node.filter.NodeHostFilter;
+import com.yahoo.vespa.hosted.provision.node.filter.NodeOsVersionFilter;
import com.yahoo.vespa.hosted.provision.node.filter.NodeTypeFilter;
import com.yahoo.vespa.hosted.provision.node.filter.ParentHostFilter;
import com.yahoo.vespa.hosted.provision.node.filter.StateFilter;
@@ -28,6 +29,7 @@ import com.yahoo.vespa.hosted.provision.restapi.v2.NodesResponse.ResponseType;
import com.yahoo.vespa.orchestrator.Orchestrator;
import com.yahoo.yolean.Exceptions;
+import javax.inject.Inject;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
@@ -37,7 +39,6 @@ import java.util.Optional;
import java.util.Set;
import java.util.logging.Level;
import java.util.stream.Collectors;
-import javax.inject.Inject;
import static com.yahoo.vespa.config.SlimeUtils.optionalString;
@@ -53,7 +54,6 @@ public class NodesApiHandler extends LoggingRequestHandler {
private final NodeRepository nodeRepository;
private final NodeRepositoryMaintenance maintenance;
private final NodeFlavors nodeFlavors;
- private static final String nodeTypeKey = "type";
@Inject
public NodesApiHandler(LoggingRequestHandler.Context parentCtx, Orchestrator orchestrator,
@@ -100,7 +100,7 @@ public class NodesApiHandler extends LoggingRequestHandler {
if (path.startsWith("/nodes/v2/acl/")) return new NodeAclResponse(request, nodeRepository);
if (path.equals( "/nodes/v2/command/")) return ResourcesResponse.fromStrings(request.getUri(), "restart", "reboot");
if (path.equals( "/nodes/v2/maintenance/")) return new JobsResponse(maintenance.jobControl());
- if (path.equals( "/nodes/v2/upgrade/")) return new UpgradeResponse(maintenance.infrastructureVersions());
+ if (path.equals( "/nodes/v2/upgrade/")) return new UpgradeResponse(maintenance.infrastructureVersions(), nodeRepository.osVersions());
throw new NotFoundException("Nothing at path '" + path + "'");
}
@@ -114,18 +114,15 @@ public class NodesApiHandler extends LoggingRequestHandler {
}
else if (path.startsWith("/nodes/v2/state/failed/")) {
List<Node> failedNodes = nodeRepository.failRecursively(lastElement(path), Agent.operator, "Failed through the nodes/v2 API");
- String failedHostnames = failedNodes.stream().map(Node::hostname).sorted().collect(Collectors.joining(", "));
- return new MessageResponse("Moved " + failedHostnames + " to failed");
+ return new MessageResponse("Moved " + hostnamesAsString(failedNodes) + " to failed");
}
else if (path.startsWith("/nodes/v2/state/parked/")) {
List<Node> parkedNodes = nodeRepository.parkRecursively(lastElement(path), Agent.operator, "Parked through the nodes/v2 API");
- String parkedHostnames = parkedNodes.stream().map(Node::hostname).sorted().collect(Collectors.joining(", "));
- return new MessageResponse("Moved " + parkedHostnames + " to parked");
+ return new MessageResponse("Moved " + hostnamesAsString(parkedNodes) + " to parked");
}
else if (path.startsWith("/nodes/v2/state/dirty/")) {
List<Node> dirtiedNodes = nodeRepository.dirtyRecursively(lastElement(path), Agent.operator, "Dirtied through the nodes/v2 API");
- String dirtiedHostnames = dirtiedNodes.stream().map(Node::hostname).sorted().collect(Collectors.joining(", "));
- return new MessageResponse("Moved " + dirtiedHostnames + " to dirty");
+ return new MessageResponse("Moved " + hostnamesAsString(dirtiedNodes) + " to dirty");
}
else if (path.startsWith("/nodes/v2/state/active/")) {
nodeRepository.reactivate(lastElement(path), Agent.operator, "Reactivated through nodes/v2 API");
@@ -143,7 +140,7 @@ public class NodesApiHandler extends LoggingRequestHandler {
return new MessageResponse("Updated " + node.hostname());
}
else if (path.startsWith("/nodes/v2/upgrade/")) {
- return setInfrastructureVersion(request);
+ return setTargetVersions(request);
}
throw new NotFoundException("Nothing at '" + path + "'");
@@ -227,10 +224,10 @@ public class NodesApiHandler extends LoggingRequestHandler {
additionalIpAddresses,
parentHostname,
nodeFlavors.getFlavorOrThrow(inspector.field("flavor").asString()),
- nodeTypeFromSlime(inspector.field(nodeTypeKey)));
+ nodeTypeFromSlime(inspector.field("type")));
}
- private NodeType nodeTypeFromSlime(Inspector object) {
+ private static NodeType nodeTypeFromSlime(Inspector object) {
if (! object.valid()) return NodeType.tenant; // default
switch (object.asString()) {
case "tenant" : return NodeType.tenant;
@@ -252,18 +249,19 @@ public class NodesApiHandler extends LoggingRequestHandler {
filter = StateFilter.from(request.getProperty("state"), filter);
filter = NodeTypeFilter.from(request.getProperty("type"), filter);
filter = ParentHostFilter.from(request.getProperty("parentHost"), filter);
+ filter = NodeOsVersionFilter.from(request.getProperty("osVersion"), filter);
return filter;
}
- private String lastElement(String path) {
+ private static String lastElement(String path) {
if (path.endsWith("/"))
path = path.substring(0, path.length()-1);
int lastSlash = path.lastIndexOf("/");
if (lastSlash < 0) return path;
- return path.substring(lastSlash + 1, path.length());
+ return path.substring(lastSlash + 1);
}
- private boolean isPatchOverride(HttpRequest request) {
+ private static boolean isPatchOverride(HttpRequest request) {
// Since Jersey's HttpUrlConnector does not support PATCH we support this by override this on POST requests.
String override = request.getHeader("X-HTTP-Method-Override");
if (override != null) {
@@ -284,18 +282,37 @@ public class NodesApiHandler extends LoggingRequestHandler {
return new MessageResponse((active ? "Re-activated" : "Deactivated" ) + " job '" + jobName + "'");
}
- private MessageResponse setInfrastructureVersion(HttpRequest request) {
+ private MessageResponse setTargetVersions(HttpRequest request) {
NodeType nodeType = NodeType.valueOf(lastElement(request.getUri().getPath()).toLowerCase());
Inspector inspector = toSlime(request.getData()).get();
+ List<String> messageParts = new ArrayList<>(2);
- Inspector versionField = inspector.field("version");
- if (!versionField.valid())
- throw new IllegalArgumentException("'version' is missing");
- Version version = Version.fromString(versionField.asString());
boolean force = inspector.field("force").asBool();
+ Inspector versionField = inspector.field("version");
+ Inspector osVersionField = inspector.field("osVersion");
+
+ if (versionField.valid()) {
+ Version version = Version.fromString(versionField.asString());
+ maintenance.infrastructureVersions().setTargetVersion(nodeType, version, force);
+ messageParts.add("version to " + version.toFullString());
+ }
+
+ if (osVersionField.valid()) {
+ Version osVersion = Version.fromString(osVersionField.asString());
+ nodeRepository.osVersions().setTarget(nodeType, osVersion, force);
+ messageParts.add("osVersion to " + osVersion.toFullString());
+ }
- maintenance.infrastructureVersions().setTargetVersion(nodeType, version, force);
+ if (messageParts.isEmpty()) {
+ throw new IllegalArgumentException("At least one of 'version' and 'osVersion' must be set");
+ }
- return new MessageResponse("Set version for " + nodeType + " to " + version.toFullString());
+ return new MessageResponse("Set " + String.join(", ", messageParts) +
+ " for nodes of type " + nodeType);
}
+
+ private static String hostnamesAsString(List<Node> nodes) {
+ return nodes.stream().map(Node::hostname).sorted().collect(Collectors.joining(", "));
+ }
+
}
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodesResponse.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodesResponse.java
index 99ebb3e517b..970871a4d05 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodesResponse.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodesResponse.java
@@ -169,6 +169,8 @@ class NodesResponse extends HttpResponse {
}
object.setLong("rebootGeneration", node.status().reboot().wanted());
object.setLong("currentRebootGeneration", node.status().reboot().current());
+ node.status().osVersion().ifPresent(version -> object.setString("currentOsVersion", version.toFullString()));
+ nodeRepository.osVersions().targetFor(node.type()).ifPresent(version -> object.setString("wantedOsVersion", version.toFullString()));
node.status().vespaVersion()
.filter(version -> !version.isEmpty())
.ifPresent(version -> {
@@ -231,7 +233,7 @@ class NodesResponse extends HttpResponse {
path = path.substring(0, path.length()-1);
int lastSlash = path.lastIndexOf("/");
if (lastSlash < 0) return path;
- return path.substring(lastSlash+1, path.length());
+ return path.substring(lastSlash+1);
}
private static Node.State stateFromString(String stateString) {
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/UpgradeResponse.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/UpgradeResponse.java
index 3fb712e182f..392cba7baa9 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/UpgradeResponse.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/UpgradeResponse.java
@@ -6,24 +6,25 @@ import com.yahoo.slime.Cursor;
import com.yahoo.slime.JsonFormat;
import com.yahoo.slime.Slime;
import com.yahoo.vespa.hosted.provision.maintenance.InfrastructureVersions;
+import com.yahoo.vespa.hosted.provision.provisioning.OsVersions;
import java.io.IOException;
import java.io.OutputStream;
-import java.util.Comparator;
-import java.util.Map;
/**
- * A response containing infrastructure versions
+ * A response containing targets for infrastructure Vespa version and OS version.
*
* @author freva
*/
public class UpgradeResponse extends HttpResponse {
private final InfrastructureVersions infrastructureVersions;
+ private final OsVersions osVersions;
- public UpgradeResponse(InfrastructureVersions infrastructureVersions) {
+ public UpgradeResponse(InfrastructureVersions infrastructureVersions, OsVersions osVersions) {
super(200);
this.infrastructureVersions = infrastructureVersions;
+ this.osVersions = osVersions;
}
@Override
@@ -34,6 +35,9 @@ public class UpgradeResponse extends HttpResponse {
Cursor versionsObject = root.setObject("versions");
infrastructureVersions.getTargetVersions().forEach((nodeType, version) -> versionsObject.setString(nodeType.name(), version.toFullString()));
+ Cursor osVersionsObject = root.setObject("osVersions");
+ osVersions.targets().forEach((nodeType, version) -> osVersionsObject.setString(nodeType.name(), version.toFullString()));
+
new JsonFormat(true).encode(stream, slime);
}
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/monitoring/MetricsReporterTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/monitoring/MetricsReporterTest.java
index 5e7c6787973..7157f893970 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/monitoring/MetricsReporterTest.java
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/monitoring/MetricsReporterTest.java
@@ -70,6 +70,7 @@ public class MetricsReporterTest {
expectedMetrics.put("hostedVespa.inactiveHosts", 0L);
expectedMetrics.put("hostedVespa.dirtyHosts", 0L);
expectedMetrics.put("hostedVespa.failedHosts", 0L);
+ expectedMetrics.put("hostedVespa.pendingRedeployments", 42);
expectedMetrics.put("hostedVespa.docker.totalCapacityDisk", 0.0);
expectedMetrics.put("hostedVespa.docker.totalCapacityMem", 0.0);
expectedMetrics.put("hostedVespa.docker.totalCapacityCpu", 0.0);
@@ -100,8 +101,10 @@ public class MetricsReporterTest {
metric,
orchestrator,
serviceMonitor,
+ () -> 42,
Duration.ofMinutes(1),
- new JobControl(nodeRepository.database()));
+ new JobControl(nodeRepository.database())
+ );
metricsReporter.maintain();
assertEquals(expectedMetrics, metric.values);
@@ -144,7 +147,15 @@ public class MetricsReporterTest {
when(serviceModel.getServiceInstancesByHostName()).thenReturn(Collections.emptyMap());
TestMetric metric = new TestMetric();
- MetricsReporter metricsReporter = new MetricsReporter(nodeRepository, metric, orchestrator, serviceMonitor, Duration.ofMinutes(1), new JobControl(nodeRepository.database()));
+ MetricsReporter metricsReporter = new MetricsReporter(
+ nodeRepository,
+ metric,
+ orchestrator,
+ serviceMonitor,
+ () -> 42,
+ Duration.ofMinutes(1),
+ new JobControl(nodeRepository.database())
+ );
metricsReporter.maintain();
assertEquals(0L, metric.values.get("hostedVespa.readyHosts")); /** Only tenants counts **/
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/persistence/NodeTypeVersionsSerializerTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/persistence/NodeTypeVersionsSerializerTest.java
new file mode 100644
index 00000000000..4639a86aeec
--- /dev/null
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/persistence/NodeTypeVersionsSerializerTest.java
@@ -0,0 +1,28 @@
+// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.vespa.hosted.provision.persistence;
+
+import com.yahoo.component.Version;
+import com.yahoo.config.provision.NodeType;
+import org.junit.Test;
+
+import java.util.Map;
+import java.util.TreeMap;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * @author mpolden
+ */
+public class NodeTypeVersionsSerializerTest {
+
+ @Test
+ public void test_serialization() {
+ Map<NodeType, Version> versions = new TreeMap<>();
+ versions.put(NodeType.host, Version.fromString("7.1"));
+ versions.put(NodeType.confighost, Version.fromString("7.2"));
+
+ Map<NodeType, Version> serialized = NodeTypeVersionsSerializer.fromJson(NodeTypeVersionsSerializer.toJson(versions));
+ assertEquals(versions, serialized);
+ }
+
+}
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/persistence/SerializationTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/persistence/SerializationTest.java
index 0c32c13f387..6c9d0be69b2 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/persistence/SerializationTest.java
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/persistence/SerializationTest.java
@@ -21,7 +21,6 @@ import com.yahoo.vespa.hosted.provision.node.History;
import com.yahoo.vespa.hosted.provision.provisioning.FlavorConfigBuilder;
import org.junit.Test;
-import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.Arrays;
@@ -240,7 +239,7 @@ public class SerializationTest {
}
@Test
- public void serialize_additional_ip_addresses() throws IOException {
+ public void serialize_additional_ip_addresses() {
Node node = createNode();
// Test round-trip with additional addresses
@@ -326,7 +325,7 @@ public class SerializationTest {
}
@Test
- public void vespa_version_serialization() throws Exception {
+ public void vespa_version_serialization() {
String nodeWithWantedVespaVersion =
"{\n" +
" \"type\" : \"tenant\",\n" +
@@ -343,6 +342,18 @@ public class SerializationTest {
assertEquals("6.42.2", node.allocation().get().membership().cluster().vespaVersion().toString());
}
+ @Test
+ public void os_version_serialization() {
+ Node serialized = nodeSerializer.fromJson(State.provisioned, nodeSerializer.toJson(createNode()));
+ assertFalse(serialized.status().osVersion().isPresent());
+
+ // Update OS version
+ serialized = serialized.with(serialized.status()
+ .withOsVersion(Version.fromString("7.1")));
+ serialized = nodeSerializer.fromJson(State.provisioned, nodeSerializer.toJson(serialized));
+ assertEquals(Version.fromString("7.1"), serialized.status().osVersion().get());
+ }
+
private byte[] createNodeJson(String hostname, String... ipAddress) {
String ipAddressJsonPart = "";
if (ipAddress.length > 0) {
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/OsVersionsTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/OsVersionsTest.java
new file mode 100644
index 00000000000..88f5dcb9854
--- /dev/null
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/OsVersionsTest.java
@@ -0,0 +1,63 @@
+// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.vespa.hosted.provision.provisioning;
+
+import com.yahoo.component.Version;
+import com.yahoo.config.provision.NodeType;
+import com.yahoo.vespa.hosted.provision.NodeRepositoryTester;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.time.Duration;
+import java.util.Map;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+/**
+ * @author mpolden
+ */
+public class OsVersionsTest {
+
+ private OsVersions versions;
+
+ @Before
+ public void before() {
+ versions = new OsVersions(
+ new NodeRepositoryTester().nodeRepository().database(),
+ Duration.ofDays(1) // Long TTL to avoid timed expiry during test
+ );
+ }
+
+ @Test
+ public void test_versions() {
+ assertTrue("No versions set", versions.targets().isEmpty());
+ assertSame("Caches empty target versions", versions.targets(), versions.targets());
+
+ // Upgrade OS
+ Version version1 = Version.fromString("7.1");
+ versions.setTarget(NodeType.host, version1, false);
+ Map<NodeType, Version> targetVersions = versions.targets();
+ assertSame("Caches target versions", targetVersions, versions.targets());
+ assertEquals(version1, versions.targetFor(NodeType.host).get());
+
+ // Upgrade OS again
+ Version version2 = Version.fromString("7.2");
+ versions.setTarget(NodeType.host, version2, false);
+ assertNotSame("Cache invalidated", targetVersions, versions.targets());
+ assertEquals(version2, versions.targetFor(NodeType.host).get());
+
+ // Downgrading fails
+ try {
+ versions.setTarget(NodeType.host, version1, false);
+ fail("Expected exception");
+ } catch (IllegalArgumentException ignored) {}
+
+ // Forcing downgrade succeeds
+ versions.setTarget(NodeType.host, version1, true);
+ assertEquals(version1, versions.targetFor(NodeType.host).get());
+ }
+
+}
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/RestApiTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/RestApiTest.java
index ef0feecc037..448b64d1e78 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/RestApiTest.java
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/RestApiTest.java
@@ -21,12 +21,12 @@ import java.io.IOException;
import java.nio.charset.CharacterCodingException;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
-import java.util.Optional;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
/**
@@ -506,21 +506,21 @@ public class RestApiTest {
@Test
public void test_upgrade() throws IOException {
// Initially, no versions are set
- assertResponse(new Request("http://localhost:8080/nodes/v2/upgrade/"), "{\"versions\":{}}");
+ assertResponse(new Request("http://localhost:8080/nodes/v2/upgrade/"), "{\"versions\":{},\"osVersions\":{}}");
// Set version for config and confighost
assertResponse(new Request("http://localhost:8080/nodes/v2/upgrade/config",
Utf8.toBytes("{\"version\": \"6.123.456\"}"),
Request.Method.PATCH),
- "{\"message\":\"Set version for config to 6.123.456\"}");
+ "{\"message\":\"Set version to 6.123.456 for nodes of type config\"}");
assertResponse(new Request("http://localhost:8080/nodes/v2/upgrade/confighost",
Utf8.toBytes("{\"version\": \"6.123.456\"}"),
Request.Method.PATCH),
- "{\"message\":\"Set version for confighost to 6.123.456\"}");
+ "{\"message\":\"Set version to 6.123.456 for nodes of type confighost\"}");
// Verify versions are set
assertResponse(new Request("http://localhost:8080/nodes/v2/upgrade/"),
- "{\"versions\":{\"config\":\"6.123.456\",\"confighost\":\"6.123.456\"}}");
+ "{\"versions\":{\"config\":\"6.123.456\",\"confighost\":\"6.123.456\"},\"osVersions\":{}}");
// Downgrade without force fails
assertResponse(new Request("http://localhost:8080/nodes/v2/upgrade/confighost",
@@ -534,11 +534,84 @@ public class RestApiTest {
assertResponse(new Request("http://localhost:8080/nodes/v2/upgrade/confighost",
Utf8.toBytes("{\"version\": \"6.123.1\",\"force\":true}"),
Request.Method.PATCH),
- "{\"message\":\"Set version for confighost to 6.123.1\"}");
+ "{\"message\":\"Set version to 6.123.1 for nodes of type confighost\"}");
// Verify version has been updated
assertResponse(new Request("http://localhost:8080/nodes/v2/upgrade/"),
- "{\"versions\":{\"config\":\"6.123.456\",\"confighost\":\"6.123.1\"}}");
+ "{\"versions\":{\"config\":\"6.123.456\",\"confighost\":\"6.123.1\"},\"osVersions\":{}}");
+
+ // Upgrade OS for confighost and host
+ assertResponse(new Request("http://localhost:8080/nodes/v2/upgrade/confighost",
+ Utf8.toBytes("{\"osVersion\": \"7.5.2\"}"),
+ Request.Method.PATCH),
+ "{\"message\":\"Set osVersion to 7.5.2 for nodes of type confighost\"}");
+ assertResponse(new Request("http://localhost:8080/nodes/v2/upgrade/host",
+ Utf8.toBytes("{\"osVersion\": \"7.5.2\"}"),
+ Request.Method.PATCH),
+ "{\"message\":\"Set osVersion to 7.5.2 for nodes of type host\"}");
+
+ // OS versions are set
+ assertResponse(new Request("http://localhost:8080/nodes/v2/upgrade/"),
+ "{\"versions\":{\"config\":\"6.123.456\",\"confighost\":\"6.123.1\"},\"osVersions\":{\"host\":\"7.5.2\",\"confighost\":\"7.5.2\"}}");
+
+ // Upgrade OS and Vespa together
+ assertResponse(new Request("http://localhost:8080/nodes/v2/upgrade/confighost",
+ Utf8.toBytes("{\"version\": \"6.124.42\", \"osVersion\": \"7.5.2\"}"),
+ Request.Method.PATCH),
+ "{\"message\":\"Set version to 6.124.42, osVersion to 7.5.2 for nodes of type confighost\"}");
+
+ // Attempt to upgrade unsupported node type
+ assertResponse(new Request("http://localhost:8080/nodes/v2/upgrade/config",
+ Utf8.toBytes("{\"osVersion\": \"7.5.2\"}"),
+ Request.Method.PATCH),
+ 400,
+ "{\"error-code\":\"BAD_REQUEST\",\"message\":\"Setting target OS version for config nodes is unsupported\"}");
+
+ // Attempt to downgrade OS
+ assertResponse(new Request("http://localhost:8080/nodes/v2/upgrade/confighost",
+ Utf8.toBytes("{\"osVersion\": \"7.4.2\"}"),
+ Request.Method.PATCH),
+ 400,
+ "{\"error-code\":\"BAD_REQUEST\",\"message\":\"Cannot set target OS version to 7.4.2 without setting 'force', as it's lower than the current version: 7.5.2\"}");
+
+ // Downgrading OS with force succeeds
+ assertResponse(new Request("http://localhost:8080/nodes/v2/upgrade/confighost",
+ Utf8.toBytes("{\"osVersion\": \"7.4.2\", \"force\": true}"),
+ Request.Method.PATCH),
+ "{\"message\":\"Set osVersion to 7.4.2 for nodes of type confighost\"}");
+ }
+
+ @Test
+ public void test_os_version() throws Exception {
+ // Schedule OS upgrade
+ assertResponse(new Request("http://localhost:8080/nodes/v2/upgrade/host",
+ Utf8.toBytes("{\"osVersion\": \"7.5.2\"}"),
+ Request.Method.PATCH),
+ "{\"message\":\"Set osVersion to 7.5.2 for nodes of type host\"}");
+
+ // Other node type does not return wanted OS version
+ Response r = container.handleRequest(new Request("http://localhost:8080/nodes/v2/node/host1.yahoo.com"));
+ assertFalse("Response omits wantedOsVersions field", r.getBodyAsString().contains("wantedOsVersion"));
+
+ // Node updates its node object after upgrading OS
+ assertResponse(new Request("http://localhost:8080/nodes/v2/node/dockerhost1.yahoo.com",
+ Utf8.toBytes("{\"currentOsVersion\": \"7.5.2\"}"),
+ Request.Method.PATCH),
+ "{\"message\":\"Updated dockerhost1.yahoo.com\"}");
+ assertFile(new Request("http://localhost:8080/nodes/v2/node/dockerhost1.yahoo.com"), "docker-node1-os-upgrade-complete.json");
+
+ // Another node upgrades
+ assertResponse(new Request("http://localhost:8080/nodes/v2/node/dockerhost2.yahoo.com",
+ Utf8.toBytes("{\"currentOsVersion\": \"7.5.2\"}"),
+ Request.Method.PATCH),
+ "{\"message\":\"Updated dockerhost2.yahoo.com\"}");
+
+ // Filter nodes by osVersion
+ assertResponse(new Request("http://localhost:8080/nodes/v2/node/?osVersion=7.5.2"),
+ "{\"nodes\":[" +
+ "{\"url\":\"http://localhost:8080/nodes/v2/node/dockerhost2.yahoo.com\"}," +
+ "{\"url\":\"http://localhost:8080/nodes/v2/node/dockerhost1.yahoo.com\"}" +
+ "]}");
}
/** Tests the rendering of each node separately to make it easier to find errors */
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/docker-node1-os-upgrade-complete.json b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/docker-node1-os-upgrade-complete.json
new file mode 100644
index 00000000000..2e8092012fb
--- /dev/null
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/docker-node1-os-upgrade-complete.json
@@ -0,0 +1,72 @@
+{
+ "url": "http://localhost:8080/nodes/v2/node/dockerhost1.yahoo.com",
+ "id": "dockerhost1.yahoo.com",
+ "state": "active",
+ "type": "host",
+ "hostname": "dockerhost1.yahoo.com",
+ "openStackId": "dockerhost1",
+ "flavor": "large",
+ "canonicalFlavor": "large",
+ "minDiskAvailableGb": 1600.0,
+ "minMainMemoryAvailableGb": 32.0,
+ "description": "Flavor-name-is-large",
+ "minCpuCores": 4.0,
+ "fastDisk": true,
+ "environment": "BARE_METAL",
+ "owner": {
+ "tenant": "zoneapp",
+ "application": "zoneapp",
+ "instance": "zoneapp"
+ },
+ "membership": {
+ "clustertype": "container",
+ "clusterid": "node-admin",
+ "group": "0",
+ "index": 0,
+ "retired": false
+ },
+ "restartGeneration": 0,
+ "currentRestartGeneration": 0,
+ "wantedDockerImage": "docker-registry.domain.tld:8080/dist/vespa:6.42.0",
+ "wantedVespaVersion": "6.42.0",
+ "allowedToBeDown": false,
+ "rebootGeneration": 1,
+ "currentRebootGeneration": 0,
+ "currentOsVersion": "7.5.2",
+ "wantedOsVersion": "7.5.2",
+ "failCount": 0,
+ "hardwareFailure": false,
+ "wantToRetire": false,
+ "wantToDeprovision": false,
+ "history": [
+ {
+ "event": "provisioned",
+ "at": 123,
+ "agent": "system"
+ },
+ {
+ "event": "readied",
+ "at": 123,
+ "agent": "system"
+ },
+ {
+ "event": "reserved",
+ "at": 123,
+ "agent": "application"
+ },
+ {
+ "event": "activated",
+ "at": 123,
+ "agent": "application"
+ }
+ ],
+ "ipAddresses": [
+ "::1",
+ "127.0.0.1"
+ ],
+ "additionalIpAddresses": [
+ "::2",
+ "::3",
+ "::4"
+ ]
+}
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/docker-node1-os-upgrade.json b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/docker-node1-os-upgrade.json
new file mode 100644
index 00000000000..88bda7544d9
--- /dev/null
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/docker-node1-os-upgrade.json
@@ -0,0 +1,71 @@
+{
+ "url": "http://localhost:8080/nodes/v2/node/dockerhost1.yahoo.com",
+ "id": "dockerhost1.yahoo.com",
+ "state": "active",
+ "type": "host",
+ "hostname": "dockerhost1.yahoo.com",
+ "openStackId": "dockerhost1",
+ "flavor": "large",
+ "canonicalFlavor": "large",
+ "minDiskAvailableGb": 1600.0,
+ "minMainMemoryAvailableGb": 32.0,
+ "description": "Flavor-name-is-large",
+ "minCpuCores": 4.0,
+ "fastDisk": true,
+ "environment": "BARE_METAL",
+ "owner": {
+ "tenant": "zoneapp",
+ "application": "zoneapp",
+ "instance": "zoneapp"
+ },
+ "membership": {
+ "clustertype": "container",
+ "clusterid": "node-admin",
+ "group": "0",
+ "index": 0,
+ "retired": false
+ },
+ "restartGeneration": 0,
+ "currentRestartGeneration": 0,
+ "wantedDockerImage": "docker-registry.domain.tld:8080/dist/vespa:6.42.0",
+ "wantedVespaVersion": "6.42.0",
+ "allowedToBeDown": false,
+ "rebootGeneration": 1,
+ "currentRebootGeneration": 0,
+ "wantedOsVersion": "7.5.2",
+ "failCount": 0,
+ "hardwareFailure": false,
+ "wantToRetire": false,
+ "wantToDeprovision": false,
+ "history": [
+ {
+ "event": "provisioned",
+ "at": 123,
+ "agent": "system"
+ },
+ {
+ "event": "readied",
+ "at": 123,
+ "agent": "system"
+ },
+ {
+ "event": "reserved",
+ "at": 123,
+ "agent": "application"
+ },
+ {
+ "event": "activated",
+ "at": 123,
+ "agent": "application"
+ }
+ ],
+ "ipAddresses": [
+ "::1",
+ "127.0.0.1"
+ ],
+ "additionalIpAddresses": [
+ "::2",
+ "::3",
+ "::4"
+ ]
+}
diff --git a/searchcommon/src/vespa/searchcommon/common/datatype.cpp b/searchcommon/src/vespa/searchcommon/common/datatype.cpp
index 81e6b8a1f34..f3b2099294e 100644
--- a/searchcommon/src/vespa/searchcommon/common/datatype.cpp
+++ b/searchcommon/src/vespa/searchcommon/common/datatype.cpp
@@ -10,7 +10,7 @@ namespace search::index::schema {
using config::InvalidConfigException;
DataType
-dataTypeFromName(const vespalib::stringref &name) {
+dataTypeFromName(vespalib::stringref name) {
if (name == "UINT1") { return DataType::UINT1; }
else if (name == "UINT2") { return DataType::UINT2; }
else if (name == "UINT4") { return DataType::UINT4; }
@@ -65,7 +65,7 @@ operator<<(std::ostream &os, const DataType &type)
}
CollectionType
-collectionTypeFromName(const vespalib::stringref &name) {
+collectionTypeFromName(vespalib::stringref name) {
if (name == "SINGLE") { return CollectionType::SINGLE; }
else if (name == "ARRAY") { return CollectionType::ARRAY; }
else if (name == "WEIGHTEDSET") { return CollectionType::WEIGHTEDSET; }
diff --git a/searchcommon/src/vespa/searchcommon/common/datatype.h b/searchcommon/src/vespa/searchcommon/common/datatype.h
index ad762b9acc4..f21b6b9d5e9 100644
--- a/searchcommon/src/vespa/searchcommon/common/datatype.h
+++ b/searchcommon/src/vespa/searchcommon/common/datatype.h
@@ -34,11 +34,11 @@ enum class CollectionType { SINGLE = 0,
WEIGHTEDSET = 2
};
-DataType dataTypeFromName(const vespalib::stringref &name);
+DataType dataTypeFromName(vespalib::stringref name);
vespalib::string getTypeName(DataType type);
std::ostream &operator<<(std::ostream &os, const DataType &type);
-CollectionType collectionTypeFromName(const vespalib::stringref &n);
+CollectionType collectionTypeFromName(vespalib::stringref n);
vespalib::string getTypeName(CollectionType type);
std::ostream &operator<<(std::ostream &os, const CollectionType &type);
diff --git a/searchcommon/src/vespa/searchcommon/common/schema.cpp b/searchcommon/src/vespa/searchcommon/common/schema.cpp
index 6cd9d87fa77..5e9db03bf31 100644
--- a/searchcommon/src/vespa/searchcommon/common/schema.cpp
+++ b/searchcommon/src/vespa/searchcommon/common/schema.cpp
@@ -17,7 +17,7 @@ namespace {
template <typename T>
void
writeFields(vespalib::asciistream & os,
- const vespalib::stringref &prefix,
+ vespalib::stringref prefix,
const std::vector<T> & fields)
{
os << prefix << "[" << fields.size() << "]\n";
@@ -55,7 +55,7 @@ struct FieldName {
template <typename T>
uint32_t
-getFieldId(const vespalib::stringref & name, const T &map)
+getFieldId(vespalib::stringref name, const T &map)
{
typename T::const_iterator it = map.find(name);
return (it != map.end()) ? it->second : Schema::UNKNOWN_FIELD_ID;
@@ -68,7 +68,7 @@ namespace index {
const uint32_t Schema::UNKNOWN_FIELD_ID(std::numeric_limits<uint32_t>::max());
-Schema::Field::Field(const vespalib::stringref &n, DataType dt)
+Schema::Field::Field(vespalib::stringref n, DataType dt)
: _name(n),
_dataType(dt),
_collectionType(schema::CollectionType::SINGLE),
@@ -76,7 +76,7 @@ Schema::Field::Field(const vespalib::stringref &n, DataType dt)
{
}
-Schema::Field::Field(const vespalib::stringref &n,
+Schema::Field::Field(vespalib::stringref n,
DataType dt, CollectionType ct)
: _name(n),
_dataType(dt),
@@ -100,7 +100,7 @@ Schema::Field::Field(const std::vector<vespalib::string> & lines)
Schema::Field::~Field() { }
void
-Schema::Field::write(vespalib::asciistream & os, const vespalib::stringref & prefix) const
+Schema::Field::write(vespalib::asciistream & os, vespalib::stringref prefix) const
{
os << prefix << "name " << _name << "\n";
os << prefix << "datatype " << getTypeName(_dataType) << "\n";
@@ -128,7 +128,7 @@ Schema::Field::operator!=(const Field &rhs) const
_timestamp != rhs._timestamp;
}
-Schema::IndexField::IndexField(const vespalib::stringref &name, DataType dt)
+Schema::IndexField::IndexField(vespalib::stringref name, DataType dt)
: Field(name, dt),
_prefix(false),
_phrases(false),
@@ -137,7 +137,7 @@ Schema::IndexField::IndexField(const vespalib::stringref &name, DataType dt)
{
}
-Schema::IndexField::IndexField(const vespalib::stringref &name, DataType dt,
+Schema::IndexField::IndexField(vespalib::stringref name, DataType dt,
CollectionType ct)
: Field(name, dt, ct),
_prefix(false),
@@ -157,7 +157,7 @@ Schema::IndexField::IndexField(const std::vector<vespalib::string> &lines)
}
void
-Schema::IndexField::write(vespalib::asciistream & os, const vespalib::stringref & prefix) const
+Schema::IndexField::write(vespalib::asciistream & os, vespalib::stringref prefix) const
{
Field::write(os, prefix);
os << prefix << "prefix " << (_prefix ? "true" : "false") << "\n";
@@ -398,25 +398,25 @@ Schema::addFieldSet(const FieldSet &fieldSet)
}
uint32_t
-Schema::getIndexFieldId(const vespalib::stringref & name) const
+Schema::getIndexFieldId(vespalib::stringref name) const
{
return getFieldId(name, _indexIds);
}
uint32_t
-Schema::getAttributeFieldId(const vespalib::stringref & name) const
+Schema::getAttributeFieldId(vespalib::stringref name) const
{
return getFieldId(name, _attributeIds);
}
uint32_t
-Schema::getSummaryFieldId(const vespalib::stringref & name) const
+Schema::getSummaryFieldId(vespalib::stringref name) const
{
return getFieldId(name, _summaryIds);
}
uint32_t
-Schema::getFieldSetId(const vespalib::stringref &name) const
+Schema::getFieldSetId(vespalib::stringref name) const
{
return getFieldId(name, _fieldSetIds);
}
diff --git a/searchcommon/src/vespa/searchcommon/common/schema.h b/searchcommon/src/vespa/searchcommon/common/schema.h
index 1c3ab3ccd56..d066ccb0a27 100644
--- a/searchcommon/src/vespa/searchcommon/common/schema.h
+++ b/searchcommon/src/vespa/searchcommon/common/schema.h
@@ -38,8 +38,8 @@ public:
fastos::TimeStamp _timestamp;
public:
- Field(const vespalib::stringref &n, DataType dt);
- Field(const vespalib::stringref &n, DataType dt, CollectionType ct);
+ Field(vespalib::stringref n, DataType dt);
+ Field(vespalib::stringref n, DataType dt, CollectionType ct);
/**
* Create this field based on the given config lines.
@@ -52,7 +52,7 @@ public:
virtual void
write(vespalib::asciistream & os,
- const vespalib::stringref & prefix) const;
+ vespalib::stringref prefix) const;
const vespalib::string &getName() const { return _name; }
DataType getDataType() const { return _dataType; }
@@ -81,8 +81,8 @@ public:
uint32_t _avgElemLen;
public:
- IndexField(const vespalib::stringref &name, DataType dt);
- IndexField(const vespalib::stringref &name, DataType dt, CollectionType ct);
+ IndexField(vespalib::stringref name, DataType dt);
+ IndexField(vespalib::stringref name, DataType dt, CollectionType ct);
/**
* Create this index field based on the given config lines.
**/
@@ -97,7 +97,7 @@ public:
void
write(vespalib::asciistream &os,
- const vespalib::stringref &prefix) const override;
+ vespalib::stringref prefix) const override;
bool hasPrefix() const { return _prefix; }
bool hasPhrases() const { return _phrases; }
@@ -122,7 +122,7 @@ public:
std::vector<vespalib::string> _fields;
public:
- FieldSet(const vespalib::stringref & n) : _name(n), _fields() {}
+ FieldSet(vespalib::stringref n) : _name(n), _fields() {}
/**
* Create this field collection based on the given config lines.
@@ -131,7 +131,7 @@ public:
~FieldSet();
- FieldSet &addField(const vespalib::stringref &fieldName) {
+ FieldSet &addField(vespalib::stringref fieldName) {
_fields.push_back(fieldName);
return *this;
}
@@ -285,7 +285,7 @@ public:
* @return the field id or UNKNOWN_FIELD_ID if not found.
* @param name the name of the field.
**/
- uint32_t getIndexFieldId(const vespalib::stringref & name) const;
+ uint32_t getIndexFieldId(vespalib::stringref name) const;
/**
* Check if a field is an index
@@ -294,7 +294,7 @@ public:
* @param name the name of the field.
**/
bool
- isIndexField(const vespalib::stringref & name) const
+ isIndexField(vespalib::stringref name) const
{
return _indexIds.find(name) != _indexIds.end();
}
@@ -306,7 +306,7 @@ public:
* @param name the name of the field.
**/
bool
- isSummaryField(const vespalib::stringref & name) const
+ isSummaryField(vespalib::stringref name) const
{
return _summaryIds.find(name) != _summaryIds.end();
}
@@ -317,7 +317,7 @@ public:
* @param name the name of the field.
**/
bool
- isAttributeField(const vespalib::stringref & name) const
+ isAttributeField(vespalib::stringref name) const
{
return _attributeIds.find(name) != _attributeIds.end();
}
@@ -347,7 +347,7 @@ public:
* @return the field id or UNKNOWN_FIELD_ID if not found.
* @param name the name of the field.
**/
- uint32_t getAttributeFieldId(const vespalib::stringref & name) const;
+ uint32_t getAttributeFieldId(vespalib::stringref name) const;
/**
* Get information about a specific summary field using the given fieldId.
@@ -374,7 +374,7 @@ public:
* @return the field id or UNKNOWN_FIELD_ID if not found.
* @param name the name of the field.
**/
- uint32_t getSummaryFieldId(const vespalib::stringref & name) const;
+ uint32_t getSummaryFieldId(vespalib::stringref name) const;
/**
* Get information about a specific field set
@@ -395,7 +395,7 @@ public:
* @param name the name of the field set.
**/
uint32_t
- getFieldSetId(const vespalib::stringref &name) const;
+ getFieldSetId(vespalib::stringref name) const;
const std::vector<ImportedAttributeField> &getImportedAttributeFields() const {
return _importedAttributeFields;
diff --git a/searchcore/src/tests/proton/matching/matching_test.cpp b/searchcore/src/tests/proton/matching/matching_test.cpp
index c7ea75f50d6..293d87870e5 100644
--- a/searchcore/src/tests/proton/matching/matching_test.cpp
+++ b/searchcore/src/tests/proton/matching/matching_test.cpp
@@ -73,16 +73,14 @@ FakeResult make_elem_result(const std::vector<std::pair<uint32_t,std::vector<uin
return result;
}
-vespalib::string make_simple_stack_dump(const vespalib::string &field,
- const vespalib::string &term)
+vespalib::string make_simple_stack_dump(const vespalib::string &field, const vespalib::string &term)
{
QueryBuilder<ProtonNodeTypes> builder;
builder.addStringTerm(term, field, 1, search::query::Weight(1));
return StackDumpCreator::create(*builder.build());
}
-vespalib::string make_same_element_stack_dump(const vespalib::string &a1_term,
- const vespalib::string &f1_term)
+vespalib::string make_same_element_stack_dump(const vespalib::string &a1_term, const vespalib::string &f1_term)
{
QueryBuilder<ProtonNodeTypes> builder;
builder.addSameElement(2, "");
@@ -110,15 +108,15 @@ public:
}
return _vectors.find(name)->second;
}
- virtual const IAttributeVector *
+ const IAttributeVector *
getAttribute(const string &name) const override {
return get(name);
}
- virtual const IAttributeVector *
+ const IAttributeVector *
getAttributeStableEnum(const string &name) const override {
return get(name);
}
- virtual void
+ void
getAttributeList(std::vector<const IAttributeVector *> & list) const override {
Map::const_iterator pos = _vectors.begin();
Map::const_iterator end = _vectors.end();
@@ -126,7 +124,7 @@ public:
list.push_back(pos->second);
}
}
- ~MyAttributeContext() {
+ ~MyAttributeContext() override {
Map::iterator pos = _vectors.begin();
Map::iterator end = _vectors.end();
for (; pos != end; ++pos) {
@@ -233,11 +231,7 @@ struct MyWorld {
typedef DocumentMetaStore::Result PutRes;
document::BucketId bucketId(BucketFactory::getBucketId(docId));
uint32_t docSize = 1;
- PutRes putRes(metaStore.put(gid,
- bucketId,
- Timestamp(0u),
- docSize,
- i));
+ PutRes putRes(metaStore.put(gid, bucketId, Timestamp(0u), docSize, i));
metaStore.setBucketState(bucketId, true);
}
}
@@ -287,19 +281,14 @@ struct MyWorld {
}
void basicResults() {
- searchContext.idx(0).getFake().addResult("f1", "foo",
- FakeResult()
- .doc(10).doc(20).doc(30));
- searchContext.idx(0).getFake().addResult(
- "f1", "spread",
- FakeResult()
- .doc(100).doc(200).doc(300).doc(400).doc(500)
- .doc(600).doc(700).doc(800).doc(900));
+ searchContext.idx(0).getFake().addResult("f1", "foo", FakeResult().doc(10).doc(20).doc(30));
+ searchContext.idx(0).getFake().addResult("f1", "spread", FakeResult()
+ .doc(100).doc(200).doc(300).doc(400).doc(500)
+ .doc(600).doc(700).doc(800).doc(900));
}
void setStackDump(Request &request, const vespalib::string &stack_dump) {
- request.stackDump.assign(stack_dump.data(),
- stack_dump.data() + stack_dump.size());
+ request.stackDump.assign(stack_dump.data(), stack_dump.data() + stack_dump.size());
}
SearchRequest::SP createRequest(const vespalib::string &stack_dump)
@@ -311,14 +300,12 @@ struct MyWorld {
return request;
}
- SearchRequest::SP createSimpleRequest(const vespalib::string &field,
- const vespalib::string &term)
+ SearchRequest::SP createSimpleRequest(const vespalib::string &field, const vespalib::string &term)
{
return createRequest(make_simple_stack_dump(field, term));
}
- SearchRequest::SP createSameElementRequest(const vespalib::string &a1_term,
- const vespalib::string &f1_term)
+ SearchRequest::SP createSameElementRequest(const vespalib::string &a1_term, const vespalib::string &f1_term)
{
return createRequest(make_same_element_stack_dump(a1_term, f1_term));
}
@@ -340,10 +327,12 @@ struct MyWorld {
}
};
- MatchToolsFactory::UP create_mtf(SearchRequest::SP req) {
+ void verify_diversity_filter(SearchRequest::SP req, bool expectDiverse) {
Matcher::SP matcher = createMatcher();
search::fef::Properties overrides;
- return matcher->create_match_tools_factory(*req, searchContext, attributeContext, metaStore, overrides);
+ auto mtf = matcher->create_match_tools_factory(*req, searchContext, attributeContext, metaStore, overrides);
+ auto diversity = mtf->createDiversifier();
+ EXPECT_EQUAL(expectDiverse, static_cast<bool>(diversity));
}
double get_first_phase_termwise_limit() {
@@ -361,20 +350,16 @@ struct MyWorld {
Matcher::SP matcher = createMatcher();
SearchSession::OwnershipBundle owned_objects;
owned_objects.search_handler.reset(new MySearchHandler(matcher));
- owned_objects.context.reset(new MatchContext(
- IAttributeContext::UP(new MyAttributeContext),
- matching::ISearchContext::UP(new FakeSearchContext)));
+ owned_objects.context.reset(new MatchContext(std::make_unique<MyAttributeContext>(),
+ std::make_unique<FakeSearchContext>()));
vespalib::SimpleThreadBundle threadBundle(threads);
- SearchReply::UP reply =
- matcher->match(*req, threadBundle, searchContext, attributeContext,
- *sessionManager, metaStore,
- std::move(owned_objects));
+ SearchReply::UP reply = matcher->match(*req, threadBundle, searchContext, attributeContext,
+ *sessionManager, metaStore, std::move(owned_objects));
matchingStats.add(matcher->getStats());
return reply;
}
- DocsumRequest::SP createSimpleDocsumRequest(const vespalib::string & field,
- const vespalib::string & term)
+ DocsumRequest::SP createSimpleDocsumRequest(const vespalib::string & field, const vespalib::string & term)
{
DocsumRequest::SP request(new DocsumRequest);
setStackDump(*request, make_simple_stack_dump(field, term));
@@ -394,21 +379,19 @@ struct MyWorld {
Matcher::SP matcher = createMatcher();
const FieldInfo *field = matcher->get_index_env().getFieldByName(field_name);
if (field == nullptr) {
- return std::unique_ptr<FieldInfo>(nullptr);
+ return std::unique_ptr<FieldInfo>();
}
return std::make_unique<FieldInfo>(*field);
}
FeatureSet::SP getSummaryFeatures(DocsumRequest::SP req) {
Matcher::SP matcher = createMatcher();
- return matcher->getSummaryFeatures(*req, searchContext,
- attributeContext, *sessionManager);
+ return matcher->getSummaryFeatures(*req, searchContext, attributeContext, *sessionManager);
}
FeatureSet::SP getRankFeatures(DocsumRequest::SP req) {
Matcher::SP matcher = createMatcher();
- return matcher->getRankFeatures(*req, searchContext, attributeContext,
- *sessionManager);
+ return matcher->getRankFeatures(*req, searchContext, attributeContext, *sessionManager);
}
};
@@ -551,26 +534,34 @@ TEST("require that re-ranking is not diverse when not requested to be.") {
world.setupSecondPhaseRanking();
world.basicResults();
SearchRequest::SP request = world.createSimpleRequest("f1", "spread");
- auto mtf = world.create_mtf(request);
- auto diversity = mtf->createDiversifier();
- EXPECT_FALSE(diversity);
+ world.verify_diversity_filter(request, false);
}
using namespace search::fef::indexproperties::matchphase;
+
+TEST("require that re-ranking is diverse when requested to be") {
+ MyWorld world;
+ world.basicSetup();
+ world.setupSecondPhaseRanking();
+ world.basicResults();
+ SearchRequest::SP request = world.createSimpleRequest("f1", "spread");
+ auto & rankProperies = request->propertiesMap.lookupCreate(MapNames::RANK);
+ rankProperies.add(DiversityAttribute::NAME, "a2")
+ .add(DiversityMinGroups::NAME, "3")
+ .add(DiversityCutoffStrategy::NAME, "strict");
+ world.verify_diversity_filter(request, true);
+}
+
TEST("require that re-ranking is diverse with diversity = 1/1") {
MyWorld world;
world.basicSetup();
world.setupSecondPhaseRanking();
world.basicResults();
SearchRequest::SP request = world.createSimpleRequest("f1", "spread");
- auto mtf = world.create_mtf(request);
auto & rankProperies = request->propertiesMap.lookupCreate(MapNames::RANK);
rankProperies.add(DiversityAttribute::NAME, "a2")
.add(DiversityMinGroups::NAME, "3")
.add(DiversityCutoffStrategy::NAME, "strict");
- mtf = world.create_mtf(request);
- auto diversity = mtf->createDiversifier();
- EXPECT_TRUE(diversity);
SearchReply::UP reply = world.performSearch(request, 1);
EXPECT_EQUAL(9u, world.matchingStats.docsMatched());
EXPECT_EQUAL(9u, world.matchingStats.docsRanked());
@@ -586,8 +577,6 @@ TEST("require that re-ranking is diverse with diversity = 1/1") {
EXPECT_EQUAL(600.0, reply->hits[3].metric);
EXPECT_EQUAL(document::DocumentId("doc::500").getGlobalId(), reply->hits[4].gid);
EXPECT_EQUAL(500.0, reply->hits[4].metric);
- EXPECT_GREATER(world.matchingStats.matchTimeAvg(), 0.0000001);
- EXPECT_GREATER(world.matchingStats.rerankTimeAvg(), 0.0000001);
}
TEST("require that re-ranking is diverse with diversity = 1/10") {
@@ -596,16 +585,10 @@ TEST("require that re-ranking is diverse with diversity = 1/10") {
world.setupSecondPhaseRanking();
world.basicResults();
SearchRequest::SP request = world.createSimpleRequest("f1", "spread");
- auto mtf = world.create_mtf(request);
- auto diversity = mtf->createDiversifier();
- EXPECT_FALSE(diversity);
auto & rankProperies = request->propertiesMap.lookupCreate(MapNames::RANK);
rankProperies.add(DiversityAttribute::NAME, "a3")
.add(DiversityMinGroups::NAME, "3")
.add(DiversityCutoffStrategy::NAME, "strict");
- mtf = world.create_mtf(request);
- diversity = mtf->createDiversifier();
- EXPECT_TRUE(diversity);
SearchReply::UP reply = world.performSearch(request, 1);
EXPECT_EQUAL(9u, world.matchingStats.docsMatched());
EXPECT_EQUAL(9u, world.matchingStats.docsRanked());
@@ -622,8 +605,6 @@ TEST("require that re-ranking is diverse with diversity = 1/10") {
EXPECT_EQUAL(600.0, reply->hits[3].metric);
EXPECT_EQUAL(document::DocumentId("doc::500").getGlobalId(), reply->hits[4].gid);
EXPECT_EQUAL(500.0, reply->hits[4].metric);
- EXPECT_GREATER(world.matchingStats.matchTimeAvg(), 0.0000001);
- EXPECT_GREATER(world.matchingStats.rerankTimeAvg(), 0.0000001);
}
TEST("require that sortspec can be used (multi-threaded)") {
diff --git a/searchcore/src/tests/proton/summaryengine/summaryengine.cpp b/searchcore/src/tests/proton/summaryengine/summaryengine.cpp
index 0a520044985..56596ec5bb6 100644
--- a/searchcore/src/tests/proton/summaryengine/summaryengine.cpp
+++ b/searchcore/src/tests/proton/summaryengine/summaryengine.cpp
@@ -38,7 +38,7 @@ class MySearchHandler : public ISearchHandler {
std::string _name;
stringref _reply;
public:
- MySearchHandler(const std::string &name = "my", const stringref &reply = MYREPLY)
+ MySearchHandler(const std::string &name = "my", stringref reply = MYREPLY)
: _name(name), _reply(reply)
{}
@@ -181,7 +181,7 @@ TEST("requireThatHandlersAreStored") {
}
bool
-assertDocsumReply(SummaryEngine &engine, const std::string &searchDocType, const stringref &expReply) {
+assertDocsumReply(SummaryEngine &engine, const std::string &searchDocType, stringref expReply) {
DocsumRequest::UP request(createRequest());
request->propertiesMap.lookupCreate(search::MapNames::MATCH).add("documentdb.searchdoctype", searchDocType);
MyDocsumClient client;
diff --git a/searchcore/src/vespa/searchcore/fdispatch/search/query.cpp b/searchcore/src/vespa/searchcore/fdispatch/search/query.cpp
index 48c7110ff9f..d50a2aed46a 100644
--- a/searchcore/src/vespa/searchcore/fdispatch/search/query.cpp
+++ b/searchcore/src/vespa/searchcore/fdispatch/search/query.cpp
@@ -35,7 +35,7 @@ FastS_query::FastS_query(const search::docsummary::GetDocsumArgs &docsumArgs)
void
-FastS_query::SetStackDump(const vespalib::stringref &stackRef)
+FastS_query::SetStackDump(vespalib::stringref stackRef)
{
_stackDump = stackRef;
}
diff --git a/searchcore/src/vespa/searchcore/fdispatch/search/query.h b/searchcore/src/vespa/searchcore/fdispatch/search/query.h
index 4d336d9843e..b6949e70d8f 100644
--- a/searchcore/src/vespa/searchcore/fdispatch/search/query.h
+++ b/searchcore/src/vespa/searchcore/fdispatch/search/query.h
@@ -25,7 +25,7 @@ public:
FastS_query(const search::docsummary::GetDocsumArgs &docsumArgs);
~FastS_query();
- void SetStackDump(const vespalib::stringref& stackDump);
+ void SetStackDump(vespalib::stringref stackDump);
void SetSortSpec(const char *spec) { _sortSpec = spec; }
void SetLocation(const char *loc) { _location = loc; }
void SetRankProperties(const search::fef::Properties &rp) { _rankProperties = rp; }
@@ -66,8 +66,8 @@ private:
return false;
return (strcmp(a, b) == 0);
}
- static bool cmp_str_ref(const vespalib::stringref &a,
- const vespalib::stringref &b)
+ static bool cmp_str_ref(vespalib::stringref a,
+ vespalib::stringref b)
{
return (a.size() == b.size() &&
memcmp(a.data(), b.data(), a.size()) == 0);
diff --git a/searchcore/src/vespa/searchcore/fdispatch/search/search_path.cpp b/searchcore/src/vespa/searchcore/fdispatch/search/search_path.cpp
index 90c6fa2155c..daaf2a7c1db 100644
--- a/searchcore/src/vespa/searchcore/fdispatch/search/search_path.cpp
+++ b/searchcore/src/vespa/searchcore/fdispatch/search/search_path.cpp
@@ -15,7 +15,7 @@ SearchPath::Element::Element()
}
vespalib::stringref
-SearchPath::parseElement(const vespalib::stringref &spec, size_t numNodes)
+SearchPath::parseElement(vespalib::stringref spec, size_t numNodes)
{
_elements.push_back(Element());
vespalib::string::size_type specSepPos(spec.find('/'));
@@ -32,7 +32,7 @@ SearchPath::parseElement(const vespalib::stringref &spec, size_t numNodes)
}
void
-SearchPath::parsePartList(const vespalib::stringref &partSpec, size_t numNodes)
+SearchPath::parsePartList(vespalib::stringref partSpec, size_t numNodes)
{
try {
if (!partSpec.empty() && (partSpec[0] != '*')) {
@@ -94,7 +94,7 @@ SearchPath::parsePartRange(vespalib::asciistream &spec, size_t numNodes)
}
void
-SearchPath::parseRow(const vespalib::stringref &rowSpec)
+SearchPath::parseRow(vespalib::stringref rowSpec)
{
if (!rowSpec.empty()) {
// FIXME C++17 range-safe from_chars() instead of strtoul()
diff --git a/searchcore/src/vespa/searchcore/fdispatch/search/search_path.h b/searchcore/src/vespa/searchcore/fdispatch/search/search_path.h
index 847fb525b95..bbf1002742e 100644
--- a/searchcore/src/vespa/searchcore/fdispatch/search/search_path.h
+++ b/searchcore/src/vespa/searchcore/fdispatch/search/search_path.h
@@ -43,11 +43,11 @@ public:
private:
ElementVector _elements;
- vespalib::stringref parseElement(const vespalib::stringref &spec, size_t numNodes);
- void parsePartList(const vespalib::stringref &partSpec, size_t numNodes);
+ vespalib::stringref parseElement(vespalib::stringref spec, size_t numNodes);
+ void parsePartList(vespalib::stringref partSpec, size_t numNodes);
void parsePartList(vespalib::asciistream &spec, size_t numNodes);
void parsePartRange(vespalib::asciistream &spec, size_t numNodes);
- void parseRow(const vespalib::stringref &rowSpec);
+ void parseRow(vespalib::stringref rowSpec);
public:
SearchPath(const vespalib::string &spec, size_t numNodes);
diff --git a/searchcore/src/vespa/searchcore/proton/matching/attribute_limiter.cpp b/searchcore/src/vespa/searchcore/proton/matching/attribute_limiter.cpp
index ca96033c358..d165a18ae37 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/attribute_limiter.cpp
+++ b/searchcore/src/vespa/searchcore/proton/matching/attribute_limiter.cpp
@@ -44,7 +44,7 @@ vespalib::string LOOSE_STR("loose");
}
AttributeLimiter::DiversityCutoffStrategy
-AttributeLimiter::toDiversityCutoffStrategy(const vespalib::stringref & strategy)
+AttributeLimiter::toDiversityCutoffStrategy(vespalib::stringref strategy)
{
return (strategy == STRICT_STR) ? DiversityCutoffStrategy::STRICT : DiversityCutoffStrategy::LOOSE;
}
diff --git a/searchcore/src/vespa/searchcore/proton/matching/attribute_limiter.h b/searchcore/src/vespa/searchcore/proton/matching/attribute_limiter.h
index 0c23ea05fbd..d7772c6a393 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/attribute_limiter.h
+++ b/searchcore/src/vespa/searchcore/proton/matching/attribute_limiter.h
@@ -34,7 +34,7 @@ public:
search::queryeval::SearchIterator::UP create_search(size_t want_hits, size_t max_group_size, bool strictSearch);
bool was_used() const { return ((!_match_datas.empty()) || (_blueprint.get() != nullptr)); }
ssize_t getEstimatedHits() const { return _estimatedHits; }
- static DiversityCutoffStrategy toDiversityCutoffStrategy(const vespalib::stringref & strategy);
+ static DiversityCutoffStrategy toDiversityCutoffStrategy(vespalib::stringref strategy);
private:
const vespalib::string & toString(DiversityCutoffStrategy strategy);
search::queryeval::Searchable & _searchable_attributes;
diff --git a/searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp b/searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp
index fe10c1d51c3..055bc5fe1c2 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp
+++ b/searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp
@@ -147,7 +147,7 @@ MatchToolsFactory(QueryLimiter & queryLimiter,
const vespalib::Doom & hardDoom,
ISearchContext & searchContext,
IAttributeContext & attributeContext,
- const vespalib::stringref & queryStack,
+ vespalib::stringref queryStack,
const vespalib::string & location,
const ViewResolver & viewResolver,
const IDocumentMetaStore & metaStore,
diff --git a/searchcore/src/vespa/searchcore/proton/matching/match_tools.h b/searchcore/src/vespa/searchcore/proton/matching/match_tools.h
index 97baafb8bc3..0615c334628 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/match_tools.h
+++ b/searchcore/src/vespa/searchcore/proton/matching/match_tools.h
@@ -92,7 +92,7 @@ public:
const vespalib::Doom & hardDoom,
ISearchContext &searchContext,
search::attribute::IAttributeContext &attributeContext,
- const vespalib::stringref &queryStack,
+ vespalib::stringref queryStack,
const vespalib::string &location,
const ViewResolver &viewResolver,
const search::IDocumentMetaStore &metaStore,
diff --git a/searchcore/src/vespa/searchcore/proton/matching/query.cpp b/searchcore/src/vespa/searchcore/proton/matching/query.cpp
index e550ad8cad7..a8f75928a6d 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/query.cpp
+++ b/searchcore/src/vespa/searchcore/proton/matching/query.cpp
@@ -103,7 +103,7 @@ Query::Query() = default;
Query::~Query() = default;
bool
-Query::buildTree(const vespalib::stringref &stack, const string &location,
+Query::buildTree(vespalib::stringref stack, const string &location,
const ViewResolver &resolver, const IIndexEnvironment &indexEnv)
{
SimpleQueryStackDumpIterator stack_dump_iterator(stack);
diff --git a/searchcore/src/vespa/searchcore/proton/matching/query.h b/searchcore/src/vespa/searchcore/proton/matching/query.h
index 21365f75133..58d1d249ce6 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/query.h
+++ b/searchcore/src/vespa/searchcore/proton/matching/query.h
@@ -32,7 +32,7 @@ public:
*
* @return success(true)/failure(false)
**/
- bool buildTree(const vespalib::stringref &stack,
+ bool buildTree(vespalib::stringref stack,
const vespalib::string &location,
const ViewResolver &resolver,
const search::fef::IIndexEnvironment &idxEnv);
diff --git a/searchcore/src/vespa/searchcore/proton/matching/viewresolver.cpp b/searchcore/src/vespa/searchcore/proton/matching/viewresolver.cpp
index b1442fe5e92..87e6c4db12d 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/viewresolver.cpp
+++ b/searchcore/src/vespa/searchcore/proton/matching/viewresolver.cpp
@@ -6,15 +6,15 @@
namespace proton::matching {
ViewResolver &
-ViewResolver::add(const vespalib::stringref &view,
- const vespalib::stringref &field)
+ViewResolver::add(vespalib::stringref view,
+ vespalib::stringref field)
{
_map[view].push_back(field);
return *this;
}
bool
-ViewResolver::resolve(const vespalib::stringref &view,
+ViewResolver::resolve(vespalib::stringref view,
std::vector<vespalib::string> &fields) const
{
Map::const_iterator pos = _map.find(view);
diff --git a/searchcore/src/vespa/searchcore/proton/matching/viewresolver.h b/searchcore/src/vespa/searchcore/proton/matching/viewresolver.h
index 124ebc67d52..edff7a696c3 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/viewresolver.h
+++ b/searchcore/src/vespa/searchcore/proton/matching/viewresolver.h
@@ -34,8 +34,8 @@ public:
* @param view the name of the view
* @param field the name of the field
**/
- ViewResolver &add(const vespalib::stringref &view,
- const vespalib::stringref &field);
+ ViewResolver &add(vespalib::stringref view,
+ vespalib::stringref field);
/**
* Resolve a view to obtain the set of fields it
@@ -47,7 +47,7 @@ public:
* @param fields vector that will be filled out with the fields
* that are part of the requested view.
**/
- bool resolve(const vespalib::stringref &view,
+ bool resolve(vespalib::stringref view,
std::vector<vespalib::string> &fields) const;
/**
diff --git a/searchcorespi/src/vespa/searchcorespi/plugin/factoryloader.cpp b/searchcorespi/src/vespa/searchcorespi/plugin/factoryloader.cpp
index 3180f7ed29d..ba2b0b962f6 100644
--- a/searchcorespi/src/vespa/searchcorespi/plugin/factoryloader.cpp
+++ b/searchcorespi/src/vespa/searchcorespi/plugin/factoryloader.cpp
@@ -1,5 +1,5 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/searchcorespi/plugin/factoryloader.h>
+#include "factoryloader.h"
#include <vespa/vespalib/util/exceptions.h>
using vespalib::stringref;
@@ -13,18 +13,16 @@ FactoryLoader::FactoryLoader() :
{
}
-FactoryLoader::~FactoryLoader()
-{
-}
+FactoryLoader::~FactoryLoader() = default;
IIndexManagerFactory::UP
-FactoryLoader::create(const stringref & factory)
+FactoryLoader::create(stringref factory)
{
typedef IIndexManagerFactory* (*FuncT)();
_libraries.loadLibrary(factory);
const FastOS_DynamicLibrary & lib = *_libraries.get(factory);
FuncT registrationMethod = reinterpret_cast<FuncT>(lib.GetSymbol("createIndexManagerFactory"));
- if (registrationMethod == NULL) {
+ if (registrationMethod == nullptr) {
throw IllegalArgumentException(make_string("Failed locating symbol 'createIndexManagerFactory' in library '%s' for factory '%s'.",
lib.GetLibName(), vespalib::string(factory).c_str()));
}
diff --git a/searchcorespi/src/vespa/searchcorespi/plugin/factoryloader.h b/searchcorespi/src/vespa/searchcorespi/plugin/factoryloader.h
index e581b540dff..3eda6557fa0 100644
--- a/searchcorespi/src/vespa/searchcorespi/plugin/factoryloader.h
+++ b/searchcorespi/src/vespa/searchcorespi/plugin/factoryloader.h
@@ -17,7 +17,7 @@ public:
* @param the name of the library. Like 'vesparise'.
* @return the factory that is created.
*/
- IIndexManagerFactory::UP create(const vespalib::stringref & factory);
+ IIndexManagerFactory::UP create(vespalib::stringref factory);
private:
vespalib::LibraryPool _libraries;
};
diff --git a/searchcorespi/src/vespa/searchcorespi/plugin/factoryregistry.cpp b/searchcorespi/src/vespa/searchcorespi/plugin/factoryregistry.cpp
index 683b1e420b5..bd1b914cf39 100644
--- a/searchcorespi/src/vespa/searchcorespi/plugin/factoryregistry.cpp
+++ b/searchcorespi/src/vespa/searchcorespi/plugin/factoryregistry.cpp
@@ -9,15 +9,11 @@ using vespalib::string;
namespace searchcorespi {
-FactoryRegistry::FactoryRegistry()
-{
-}
+FactoryRegistry::FactoryRegistry() = default;
-FactoryRegistry::~FactoryRegistry()
-{
-}
+FactoryRegistry::~FactoryRegistry() = default;
-void FactoryRegistry::add(const stringref & uniqueName, const IIndexManagerFactory::SP & factory)
+void FactoryRegistry::add(stringref uniqueName, const IIndexManagerFactory::SP & factory)
{
LockGuard guard(_lock);
if (_registry.find(uniqueName) == _registry.end()) {
@@ -27,7 +23,7 @@ void FactoryRegistry::add(const stringref & uniqueName, const IIndexManagerFacto
}
}
-void FactoryRegistry::remove(const stringref & uniqueName)
+void FactoryRegistry::remove(stringref uniqueName)
{
LockGuard guard(_lock);
if (_registry.find(uniqueName) == _registry.end()) {
@@ -37,7 +33,7 @@ void FactoryRegistry::remove(const stringref & uniqueName)
}
const IIndexManagerFactory::SP &
-FactoryRegistry::get(const stringref & uniqueName) const
+FactoryRegistry::get(stringref uniqueName) const
{
LockGuard guard(_lock);
Registry::const_iterator found = _registry.find(uniqueName);
@@ -48,7 +44,7 @@ FactoryRegistry::get(const stringref & uniqueName) const
}
bool
-FactoryRegistry::isRegistered(const vespalib::stringref & uniqueName) const
+FactoryRegistry::isRegistered(vespalib::stringref uniqueName) const
{
LockGuard guard(_lock);
Registry::const_iterator found = _registry.find(uniqueName);
diff --git a/searchcorespi/src/vespa/searchcorespi/plugin/factoryregistry.h b/searchcorespi/src/vespa/searchcorespi/plugin/factoryregistry.h
index 64cc75721d8..feb27d62950 100644
--- a/searchcorespi/src/vespa/searchcorespi/plugin/factoryregistry.h
+++ b/searchcorespi/src/vespa/searchcorespi/plugin/factoryregistry.h
@@ -22,23 +22,23 @@ public:
* @param factory The factory instance for producing IndexManagers.
* @throws vespalib::IllegalArgument if factory is already registered.
*/
- void add(const vespalib::stringref & uniqueName, const IIndexManagerFactory::SP & factory);
+ void add(vespalib::stringref uniqueName, const IIndexManagerFactory::SP & factory);
/**
* Will unregister a factory. Should be called when a sharedlibrary is being unloaded.
* @param uniqueName Unique name of factory to remove from registry.
* @throws vespalib::IllegalArgument if factory is already registered.
*/
- void remove(const vespalib::stringref & uniqueName);
+ void remove(vespalib::stringref uniqueName);
/**
* This method will fetch a factory given its unique name.
* @param name The name of the factory to return.
* @return The factory.
*/
- const IIndexManagerFactory::SP & get(const vespalib::stringref & uniqueName) const;
+ const IIndexManagerFactory::SP & get(vespalib::stringref uniqueName) const;
/**
* Returns true if a factory with the given name has been registered.
*/
- bool isRegistered(const vespalib::stringref & uniqueName) const;
+ bool isRegistered(vespalib::stringref uniqueName) const;
private:
typedef std::map<vespalib::string, IIndexManagerFactory::SP> Registry;
diff --git a/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/integration/ml/TensorFlowImporter.java b/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/integration/ml/TensorFlowImporter.java
index ff584559a83..303ba228fa6 100644
--- a/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/integration/ml/TensorFlowImporter.java
+++ b/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/integration/ml/TensorFlowImporter.java
@@ -23,6 +23,7 @@ public class TensorFlowImporter extends ModelImporter {
* @param modelName the name of the model to import, consisting of characters in [A-Za-z0-9_]
* @param modelDir the directory containing the TensorFlow model files to import
*/
+ @Override
public ImportedModel importModel(String modelName, String modelDir) {
try (SavedModelBundle model = SavedModelBundle.load(modelDir, "serve")) {
return importModel(modelName, model);
diff --git a/searchlib/src/tests/diskindex/bitvector/bitvector_test.cpp b/searchlib/src/tests/diskindex/bitvector/bitvector_test.cpp
index dc352f70706..e33158e559f 100644
--- a/searchlib/src/tests/diskindex/bitvector/bitvector_test.cpp
+++ b/searchlib/src/tests/diskindex/bitvector/bitvector_test.cpp
@@ -20,7 +20,7 @@ struct FieldWriterWrapper
FieldWriterWrapper(uint32_t docIdLimit, uint64_t numWordIds);
FieldWriterWrapper &
- newWord(const vespalib::stringref &word);
+ newWord(vespalib::stringref word);
FieldWriterWrapper &
add(uint32_t docId);
@@ -51,7 +51,7 @@ FieldWriterWrapper::open(const std::string &path,
}
FieldWriterWrapper &
-FieldWriterWrapper::newWord(const vespalib::stringref &word)
+FieldWriterWrapper::newWord(vespalib::stringref word)
{
_writer.newWord(word);
return *this;
diff --git a/searchlib/src/tests/memoryindex/dictionary/dictionary_test.cpp b/searchlib/src/tests/memoryindex/dictionary/dictionary_test.cpp
index c926d1c2831..0990f21f820 100644
--- a/searchlib/src/tests/memoryindex/dictionary/dictionary_test.cpp
+++ b/searchlib/src/tests/memoryindex/dictionary/dictionary_test.cpp
@@ -69,7 +69,7 @@ public:
{}
virtual void
- startWord(const vespalib::stringref &word) override
+ startWord(vespalib::stringref word) override
{
assert(_insideField);
assert(!_insideWord);
@@ -452,7 +452,7 @@ public:
{
}
- WrapInserter &word(const vespalib::stringref &word_)
+ WrapInserter &word(vespalib::stringref word_)
{
_inserter.setNextWord(word_);
return *this;
diff --git a/searchlib/src/tests/memoryindex/document_remover/document_remover_test.cpp b/searchlib/src/tests/memoryindex/document_remover/document_remover_test.cpp
index 6f09dd5c924..af7a9422e49 100644
--- a/searchlib/src/tests/memoryindex/document_remover/document_remover_test.cpp
+++ b/searchlib/src/tests/memoryindex/document_remover/document_remover_test.cpp
@@ -18,7 +18,7 @@ struct WordFieldPair
{
vespalib::string _word;
uint32_t _fieldId;
- WordFieldPair(const vespalib::stringref &word, uint32_t fieldId)
+ WordFieldPair(vespalib::stringref word, uint32_t fieldId)
: _word(word), _fieldId(fieldId)
{}
bool operator<(const WordFieldPair &rhs) {
diff --git a/searchlib/src/vespa/searchlib/attribute/attributevector.cpp b/searchlib/src/vespa/searchlib/attribute/attributevector.cpp
index e2dc9f4c856..e86c3018242 100644
--- a/searchlib/src/vespa/searchlib/attribute/attributevector.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/attributevector.cpp
@@ -58,9 +58,9 @@ namespace search {
IMPLEMENT_IDENTIFIABLE_ABSTRACT(AttributeVector, vespalib::Identifiable);
-AttributeVector::BaseName::BaseName(const vespalib::stringref &base,
- const vespalib::stringref &snap,
- const vespalib::stringref &name)
+AttributeVector::BaseName::BaseName(vespalib::stringref base,
+ vespalib::stringref snap,
+ vespalib::stringref name)
: string(base),
_name(name)
{
@@ -118,7 +118,7 @@ AttributeVector::BaseName::getSnapshotName() const
AttributeVector::BaseName::string
-AttributeVector::BaseName::createAttributeName(const vespalib::stringref & s)
+AttributeVector::BaseName::createAttributeName(vespalib::stringref s)
{
size_t p(s.rfind('/'));
if (p == string::npos) {
@@ -158,7 +158,7 @@ AttributeVector::ValueModifier::~ValueModifier() {
}
-AttributeVector::AttributeVector(const vespalib::stringref &baseFileName, const Config &c)
+AttributeVector::AttributeVector(vespalib::stringref baseFileName, const Config &c)
: _baseFileName(baseFileName),
_config(c),
_interlock(std::make_shared<attribute::Interlock>()),
@@ -383,14 +383,14 @@ AttributeVector::loadFile(const char *suffix)
bool
-AttributeVector::saveAs(const vespalib::stringref &baseFileName)
+AttributeVector::saveAs(vespalib::stringref baseFileName)
{
_baseFileName = baseFileName;
return save();
}
bool
-AttributeVector::saveAs(const vespalib::stringref &baseFileName,
+AttributeVector::saveAs(vespalib::stringref baseFileName,
IAttributeSaveTarget & saveTarget)
{
_baseFileName = baseFileName;
diff --git a/searchlib/src/vespa/searchlib/attribute/attributevector.h b/searchlib/src/vespa/searchlib/attribute/attributevector.h
index bcd4b1ae079..21ffe811a80 100644
--- a/searchlib/src/vespa/searchlib/attribute/attributevector.h
+++ b/searchlib/src/vespa/searchlib/attribute/attributevector.h
@@ -127,19 +127,19 @@ public:
{
public:
typedef vespalib::string string;
- BaseName(const vespalib::stringref &s)
+ BaseName(vespalib::stringref s)
: string(s),
_name(createAttributeName(s))
{ }
- BaseName & operator = (const vespalib::stringref & s) {
+ BaseName & operator = (vespalib::stringref s) {
BaseName n(s);
std::swap(*this, n);
return *this;
}
- BaseName(const vespalib::stringref &base,
- const vespalib::stringref &snap,
- const vespalib::stringref &name);
+ BaseName(vespalib::stringref base,
+ vespalib::stringref snap,
+ vespalib::stringref name);
~BaseName();
string getIndexName() const;
@@ -147,7 +147,7 @@ public:
const string & getAttributeName() const { return _name; }
string getDirName() const;
private:
- static string createAttributeName(const vespalib::stringref & s);
+ static string createAttributeName(vespalib::stringref s);
string _name;
};
@@ -205,7 +205,7 @@ protected:
}
- AttributeVector(const vespalib::stringref &baseFileName, const Config & c);
+ AttributeVector(vespalib::stringref baseFileName, const Config & c);
void checkSetMaxValueCount(int index) {
_highestValueCount = std::max(index, _highestValueCount);
@@ -403,7 +403,7 @@ public:
BasicType getInternalBasicType() const { return _config.basicType(); }
CollectionType getInternalCollectionType() const { return _config.collectionType(); }
const BaseName & getBaseFileName() const { return _baseFileName; }
- void setBaseFileName(const vespalib::stringref & name) { _baseFileName = name; }
+ void setBaseFileName(vespalib::stringref name) { _baseFileName = name; }
// Implements IAttributeVector
const vespalib::string & getName() const override final { return _baseFileName.getAttributeName(); }
@@ -437,13 +437,13 @@ public:
* Updates the base file name of this attribute vector and saves
* it to file(s)
*/
- bool saveAs(const vespalib::stringref &baseFileName);
+ bool saveAs(vespalib::stringref baseFileName);
/**
* Updates the base file name of this attribute vector and saves
* it using the given saveTarget
*/
- bool saveAs(const vespalib::stringref &baseFileName, IAttributeSaveTarget &saveTarget);
+ bool saveAs(vespalib::stringref baseFileName, IAttributeSaveTarget &saveTarget);
/** Saves this attribute vector to file(s) **/
bool save();
diff --git a/searchlib/src/vespa/searchlib/bitcompression/compression.cpp b/searchlib/src/vespa/searchlib/bitcompression/compression.cpp
index b56f4760ec7..1031aab71f5 100644
--- a/searchlib/src/vespa/searchlib/bitcompression/compression.cpp
+++ b/searchlib/src/vespa/searchlib/bitcompression/compression.cpp
@@ -267,7 +267,7 @@ writeBits(const uint64_t *bits, uint32_t bitOffset, uint32_t bitLength)
template <bool bigEndian>
void
FeatureEncodeContext<bigEndian>::
-writeString(const vespalib::stringref &buf)
+writeString(vespalib::stringref buf)
{
size_t len = buf.size();
for (unsigned int i = 0; i < len; ++i) {
diff --git a/searchlib/src/vespa/searchlib/bitcompression/compression.h b/searchlib/src/vespa/searchlib/bitcompression/compression.h
index 954afc60a1a..931e4165b21 100644
--- a/searchlib/src/vespa/searchlib/bitcompression/compression.h
+++ b/searchlib/src/vespa/searchlib/bitcompression/compression.h
@@ -1672,7 +1672,7 @@ public:
writeBits(const uint64_t *bits, uint32_t bitOffset, uint32_t bitLength);
void
- writeString(const vespalib::stringref &buf);
+ writeString(vespalib::stringref buf);
virtual void
writeHeader(const vespalib::GenericHeader &header);
diff --git a/searchlib/src/vespa/searchlib/bitcompression/pagedict4.cpp b/searchlib/src/vespa/searchlib/bitcompression/pagedict4.cpp
index 23fcfb0b719..ddf617d37ed 100644
--- a/searchlib/src/vespa/searchlib/bitcompression/pagedict4.cpp
+++ b/searchlib/src/vespa/searchlib/bitcompression/pagedict4.cpp
@@ -101,8 +101,8 @@ typedef PageDict4StartOffset StartOffset;
#define K_VALUE_COUNTFILE_L6_ACCNUMDOCS 16
static uint32_t
-getLCP(const vespalib::stringref &word,
- const vespalib::stringref &prevWord)
+getLCP(vespalib::stringref word,
+ vespalib::stringref prevWord)
{
size_t len1 = word.size();
size_t len2 = prevWord.size();
@@ -118,7 +118,7 @@ getLCP(const vespalib::stringref &word,
static void
-addLCPWord(const vespalib::stringref &word, size_t lcp, std::vector<char> &v)
+addLCPWord(vespalib::stringref word, size_t lcp, std::vector<char> &v)
{
v.push_back(lcp);
size_t pos = lcp;
@@ -189,7 +189,7 @@ PageDict4SSWriter::~PageDict4SSWriter()
}
void
-PageDict4SSWriter::addL6Skip(const vespalib::stringref &word,
+PageDict4SSWriter::addL6Skip(vespalib::stringref word,
const StartOffset &startOffset,
uint64_t wordNum,
uint64_t pageNum,
@@ -226,7 +226,7 @@ PageDict4SSWriter::addL6Skip(const vespalib::stringref &word,
void
PageDict4SSWriter::
-addOverflowCounts(const vespalib::stringref &word,
+addOverflowCounts(vespalib::stringref word,
const Counts &counts,
const StartOffset &startOffset,
uint64_t wordNum)
@@ -454,7 +454,7 @@ PageDict4SPWriter::resetPage()
void
-PageDict4SPWriter::addL3Skip(const vespalib::stringref &word,
+PageDict4SPWriter::addL3Skip(vespalib::stringref word,
const StartOffset &startOffset,
uint64_t wordNum,
uint64_t pageNum)
@@ -771,7 +771,7 @@ PageDict4PWriter::resetPage()
void
PageDict4PWriter::
-addCounts(const vespalib::stringref &word,
+addCounts(vespalib::stringref word,
const Counts &counts)
{
assert(_countsWordOffset == _words.size());
@@ -825,7 +825,7 @@ addCounts(const vespalib::stringref &word,
/* Private use */
void
-PageDict4PWriter::addOverflowCounts(const vespalib::stringref &word,
+PageDict4PWriter::addOverflowCounts(vespalib::stringref word,
const Counts &counts)
{
assert(_countsEntries == 0);
@@ -1082,7 +1082,7 @@ PageDict4SSReader::setup(DC &ssd)
PageDict4SSLookupRes
PageDict4SSReader::
-lookup(const vespalib::stringref &key)
+lookup(vespalib::stringref key)
{
PageDict4SSLookupRes res;
@@ -1327,9 +1327,9 @@ void
PageDict4SPLookupRes::
lookup(const SSReader &ssReader,
const void *sparsePage,
- const vespalib::stringref &key,
- const vespalib::stringref &l6Word,
- const vespalib::stringref &lastSPWord,
+ vespalib::stringref key,
+ vespalib::stringref l6Word,
+ vespalib::stringref lastSPWord,
const StartOffset &l6StartOffset,
uint64_t l6WordNum,
uint64_t lowestPageNum)
@@ -1525,9 +1525,9 @@ bool
PageDict4PLookupRes::
lookup(const SSReader &ssReader,
const void *page,
- const vespalib::stringref &key,
- const vespalib::stringref &l3Word,
- const vespalib::stringref &lastPWord,
+ vespalib::stringref key,
+ vespalib::stringref l3Word,
+ vespalib::stringref lastPWord,
const StartOffset &l3StartOffset,
uint64_t l3WordNum)
{
diff --git a/searchlib/src/vespa/searchlib/bitcompression/pagedict4.h b/searchlib/src/vespa/searchlib/bitcompression/pagedict4.h
index 717702d4ef7..dc0ea3a5201 100644
--- a/searchlib/src/vespa/searchlib/bitcompression/pagedict4.h
+++ b/searchlib/src/vespa/searchlib/bitcompression/pagedict4.h
@@ -141,7 +141,7 @@ public:
* startOffset represents file position / accNumDocs after word.
*/
void
- addL6Skip(const vespalib::stringref &word,
+ addL6Skip(vespalib::stringref word,
const StartOffset &startOffset,
uint64_t wordNum,
uint64_t pageNum,
@@ -153,7 +153,7 @@ public:
* startOffset represents file position / accNumDocs at start of entry.
*/
void
- addOverflowCounts(const vespalib::stringref &word,
+ addOverflowCounts(vespalib::stringref word,
const Counts &counts,
const StartOffset &startOffset,
uint64_t wordNum);
@@ -263,7 +263,7 @@ public:
resetPage();
void
- addL3Skip(const vespalib::stringref &word,
+ addL3Skip(vespalib::stringref word,
const StartOffset &startOffset,
uint64_t wordNum,
uint64_t pageNum);
@@ -293,7 +293,7 @@ public:
* startOffset represents file position / accNumDocs at start of entry.
*/
void
- addOverflowCounts(const vespalib::stringref &word,
+ addOverflowCounts(vespalib::stringref word,
const Counts &counts,
const StartOffset &startOffset,
uint64_t wordNum)
@@ -386,7 +386,7 @@ private:
EC &_pe;
void
- addOverflowCounts(const vespalib::stringref &word,
+ addOverflowCounts(vespalib::stringref word,
const Counts &counts);
public:
@@ -408,7 +408,7 @@ public:
resetPage();
void
- addCounts(const vespalib::stringref &word,
+ addCounts(vespalib::stringref word,
const Counts &counts);
void
@@ -493,7 +493,7 @@ public:
{
}
- L7Entry(const vespalib::stringref &l7Word,
+ L7Entry(vespalib::stringref l7Word,
const StartOffset &l7StartOffset,
uint64_t l7WordNum,
uint64_t l6Offset,
@@ -511,7 +511,7 @@ public:
}
bool
- operator<(const vespalib::stringref &word) const
+ operator<(vespalib::stringref word) const
{
return _l7Word < word;
}
@@ -576,7 +576,7 @@ public:
setup(DC &ssd);
PageDict4SSLookupRes
- lookup(const vespalib::stringref &key);
+ lookup(vespalib::stringref key);
PageDict4SSLookupRes
lookupOverflow(uint64_t wordNum) const;
@@ -610,9 +610,9 @@ public:
void
lookup(const SSReader &ssReader,
const void *sparsePage,
- const vespalib::stringref &key,
- const vespalib::stringref &l6Word,
- const vespalib::stringref &lastSPWord,
+ vespalib::stringref key,
+ vespalib::stringref l6Word,
+ vespalib::stringref lastSPWord,
const StartOffset &l6StartOffset,
uint64_t l6WordNum,
uint64_t lowestPageNum);
@@ -641,9 +641,9 @@ public:
bool
lookup(const SSReader &ssReader,
const void *page,
- const vespalib::stringref &key,
- const vespalib::stringref &l3Word,
- const vespalib::stringref &lastPWord,
+ vespalib::stringref key,
+ vespalib::stringref l3Word,
+ vespalib::stringref lastPWord,
const StartOffset &l3StartOffset,
uint64_t l3WordNum);
};
diff --git a/searchlib/src/vespa/searchlib/common/packets.cpp b/searchlib/src/vespa/searchlib/common/packets.cpp
index 90157e318e9..e7ec0ffc9b9 100644
--- a/searchlib/src/vespa/searchlib/common/packets.cpp
+++ b/searchlib/src/vespa/searchlib/common/packets.cpp
@@ -239,7 +239,7 @@ FS4Properties::allocEntries(uint32_t cnt)
_backing.reserve(cnt*2*40); // Assume strings are average 40 bytes
}
-void FS4Properties::set(StringRef & e, const vespalib::stringref & s)
+void FS4Properties::set(StringRef & e, vespalib::stringref s)
{
e.first = _backing.size();
e.second = s.size();
diff --git a/searchlib/src/vespa/searchlib/common/packets.h b/searchlib/src/vespa/searchlib/common/packets.h
index 87e2bd998b1..3fd87ccfa25 100644
--- a/searchlib/src/vespa/searchlib/common/packets.h
+++ b/searchlib/src/vespa/searchlib/common/packets.h
@@ -165,7 +165,7 @@ private:
vespalib::string _name;
vespalib::string _backing;
const char * c_str(size_t sz) const { return _backing.c_str() + sz; }
- void set(StringRef & e, const vespalib::stringref & s);
+ void set(StringRef & e, vespalib::stringref s);
public:
FS4Properties(FS4Properties &&);
FS4Properties &operator=(FS4Properties &&);
@@ -174,15 +174,15 @@ public:
~FS4Properties();
void allocEntries(uint32_t cnt);
void setName(const char *name, uint32_t nameSize) { _name.assign(name, nameSize); }
- void setName(const vespalib::stringref &val) {
+ void setName(vespalib::stringref val) {
setName(val.data(), val.size());
}
void setKey(uint32_t entry, const char *key, uint32_t keySize);
- void setKey(uint32_t entry, const vespalib::stringref &val) {
+ void setKey(uint32_t entry, vespalib::stringref val) {
setKey(entry, val.data(), val.size());
}
void setValue(uint32_t entry, const char *value, uint32_t valueSize);
- void setValue(uint32_t entry, const vespalib::stringref &val) {
+ void setValue(uint32_t entry, vespalib::stringref val) {
setValue(entry, val.data(), val.size());
}
uint32_t size() const { return _entries.size(); }
@@ -282,7 +282,7 @@ public:
uint32_t _errorCode;
string _message;
- void setErrorMessage(const vespalib::stringref &msg) { _message = msg; }
+ void setErrorMessage(vespalib::stringref msg) { _message = msg; }
FS4Packet_ERROR();
~FS4Packet_ERROR();
@@ -464,12 +464,12 @@ public:
string _stackDump; // if QF_PARSEDQUERY
void setQueryFlags(uint32_t qflags) { _qflags = ACTIVE_QUERY_FLAGS & qflags; }
- void setRanking(const vespalib::stringref &ranking) { _ranking = ranking; }
- void setSortSpec(const vespalib::stringref &spec) { _sortSpec = spec; }
- void setGroupSpec(const vespalib::stringref &spec) { _groupSpec = spec; }
- void setSessionId(const vespalib::stringref &sid) { _sessionId = sid; }
- void setLocation(const vespalib::stringref &loc) { _location = loc; }
- void setStackDump(const vespalib::stringref &buf) { _stackDump = buf; }
+ void setRanking(vespalib::stringref ranking) { _ranking = ranking; }
+ void setSortSpec(vespalib::stringref spec) { _sortSpec = spec; }
+ void setGroupSpec(vespalib::stringref spec) { _groupSpec = spec; }
+ void setSessionId(vespalib::stringref sid) { _sessionId = sid; }
+ void setLocation(vespalib::stringref loc) { _location = loc; }
+ void setStackDump(vespalib::stringref buf) { _stackDump = buf; }
void setTimeout(const fastos::TimeStamp & timeout);
fastos::TimeStamp getTimeout() const;
uint32_t getQueryFlags() const { return _qflags; }
@@ -512,10 +512,10 @@ public:
void AllocateDocIDs(uint32_t cnt);
- void setResultClassName(const vespalib::stringref &name) { _resultClassName = name; }
- void setStackDump(const vespalib::stringref &buf) { _stackDump = buf; }
- void setRanking(const vespalib::stringref &ranking) { _ranking = ranking; }
- void setLocation(const vespalib::stringref &loc) { _location = loc; }
+ void setResultClassName(vespalib::stringref name) { _resultClassName = name; }
+ void setStackDump(vespalib::stringref buf) { _stackDump = buf; }
+ void setRanking(vespalib::stringref ranking) { _ranking = ranking; }
+ void setLocation(vespalib::stringref loc) { _location = loc; }
void setTimeout(const fastos::TimeStamp & timeout);
fastos::TimeStamp getTimeout() const;
diff --git a/searchlib/src/vespa/searchlib/diskindex/dictionarywordreader.h b/searchlib/src/vespa/searchlib/diskindex/dictionarywordreader.h
index 9436c17cdbc..ce791314b36 100644
--- a/searchlib/src/vespa/searchlib/diskindex/dictionarywordreader.h
+++ b/searchlib/src/vespa/searchlib/diskindex/dictionarywordreader.h
@@ -29,7 +29,7 @@ public:
}
void
- tryWriteWord(const vespalib::stringref &word)
+ tryWriteWord(vespalib::stringref word)
{
if (word != _word || _wordNum == 0) {
++_wordNum;
diff --git a/searchlib/src/vespa/searchlib/diskindex/diskindex.cpp b/searchlib/src/vespa/searchlib/diskindex/diskindex.cpp
index 98f53da9858..e2fb7367b94 100644
--- a/searchlib/src/vespa/searchlib/diskindex/diskindex.cpp
+++ b/searchlib/src/vespa/searchlib/diskindex/diskindex.cpp
@@ -199,7 +199,7 @@ DiskIndex::setup(const TuneFileSearch &tuneFileSearch,
}
DiskIndex::LookupResult::UP
-DiskIndex::lookup(uint32_t index, const vespalib::stringref & word)
+DiskIndex::lookup(uint32_t index, vespalib::stringref word)
{
/** Only used for testing */
IndexList indexes;
@@ -252,7 +252,7 @@ unite(const DiskIndex::IndexList & indexes, const DiskIndex::LookupResultVector
}
DiskIndex::LookupResultVector
-DiskIndex::lookup(const std::vector<uint32_t> & indexes, const vespalib::stringref & word)
+DiskIndex::lookup(const std::vector<uint32_t> & indexes, vespalib::stringref word)
{
Key key(indexes, word);
LookupResultVector result;
diff --git a/searchlib/src/vespa/searchlib/diskindex/diskindex.h b/searchlib/src/vespa/searchlib/diskindex/diskindex.h
index eaeb768cc9a..dd3daab34cd 100644
--- a/searchlib/src/vespa/searchlib/diskindex/diskindex.h
+++ b/searchlib/src/vespa/searchlib/diskindex/diskindex.h
@@ -111,8 +111,8 @@ public:
* @param word the word to lookup.
* @return the lookup result or NULL if the word is not found.
**/
- LookupResult::UP lookup(uint32_t indexId, const vespalib::stringref & word);
- LookupResultVector lookup(const std::vector<uint32_t> & indexes, const vespalib::stringref & word);
+ LookupResult::UP lookup(uint32_t indexId, vespalib::stringref word);
+ LookupResultVector lookup(const std::vector<uint32_t> & indexes, vespalib::stringref word);
/**
diff --git a/searchlib/src/vespa/searchlib/diskindex/fieldwriter.cpp b/searchlib/src/vespa/searchlib/diskindex/fieldwriter.cpp
index 6b66568ef7a..ab90a1dacc5 100644
--- a/searchlib/src/vespa/searchlib/diskindex/fieldwriter.cpp
+++ b/searchlib/src/vespa/searchlib/diskindex/fieldwriter.cpp
@@ -121,7 +121,7 @@ FieldWriter::flush()
void
-FieldWriter::newWord(uint64_t wordNum, const vespalib::stringref &word)
+FieldWriter::newWord(uint64_t wordNum, vespalib::stringref word)
{
assert(wordNum <= _numWordIds);
assert(wordNum != noWordNum());
@@ -135,7 +135,7 @@ FieldWriter::newWord(uint64_t wordNum, const vespalib::stringref &word)
void
-FieldWriter::newWord(const vespalib::stringref &word)
+FieldWriter::newWord(vespalib::stringref word)
{
newWord(_wordNum + 1, word);
}
diff --git a/searchlib/src/vespa/searchlib/diskindex/fieldwriter.h b/searchlib/src/vespa/searchlib/diskindex/fieldwriter.h
index 8f879360ea5..74f515958fe 100644
--- a/searchlib/src/vespa/searchlib/diskindex/fieldwriter.h
+++ b/searchlib/src/vespa/searchlib/diskindex/fieldwriter.h
@@ -58,8 +58,8 @@ public:
FieldWriter(uint32_t docIdLimit, uint64_t numWordIds);
~FieldWriter();
- void newWord(uint64_t wordNum, const vespalib::stringref &word);
- void newWord(const vespalib::stringref &word);
+ void newWord(uint64_t wordNum, vespalib::stringref word);
+ void newWord(vespalib::stringref word);
void add(const DocIdAndFeatures &features) {
assert(features._docId < _docIdLimit);
diff --git a/searchlib/src/vespa/searchlib/diskindex/indexbuilder.cpp b/searchlib/src/vespa/searchlib/diskindex/indexbuilder.cpp
index b744a68932d..f14d158d616 100644
--- a/searchlib/src/vespa/searchlib/diskindex/indexbuilder.cpp
+++ b/searchlib/src/vespa/searchlib/diskindex/indexbuilder.cpp
@@ -46,7 +46,7 @@ public:
~FileHandle();
void
- open(const vespalib::stringref &dir,
+ open(vespalib::stringref dir,
const SchemaUtil::IndexIterator &index,
uint32_t docIdLimit, uint64_t numWordIds,
const TuneFileSeqWrite &tuneFileWrite,
@@ -172,7 +172,7 @@ public:
FileHandle _files;
void
- startWord(const vespalib::stringref &word);
+ startWord(vespalib::stringref word);
void
endWord();
@@ -282,7 +282,7 @@ FileHandle::~FileHandle()
void
-FileHandle::open(const vespalib::stringref &dir,
+FileHandle::open(vespalib::stringref dir,
const SchemaUtil::IndexIterator &index,
uint32_t docIdLimit, uint64_t numWordIds,
const TuneFileSeqWrite &tuneFileWrite,
@@ -346,7 +346,7 @@ IndexBuilder::FieldHandle::~FieldHandle()
void
-IndexBuilder::FieldHandle::startWord(const vespalib::stringref &word)
+IndexBuilder::FieldHandle::startWord(vespalib::stringref word)
{
assert(_valid);
_files._fieldWriter->newWord(word);
@@ -553,7 +553,7 @@ IndexBuilder::~IndexBuilder()
void
-IndexBuilder::startWord(const vespalib::stringref &word)
+IndexBuilder::startWord(vespalib::stringref word)
{
assert(_currentField != nullptr);
assert(!_inWord);
@@ -649,14 +649,14 @@ IndexBuilder::addOcc(const WordDocElementWordPosFeatures &features)
void
-IndexBuilder::setPrefix(const vespalib::stringref &prefix)
+IndexBuilder::setPrefix(vespalib::stringref prefix)
{
_prefix = prefix;
}
vespalib::string
-IndexBuilder::appendToPrefix(const vespalib::stringref &name)
+IndexBuilder::appendToPrefix(vespalib::stringref name)
{
if (_prefix.empty())
return name;
diff --git a/searchlib/src/vespa/searchlib/diskindex/indexbuilder.h b/searchlib/src/vespa/searchlib/diskindex/indexbuilder.h
index 50cb17242da..dd5baf7c699 100644
--- a/searchlib/src/vespa/searchlib/diskindex/indexbuilder.h
+++ b/searchlib/src/vespa/searchlib/diskindex/indexbuilder.h
@@ -51,7 +51,7 @@ public:
IndexBuilder(const Schema &schema);
virtual ~IndexBuilder();
- virtual void startWord(const vespalib::stringref &word) override;
+ virtual void startWord(vespalib::stringref word) override;
virtual void endWord() override;
virtual void startDocument(uint32_t docId) override;
virtual void endDocument() override;
@@ -65,9 +65,9 @@ public:
// TODO: methods for document summary.
inline FieldHandle & getIndexFieldHandle(uint32_t fieldId);
- void setPrefix(const vespalib::stringref &prefix);
+ void setPrefix(vespalib::stringref prefix);
- vespalib::string appendToPrefix(const vespalib::stringref &name);
+ vespalib::string appendToPrefix(vespalib::stringref name);
void
open(uint32_t docIdLimit, uint64_t numWordIds,
diff --git a/searchlib/src/vespa/searchlib/diskindex/pagedict4file.cpp b/searchlib/src/vespa/searchlib/diskindex/pagedict4file.cpp
index 791e41de497..1870de30bad 100644
--- a/searchlib/src/vespa/searchlib/diskindex/pagedict4file.cpp
+++ b/searchlib/src/vespa/searchlib/diskindex/pagedict4file.cpp
@@ -321,7 +321,7 @@ PageDict4FileSeqWrite::~PageDict4FileSeqWrite()
void
-PageDict4FileSeqWrite::writeWord(const vespalib::stringref &word,
+PageDict4FileSeqWrite::writeWord(vespalib::stringref word,
const PostingListCounts &counts)
{
_pWriter->addCounts(word, counts);
diff --git a/searchlib/src/vespa/searchlib/diskindex/pagedict4file.h b/searchlib/src/vespa/searchlib/diskindex/pagedict4file.h
index 7baa883a740..e176ba26d88 100644
--- a/searchlib/src/vespa/searchlib/diskindex/pagedict4file.h
+++ b/searchlib/src/vespa/searchlib/diskindex/pagedict4file.h
@@ -159,7 +159,7 @@ public:
* Write word and counts. Only nonzero counts should be supplied.
*/
virtual void
- writeWord(const vespalib::stringref &word,
+ writeWord(vespalib::stringref word,
const PostingListCounts &counts) override;
/**
diff --git a/searchlib/src/vespa/searchlib/diskindex/pagedict4randread.cpp b/searchlib/src/vespa/searchlib/diskindex/pagedict4randread.cpp
index e610f7a9179..67f955fab07 100644
--- a/searchlib/src/vespa/searchlib/diskindex/pagedict4randread.cpp
+++ b/searchlib/src/vespa/searchlib/diskindex/pagedict4randread.cpp
@@ -146,7 +146,7 @@ PageDict4RandRead::readPHeader()
bool
-PageDict4RandRead::lookup(const vespalib::stringref &word,
+PageDict4RandRead::lookup(vespalib::stringref word,
uint64_t &wordNum,
PostingListOffsetAndCounts &offsetAndCounts)
{
diff --git a/searchlib/src/vespa/searchlib/diskindex/pagedict4randread.h b/searchlib/src/vespa/searchlib/diskindex/pagedict4randread.h
index abe0bf86543..b7159f9398e 100644
--- a/searchlib/src/vespa/searchlib/diskindex/pagedict4randread.h
+++ b/searchlib/src/vespa/searchlib/diskindex/pagedict4randread.h
@@ -46,7 +46,7 @@ public:
PageDict4RandRead();
~PageDict4RandRead();
- bool lookup(const vespalib::stringref &word, uint64_t &wordNum,
+ bool lookup(vespalib::stringref word, uint64_t &wordNum,
PostingListOffsetAndCounts &offsetAndCounts) override;
bool open(const vespalib::string &name, const TuneFileRandRead &tuneFileRead) override;
diff --git a/searchlib/src/vespa/searchlib/docstore/chunkformat.cpp b/searchlib/src/vespa/searchlib/docstore/chunkformat.cpp
index 93f1d9c0d51..0f360d99247 100644
--- a/searchlib/src/vespa/searchlib/docstore/chunkformat.cpp
+++ b/searchlib/src/vespa/searchlib/docstore/chunkformat.cpp
@@ -13,7 +13,7 @@ using vespalib::compression::decompress;
using vespalib::compression::computeMaxCompressedsize;
using vespalib::compression::CompressionConfig;
-ChunkException::ChunkException(const vespalib::string & msg, const vespalib::stringref & location) :
+ChunkException::ChunkException(const vespalib::string & msg, vespalib::stringref location) :
Exception(make_string("Illegal chunk: %s", msg.c_str()), location)
{
}
diff --git a/searchlib/src/vespa/searchlib/docstore/chunkformat.h b/searchlib/src/vespa/searchlib/docstore/chunkformat.h
index 81feaf2a27f..ede1a02f0f4 100644
--- a/searchlib/src/vespa/searchlib/docstore/chunkformat.h
+++ b/searchlib/src/vespa/searchlib/docstore/chunkformat.h
@@ -12,7 +12,7 @@ namespace search {
class ChunkException : public vespalib::Exception
{
public:
- ChunkException(const vespalib::string & msg, const vespalib::stringref & location);
+ ChunkException(const vespalib::string & msg, vespalib::stringref location);
};
// This is an interface for implementing a chunk format
diff --git a/searchlib/src/vespa/searchlib/docstore/summaryexceptions.cpp b/searchlib/src/vespa/searchlib/docstore/summaryexceptions.cpp
index 2cfa023e7ed..80510dbe883 100644
--- a/searchlib/src/vespa/searchlib/docstore/summaryexceptions.cpp
+++ b/searchlib/src/vespa/searchlib/docstore/summaryexceptions.cpp
@@ -8,9 +8,9 @@ using vespalib::make_string;
namespace search {
-SummaryException::SummaryException(const vespalib::stringref &msg,
+SummaryException::SummaryException(vespalib::stringref msg,
FastOS_FileInterface &file,
- const vespalib::stringref &location)
+ vespalib::stringref location)
: IoException(make_string("%s : Failing file = '%s'. Reason given by OS = '%s'",
vespalib::string(msg).c_str(), file.GetFileName(), file.getLastErrorString().c_str()),
getErrorType(file.GetLastError()), location)
diff --git a/searchlib/src/vespa/searchlib/docstore/summaryexceptions.h b/searchlib/src/vespa/searchlib/docstore/summaryexceptions.h
index a04639711fe..a9e8f3ca763 100644
--- a/searchlib/src/vespa/searchlib/docstore/summaryexceptions.h
+++ b/searchlib/src/vespa/searchlib/docstore/summaryexceptions.h
@@ -11,7 +11,7 @@ namespace search {
class SummaryException : public vespalib::IoException
{
public:
- SummaryException(const vespalib::stringref &msg, FastOS_FileInterface & file, const vespalib::stringref &location);
+ SummaryException(vespalib::stringref msg, FastOS_FileInterface & file, vespalib::stringref location);
};
} // namespace search
diff --git a/searchlib/src/vespa/searchlib/engine/propertiesmap.cpp b/searchlib/src/vespa/searchlib/engine/propertiesmap.cpp
index f9045612849..b09813c0258 100644
--- a/searchlib/src/vespa/searchlib/engine/propertiesmap.cpp
+++ b/searchlib/src/vespa/searchlib/engine/propertiesmap.cpp
@@ -14,13 +14,13 @@ PropertiesMap::PropertiesMap()
PropertiesMap::~PropertiesMap() { }
fef::Properties &
-PropertiesMap::lookupCreate(const vespalib::stringref &name)
+PropertiesMap::lookupCreate(vespalib::stringref name)
{
return _propertiesMap[name];
}
const fef::Properties &
-PropertiesMap::lookup(const vespalib::stringref &name) const
+PropertiesMap::lookup(vespalib::stringref name) const
{
PropsMap::const_iterator pos = _propertiesMap.find(name);
if (pos == _propertiesMap.end()) {
diff --git a/searchlib/src/vespa/searchlib/engine/propertiesmap.h b/searchlib/src/vespa/searchlib/engine/propertiesmap.h
index d4d4598add2..ba80e4a2f05 100644
--- a/searchlib/src/vespa/searchlib/engine/propertiesmap.h
+++ b/searchlib/src/vespa/searchlib/engine/propertiesmap.h
@@ -28,7 +28,7 @@ private:
* @param name name of properties
* @return the properties
**/
- const Props &lookup(const vespalib::stringref &name) const;
+ const Props &lookup(vespalib::stringref name) const;
public:
typedef PropsMap::const_iterator ITR;
@@ -43,7 +43,7 @@ public:
* @param name name of properties
* @return the properties
**/
- Props &lookupCreate(const vespalib::stringref &name);
+ Props &lookupCreate(vespalib::stringref name);
/**
* Obtain the number of named collection of properties held by
diff --git a/searchlib/src/vespa/searchlib/engine/transportserver.cpp b/searchlib/src/vespa/searchlib/engine/transportserver.cpp
index c94e36202a1..c5e59024c31 100644
--- a/searchlib/src/vespa/searchlib/engine/transportserver.cpp
+++ b/searchlib/src/vespa/searchlib/engine/transportserver.cpp
@@ -305,7 +305,7 @@ TransportServer::discardRequests()
}
void
-TransportServer::logPacket(const vespalib::stringref &msg, FNET_Packet *p, FNET_Channel *ch, FNET_Connection *conn)
+TransportServer::logPacket(vespalib::stringref msg, FNET_Packet *p, FNET_Channel *ch, FNET_Connection *conn)
{
uint32_t chid = -1;
uint32_t conntag = -1;
diff --git a/searchlib/src/vespa/searchlib/engine/transportserver.h b/searchlib/src/vespa/searchlib/engine/transportserver.h
index 76327dd8fcd..691f6fbe791 100644
--- a/searchlib/src/vespa/searchlib/engine/transportserver.h
+++ b/searchlib/src/vespa/searchlib/engine/transportserver.h
@@ -169,7 +169,7 @@ private:
void discardRequests();
// convenience method used to log packets
- static void logPacket(const vespalib::stringref &msg, FNET_Packet *p, FNET_Channel *ch, FNET_Connection *conn);
+ static void logPacket(vespalib::stringref msg, FNET_Packet *p, FNET_Channel *ch, FNET_Connection *conn);
void updateQueryMetrics(double latency_s);
void updateDocsumMetrics(double latency_s, uint32_t numDocs);
diff --git a/searchlib/src/vespa/searchlib/expression/attributenode.cpp b/searchlib/src/vespa/searchlib/expression/attributenode.cpp
index 4984aceea71..41955c08261 100644
--- a/searchlib/src/vespa/searchlib/expression/attributenode.cpp
+++ b/searchlib/src/vespa/searchlib/expression/attributenode.cpp
@@ -55,7 +55,7 @@ AttributeNode::AttributeNode() :
AttributeNode::~AttributeNode() {}
-AttributeNode::AttributeNode(const vespalib::stringref &name) :
+AttributeNode::AttributeNode(vespalib::stringref name) :
FunctionNode(),
_scratchResult(new AttributeResult()),
_hasMultiValue(false),
diff --git a/searchlib/src/vespa/searchlib/expression/attributenode.h b/searchlib/src/vespa/searchlib/expression/attributenode.h
index ca6fa368423..912b0f94c50 100644
--- a/searchlib/src/vespa/searchlib/expression/attributenode.h
+++ b/searchlib/src/vespa/searchlib/expression/attributenode.h
@@ -69,7 +69,7 @@ public:
void visitMembers(vespalib::ObjectVisitor &visitor) const override;
DECLARE_EXPRESSIONNODE(AttributeNode);
AttributeNode();
- AttributeNode(const vespalib::stringref &name);
+ AttributeNode(vespalib::stringref name);
AttributeNode(const search::attribute::IAttributeVector & attribute);
AttributeNode(const AttributeNode & attribute);
AttributeNode & operator = (const AttributeNode & attribute);
diff --git a/searchlib/src/vespa/searchlib/expression/catserializer.cpp b/searchlib/src/vespa/searchlib/expression/catserializer.cpp
index f613bd16a54..2d64f3db9f9 100644
--- a/searchlib/src/vespa/searchlib/expression/catserializer.cpp
+++ b/searchlib/src/vespa/searchlib/expression/catserializer.cpp
@@ -14,7 +14,7 @@ using vespalib::Deserializer;
using vespalib::string;
using vespalib::stringref;
-CatSerializer & CatSerializer::put(const IFieldBase & field, const stringref & value)
+CatSerializer & CatSerializer::put(const IFieldBase & field, stringref value)
{
(void) field;
getStream().write(value.data(), value.size());
diff --git a/searchlib/src/vespa/searchlib/expression/catserializer.h b/searchlib/src/vespa/searchlib/expression/catserializer.h
index b635826fbf5..cce4af3880b 100644
--- a/searchlib/src/vespa/searchlib/expression/catserializer.h
+++ b/searchlib/src/vespa/searchlib/expression/catserializer.h
@@ -14,7 +14,7 @@ class CatSerializer : public vespalib::NBOSerializer, public ResultSerializer
public:
CatSerializer(vespalib::nbostream & stream) : vespalib::NBOSerializer(stream) { }
CatSerializer & put(const vespalib::IFieldBase & field, const vespalib::Identifiable & value) override;
- CatSerializer & put(const vespalib::IFieldBase & field, const vespalib::stringref & value) override;
+ CatSerializer & put(const vespalib::IFieldBase & field, vespalib::stringref value) override;
ResultSerializer & putResult(const vespalib::IFieldBase & field, const RawResultNode & value) override;
ResultSerializer & putResult(const vespalib::IFieldBase & field, const ResultNodeVector & value) override;
void proxyPut(const ResultNode & value) override;
diff --git a/searchlib/src/vespa/searchlib/expression/documentfieldnode.cpp b/searchlib/src/vespa/searchlib/expression/documentfieldnode.cpp
index c7ce9528520..b0884d51db9 100644
--- a/searchlib/src/vespa/searchlib/expression/documentfieldnode.cpp
+++ b/searchlib/src/vespa/searchlib/expression/documentfieldnode.cpp
@@ -49,7 +49,7 @@ DocumentFieldNode & DocumentFieldNode::operator = (const DocumentFieldNode & rhs
}
std::unique_ptr<ResultNode>
-deduceResultNode(const vespalib::stringref & fieldName, const FieldValue & fv, bool preserveAccurateTypes, bool nestedMultiValue)
+deduceResultNode(vespalib::stringref fieldName, const FieldValue & fv, bool preserveAccurateTypes, bool nestedMultiValue)
{
std::unique_ptr<ResultNode> value;
const Identifiable::RuntimeClass & cInfo = fv.getClass();
diff --git a/searchlib/src/vespa/searchlib/expression/documentfieldnode.h b/searchlib/src/vespa/searchlib/expression/documentfieldnode.h
index bd5ecf61e1c..beb658f7524 100644
--- a/searchlib/src/vespa/searchlib/expression/documentfieldnode.h
+++ b/searchlib/src/vespa/searchlib/expression/documentfieldnode.h
@@ -34,7 +34,7 @@ public:
DECLARE_EXPRESSIONNODE(DocumentFieldNode);
DocumentFieldNode() : _fieldPath(), _value(), _fieldName(), _doc(NULL) { }
~DocumentFieldNode();
- DocumentFieldNode(const vespalib::stringref &name) : _fieldPath(), _value(), _fieldName(name), _doc(NULL) { }
+ DocumentFieldNode(vespalib::stringref name) : _fieldPath(), _value(), _fieldName(name), _doc(NULL) { }
DocumentFieldNode(const DocumentFieldNode & rhs);
DocumentFieldNode & operator = (const DocumentFieldNode & rhs);
const vespalib::string & getFieldName() const override { return _fieldName; }
diff --git a/searchlib/src/vespa/searchlib/expression/stringbucketresultnode.cpp b/searchlib/src/vespa/searchlib/expression/stringbucketresultnode.cpp
index c55c35f205d..603600847b7 100644
--- a/searchlib/src/vespa/searchlib/expression/stringbucketresultnode.cpp
+++ b/searchlib/src/vespa/searchlib/expression/stringbucketresultnode.cpp
@@ -40,7 +40,7 @@ StringBucketResultNode::StringBucketResultNode()
: _from(new StringResultNode()),
_to(new StringResultNode())
{}
-StringBucketResultNode::StringBucketResultNode(const vespalib::stringref & from, const vespalib::stringref & to)
+StringBucketResultNode::StringBucketResultNode(vespalib::stringref from, vespalib::stringref to)
: _from(new StringResultNode(from)),
_to(new StringResultNode(to))
{}
diff --git a/searchlib/src/vespa/searchlib/expression/stringbucketresultnode.h b/searchlib/src/vespa/searchlib/expression/stringbucketresultnode.h
index bef885c3c53..dac84febeeb 100644
--- a/searchlib/src/vespa/searchlib/expression/stringbucketresultnode.h
+++ b/searchlib/src/vespa/searchlib/expression/stringbucketresultnode.h
@@ -23,7 +23,7 @@ public:
DECLARE_EXPRESSIONNODE(StringBucketResultNode);
DECLARE_NBO_SERIALIZE;
StringBucketResultNode();
- StringBucketResultNode(const vespalib::stringref & from, const vespalib::stringref & to);
+ StringBucketResultNode(vespalib::stringref from, vespalib::stringref to);
StringBucketResultNode(ResultNode::UP from, ResultNode::UP to) : _from(from.release()), _to(to.release()) {}
~StringBucketResultNode();
size_t hash() const override;
@@ -32,7 +32,7 @@ public:
int contains(const ConstBufferRef & v) const { return contains(v.c_str()); }
int contains(const char * v) const;
void visitMembers(vespalib::ObjectVisitor &visitor) const override;
- StringBucketResultNode &setRange(const vespalib::stringref & from, const vespalib::stringref & to) {
+ StringBucketResultNode &setRange(vespalib::stringref from, vespalib::stringref to) {
_from.reset(new StringResultNode(from));
_to.reset(new StringResultNode(to));
return *this;
diff --git a/searchlib/src/vespa/searchlib/expression/stringresultnode.h b/searchlib/src/vespa/searchlib/expression/stringresultnode.h
index 05e6b3321bb..2e8ddd57d94 100644
--- a/searchlib/src/vespa/searchlib/expression/stringresultnode.h
+++ b/searchlib/src/vespa/searchlib/expression/stringresultnode.h
@@ -13,14 +13,14 @@ public:
DECLARE_NBO_SERIALIZE;
void visitMembers(vespalib::ObjectVisitor &visitor) const override;
StringResultNode(const char * v="") : _value(v) { }
- StringResultNode(const vespalib::stringref & v) : _value(v) { }
+ StringResultNode(vespalib::stringref v) : _value(v) { }
size_t hash() const override;
int onCmp(const Identifiable & b) const override;
void set(const ResultNode & rhs) override;
StringResultNode & append(const ResultNode & rhs);
StringResultNode & clear() { _value.clear(); return *this; }
const vespalib::string & get() const { return _value; }
- void set(const vespalib::stringref & value) { _value = value; }
+ void set(vespalib::stringref value) { _value = value; }
void min(const ResultNode & b) override;
void max(const ResultNode & b) override;
void add(const ResultNode & b) override;
diff --git a/searchlib/src/vespa/searchlib/features/attributefeature.cpp b/searchlib/src/vespa/searchlib/features/attributefeature.cpp
index 7e913f96b7f..e7f4ab0e352 100644
--- a/searchlib/src/vespa/searchlib/features/attributefeature.cpp
+++ b/searchlib/src/vespa/searchlib/features/attributefeature.cpp
@@ -37,18 +37,18 @@ using namespace search::fef::indexproperties;
namespace {
template <typename X, typename Y>
-bool equals(const X & lhs, const Y & rhs) {
+bool equals(X lhs, Y rhs) {
return lhs == rhs;
}
template <>
-bool equals<ConstCharPtr, vespalib::stringref>(const ConstCharPtr & lhs, const vespalib::stringref & rhs) {
+bool equals<ConstCharPtr, vespalib::stringref>(ConstCharPtr lhs, vespalib::stringref rhs) {
return strcmp(lhs, rhs.data()) == 0;
}
template <typename T>
bool
-isUndefined(const T & value, const BasicType::Type & type)
+isUndefined(T value, BasicType::Type type)
{
switch (type) {
case BasicType::INT8:
@@ -70,14 +70,14 @@ isUndefined(const T & value, const BasicType::Type & type)
template <>
bool
-isUndefined<vespalib::stringref>(const vespalib::stringref &, const BasicType::Type &)
+isUndefined<vespalib::stringref>(vespalib::stringref, BasicType::Type)
{
return false;
}
template <typename T>
search::feature_t
-considerUndefined(const T & value, const BasicType::Type & type)
+considerUndefined(T value, BasicType::Type type)
{
if (isUndefined(value, type)) {
return search::attribute::getUndefined<search::feature_t>();
@@ -87,7 +87,7 @@ considerUndefined(const T & value, const BasicType::Type & type)
template <>
search::feature_t
-considerUndefined<ConstCharPtr>(const ConstCharPtr & value, const BasicType::Type &)
+considerUndefined<ConstCharPtr>(ConstCharPtr value, BasicType::Type )
{
return search::features::util::getAsFeature(value);
}
@@ -96,8 +96,7 @@ considerUndefined<ConstCharPtr>(const ConstCharPtr & value, const BasicType::Typ
}
-namespace search {
-namespace features {
+namespace search::features {
/**
* Implements the executor for fetching values from a single or array attribute vector
@@ -433,5 +432,4 @@ AttributeBlueprint::getDescriptions() const
desc().attribute(dataTypeSet, fef::ParameterCollection::ANY).string();
}
-} // namespace features
-} // namespace search
+}
diff --git a/searchlib/src/vespa/searchlib/features/dotproductfeature.h b/searchlib/src/vespa/searchlib/features/dotproductfeature.h
index e3cd662cdd8..c350494db0e 100644
--- a/searchlib/src/vespa/searchlib/features/dotproductfeature.h
+++ b/searchlib/src/vespa/searchlib/features/dotproductfeature.h
@@ -73,7 +73,7 @@ public:
**/
class IntegerVector : public VectorBase<int64_t, int64_t, feature_t> {
public:
- void insert(const vespalib::stringref & label, const vespalib::stringref & value) {
+ void insert(vespalib::stringref label, vespalib::stringref value) {
_vector.push_back(std::make_pair(util::strToNum<int64_t>(label), util::strToNum<feature_t>(value)));
}
};
@@ -85,7 +85,7 @@ class StringVector : public VectorBase<vespalib::string, const char *, feature_t
public:
StringVector();
~StringVector();
- void insert(const vespalib::stringref & label, const vespalib::stringref & value) {
+ void insert(vespalib::stringref label, vespalib::stringref value) {
_vector.push_back(std::make_pair(label, util::strToNum<feature_t>(value)));
}
};
@@ -98,7 +98,7 @@ private:
const search::attribute::IAttributeVector * _attribute;
public:
EnumVector(const search::attribute::IAttributeVector * attribute) : _attribute(attribute) {}
- void insert(const vespalib::stringref & label, const vespalib::stringref & value) {
+ void insert(vespalib::stringref label, vespalib::stringref value) {
search::attribute::EnumHandle e;
if (_attribute->findEnum(label.data(), e)) {
_vector.push_back(std::make_pair(e, util::strToNum<feature_t>(value)));
diff --git a/searchlib/src/vespa/searchlib/features/tensor_from_weighted_set_feature.cpp b/searchlib/src/vespa/searchlib/features/tensor_from_weighted_set_feature.cpp
index 583e910a593..3b0bde8f76f 100644
--- a/searchlib/src/vespa/searchlib/features/tensor_from_weighted_set_feature.cpp
+++ b/searchlib/src/vespa/searchlib/features/tensor_from_weighted_set_feature.cpp
@@ -36,7 +36,7 @@ namespace {
struct WeightedStringVector
{
std::vector<IAttributeVector::WeightedString> _data;
- void insert(const vespalib::stringref &key, const vespalib::stringref &weight) {
+ void insert(vespalib::stringref key, vespalib::stringref weight) {
_data.emplace_back(key, util::strToNum<int32_t>(weight));
}
};
diff --git a/searchlib/src/vespa/searchlib/features/utils.h b/searchlib/src/vespa/searchlib/features/utils.h
index 57f4c83f6a9..859c66af66a 100644
--- a/searchlib/src/vespa/searchlib/features/utils.h
+++ b/searchlib/src/vespa/searchlib/features/utils.h
@@ -35,7 +35,7 @@ template <typename T>
T strToNum(vespalib::stringref str);
template <typename T>
-feature_t getAsFeature(const T &value) __attribute__((__always_inline__));
+feature_t getAsFeature(T value) __attribute__((__always_inline__));
/**
* Converts the given value to a feature value.
@@ -44,7 +44,7 @@ feature_t getAsFeature(const T &value) __attribute__((__always_inline__));
* @return The feature value.
*/
template <typename T>
-inline feature_t getAsFeature(const T &value)
+inline feature_t getAsFeature(T value)
{
return static_cast<feature_t>(value);
}
@@ -56,7 +56,7 @@ inline feature_t getAsFeature(const T &value)
* @return The feature value.
*/
template <>
-inline feature_t getAsFeature<ConstCharPtr>(const ConstCharPtr & value) {
+inline feature_t getAsFeature<ConstCharPtr>(ConstCharPtr value) {
return static_cast<feature_t>(vespalib::hash_code(value, strlen(value)));
}
@@ -67,18 +67,7 @@ inline feature_t getAsFeature<ConstCharPtr>(const ConstCharPtr & value) {
* @return The feature value.
*/
template <>
-inline feature_t getAsFeature<vespalib::string>(const vespalib::string & value) {
- return static_cast<feature_t>(vespalib::hash_code(value));
-}
-
-/**
- * Specialization for a string value.
- *
- * @param value The string to convert.
- * @return The feature value.
- */
-template <>
-inline feature_t getAsFeature<vespalib::stringref>(const vespalib::stringref & value) {
+inline feature_t getAsFeature<vespalib::stringref>(vespalib::stringref value) {
return static_cast<feature_t>(vespalib::hash_code(value));
}
diff --git a/searchlib/src/vespa/searchlib/fef/blueprint.cpp b/searchlib/src/vespa/searchlib/fef/blueprint.cpp
index 98fdea1861f..6e04ede5253 100644
--- a/searchlib/src/vespa/searchlib/fef/blueprint.cpp
+++ b/searchlib/src/vespa/searchlib/fef/blueprint.cpp
@@ -10,7 +10,7 @@ namespace search {
namespace fef {
const FeatureType &
-Blueprint::defineInput(const vespalib::stringref &inName,
+Blueprint::defineInput(vespalib::stringref inName,
AcceptInput accept)
{
assert(_dependency_handler != nullptr);
@@ -18,8 +18,8 @@ Blueprint::defineInput(const vespalib::stringref &inName,
}
void
-Blueprint::describeOutput(const vespalib::stringref &outName,
- const vespalib::stringref &desc,
+Blueprint::describeOutput(vespalib::stringref outName,
+ vespalib::stringref desc,
const FeatureType &type)
{
(void) desc;
@@ -27,7 +27,7 @@ Blueprint::describeOutput(const vespalib::stringref &outName,
_dependency_handler->define_output(outName, type);
}
-Blueprint::Blueprint(const vespalib::stringref & baseName)
+Blueprint::Blueprint(vespalib::stringref baseName)
: _baseName(baseName),
_name(),
_dependency_handler(nullptr)
diff --git a/searchlib/src/vespa/searchlib/fef/blueprint.h b/searchlib/src/vespa/searchlib/fef/blueprint.h
index 4605df10eda..53c06dbd4cc 100644
--- a/searchlib/src/vespa/searchlib/fef/blueprint.h
+++ b/searchlib/src/vespa/searchlib/fef/blueprint.h
@@ -81,7 +81,7 @@ protected:
* @param inName feature name of input
* @param type accepted input type
**/
- const FeatureType &defineInput(const vespalib::stringref &inName,
+ const FeatureType &defineInput(vespalib::stringref inName,
AcceptInput accept = AcceptInput::NUMBER);
/**
@@ -97,7 +97,7 @@ protected:
* @param outName output name
* @param desc output description
**/
- void describeOutput(const vespalib::stringref &outName, const vespalib::stringref &desc,
+ void describeOutput(vespalib::stringref outName, vespalib::stringref desc,
const FeatureType &type = FeatureType::number());
public:
@@ -107,7 +107,7 @@ public:
* class. The @ref setup method is used to tailor a blueprint
* object for a specific set of parameters.
**/
- Blueprint(const vespalib::stringref & baseName);
+ Blueprint(vespalib::stringref baseName);
/**
* Obtain the base name of this blueprint. This method will
@@ -164,7 +164,7 @@ public:
* before invoking the @ref setup method (and must not be invoked
* by others).
**/
- void setName(const vespalib::stringref &name) { _name = name; }
+ void setName(vespalib::stringref name) { _name = name; }
/**
* Obtain the name of this blueprint.
diff --git a/searchlib/src/vespa/searchlib/fef/blueprintresolver.cpp b/searchlib/src/vespa/searchlib/fef/blueprintresolver.cpp
index 415e5625135..a8d2e4d7f6b 100644
--- a/searchlib/src/vespa/searchlib/fef/blueprintresolver.cpp
+++ b/searchlib/src/vespa/searchlib/fef/blueprintresolver.cpp
@@ -192,7 +192,7 @@ BlueprintResolver::BlueprintResolver(const BlueprintFactory &factory,
}
void
-BlueprintResolver::addSeed(const vespalib::stringref &feature)
+BlueprintResolver::addSeed(vespalib::stringref feature)
{
_seeds.push_back(feature);
}
diff --git a/searchlib/src/vespa/searchlib/fef/blueprintresolver.h b/searchlib/src/vespa/searchlib/fef/blueprintresolver.h
index 78cb8fa8b3d..317263260fe 100644
--- a/searchlib/src/vespa/searchlib/fef/blueprintresolver.h
+++ b/searchlib/src/vespa/searchlib/fef/blueprintresolver.h
@@ -101,7 +101,7 @@ public:
*
* @param feature feature name to use as a seed
**/
- void addSeed(const vespalib::stringref &feature);
+ void addSeed(vespalib::stringref feature);
/**
* Create Blueprints for all seeds and dependencies and enumerate
diff --git a/searchlib/src/vespa/searchlib/fef/parametervalidator.h b/searchlib/src/vespa/searchlib/fef/parametervalidator.h
index 6bde59641da..6e0fd7199c8 100644
--- a/searchlib/src/vespa/searchlib/fef/parametervalidator.h
+++ b/searchlib/src/vespa/searchlib/fef/parametervalidator.h
@@ -43,7 +43,7 @@ public:
Result & operator=(Result &&) = default;
~Result();
Result & addParameter(const Parameter & param) { _params.push_back(param); return *this; }
- Result & setError(const vespalib::stringref & str) {
+ Result & setError(vespalib::stringref str) {
_errorStr = str;
_params.clear();
_valid = false;
diff --git a/searchlib/src/vespa/searchlib/fef/properties.cpp b/searchlib/src/vespa/searchlib/fef/properties.cpp
index 132bf8d777a..626623a8647 100644
--- a/searchlib/src/vespa/searchlib/fef/properties.cpp
+++ b/searchlib/src/vespa/searchlib/fef/properties.cpp
@@ -84,7 +84,7 @@ Properties::~Properties()
}
Properties &
-Properties::add(const vespalib::stringref &key, const vespalib::stringref &value)
+Properties::add(vespalib::stringref key, vespalib::stringref value)
{
if (!key.empty()) {
Value & v = _data[key];
@@ -95,7 +95,7 @@ Properties::add(const vespalib::stringref &key, const vespalib::stringref &value
}
uint32_t
-Properties::count(const vespalib::stringref &key) const
+Properties::count(vespalib::stringref key) const
{
if (!key.empty()) {
Map::const_iterator node = _data.find(key);
@@ -107,7 +107,7 @@ Properties::count(const vespalib::stringref &key) const
}
Properties &
-Properties::remove(const vespalib::stringref &key)
+Properties::remove(vespalib::stringref key)
{
if (!key.empty()) {
Map::iterator node = _data.find(key);
@@ -186,7 +186,7 @@ Properties::visitProperties(IPropertiesVisitor &visitor) const
}
void
-Properties::visitNamespace(const vespalib::stringref &ns,
+Properties::visitNamespace(vespalib::stringref ns,
IPropertiesVisitor &visitor) const
{
vespalib::string tmp;
@@ -205,7 +205,7 @@ Properties::visitNamespace(const vespalib::stringref &ns,
}
Property
-Properties::lookup(const vespalib::stringref &key) const
+Properties::lookup(vespalib::stringref key) const
{
if (key.empty()) {
return Property();
@@ -217,8 +217,8 @@ Properties::lookup(const vespalib::stringref &key) const
return Property(node->second);
}
-Property Properties::lookup(const vespalib::stringref &namespace1,
- const vespalib::stringref &key) const
+Property Properties::lookup(vespalib::stringref namespace1,
+ vespalib::stringref key) const
{
if (namespace1.empty() ||
key.empty())
@@ -228,9 +228,9 @@ Property Properties::lookup(const vespalib::stringref &namespace1,
return lookup(namespace1 + "." + key);
}
-Property Properties::lookup(const vespalib::stringref &namespace1,
- const vespalib::stringref &namespace2,
- const vespalib::stringref &key) const
+Property Properties::lookup(vespalib::stringref namespace1,
+ vespalib::stringref namespace2,
+ vespalib::stringref key) const
{
if (namespace1.empty() ||
namespace2.empty() ||
@@ -241,10 +241,10 @@ Property Properties::lookup(const vespalib::stringref &namespace1,
return lookup(namespace1 + "." + namespace2 + "." + key);
}
-Property Properties::lookup(const vespalib::stringref &namespace1,
- const vespalib::stringref &namespace2,
- const vespalib::stringref &namespace3,
- const vespalib::stringref &key) const
+Property Properties::lookup(vespalib::stringref namespace1,
+ vespalib::stringref namespace2,
+ vespalib::stringref namespace3,
+ vespalib::stringref key) const
{
if (namespace1.empty() ||
namespace2.empty() ||
diff --git a/searchlib/src/vespa/searchlib/fef/properties.h b/searchlib/src/vespa/searchlib/fef/properties.h
index 06305a14ef6..1cbc0ba9064 100644
--- a/searchlib/src/vespa/searchlib/fef/properties.h
+++ b/searchlib/src/vespa/searchlib/fef/properties.h
@@ -167,7 +167,7 @@ public:
* @param key the key
* @param value the value
**/
- Properties &add(const vespalib::stringref &key, const vespalib::stringref &value);
+ Properties &add(vespalib::stringref key, vespalib::stringref value);
/**
* Obtain the number of values for a given key.
@@ -175,7 +175,7 @@ public:
* @return number of values for the given key
* @param key the key
**/
- uint32_t count(const vespalib::stringref &key) const;
+ uint32_t count(vespalib::stringref key) const;
/**
* Remove all values for the given key.
@@ -183,7 +183,7 @@ public:
* @return this object, for chaining
* @param key the key
**/
- Properties &remove(const vespalib::stringref &key);
+ Properties &remove(vespalib::stringref key);
/**
* Import all key/value pairs from src into this object. All
@@ -248,7 +248,7 @@ public:
* @param ns the namespace to visit
* @param visitor the object being notified of key/value pairs inside the namespace
**/
- void visitNamespace(const vespalib::stringref &ns,
+ void visitNamespace(vespalib::stringref ns,
IPropertiesVisitor &visitor) const;
/**
@@ -258,7 +258,7 @@ public:
* @return object encapsulating lookup result
* @param key the key to look up
**/
- Property lookup(const vespalib::stringref &key) const;
+ Property lookup(vespalib::stringref key) const;
/**
* Look up a key inside a namespace using the proposed namespace
@@ -271,8 +271,8 @@ public:
* @param namespace1 the namespace
* @param key the key to look up
**/
- Property lookup(const vespalib::stringref &namespace1,
- const vespalib::stringref &key) const;
+ Property lookup(vespalib::stringref namespace1,
+ vespalib::stringref key) const;
/**
* Look up a key inside a namespace using the proposed namespace
@@ -286,9 +286,9 @@ public:
* @param namespace the second namespace
* @param key the key to look up
**/
- Property lookup(const vespalib::stringref &namespace1,
- const vespalib::stringref &namespace2,
- const vespalib::stringref &key) const;
+ Property lookup(vespalib::stringref namespace1,
+ vespalib::stringref namespace2,
+ vespalib::stringref key) const;
/**
* Look up a key inside a namespace using the proposed namespace
@@ -303,10 +303,10 @@ public:
* @param namespace the third namespace
* @param key the key to look up
**/
- Property lookup(const vespalib::stringref &namespace1,
- const vespalib::stringref &namespace2,
- const vespalib::stringref &namespace3,
- const vespalib::stringref &key) const;
+ Property lookup(vespalib::stringref namespace1,
+ vespalib::stringref namespace2,
+ vespalib::stringref namespace3,
+ vespalib::stringref key) const;
void swap(Properties & rhs);
};
diff --git a/searchlib/src/vespa/searchlib/fef/test/ftlib.h b/searchlib/src/vespa/searchlib/fef/test/ftlib.h
index f4e4584cda1..0f1a5d8db45 100644
--- a/searchlib/src/vespa/searchlib/fef/test/ftlib.h
+++ b/searchlib/src/vespa/searchlib/fef/test/ftlib.h
@@ -21,7 +21,7 @@ using search::feature_t;
//---------------------------------------------------------------------------------------------------------------------
class StringList : public std::vector<vespalib::string> {
public:
- StringList &add(const vespalib::stringref &str) { push_back(str); return *this; }
+ StringList &add(vespalib::stringref str) { push_back(str); return *this; }
StringList &clear() { std::vector<vespalib::string>::clear(); return *this; }
};
diff --git a/searchlib/src/vespa/searchlib/index/dictionaryfile.h b/searchlib/src/vespa/searchlib/index/dictionaryfile.h
index 2f673c258f3..d4de6dd0af6 100644
--- a/searchlib/src/vespa/searchlib/index/dictionaryfile.h
+++ b/searchlib/src/vespa/searchlib/index/dictionaryfile.h
@@ -50,7 +50,7 @@ public:
/**
* Write word and counts. Only nonzero counts should be supplied.
*/
- virtual void writeWord(const vespalib::stringref &word, const PostingListCounts &counts) = 0;
+ virtual void writeWord(vespalib::stringref word, const PostingListCounts &counts) = 0;
};
@@ -66,7 +66,7 @@ public:
DictionaryFileRandRead();
virtual ~DictionaryFileRandRead();
- virtual bool lookup(const vespalib::stringref &word, uint64_t &wordNum,
+ virtual bool lookup(vespalib::stringref word, uint64_t &wordNum,
PostingListOffsetAndCounts &offsetAndCounts) = 0;
/**
diff --git a/searchlib/src/vespa/searchlib/index/indexbuilder.h b/searchlib/src/vespa/searchlib/index/indexbuilder.h
index 206eb064d31..e5769ccdb75 100644
--- a/searchlib/src/vespa/searchlib/index/indexbuilder.h
+++ b/searchlib/src/vespa/searchlib/index/indexbuilder.h
@@ -24,7 +24,7 @@ public:
~IndexBuilder();
virtual void
- startWord(const vespalib::stringref & word) = 0;
+ startWord(vespalib::stringref word) = 0;
virtual void
endWord() = 0;
diff --git a/searchlib/src/vespa/searchlib/index/olddictionaryfile.h b/searchlib/src/vespa/searchlib/index/olddictionaryfile.h
index eef500f512a..85c0f810e1e 100644
--- a/searchlib/src/vespa/searchlib/index/olddictionaryfile.h
+++ b/searchlib/src/vespa/searchlib/index/olddictionaryfile.h
@@ -177,7 +177,7 @@ public:
* Write word and counts. Only nonzero counts should be supplied.
*/
virtual void
- writeWord(const vespalib::stringref &word,
+ writeWord(vespalib::stringref word,
const std::vector<uint32_t> &indexes,
const std::vector<PostingListCounts> &counts) = 0;
diff --git a/searchlib/src/vespa/searchlib/memoryindex/memoryfieldindex.h b/searchlib/src/vespa/searchlib/memoryindex/memoryfieldindex.h
index c4583d7f49f..5b4ab7eb4fd 100644
--- a/searchlib/src/vespa/searchlib/memoryindex/memoryfieldindex.h
+++ b/searchlib/src/vespa/searchlib/memoryindex/memoryfieldindex.h
@@ -43,8 +43,8 @@ public:
class KeyComp {
private:
- const WordStore &_wordStore;
- const vespalib::stringref _word;
+ const WordStore &_wordStore;
+ const vespalib::stringref _word;
const char *
getWord(datastore::EntryRef wordRef) const
diff --git a/searchlib/src/vespa/searchlib/parsequery/parse.cpp b/searchlib/src/vespa/searchlib/parsequery/parse.cpp
index 60236275f76..cc6fd6ee915 100644
--- a/searchlib/src/vespa/searchlib/parsequery/parse.cpp
+++ b/searchlib/src/vespa/searchlib/parsequery/parse.cpp
@@ -58,7 +58,7 @@ void assert_type(ParseItem::ItemType type)
}
-ParseItem::ParseItem(ItemType type, const vespalib::stringref & idx, const char *term)
+ParseItem::ParseItem(ItemType type, vespalib::stringref idx, const char *term)
: PARSEITEM_DEFAULT_CONSTRUCTOR_LIST
{
assert_type(type);
diff --git a/searchlib/src/vespa/searchlib/parsequery/parse.h b/searchlib/src/vespa/searchlib/parsequery/parse.h
index d8cbdc696a5..15fb0e316e8 100644
--- a/searchlib/src/vespa/searchlib/parsequery/parse.h
+++ b/searchlib/src/vespa/searchlib/parsequery/parse.h
@@ -166,7 +166,7 @@ public:
* @param idx The name of the index of the ParseItem.
* @param term The actual term string of the ParseItem.
*/
- ParseItem(ItemType type, const vespalib::stringref & index, const char *term);
+ ParseItem(ItemType type, vespalib::stringref index, const char *term);
/**
* Overloaded constructor for ParseItem. Used for TERMs without index.
diff --git a/searchlib/src/vespa/searchlib/parsequery/simplequerystack.cpp b/searchlib/src/vespa/searchlib/parsequery/simplequerystack.cpp
index 36d76629f87..9f6ca50e326 100644
--- a/searchlib/src/vespa/searchlib/parsequery/simplequerystack.cpp
+++ b/searchlib/src/vespa/searchlib/parsequery/simplequerystack.cpp
@@ -124,7 +124,7 @@ private:
static ItemName _G_ItemName;
vespalib::string
-SimpleQueryStack::StackbufToString(const vespalib::stringref &theBuf)
+SimpleQueryStack::StackbufToString(vespalib::stringref theBuf)
{
vespalib::string result;
diff --git a/searchlib/src/vespa/searchlib/parsequery/simplequerystack.h b/searchlib/src/vespa/searchlib/parsequery/simplequerystack.h
index a9d99ca93f8..47bb213a8b3 100644
--- a/searchlib/src/vespa/searchlib/parsequery/simplequerystack.h
+++ b/searchlib/src/vespa/searchlib/parsequery/simplequerystack.h
@@ -93,7 +93,7 @@ public:
* @param theBuf The querystack encoded buffer.
* @return a fresh string
*/
- static vespalib::string StackbufToString(const vespalib::stringref &theBuf);
+ static vespalib::string StackbufToString(vespalib::stringref theBuf);
};
} // namespace search
diff --git a/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.cpp b/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.cpp
index 1938222b4ac..0365a4d4f14 100644
--- a/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.cpp
+++ b/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.cpp
@@ -9,7 +9,7 @@ using search::query::PredicateQueryTerm;
namespace search {
-SimpleQueryStackDumpIterator::SimpleQueryStackDumpIterator(const vespalib::stringref &buf) :
+SimpleQueryStackDumpIterator::SimpleQueryStackDumpIterator(vespalib::stringref buf) :
_buf(buf.begin()),
_bufEnd(buf.end()),
_bufLen(buf.size()),
diff --git a/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.h b/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.h
index dbb4becc819..c1049aabc55 100644
--- a/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.h
+++ b/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.h
@@ -75,7 +75,7 @@ public:
* @param buf A pointer to the buffer holding the stackdump
* @param buflen The length of the buffer in bytes
*/
- SimpleQueryStackDumpIterator(const vespalib::stringref &buf);
+ SimpleQueryStackDumpIterator(vespalib::stringref buf);
~SimpleQueryStackDumpIterator();
vespalib::stringref getStack() const { return vespalib::stringref(_buf, _bufLen); }
diff --git a/searchlib/src/vespa/searchlib/predicate/document_features_store.h b/searchlib/src/vespa/searchlib/predicate/document_features_store.h
index 5fa8e36e7de..73bd8c11f7a 100644
--- a/searchlib/src/vespa/searchlib/predicate/document_features_store.h
+++ b/searchlib/src/vespa/searchlib/predicate/document_features_store.h
@@ -39,7 +39,7 @@ class DocumentFeaturesStore {
}
public:
- KeyComp(const WordStore &word_store, const vespalib::stringref &word)
+ KeyComp(const WordStore &word_store, vespalib::stringref word)
: _word_store(word_store),
_word(word) {
}
diff --git a/searchlib/src/vespa/searchlib/query/queryterm.cpp b/searchlib/src/vespa/searchlib/query/queryterm.cpp
index 5eabaf35378..c48def1b24d 100644
--- a/searchlib/src/vespa/searchlib/query/queryterm.cpp
+++ b/searchlib/src/vespa/searchlib/query/queryterm.cpp
@@ -348,7 +348,7 @@ QueryTermSimple::~QueryTermSimple() = default;
namespace {
-bool isFullRange(const vespalib::stringref & s) {
+bool isFullRange(vespalib::stringref s) {
const size_t sz(s.size());
return (sz >= 3u) &&
(s[0] == '<' || s[0] == '[') &&
diff --git a/searchlib/src/vespa/searchlib/query/tree/querybuilder.h b/searchlib/src/vespa/searchlib/query/tree/querybuilder.h
index 3c6ff93457d..a2ad8eae84b 100644
--- a/searchlib/src/vespa/searchlib/query/tree/querybuilder.h
+++ b/searchlib/src/vespa/searchlib/query/tree/querybuilder.h
@@ -110,7 +110,7 @@ template <class NodeTypes>
typename NodeTypes::Or *createOr() { return new typename NodeTypes::Or; }
template <class NodeTypes>
-typename NodeTypes::WeakAnd *createWeakAnd(uint32_t minHits, const vespalib::stringref & view) {
+typename NodeTypes::WeakAnd *createWeakAnd(uint32_t minHits, vespalib::stringref view) {
return new typename NodeTypes::WeakAnd(minHits, view);
}
template <class NodeTypes>
@@ -118,24 +118,24 @@ typename NodeTypes::Equiv *createEquiv(int32_t id, Weight weight) {
return new typename NodeTypes::Equiv(id, weight);
}
template <class NodeTypes>
-typename NodeTypes::Phrase *createPhrase(const vespalib::stringref &view, int32_t id, Weight weight) {
+typename NodeTypes::Phrase *createPhrase(vespalib::stringref view, int32_t id, Weight weight) {
return new typename NodeTypes::Phrase(view, id, weight);
}
template <class NodeTypes>
-typename NodeTypes::SameElement *createSameElement(const vespalib::stringref &view) {
+typename NodeTypes::SameElement *createSameElement(vespalib::stringref view) {
return new typename NodeTypes::SameElement(view);
}
template <class NodeTypes>
-typename NodeTypes::WeightedSetTerm *createWeightedSetTerm(const vespalib::stringref &view, int32_t id, Weight weight) {
+typename NodeTypes::WeightedSetTerm *createWeightedSetTerm(vespalib::stringref view, int32_t id, Weight weight) {
return new typename NodeTypes::WeightedSetTerm(view, id, weight);
}
template <class NodeTypes>
-typename NodeTypes::DotProduct *createDotProduct(const vespalib::stringref &view, int32_t id, Weight weight) {
+typename NodeTypes::DotProduct *createDotProduct(vespalib::stringref view, int32_t id, Weight weight) {
return new typename NodeTypes::DotProduct(view, id, weight);
}
template <class NodeTypes>
typename NodeTypes::WandTerm *
-createWandTerm(const vespalib::stringref &view, int32_t id, Weight weight, uint32_t targetNumHits, int64_t scoreThreshold, double thresholdBoostFactor) {
+createWandTerm(vespalib::stringref view, int32_t id, Weight weight, uint32_t targetNumHits, int64_t scoreThreshold, double thresholdBoostFactor) {
return new typename NodeTypes::WandTerm(view, id, weight, targetNumHits, scoreThreshold, thresholdBoostFactor);
}
template <class NodeTypes>
@@ -155,50 +155,50 @@ typename NodeTypes::ONear *createONear(size_t distance) {
// Term nodes
template <class NodeTypes>
typename NodeTypes::NumberTerm *
-createNumberTerm(const vespalib::stringref &term, const vespalib::stringref &view, int32_t id, Weight weight) {
+createNumberTerm(vespalib::stringref term, vespalib::stringref view, int32_t id, Weight weight) {
return new typename NodeTypes::NumberTerm(term, view, id, weight);
}
template <class NodeTypes>
typename NodeTypes::PrefixTerm *
-createPrefixTerm(const vespalib::stringref &term, const vespalib::stringref &view, int32_t id, Weight weight) {
+createPrefixTerm(vespalib::stringref term, vespalib::stringref view, int32_t id, Weight weight) {
return new typename NodeTypes::PrefixTerm(term, view, id, weight);
}
template <class NodeTypes>
typename NodeTypes::RangeTerm *
-createRangeTerm(const Range &term, const vespalib::stringref &view, int32_t id, Weight weight) {
+createRangeTerm(const Range &term, vespalib::stringref view, int32_t id, Weight weight) {
return new typename NodeTypes::RangeTerm(term, view, id, weight);
}
template <class NodeTypes>
typename NodeTypes::StringTerm *
-createStringTerm(const vespalib::stringref &term, const vespalib::stringref &view, int32_t id, Weight weight) {
+createStringTerm(vespalib::stringref term, vespalib::stringref view, int32_t id, Weight weight) {
return new typename NodeTypes::StringTerm(term, view, id, weight);
}
template <class NodeTypes>
typename NodeTypes::SubstringTerm *
-createSubstringTerm(const vespalib::stringref &term, const vespalib::stringref &view, int32_t id, Weight weight) {
+createSubstringTerm(vespalib::stringref term, vespalib::stringref view, int32_t id, Weight weight) {
return new typename NodeTypes::SubstringTerm(term, view, id, weight);
}
template <class NodeTypes>
typename NodeTypes::SuffixTerm *
-createSuffixTerm(const vespalib::stringref &term, const vespalib::stringref &view, int32_t id, Weight weight) {
+createSuffixTerm(vespalib::stringref term, vespalib::stringref view, int32_t id, Weight weight) {
return new typename NodeTypes::SuffixTerm(term, view, id, weight);
}
template <class NodeTypes>
typename NodeTypes::LocationTerm *
-createLocationTerm(const Location &loc, const vespalib::stringref &view, int32_t id, Weight weight) {
+createLocationTerm(const Location &loc, vespalib::stringref view, int32_t id, Weight weight) {
return new typename NodeTypes::LocationTerm(loc, view, id, weight);
}
template <class NodeTypes>
typename NodeTypes::PredicateQuery *
-createPredicateQuery(PredicateQueryTerm::UP term, const vespalib::stringref &view, int32_t id, Weight weight) {
+createPredicateQuery(PredicateQueryTerm::UP term, vespalib::stringref view, int32_t id, Weight weight) {
return new typename NodeTypes::PredicateQuery(std::move(term), view, id, weight);
}
template <class NodeTypes>
typename NodeTypes::RegExpTerm *
-createRegExpTerm(const vespalib::stringref &term, const vespalib::stringref &view, int32_t id, Weight weight) {
+createRegExpTerm(vespalib::stringref term, vespalib::stringref view, int32_t id, Weight weight) {
return new typename NodeTypes::RegExpTerm(term, view, id, weight);
}
@@ -233,33 +233,33 @@ public:
typename NodeTypes::Or &addOr(int child_count) {
return addIntermediate(createOr<NodeTypes>(), child_count);
}
- typename NodeTypes::WeakAnd &addWeakAnd(int child_count, uint32_t minHits, const stringref & view) {
+ typename NodeTypes::WeakAnd &addWeakAnd(int child_count, uint32_t minHits, stringref view) {
return addIntermediate(createWeakAnd<NodeTypes>(minHits, view), child_count);
}
typename NodeTypes::Equiv &addEquiv(int child_count, int32_t id, Weight weight) {
return addIntermediate(createEquiv<NodeTypes>(id, weight), child_count);
}
- typename NodeTypes::Phrase &addPhrase(int child_count, const stringref &view, int32_t id, Weight weight) {
+ typename NodeTypes::Phrase &addPhrase(int child_count, stringref view, int32_t id, Weight weight) {
adjustWeight(weight);
typename NodeTypes::Phrase &node = addIntermediate(createPhrase<NodeTypes>(view, id, weight), child_count);
setWeightOverride(weight);
return node;
}
- typename NodeTypes::SameElement &addSameElement(int child_count, const stringref &view) {
+ typename NodeTypes::SameElement &addSameElement(int child_count, stringref view) {
return addIntermediate(createSameElement<NodeTypes>(view), child_count);
}
- typename NodeTypes::WeightedSetTerm &addWeightedSetTerm( int child_count, const stringref &view, int32_t id, Weight weight) {
+ typename NodeTypes::WeightedSetTerm &addWeightedSetTerm( int child_count, stringref view, int32_t id, Weight weight) {
adjustWeight(weight);
typename NodeTypes::WeightedSetTerm &node = addIntermediate(createWeightedSetTerm<NodeTypes>(view, id, weight), child_count);
return node;
}
- typename NodeTypes::DotProduct &addDotProduct( int child_count, const stringref &view, int32_t id, Weight weight) {
+ typename NodeTypes::DotProduct &addDotProduct( int child_count, stringref view, int32_t id, Weight weight) {
adjustWeight(weight);
typename NodeTypes::DotProduct &node = addIntermediate( createDotProduct<NodeTypes>(view, id, weight), child_count);
return node;
}
typename NodeTypes::WandTerm &addWandTerm(
- int child_count, const stringref &view,
+ int child_count, stringref view,
int32_t id, Weight weight, uint32_t targetNumHits,
int64_t scoreThreshold, double thresholdBoostFactor)
{
@@ -273,39 +273,39 @@ public:
return addIntermediate(createRank<NodeTypes>(), child_count);
}
- typename NodeTypes::NumberTerm &addNumberTerm(const stringref &term, const stringref &view, int32_t id, Weight weight) {
+ typename NodeTypes::NumberTerm &addNumberTerm(stringref term, stringref view, int32_t id, Weight weight) {
adjustWeight(weight);
return addTerm(createNumberTerm<NodeTypes>(term, view, id, weight));
}
- typename NodeTypes::PrefixTerm &addPrefixTerm(const stringref &term, const stringref &view, int32_t id, Weight weight) {
+ typename NodeTypes::PrefixTerm &addPrefixTerm(stringref term, stringref view, int32_t id, Weight weight) {
adjustWeight(weight);
return addTerm(createPrefixTerm<NodeTypes>(term, view, id, weight));
}
- typename NodeTypes::RangeTerm &addRangeTerm(const Range &range, const stringref &view, int32_t id, Weight weight) {
+ typename NodeTypes::RangeTerm &addRangeTerm(const Range &range, stringref view, int32_t id, Weight weight) {
adjustWeight(weight);
return addTerm(createRangeTerm<NodeTypes>(range, view, id, weight));
}
- typename NodeTypes::StringTerm &addStringTerm(const stringref &term, const stringref &view, int32_t id, Weight weight) {
+ typename NodeTypes::StringTerm &addStringTerm(stringref term, stringref view, int32_t id, Weight weight) {
adjustWeight(weight);
return addTerm(createStringTerm<NodeTypes>(term, view, id, weight));
}
- typename NodeTypes::SubstringTerm &addSubstringTerm(const stringref &t, const stringref &view, int32_t id, Weight weight) {
+ typename NodeTypes::SubstringTerm &addSubstringTerm(stringref t, stringref view, int32_t id, Weight weight) {
adjustWeight(weight);
return addTerm(createSubstringTerm<NodeTypes>(t, view, id, weight));
}
- typename NodeTypes::SuffixTerm &addSuffixTerm(const stringref &term, const stringref &view, int32_t id, Weight weight) {
+ typename NodeTypes::SuffixTerm &addSuffixTerm(stringref term, stringref view, int32_t id, Weight weight) {
adjustWeight(weight);
return addTerm(createSuffixTerm<NodeTypes>(term, view, id, weight));
}
- typename NodeTypes::LocationTerm &addLocationTerm(const Location &loc, const stringref &view, int32_t id, Weight weight) {
+ typename NodeTypes::LocationTerm &addLocationTerm(const Location &loc, stringref view, int32_t id, Weight weight) {
adjustWeight(weight);
return addTerm(createLocationTerm<NodeTypes>(loc, view, id, weight));
}
- typename NodeTypes::PredicateQuery &addPredicateQuery(PredicateQueryTerm::UP term, const stringref &view, int32_t id, Weight weight) {
+ typename NodeTypes::PredicateQuery &addPredicateQuery(PredicateQueryTerm::UP term, stringref view, int32_t id, Weight weight) {
adjustWeight(weight);
return addTerm(createPredicateQuery<NodeTypes>(std::move(term), view, id, weight));
}
- typename NodeTypes::RegExpTerm &addRegExpTerm(const stringref &term, const stringref &view, int32_t id, Weight weight) {
+ typename NodeTypes::RegExpTerm &addRegExpTerm(stringref term, stringref view, int32_t id, Weight weight) {
adjustWeight(weight);
return addTerm(createRegExpTerm<NodeTypes>(term, view, id, weight));
}
diff --git a/searchlib/src/vespa/searchlib/query/tree/simplequery.h b/searchlib/src/vespa/searchlib/query/tree/simplequery.h
index 557d0964bcb..707ed2aa0db 100644
--- a/searchlib/src/vespa/searchlib/query/tree/simplequery.h
+++ b/searchlib/src/vespa/searchlib/query/tree/simplequery.h
@@ -18,7 +18,7 @@ struct SimpleNear : Near { SimpleNear(size_t dist) : Near(dist) {} };
struct SimpleONear : ONear { SimpleONear(size_t dist) : ONear(dist) {} };
struct SimpleOr : Or {};
struct SimpleWeakAnd : WeakAnd {
- SimpleWeakAnd(uint32_t minHits, const vespalib::stringref & view) :
+ SimpleWeakAnd(uint32_t minHits, vespalib::stringref view) :
WeakAnd(minHits, view)
{}
};
@@ -27,78 +27,78 @@ struct SimpleEquiv : Equiv {
: Equiv(id, weight) {}
};
struct SimplePhrase : Phrase {
- SimplePhrase(const vespalib::stringref &view, int32_t id, Weight weight)
+ SimplePhrase(vespalib::stringref view, int32_t id, Weight weight)
: Phrase(view, id, weight) {}
};
struct SimpleSameElement : SameElement {
- SimpleSameElement(const vespalib::stringref &view) : SameElement(view) {}
+ SimpleSameElement(vespalib::stringref view) : SameElement(view) {}
};
struct SimpleWeightedSetTerm : WeightedSetTerm {
- SimpleWeightedSetTerm(const vespalib::stringref &view, int32_t id, Weight weight)
+ SimpleWeightedSetTerm(vespalib::stringref view, int32_t id, Weight weight)
: WeightedSetTerm(view, id, weight) {}
};
struct SimpleDotProduct : DotProduct {
- SimpleDotProduct(const vespalib::stringref &view, int32_t id, Weight weight)
+ SimpleDotProduct(vespalib::stringref view, int32_t id, Weight weight)
: DotProduct(view, id, weight) {}
};
struct SimpleWandTerm : WandTerm {
- SimpleWandTerm(const vespalib::stringref &view, int32_t id, Weight weight,
+ SimpleWandTerm(vespalib::stringref view, int32_t id, Weight weight,
uint32_t targetNumHits, int64_t scoreThreshold, double thresholdBoostFactor)
: WandTerm(view, id, weight, targetNumHits, scoreThreshold, thresholdBoostFactor) {}
};
struct SimpleRank : Rank {};
struct SimpleNumberTerm : NumberTerm {
- SimpleNumberTerm(Type term, const vespalib::stringref &view,
+ SimpleNumberTerm(Type term, vespalib::stringref view,
int32_t id, Weight weight)
: NumberTerm(term, view, id, weight) {
}
};
struct SimpleLocationTerm : LocationTerm {
- SimpleLocationTerm(const Type &term, const vespalib::stringref &view,
+ SimpleLocationTerm(const Type &term, vespalib::stringref view,
int32_t id, Weight weight)
: LocationTerm(term, view, id, weight) {
}
};
struct SimplePrefixTerm : PrefixTerm {
- SimplePrefixTerm(const Type &term, const vespalib::stringref &view,
+ SimplePrefixTerm(const Type &term, vespalib::stringref view,
int32_t id, Weight weight)
: PrefixTerm(term, view, id, weight) {
}
};
struct SimpleRangeTerm : RangeTerm {
- SimpleRangeTerm(const Type &term, const vespalib::stringref &view,
+ SimpleRangeTerm(const Type &term, vespalib::stringref view,
int32_t id, Weight weight)
: RangeTerm(term, view, id, weight) {
}
};
struct SimpleStringTerm : StringTerm {
- SimpleStringTerm(const Type &term, const vespalib::stringref &view,
+ SimpleStringTerm(const Type &term, vespalib::stringref view,
int32_t id, Weight weight)
: StringTerm(term, view, id, weight) {
}
};
struct SimpleSubstringTerm : SubstringTerm {
- SimpleSubstringTerm(const Type &term, const vespalib::stringref &view,
+ SimpleSubstringTerm(const Type &term, vespalib::stringref view,
int32_t id, Weight weight)
: SubstringTerm(term, view, id, weight) {
}
};
struct SimpleSuffixTerm : SuffixTerm {
- SimpleSuffixTerm(const Type &term, const vespalib::stringref &view,
+ SimpleSuffixTerm(const Type &term, vespalib::stringref view,
int32_t id, Weight weight)
: SuffixTerm(term, view, id, weight) {
}
};
struct SimplePredicateQuery : PredicateQuery {
SimplePredicateQuery(PredicateQueryTerm::UP term,
- const vespalib::stringref &view,
+ vespalib::stringref view,
int32_t id, Weight weight)
: PredicateQuery(std::move(term), view, id, weight) {
}
};
struct SimpleRegExpTerm : RegExpTerm {
- SimpleRegExpTerm(const Type &term, const vespalib::stringref &view,
+ SimpleRegExpTerm(const Type &term, vespalib::stringref view,
int32_t id, Weight weight)
: RegExpTerm(term, view, id, weight) {
}
diff --git a/searchlib/src/vespa/searchlib/query/tree/term.cpp b/searchlib/src/vespa/searchlib/query/tree/term.cpp
index de59752aa10..40044cc5dbe 100644
--- a/searchlib/src/vespa/searchlib/query/tree/term.cpp
+++ b/searchlib/src/vespa/searchlib/query/tree/term.cpp
@@ -7,7 +7,7 @@ namespace search::query {
Term::~Term() = default;
-Term::Term(const vespalib::stringref &view, int32_t id, Weight weight) :
+Term::Term(vespalib::stringref view, int32_t id, Weight weight) :
_view(view),
_id(id),
_weight(weight),
diff --git a/searchlib/src/vespa/searchlib/query/tree/term.h b/searchlib/src/vespa/searchlib/query/tree/term.h
index f931a54eda9..4fb0f44dd59 100644
--- a/searchlib/src/vespa/searchlib/query/tree/term.h
+++ b/searchlib/src/vespa/searchlib/query/tree/term.h
@@ -38,7 +38,7 @@ public:
bool usePositionData() const { return _position_data; }
protected:
- Term(const vespalib::stringref &view, int32_t id, Weight weight);
+ Term(vespalib::stringref view, int32_t id, Weight weight);
};
class TermNode : public Node, public Term {
diff --git a/searchlib/src/vespa/searchlib/query/tree/termnodes.h b/searchlib/src/vespa/searchlib/query/tree/termnodes.h
index 9ea2c54f1a0..35c23dde985 100644
--- a/searchlib/src/vespa/searchlib/query/tree/termnodes.h
+++ b/searchlib/src/vespa/searchlib/query/tree/termnodes.h
@@ -15,7 +15,7 @@ typedef TermBase<vespalib::string> StringBase;
class NumberTerm : public QueryNodeMixin<NumberTerm, StringBase >
{
public:
- NumberTerm(Type term, const vespalib::stringref &view, int32_t id, Weight weight)
+ NumberTerm(Type term, vespalib::stringref view, int32_t id, Weight weight)
: QueryNodeMixinType(term, view, id, weight) {}
virtual ~NumberTerm() = 0;
};
@@ -25,7 +25,7 @@ public:
class PrefixTerm : public QueryNodeMixin<PrefixTerm, StringBase >
{
public:
- PrefixTerm(const Type &term, const vespalib::stringref &view,
+ PrefixTerm(const Type &term, vespalib::stringref view,
int32_t id, Weight weight)
: QueryNodeMixinType(term, view, id, weight)
{}
@@ -37,7 +37,7 @@ public:
class RangeTerm : public QueryNodeMixin<RangeTerm, TermBase<Range> >
{
public:
- RangeTerm(const Type& term, const vespalib::stringref &view,
+ RangeTerm(const Type& term, vespalib::stringref view,
int32_t id, Weight weight)
: QueryNodeMixinType(term, view, id, weight)
{}
@@ -58,7 +58,7 @@ public:
class SubstringTerm : public QueryNodeMixin<SubstringTerm, StringBase >
{
public:
- SubstringTerm(const Type &term, const vespalib::stringref &view,
+ SubstringTerm(const Type &term, vespalib::stringref view,
int32_t id, Weight weight)
: QueryNodeMixinType(term, view, id, weight)
{}
@@ -70,7 +70,7 @@ class SubstringTerm : public QueryNodeMixin<SubstringTerm, StringBase >
class SuffixTerm : public QueryNodeMixin<SuffixTerm, StringBase >
{
public:
- SuffixTerm(const Type &term, const vespalib::stringref &view,
+ SuffixTerm(const Type &term, vespalib::stringref view,
int32_t id, Weight weight)
: QueryNodeMixinType(term, view, id, weight)
{}
@@ -82,7 +82,7 @@ public:
class LocationTerm : public QueryNodeMixin<LocationTerm, TermBase<Location> >
{
public:
- LocationTerm(const Type &term, const vespalib::stringref &view,
+ LocationTerm(const Type &term, vespalib::stringref view,
int32_t id, Weight weight)
: QueryNodeMixinType(term, view, id, weight)
{}
@@ -95,7 +95,7 @@ class PredicateQuery : public QueryNodeMixin<PredicateQuery,
TermBase<PredicateQueryTerm::UP> >
{
public:
- PredicateQuery(PredicateQueryTerm::UP term, const vespalib::stringref &view,
+ PredicateQuery(PredicateQueryTerm::UP term, vespalib::stringref view,
int32_t id, Weight weight)
: QueryNodeMixinType(std::move(term), view, id, weight)
{}
@@ -106,7 +106,7 @@ public:
class RegExpTerm : public QueryNodeMixin<RegExpTerm, StringBase>
{
public:
- RegExpTerm(const Type &term, const vespalib::stringref &view,
+ RegExpTerm(const Type &term, vespalib::stringref view,
int32_t id, Weight weight)
: QueryNodeMixinType(term, view, id, weight)
{}
diff --git a/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.cpp b/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.cpp
index bbd50e468e2..215b4db637a 100644
--- a/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.cpp
+++ b/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.cpp
@@ -86,7 +86,7 @@ TensorReader::getNumCells() {
}
-DenseTensorAttribute::DenseTensorAttribute(const vespalib::stringref &baseFileName,
+DenseTensorAttribute::DenseTensorAttribute(vespalib::stringref baseFileName,
const Config &cfg)
: TensorAttribute(baseFileName, cfg, _denseTensorStore),
_denseTensorStore(cfg.tensorType())
diff --git a/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.h b/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.h
index 68ca6ae7295..1924a3c6b89 100644
--- a/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.h
+++ b/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.h
@@ -19,7 +19,7 @@ class DenseTensorAttribute : public TensorAttribute
{
DenseTensorStore _denseTensorStore;
public:
- DenseTensorAttribute(const vespalib::stringref &baseFileName, const Config &cfg);
+ DenseTensorAttribute(vespalib::stringref baseFileName, const Config &cfg);
virtual ~DenseTensorAttribute();
virtual void setTensor(DocId docId, const Tensor &tensor) override;
virtual std::unique_ptr<Tensor> getTensor(DocId docId) const override;
diff --git a/searchlib/src/vespa/searchlib/tensor/generic_tensor_attribute.cpp b/searchlib/src/vespa/searchlib/tensor/generic_tensor_attribute.cpp
index 76ce89d9b45..b63c00426fa 100644
--- a/searchlib/src/vespa/searchlib/tensor/generic_tensor_attribute.cpp
+++ b/searchlib/src/vespa/searchlib/tensor/generic_tensor_attribute.cpp
@@ -36,7 +36,7 @@ public:
}
-GenericTensorAttribute::GenericTensorAttribute(const vespalib::stringref &baseFileName, const Config &cfg)
+GenericTensorAttribute::GenericTensorAttribute(vespalib::stringref baseFileName, const Config &cfg)
: TensorAttribute(baseFileName, cfg, _genericTensorStore)
{
}
diff --git a/searchlib/src/vespa/searchlib/tensor/generic_tensor_attribute.h b/searchlib/src/vespa/searchlib/tensor/generic_tensor_attribute.h
index 948e72cd41a..12a2a08b930 100644
--- a/searchlib/src/vespa/searchlib/tensor/generic_tensor_attribute.h
+++ b/searchlib/src/vespa/searchlib/tensor/generic_tensor_attribute.h
@@ -16,7 +16,7 @@ class GenericTensorAttribute : public TensorAttribute
{
GenericTensorStore _genericTensorStore; // data store for serialized tensors
public:
- GenericTensorAttribute(const vespalib::stringref &baseFileName, const Config &cfg);
+ GenericTensorAttribute(vespalib::stringref baseFileName, const Config &cfg);
virtual ~GenericTensorAttribute();
virtual void setTensor(DocId docId, const Tensor &tensor) override;
virtual std::unique_ptr<Tensor> getTensor(DocId docId) const override;
diff --git a/searchlib/src/vespa/searchlib/tensor/tensor_attribute.cpp b/searchlib/src/vespa/searchlib/tensor/tensor_attribute.cpp
index 2c005fb3277..494c12dcff9 100644
--- a/searchlib/src/vespa/searchlib/tensor/tensor_attribute.cpp
+++ b/searchlib/src/vespa/searchlib/tensor/tensor_attribute.cpp
@@ -38,7 +38,7 @@ shouldCreateMapper(const ValueType &tensorType)
}
-TensorAttribute::TensorAttribute(const vespalib::stringref &baseFileName,
+TensorAttribute::TensorAttribute(vespalib::stringref baseFileName,
const Config &cfg,
TensorStore &tensorStore)
: NotImplementedAttribute(baseFileName, cfg),
diff --git a/searchlib/src/vespa/searchlib/tensor/tensor_attribute.h b/searchlib/src/vespa/searchlib/tensor/tensor_attribute.h
index c5a76014485..1ef3d8a1a96 100644
--- a/searchlib/src/vespa/searchlib/tensor/tensor_attribute.h
+++ b/searchlib/src/vespa/searchlib/tensor/tensor_attribute.h
@@ -32,7 +32,7 @@ protected:
public:
DECLARE_IDENTIFIABLE_ABSTRACT(TensorAttribute);
using RefCopyVector = vespalib::Array<RefType>;
- TensorAttribute(const vespalib::stringref &baseFileName, const Config &cfg,
+ TensorAttribute(vespalib::stringref baseFileName, const Config &cfg,
TensorStore &tensorStore);
virtual ~TensorAttribute();
virtual const ITensorAttribute *asTensorAttribute() const override;
diff --git a/searchlib/src/vespa/searchlib/transactionlog/translogserver.cpp b/searchlib/src/vespa/searchlib/transactionlog/translogserver.cpp
index bfca137ba06..f9a82c8d20f 100644
--- a/searchlib/src/vespa/searchlib/transactionlog/translogserver.cpp
+++ b/searchlib/src/vespa/searchlib/transactionlog/translogserver.cpp
@@ -238,7 +238,7 @@ TransLogServer::getDomainNames()
}
Domain::SP
-TransLogServer::findDomain(const stringref &domainName)
+TransLogServer::findDomain(stringref domainName)
{
Guard domainGuard(_lock);
Domain::SP domain;
diff --git a/searchlib/src/vespa/searchlib/transactionlog/translogserver.h b/searchlib/src/vespa/searchlib/transactionlog/translogserver.h
index d78d3d39887..9dcc17a4a1f 100644
--- a/searchlib/src/vespa/searchlib/transactionlog/translogserver.h
+++ b/searchlib/src/vespa/searchlib/transactionlog/translogserver.h
@@ -69,7 +69,7 @@ private:
void logMetric() const;
std::vector<vespalib::string> getDomainNames();
- Domain::SP findDomain(const vespalib::stringref &name);
+ Domain::SP findDomain(vespalib::stringref name);
vespalib::string dir() const { return _baseDir + "/" + _name; }
vespalib::string domainList() const { return dir() + "/" + _name + ".domains"; }
diff --git a/searchsummary/src/vespa/searchsummary/docsummary/dynamicteaserdfw.cpp b/searchsummary/src/vespa/searchsummary/docsummary/dynamicteaserdfw.cpp
index 73c62db864c..4112afc1895 100644
--- a/searchsummary/src/vespa/searchsummary/docsummary/dynamicteaserdfw.cpp
+++ b/searchsummary/src/vespa/searchsummary/docsummary/dynamicteaserdfw.cpp
@@ -119,7 +119,7 @@ private:
public:
JuniperQueryAdapter(KeywordExtractor *kwExtractor,
- const vespalib::stringref &buf,
+ vespalib::stringref buf,
const search::fef::Properties *highlightTerms = NULL)
: _kwExtractor(kwExtractor), _buf(buf), _highlightTerms(highlightTerms), _visitor(NULL) {}
diff --git a/searchsummary/src/vespa/searchsummary/docsummary/getdocsumargs.h b/searchsummary/src/vespa/searchsummary/docsummary/getdocsumargs.h
index 44cb674597f..a5536a913e5 100644
--- a/searchsummary/src/vespa/searchsummary/docsummary/getdocsumargs.h
+++ b/searchsummary/src/vespa/searchsummary/docsummary/getdocsumargs.h
@@ -39,7 +39,7 @@ public:
void SetResultClassName(uint32_t len, const char *name) {
_resultClassName.assign(name, len);
}
- void setResultClassName(const vespalib::stringref & name) { _resultClassName = name; }
+ void setResultClassName(vespalib::stringref name) { _resultClassName = name; }
void SetStackDump(uint32_t stackItems,
uint32_t stackDumpLen, const char *stackDump);
void SetLocation(uint32_t locationLen, const char *location) {
diff --git a/searchsummary/src/vespa/searchsummary/docsummary/itokenizer.h b/searchsummary/src/vespa/searchsummary/docsummary/itokenizer.h
index 15a367761ec..e9fc3579f31 100644
--- a/searchsummary/src/vespa/searchsummary/docsummary/itokenizer.h
+++ b/searchsummary/src/vespa/searchsummary/docsummary/itokenizer.h
@@ -35,8 +35,8 @@ public:
_text(textBegin, textEnd - textBegin), _stem(), _type(type) {}
Token(const char * textBegin, const char * textEnd, const char * stemBegin, const char * stemEnd, Type type) :
_text(textBegin, textEnd - textBegin), _stem(stemBegin, stemEnd - stemBegin), _type(type) {}
- const vespalib::stringref & getText() const { return _text; }
- const vespalib::stringref & getStem() const { return _stem; }
+ vespalib::stringref getText() const { return _text; }
+ vespalib::stringref getStem() const { return _stem; }
bool hasStem() const { return _stem.data() != NULL; }
Type getType() const { return _type; }
};
diff --git a/searchsummary/src/vespa/searchsummary/docsummary/summaryfeaturesdfw.cpp b/searchsummary/src/vespa/searchsummary/docsummary/summaryfeaturesdfw.cpp
index a5fb9bd8539..7cf1e65fbc0 100644
--- a/searchsummary/src/vespa/searchsummary/docsummary/summaryfeaturesdfw.cpp
+++ b/searchsummary/src/vespa/searchsummary/docsummary/summaryfeaturesdfw.cpp
@@ -79,7 +79,7 @@ SummaryFeaturesDFW::insertField(uint32_t docid, GeneralResult *, GetDocsumsState
}
}
-void FeaturesDFW::featureDump(vespalib::JSONStringer & json, const vespalib::stringref & name, double feature)
+void FeaturesDFW::featureDump(vespalib::JSONStringer & json, vespalib::stringref name, double feature)
{
json.appendKey(name);
if (std::isnan(feature) || std::isinf(feature)) {
diff --git a/searchsummary/src/vespa/searchsummary/docsummary/summaryfeaturesdfw.h b/searchsummary/src/vespa/searchsummary/docsummary/summaryfeaturesdfw.h
index 5229e26475b..e417e89cf04 100644
--- a/searchsummary/src/vespa/searchsummary/docsummary/summaryfeaturesdfw.h
+++ b/searchsummary/src/vespa/searchsummary/docsummary/summaryfeaturesdfw.h
@@ -13,7 +13,7 @@ class IDocsumEnvironment;
class FeaturesDFW : public IDocsumFieldWriter
{
protected:
- void featureDump(vespalib::JSONStringer & json, const vespalib::stringref & name, double feature);
+ void featureDump(vespalib::JSONStringer & json, vespalib::stringref name, double feature);
};
class SummaryFeaturesDFW : public FeaturesDFW
diff --git a/slobrok/src/vespa/slobrok/sbregister.cpp b/slobrok/src/vespa/slobrok/sbregister.cpp
index a2ec4a4a7b2..8f8e42a39aa 100644
--- a/slobrok/src/vespa/slobrok/sbregister.cpp
+++ b/slobrok/src/vespa/slobrok/sbregister.cpp
@@ -32,7 +32,7 @@ createSpec(FRT_Supervisor &orb)
void
-discard(std::vector<vespalib::string> &vec, const vespalib::stringref & val)
+discard(std::vector<vespalib::string> &vec, vespalib::stringref val)
{
uint32_t i = 0;
uint32_t size = vec.size();
@@ -94,7 +94,7 @@ RegisterAPI::~RegisterAPI()
void
-RegisterAPI::registerName(const vespalib::stringref & name)
+RegisterAPI::registerName(vespalib::stringref name)
{
std::lock_guard<std::mutex> guard(_lock);
for (uint32_t i = 0; i < _names.size(); ++i) {
@@ -111,7 +111,7 @@ RegisterAPI::registerName(const vespalib::stringref & name)
void
-RegisterAPI::unregisterName(const vespalib::stringref & name)
+RegisterAPI::unregisterName(vespalib::stringref name)
{
std::lock_guard<std::mutex> guard(_lock);
_busy = true;
diff --git a/slobrok/src/vespa/slobrok/sbregister.h b/slobrok/src/vespa/slobrok/sbregister.h
index d8812c0f3d0..234e6c076d4 100644
--- a/slobrok/src/vespa/slobrok/sbregister.h
+++ b/slobrok/src/vespa/slobrok/sbregister.h
@@ -40,13 +40,13 @@ public:
* @brief Register a service with the slobrok cluster.
* @param name service name to register
**/
- void registerName(const vespalib::stringref & name);
+ void registerName(vespalib::stringref name);
/**
* @brief Unregister a service with the slobrok cluster
* @param name service name to unregister
**/
- void unregisterName(const vespalib::stringref & name);
+ void unregisterName(vespalib::stringref name);
/**
* @brief Check progress
diff --git a/staging_vespalib/src/vespa/vespalib/net/json_handler_repo.cpp b/staging_vespalib/src/vespa/vespalib/net/json_handler_repo.cpp
index 97bb4a9aac7..3082615c59e 100644
--- a/staging_vespalib/src/vespa/vespalib/net/json_handler_repo.cpp
+++ b/staging_vespalib/src/vespa/vespalib/net/json_handler_repo.cpp
@@ -18,7 +18,7 @@ void remove_seq(T &collection, size_t seq) {
} // namespace vespalib::<unnamed>
size_t
-JsonHandlerRepo::State::bind(const vespalib::stringref &path_prefix,
+JsonHandlerRepo::State::bind(vespalib::stringref path_prefix,
const JsonGetHandler &get_handler)
{
std::lock_guard<std::mutex> guard(lock);
@@ -29,7 +29,7 @@ JsonHandlerRepo::State::bind(const vespalib::stringref &path_prefix,
}
size_t
-JsonHandlerRepo::State::add_root_resource(const vespalib::stringref &path)
+JsonHandlerRepo::State::add_root_resource(vespalib::stringref path)
{
std::lock_guard<std::mutex> guard(lock);
size_t my_seq = ++seq;
@@ -47,14 +47,14 @@ JsonHandlerRepo::State::unbind(size_t my_seq) {
//-----------------------------------------------------------------------------
JsonHandlerRepo::Token::UP
-JsonHandlerRepo::bind(const vespalib::stringref &path_prefix,
+JsonHandlerRepo::bind(vespalib::stringref path_prefix,
const JsonGetHandler &get_handler)
{
return Token::UP(new Unbinder(_state, _state->bind(path_prefix, get_handler)));
}
JsonHandlerRepo::Token::UP
-JsonHandlerRepo::add_root_resource(const vespalib::stringref &path)
+JsonHandlerRepo::add_root_resource(vespalib::stringref path)
{
return Token::UP(new Unbinder(_state, _state->add_root_resource(path)));
}
diff --git a/staging_vespalib/src/vespa/vespalib/net/json_handler_repo.h b/staging_vespalib/src/vespa/vespalib/net/json_handler_repo.h
index b9c8cfdc169..d1450f957de 100644
--- a/staging_vespalib/src/vespa/vespalib/net/json_handler_repo.h
+++ b/staging_vespalib/src/vespa/vespalib/net/json_handler_repo.h
@@ -34,7 +34,7 @@ private:
vespalib::string path_prefix;
const JsonGetHandler *handler;
Hook(size_t seq_in,
- const vespalib::stringref &prefix_in,
+ vespalib::stringref prefix_in,
const JsonGetHandler &handler_in)
: seq(seq_in), path_prefix(prefix_in), handler(&handler_in) {}
bool operator <(const Hook &rhs) const {
@@ -59,9 +59,9 @@ private:
std::vector<Hook> hooks;
std::vector<Resource> root_resources;
State() : lock(), seq(0), hooks(), root_resources() {}
- size_t bind(const vespalib::stringref &path_prefix,
+ size_t bind(vespalib::stringref path_prefix,
const JsonGetHandler &get_handler);
- size_t add_root_resource(const vespalib::stringref &path);
+ size_t add_root_resource(vespalib::stringref path);
void unbind(size_t my_seq);
};
@@ -79,9 +79,9 @@ private:
public:
JsonHandlerRepo() : _state(std::make_shared<State>()) {}
- Token::UP bind(const vespalib::stringref &path_prefix,
+ Token::UP bind(vespalib::stringref path_prefix,
const JsonGetHandler &get_handler);
- Token::UP add_root_resource(const vespalib::stringref &path);
+ Token::UP add_root_resource(vespalib::stringref path);
std::vector<vespalib::string> get_root_resources() const;
vespalib::string get(const vespalib::string &host,
const vespalib::string &path,
diff --git a/staging_vespalib/src/vespa/vespalib/objects/asciiserializer.cpp b/staging_vespalib/src/vespa/vespalib/objects/asciiserializer.cpp
index 5006e267acc..698900a8e80 100644
--- a/staging_vespalib/src/vespa/vespalib/objects/asciiserializer.cpp
+++ b/staging_vespalib/src/vespa/vespalib/objects/asciiserializer.cpp
@@ -39,7 +39,7 @@ AsciiSerializer &AsciiSerializer::put(const IFieldBase &, double value) {
return *this;
}
-AsciiSerializer &AsciiSerializer::put(const IFieldBase &, const stringref & value) {
+AsciiSerializer &AsciiSerializer::put(const IFieldBase &, stringref value) {
_stream << value;
return *this;
}
diff --git a/staging_vespalib/src/vespa/vespalib/objects/asciiserializer.h b/staging_vespalib/src/vespa/vespalib/objects/asciiserializer.h
index 999adcce575..0066c96934e 100644
--- a/staging_vespalib/src/vespa/vespalib/objects/asciiserializer.h
+++ b/staging_vespalib/src/vespa/vespalib/objects/asciiserializer.h
@@ -18,7 +18,7 @@ public:
AsciiSerializer &put(const IFieldBase &field, uint64_t value) override;
AsciiSerializer &put(const IFieldBase &field, float value) override;
AsciiSerializer &put(const IFieldBase &field, double value) override;
- AsciiSerializer &put(const IFieldBase &field, const stringref &val) override;
+ AsciiSerializer &put(const IFieldBase &field, stringref val) override;
const asciistream &getStream() const { return _stream; }
asciistream &getStream() { return _stream; }
diff --git a/staging_vespalib/src/vespa/vespalib/objects/nboserializer.cpp b/staging_vespalib/src/vespa/vespalib/objects/nboserializer.cpp
index 91c2eb7239b..e56ca6ca026 100644
--- a/staging_vespalib/src/vespa/vespalib/objects/nboserializer.cpp
+++ b/staging_vespalib/src/vespa/vespalib/objects/nboserializer.cpp
@@ -43,7 +43,7 @@ NBOSerializer &NBOSerializer::put(const IFieldBase &, double value) {
return *this;
}
-NBOSerializer &NBOSerializer::put(const IFieldBase &, const stringref & value) {
+NBOSerializer &NBOSerializer::put(const IFieldBase &, stringref value) {
_stream << value;
return *this;
}
diff --git a/staging_vespalib/src/vespa/vespalib/objects/nboserializer.h b/staging_vespalib/src/vespa/vespalib/objects/nboserializer.h
index 516005c2b3f..ee75710dbfb 100644
--- a/staging_vespalib/src/vespa/vespalib/objects/nboserializer.h
+++ b/staging_vespalib/src/vespa/vespalib/objects/nboserializer.h
@@ -18,7 +18,7 @@ public:
NBOSerializer &put(const IFieldBase &field, uint64_t value) override;
NBOSerializer &put(const IFieldBase &field, float value) override;
NBOSerializer &put(const IFieldBase &field, double value) override;
- NBOSerializer &put(const IFieldBase &field, const stringref &val) override;
+ NBOSerializer &put(const IFieldBase &field, stringref val) override;
NBOSerializer &get(const IFieldBase &field, bool &value) override;
NBOSerializer &get(const IFieldBase &field, uint8_t &value) override;
diff --git a/staging_vespalib/src/vespa/vespalib/objects/serializer.h b/staging_vespalib/src/vespa/vespalib/objects/serializer.h
index 7d506d6a6bd..0458903e830 100644
--- a/staging_vespalib/src/vespa/vespalib/objects/serializer.h
+++ b/staging_vespalib/src/vespa/vespalib/objects/serializer.h
@@ -21,7 +21,7 @@ public:
virtual Serializer & put(const IFieldBase & field, uint64_t value) = 0;
virtual Serializer & put(const IFieldBase & field, float value) = 0;
virtual Serializer & put(const IFieldBase & field, double value) = 0;
- virtual Serializer & put(const IFieldBase & field, const stringref & value) = 0;
+ virtual Serializer & put(const IFieldBase & field, stringref value) = 0;
virtual Serializer & put(const IFieldBase & field, const Identifiable & value);
virtual Serializer & put(const IFieldBase & field, int8_t value);
@@ -40,7 +40,7 @@ public:
Serializer & operator << (int64_t value) { return put(_unspecifiedField, value); }
Serializer & operator << (float value) { return put(_unspecifiedField, value); }
Serializer & operator << (double value) { return put(_unspecifiedField, value); }
- Serializer & operator << (const stringref & value) { return put(_unspecifiedField, value); }
+ Serializer & operator << (stringref value) { return put(_unspecifiedField, value); }
template <typename T>
Serializer & operator << (const vespalib::Array<T> & v);
template <typename T>
diff --git a/staging_vespalib/src/vespa/vespalib/objects/visit.h b/staging_vespalib/src/vespa/vespalib/objects/visit.h
index 4d45ceea7fb..22c73dceefd 100644
--- a/staging_vespalib/src/vespa/vespalib/objects/visit.h
+++ b/staging_vespalib/src/vespa/vespalib/objects/visit.h
@@ -22,5 +22,5 @@ void visit(vespalib::ObjectVisitor &self, const vespalib::string &name, uint64_t
void visit(vespalib::ObjectVisitor &self, const vespalib::string &name, float value);
void visit(vespalib::ObjectVisitor &self, const vespalib::string &name, double value);
void visit(vespalib::ObjectVisitor &self, const vespalib::string &name, const vespalib::string &value);
-void visit(vespalib::ObjectVisitor &self, const vespalib::string &name, const vespalib::stringref &value);
+void visit(vespalib::ObjectVisitor &self, const vespalib::string &name, vespalib::stringref value);
void visit(vespalib::ObjectVisitor &self, const vespalib::string &name, const char *value);
diff --git a/staging_vespalib/src/vespa/vespalib/util/growablebytebuffer.cpp b/staging_vespalib/src/vespa/vespalib/util/growablebytebuffer.cpp
index 22064864b22..57e88873e81 100644
--- a/staging_vespalib/src/vespa/vespalib/util/growablebytebuffer.cpp
+++ b/staging_vespalib/src/vespa/vespalib/util/growablebytebuffer.cpp
@@ -69,7 +69,7 @@ GrowableByteBuffer::putDouble(double v)
}
void
-GrowableByteBuffer::putString(const vespalib::stringref& v)
+GrowableByteBuffer::putString(vespalib::stringref v)
{
putInt(v.size());
putBytes(v.data(), v.size());
diff --git a/staging_vespalib/src/vespa/vespalib/util/growablebytebuffer.h b/staging_vespalib/src/vespa/vespalib/util/growablebytebuffer.h
index 787ea0e028e..beb7e93d343 100644
--- a/staging_vespalib/src/vespa/vespalib/util/growablebytebuffer.h
+++ b/staging_vespalib/src/vespa/vespalib/util/growablebytebuffer.h
@@ -70,7 +70,7 @@ public:
/**
Adds a string to the buffer.
*/
- void putString(const vespalib::stringref & v);
+ void putString(vespalib::stringref v);
/**
Adds a single byte to the buffer.
diff --git a/staging_vespalib/src/vespa/vespalib/util/jsonwriter.cpp b/staging_vespalib/src/vespa/vespalib/util/jsonwriter.cpp
index 0ad52f9aac2..71017e28c4c 100644
--- a/staging_vespalib/src/vespa/vespalib/util/jsonwriter.cpp
+++ b/staging_vespalib/src/vespa/vespalib/util/jsonwriter.cpp
@@ -173,7 +173,7 @@ JSONWriter::appendNull()
}
JSONWriter &
-JSONWriter::appendKey(const vespalib::stringref & str)
+JSONWriter::appendKey(stringref str)
{
considerComma();
indent();
@@ -243,7 +243,7 @@ JSONWriter::appendUInt64(uint64_t v)
}
JSONWriter &
-JSONWriter::appendString(const vespalib::stringref & str)
+JSONWriter::appendString(stringref str)
{
considerComma();
quote(str.data(), str.size());
@@ -252,7 +252,7 @@ JSONWriter::appendString(const vespalib::stringref & str)
}
JSONWriter &
-JSONWriter::appendJSON(const vespalib::stringref & json)
+JSONWriter::appendJSON(stringref json)
{
considerComma();
(*_os) << json;
diff --git a/staging_vespalib/src/vespa/vespalib/util/jsonwriter.h b/staging_vespalib/src/vespa/vespalib/util/jsonwriter.h
index 77a805b3c0d..0e9e3e10bc3 100644
--- a/staging_vespalib/src/vespa/vespalib/util/jsonwriter.h
+++ b/staging_vespalib/src/vespa/vespalib/util/jsonwriter.h
@@ -49,14 +49,14 @@ public:
JSONWriter & beginArray();
JSONWriter & endArray();
JSONWriter & appendNull();
- JSONWriter & appendKey(const stringref & str);
+ JSONWriter & appendKey(stringref str);
JSONWriter & appendBool(bool v);
JSONWriter & appendDouble(double v);
JSONWriter & appendFloat(float v);
JSONWriter & appendInt64(int64_t v);
JSONWriter & appendUInt64(uint64_t v);
- JSONWriter & appendString(const stringref & str);
- JSONWriter & appendJSON(const stringref & json);
+ JSONWriter & appendString(stringref str);
+ JSONWriter & appendJSON(stringref json);
void setPretty() { _pretty = true; };
};
diff --git a/staging_vespalib/src/vespa/vespalib/util/librarypool.cpp b/staging_vespalib/src/vespa/vespalib/util/librarypool.cpp
index 45ba2979dc2..2a3ca21c369 100644
--- a/staging_vespalib/src/vespa/vespalib/util/librarypool.cpp
+++ b/staging_vespalib/src/vespa/vespalib/util/librarypool.cpp
@@ -19,7 +19,7 @@ LibraryPool::~LibraryPool()
}
void
-LibraryPool::loadLibrary(const stringref & libName)
+LibraryPool::loadLibrary(stringref libName)
{
LockGuard guard(_lock);
if (_libraries.find(libName) == _libraries.end()) {
@@ -36,7 +36,7 @@ LibraryPool::loadLibrary(const stringref & libName)
}
FastOS_DynamicLibrary *
-LibraryPool::get(const stringref & name)
+LibraryPool::get(stringref name)
{
LockGuard guard(_lock);
LibraryMap::const_iterator found(_libraries.find(name));
@@ -46,7 +46,7 @@ LibraryPool::get(const stringref & name)
}
const FastOS_DynamicLibrary *
-LibraryPool::get(const stringref & name) const
+LibraryPool::get(stringref name) const
{
LockGuard guard(_lock);
LibraryMap::const_iterator found(_libraries.find(name));
diff --git a/staging_vespalib/src/vespa/vespalib/util/librarypool.h b/staging_vespalib/src/vespa/vespalib/util/librarypool.h
index 1d8ea1eabec..f9149589338 100644
--- a/staging_vespalib/src/vespa/vespalib/util/librarypool.h
+++ b/staging_vespalib/src/vespa/vespalib/util/librarypool.h
@@ -20,14 +20,14 @@ public:
* @param name The name of the library to load. That is without the 'lib' prefix and the '.so' extension.
* @throws IllegalArgumentException if there are any errors.
*/
- void loadLibrary(const vespalib::stringref & name);
+ void loadLibrary(stringref name);
/**
* Will return the library requested. NULL if not found.
* @param name The name of the library as given in the @ref loadLibrary call.
* @return The library that has already been loaded. NULL if not found.
*/
- FastOS_DynamicLibrary *get(const vespalib::stringref & name);
- const FastOS_DynamicLibrary *get(const vespalib::stringref & name) const;
+ FastOS_DynamicLibrary *get(stringref name);
+ const FastOS_DynamicLibrary *get(stringref name) const;
private:
typedef std::shared_ptr<FastOS_DynamicLibrary> DynamicLibrarySP;
typedef std::map<vespalib::string, DynamicLibrarySP> LibraryMap;
diff --git a/staging_vespalib/src/vespa/vespalib/util/xmlstream.cpp b/staging_vespalib/src/vespa/vespalib/util/xmlstream.cpp
index 0390933f89a..6399faeefec 100644
--- a/staging_vespalib/src/vespa/vespalib/util/xmlstream.cpp
+++ b/staging_vespalib/src/vespa/vespalib/util/xmlstream.cpp
@@ -446,18 +446,18 @@ XmlContentWrapper::XmlContentWrapper(const char* value, uint32_t size)
using CharP = char *;
using ConstCharP = const char *;
-template XmlAttribute::XmlAttribute(const std::string &, const std::string &, unsigned int);
-template XmlAttribute::XmlAttribute(const std::string &, const vespalib::string &, unsigned int);
-template XmlAttribute::XmlAttribute(const std::string &, const vespalib::stringref &, unsigned int);
-template XmlAttribute::XmlAttribute(const std::string &, const CharP &, unsigned int);
-template XmlAttribute::XmlAttribute(const std::string &, const ConstCharP &, unsigned int);
-template XmlAttribute::XmlAttribute(const std::string &, const bool &, unsigned int);
-template XmlAttribute::XmlAttribute(const std::string &, const int16_t &, unsigned int);
-template XmlAttribute::XmlAttribute(const std::string &, const int32_t &, unsigned int);
-template XmlAttribute::XmlAttribute(const std::string &, const int64_t &, unsigned int);
-template XmlAttribute::XmlAttribute(const std::string &, const uint16_t &, unsigned int);
-template XmlAttribute::XmlAttribute(const std::string &, const uint32_t &, unsigned int);
-template XmlAttribute::XmlAttribute(const std::string &, const uint64_t &, unsigned int);
-template XmlAttribute::XmlAttribute(const std::string &, const double &, unsigned int);
+template XmlAttribute::XmlAttribute(const std::string &, std::string, unsigned int);
+template XmlAttribute::XmlAttribute(const std::string &, vespalib::string, unsigned int);
+template XmlAttribute::XmlAttribute(const std::string &, vespalib::stringref, unsigned int);
+template XmlAttribute::XmlAttribute(const std::string &, CharP, unsigned int);
+template XmlAttribute::XmlAttribute(const std::string &, ConstCharP, unsigned int);
+template XmlAttribute::XmlAttribute(const std::string &, bool, unsigned int);
+template XmlAttribute::XmlAttribute(const std::string &, int16_t, unsigned int);
+template XmlAttribute::XmlAttribute(const std::string &, int32_t, unsigned int);
+template XmlAttribute::XmlAttribute(const std::string &, int64_t, unsigned int);
+template XmlAttribute::XmlAttribute(const std::string &, uint16_t, unsigned int);
+template XmlAttribute::XmlAttribute(const std::string &, uint32_t, unsigned int);
+template XmlAttribute::XmlAttribute(const std::string &, uint64_t, unsigned int);
+template XmlAttribute::XmlAttribute(const std::string &, double, unsigned int);
}
diff --git a/staging_vespalib/src/vespa/vespalib/util/xmlstream.h b/staging_vespalib/src/vespa/vespalib/util/xmlstream.h
index 3185fa8c119..5455251eea1 100644
--- a/staging_vespalib/src/vespa/vespalib/util/xmlstream.h
+++ b/staging_vespalib/src/vespa/vespalib/util/xmlstream.h
@@ -90,7 +90,7 @@ public:
XmlAttribute(const XmlAttribute&);
/** Add any value that can be written to an ostringstream. */
template<typename T>
- XmlAttribute(const std::string& name, const T& value, uint32_t flags = NONE);
+ XmlAttribute(const std::string& name, T value, uint32_t flags = NONE);
XmlAttribute(const std::string& name, const char * value, uint32_t flags = NONE);
~XmlAttribute();
diff --git a/staging_vespalib/src/vespa/vespalib/util/xmlstream.hpp b/staging_vespalib/src/vespa/vespalib/util/xmlstream.hpp
index babcf91e791..7ee7d8d0b82 100644
--- a/staging_vespalib/src/vespa/vespalib/util/xmlstream.hpp
+++ b/staging_vespalib/src/vespa/vespalib/util/xmlstream.hpp
@@ -9,7 +9,7 @@
namespace vespalib::xml {
template<typename T>
-XmlAttribute::XmlAttribute(const std::string& name, const T& value, uint32_t flags)
+XmlAttribute::XmlAttribute(const std::string& name, T value, uint32_t flags)
: _name(name),
_value(),
_next()
diff --git a/storage/src/tests/visiting/commandqueuetest.cpp b/storage/src/tests/visiting/commandqueuetest.cpp
index 7b6d5dcafd6..e335df353f6 100644
--- a/storage/src/tests/visiting/commandqueuetest.cpp
+++ b/storage/src/tests/visiting/commandqueuetest.cpp
@@ -34,7 +34,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION(CommandQueueTest);
namespace {
std::shared_ptr<api::CreateVisitorCommand> getCommand(
- const vespalib::stringref & name, int timeout,
+ vespalib::stringref name, int timeout,
uint8_t priority = 0)
{
vespalib::asciistream ost;
diff --git a/storage/src/vespa/storage/common/hostreporter/kernelmetrictool.cpp b/storage/src/vespa/storage/common/hostreporter/kernelmetrictool.cpp
index c8d73737d7c..aa985f282f1 100644
--- a/storage/src/vespa/storage/common/hostreporter/kernelmetrictool.cpp
+++ b/storage/src/vespa/storage/common/hostreporter/kernelmetrictool.cpp
@@ -30,8 +30,8 @@ vespalib::string stripWhitespace(const vespalib::string& s) {
return s.substr(start, stop - start + 1);
}
-vespalib::string getLine(const vespalib::stringref& key,
- const vespalib::stringref& content)
+vespalib::string getLine(vespalib::stringref key,
+ vespalib::stringref content)
{
vespalib::string::size_type start(0);
vespalib::string::size_type stop(content.find('\n'));
@@ -63,7 +63,7 @@ uint32_t getTokenCount(const vespalib::string& line) {
return st.size();
}
-uint64_t toLong(const vespalib::stringref& s, int base) {
+uint64_t toLong(vespalib::stringref s, int base) {
char* endptr;
// FIXME C++17 range-safe from_chars() instead of strtoull()
uint64_t result(strtoull(s.data(), &endptr, base));
diff --git a/storage/src/vespa/storage/common/hostreporter/kernelmetrictool.h b/storage/src/vespa/storage/common/hostreporter/kernelmetrictool.h
index dd41cb1fcd2..80a2b2738bc 100644
--- a/storage/src/vespa/storage/common/hostreporter/kernelmetrictool.h
+++ b/storage/src/vespa/storage/common/hostreporter/kernelmetrictool.h
@@ -15,14 +15,14 @@ vespalib::string readFile(const char* fileName);
vespalib::string stripWhitespace(const vespalib::string& s);
-vespalib::string getLine(const vespalib::stringref& key,
- const vespalib::stringref& content);
+vespalib::string getLine(vespalib::stringref key,
+ vespalib::stringref content);
vespalib::string getToken(uint32_t index, const vespalib::string& line);
uint32_t getTokenCount(const vespalib::string& line);
-uint64_t toLong(const vespalib::stringref& s, int base = 0) ;
+uint64_t toLong(vespalib::stringref s, int base = 0) ;
} /* namespace kernelmetrictool */
} /* namespace storage */
diff --git a/storage/src/vespa/storage/config/distributorconfiguration.h b/storage/src/vespa/storage/config/distributorconfiguration.h
index d3e589f9d00..5dfc4f66cb8 100644
--- a/storage/src/vespa/storage/config/distributorconfiguration.h
+++ b/storage/src/vespa/storage/config/distributorconfiguration.h
@@ -70,11 +70,11 @@ public:
_lastGarbageCollectionChange = lastChangeTime;
}
- bool stateCheckerIsActive(const vespalib::stringref & stateCheckerName) const {
+ bool stateCheckerIsActive(vespalib::stringref stateCheckerName) const {
return _blockedStateCheckers.find(stateCheckerName) == _blockedStateCheckers.end();
}
- void disableStateChecker(const vespalib::stringref & stateCheckerName) {
+ void disableStateChecker(vespalib::stringref stateCheckerName) {
_blockedStateCheckers.insert(stateCheckerName);
}
diff --git a/storage/src/vespa/storage/storageserver/fnetlistener.cpp b/storage/src/vespa/storage/storageserver/fnetlistener.cpp
index 32ea8982ffb..1a72190b2a6 100644
--- a/storage/src/vespa/storage/storageserver/fnetlistener.cpp
+++ b/storage/src/vespa/storage/storageserver/fnetlistener.cpp
@@ -43,7 +43,7 @@ FNetListener::getListenPort() const
}
void
-FNetListener::registerHandle(const vespalib::stringref & handle) {
+FNetListener::registerHandle(vespalib::stringref handle) {
_slobrokRegister.registerName(handle);
while (_slobrokRegister.busy()) {
LOG(debug, "Waiting to register in slobrok");
diff --git a/storage/src/vespa/storage/storageserver/fnetlistener.h b/storage/src/vespa/storage/storageserver/fnetlistener.h
index bf004a3eb2b..abcba18e0be 100644
--- a/storage/src/vespa/storage/storageserver/fnetlistener.h
+++ b/storage/src/vespa/storage/storageserver/fnetlistener.h
@@ -27,7 +27,7 @@ public:
void RPC_getCurrentTime(FRT_RPCRequest *req);
void RPC_setDistributionStates(FRT_RPCRequest* req);
- void registerHandle(const vespalib::stringref & handle);
+ void registerHandle(vespalib::stringref handle);
void close();
int getListenPort() const;
diff --git a/storage/src/vespa/storage/visiting/visitorthread.cpp b/storage/src/vespa/storage/visiting/visitorthread.cpp
index 6bf28b08540..d5b56c3ee53 100644
--- a/storage/src/vespa/storage/visiting/visitorthread.cpp
+++ b/storage/src/vespa/storage/visiting/visitorthread.cpp
@@ -365,7 +365,7 @@ VisitorThread::handleNonExistingVisitorCall(const Event& entry,
* Utility function to get a visitor instance from a given library.
*/
std::shared_ptr<Visitor>
-VisitorThread::createVisitor(const vespalib::stringref & libName,
+VisitorThread::createVisitor(vespalib::stringref libName,
const vdslib::Parameters& params,
vespalib::asciistream & error)
{
diff --git a/storage/src/vespa/storage/visiting/visitorthread.h b/storage/src/vespa/storage/visiting/visitorthread.h
index 97ca70f3761..a9dcd8f5806 100644
--- a/storage/src/vespa/storage/visiting/visitorthread.h
+++ b/storage/src/vespa/storage/visiting/visitorthread.h
@@ -125,7 +125,7 @@ private:
void trimRecentlyCompletedList(framework::SecondTime currentTime);
void handleNonExistingVisitorCall(const Event& entry, api::ReturnCode& code);
- std::shared_ptr<Visitor> createVisitor(const vespalib::stringref & libName,
+ std::shared_ptr<Visitor> createVisitor(vespalib::stringref libName,
const vdslib::Parameters& params,
vespalib::asciistream & error);
diff --git a/storageapi/src/vespa/storageapi/message/bucket.cpp b/storageapi/src/vespa/storageapi/message/bucket.cpp
index afceac0f78d..ee8aff31914 100644
--- a/storageapi/src/vespa/storageapi/message/bucket.cpp
+++ b/storageapi/src/vespa/storageapi/message/bucket.cpp
@@ -453,7 +453,7 @@ RequestBucketInfoCommand::RequestBucketInfoCommand(
RequestBucketInfoCommand::RequestBucketInfoCommand(
document::BucketSpace bucketSpace,
uint16_t distributor, const lib::ClusterState& state,
- const vespalib::stringref & distributionHash)
+ vespalib::stringref distributionHash)
: StorageCommand(MessageType::REQUESTBUCKETINFO),
_bucketSpace(bucketSpace),
_buckets(),
diff --git a/storageapi/src/vespa/storageapi/message/bucket.h b/storageapi/src/vespa/storageapi/message/bucket.h
index c0f65a0006a..f6185d9f8e7 100644
--- a/storageapi/src/vespa/storageapi/message/bucket.h
+++ b/storageapi/src/vespa/storageapi/message/bucket.h
@@ -349,7 +349,7 @@ public:
RequestBucketInfoCommand(document::BucketSpace bucketSpace,
uint16_t distributor,
const lib::ClusterState& state,
- const vespalib::stringref & _distributionHash);
+ vespalib::stringref _distributionHash);
RequestBucketInfoCommand(document::BucketSpace bucketSpace,
uint16_t distributor,
diff --git a/storageapi/src/vespa/storageapi/message/persistence.cpp b/storageapi/src/vespa/storageapi/message/persistence.cpp
index c1db27b4c1a..0b641eea253 100644
--- a/storageapi/src/vespa/storageapi/message/persistence.cpp
+++ b/storageapi/src/vespa/storageapi/message/persistence.cpp
@@ -176,7 +176,7 @@ UpdateReply::print(std::ostream& out, bool verbose, const std::string& indent) c
}
GetCommand::GetCommand(const document::Bucket &bucket, const document::DocumentId& docId,
- const vespalib::stringref & fieldSet, Timestamp before)
+ vespalib::stringref fieldSet, Timestamp before)
: BucketInfoCommand(MessageType::GET, bucket),
_docId(docId),
_beforeTimestamp(before),
diff --git a/storageapi/src/vespa/storageapi/message/persistence.h b/storageapi/src/vespa/storageapi/message/persistence.h
index 59934154cf5..6e93c0e7c05 100644
--- a/storageapi/src/vespa/storageapi/message/persistence.h
+++ b/storageapi/src/vespa/storageapi/message/persistence.h
@@ -188,13 +188,13 @@ class GetCommand : public BucketInfoCommand {
public:
GetCommand(const document::Bucket &bucket, const document::DocumentId&,
- const vespalib::stringref & fieldSet, Timestamp before = MAX_TIMESTAMP);
+ vespalib::stringref fieldSet, Timestamp before = MAX_TIMESTAMP);
~GetCommand() override;
void setBeforeTimestamp(Timestamp ts) { _beforeTimestamp = ts; }
const document::DocumentId& getDocumentId() const { return _docId; }
Timestamp getBeforeTimestamp() const { return _beforeTimestamp; }
const vespalib::string& getFieldSet() const { return _fieldSet; }
- void setFieldSet(const vespalib::stringref & fieldSet) { _fieldSet = fieldSet; }
+ void setFieldSet(vespalib::stringref fieldSet) { _fieldSet = fieldSet; }
vespalib::string getSummary() const override;
void print(std::ostream& out, bool verbose, const std::string& indent) const override;
diff --git a/storageapi/src/vespa/storageapi/message/removelocation.cpp b/storageapi/src/vespa/storageapi/message/removelocation.cpp
index ab44f0e6890..b53584601ef 100644
--- a/storageapi/src/vespa/storageapi/message/removelocation.cpp
+++ b/storageapi/src/vespa/storageapi/message/removelocation.cpp
@@ -8,7 +8,7 @@ namespace storage::api {
IMPLEMENT_COMMAND(RemoveLocationCommand, RemoveLocationReply)
IMPLEMENT_REPLY(RemoveLocationReply)
-RemoveLocationCommand::RemoveLocationCommand(const vespalib::stringref & documentSelection,
+RemoveLocationCommand::RemoveLocationCommand(vespalib::stringref documentSelection,
const document::Bucket &bucket)
: BucketInfoCommand(MessageType::REMOVELOCATION, bucket),
_documentSelection(documentSelection)
diff --git a/storageapi/src/vespa/storageapi/message/removelocation.h b/storageapi/src/vespa/storageapi/message/removelocation.h
index 54edbc5916e..46555497035 100644
--- a/storageapi/src/vespa/storageapi/message/removelocation.h
+++ b/storageapi/src/vespa/storageapi/message/removelocation.h
@@ -10,7 +10,7 @@ namespace storage::api {
class RemoveLocationCommand : public BucketInfoCommand
{
public:
- RemoveLocationCommand(const vespalib::stringref & documentSelection, const document::Bucket &bucket);
+ RemoveLocationCommand(vespalib::stringref documentSelection, const document::Bucket &bucket);
~RemoveLocationCommand();
void print(std::ostream& out, bool verbose, const std::string& indent) const override;
diff --git a/storageapi/src/vespa/storageapi/message/stat.cpp b/storageapi/src/vespa/storageapi/message/stat.cpp
index b061be885ff..a971aa0c4d5 100644
--- a/storageapi/src/vespa/storageapi/message/stat.cpp
+++ b/storageapi/src/vespa/storageapi/message/stat.cpp
@@ -12,7 +12,7 @@ IMPLEMENT_COMMAND(GetBucketListCommand, GetBucketListReply)
IMPLEMENT_REPLY(GetBucketListReply)
StatBucketCommand::StatBucketCommand(const document::Bucket& bucket,
- const vespalib::stringref & documentSelection)
+ vespalib::stringref documentSelection)
: BucketCommand(MessageType::STATBUCKET, bucket),
_docSelection(documentSelection)
{
@@ -33,7 +33,7 @@ StatBucketCommand::print(std::ostream& out, bool verbose,
}
StatBucketReply::StatBucketReply(const StatBucketCommand& cmd,
- const vespalib::stringref & results)
+ vespalib::stringref results)
: BucketReply(cmd),
_results(results)
{
diff --git a/storageapi/src/vespa/storageapi/message/stat.h b/storageapi/src/vespa/storageapi/message/stat.h
index 637c43255b8..9020d16622a 100644
--- a/storageapi/src/vespa/storageapi/message/stat.h
+++ b/storageapi/src/vespa/storageapi/message/stat.h
@@ -22,7 +22,7 @@ private:
vespalib::string _docSelection;
public:
StatBucketCommand(const document::Bucket &bucket,
- const vespalib::stringref & documentSelection);
+ vespalib::stringref documentSelection);
~StatBucketCommand();
const vespalib::string& getDocumentSelection() const { return _docSelection; }
@@ -33,7 +33,7 @@ public:
class StatBucketReply : public BucketReply {
vespalib::string _results;
public:
- StatBucketReply(const StatBucketCommand&, const vespalib::stringref & results = "");
+ StatBucketReply(const StatBucketCommand&, vespalib::stringref results = "");
const vespalib::string& getResults() { return _results; }
void print(std::ostream& out, bool verbose, const std::string& indent) const override;
DECLARE_STORAGEREPLY(StatBucketReply, onStatBucketReply)
@@ -63,7 +63,7 @@ public:
vespalib::string _bucketInformation;
BucketInfo(const document::BucketId& id,
- const vespalib::stringref & bucketInformation)
+ vespalib::stringref bucketInformation)
: _bucket(id),
_bucketInformation(bucketInformation)
{}
diff --git a/storageapi/src/vespa/storageapi/message/visitor.cpp b/storageapi/src/vespa/storageapi/message/visitor.cpp
index 3cb6f72d5d9..f5850de98ad 100644
--- a/storageapi/src/vespa/storageapi/message/visitor.cpp
+++ b/storageapi/src/vespa/storageapi/message/visitor.cpp
@@ -14,9 +14,9 @@ IMPLEMENT_COMMAND(VisitorInfoCommand, VisitorInfoReply)
IMPLEMENT_REPLY(VisitorInfoReply)
CreateVisitorCommand::CreateVisitorCommand(document::BucketSpace bucketSpace,
- const vespalib::stringref & libraryName,
- const vespalib::stringref & instanceId,
- const vespalib::stringref & docSelection)
+ vespalib::stringref libraryName,
+ vespalib::stringref instanceId,
+ vespalib::stringref docSelection)
: StorageCommand(MessageType::VISITOR_CREATE),
_bucketSpace(bucketSpace),
_libName(libraryName),
@@ -140,7 +140,7 @@ CreateVisitorReply::print(std::ostream& out, bool verbose,
}
}
-DestroyVisitorCommand::DestroyVisitorCommand(const vespalib::stringref & instanceId)
+DestroyVisitorCommand::DestroyVisitorCommand(vespalib::stringref instanceId)
: StorageCommand(MessageType::VISITOR_DESTROY),
_instanceId(instanceId)
{
diff --git a/storageapi/src/vespa/storageapi/message/visitor.h b/storageapi/src/vespa/storageapi/message/visitor.h
index 0e78ea93753..0019488b583 100644
--- a/storageapi/src/vespa/storageapi/message/visitor.h
+++ b/storageapi/src/vespa/storageapi/message/visitor.h
@@ -54,22 +54,22 @@ private:
public:
CreateVisitorCommand(document::BucketSpace bucketSpace,
- const vespalib::stringref & libraryName,
- const vespalib::stringref & instanceId,
- const vespalib::stringref & docSelection);
+ vespalib::stringref libraryName,
+ vespalib::stringref instanceId,
+ vespalib::stringref docSelection);
/** Create another command with similar visitor settings. */
CreateVisitorCommand(const CreateVisitorCommand& template_);
~CreateVisitorCommand();
void setVisitorCmdId(uint32_t id) { _visitorCmdId = id; }
- void setControlDestination(const vespalib::stringref & d)
+ void setControlDestination(vespalib::stringref d)
{ _controlDestination = d; }
- void setDataDestination(const vespalib::stringref & d) { _dataDestination = d; }
+ void setDataDestination(vespalib::stringref d) { _dataDestination = d; }
void setParameters(const vdslib::Parameters& params) { _params = params; }
void setMaximumPendingReplyCount(uint32_t count)
{ _maxPendingReplyCount = count; }
- void setFieldSet(const vespalib::stringref& fieldSet)
+ void setFieldSet(vespalib::stringref fieldSet)
{ _fieldSet = fieldSet; }
void setVisitRemoves(bool value = true) { _visitRemoves = value; }
void setVisitInconsistentBuckets(bool visitInconsistent = true)
@@ -77,7 +77,7 @@ public:
void addBucketToBeVisited(const document::BucketId& id)
{ _buckets.push_back(id); }
void setVisitorId(const VisitorId id) { _visitorId = id; }
- void setInstanceId(const vespalib::stringref & id) { _instanceId = id; }
+ void setInstanceId(vespalib::stringref id) { _instanceId = id; }
void setQueueTimeout(uint32_t milliSecs) { _queueTimeout = milliSecs; }
void setFromTime(Timestamp ts) { _fromTime = ts; }
void setToTime(Timestamp ts) { _toTime = ts; }
@@ -157,7 +157,7 @@ private:
vespalib::string _instanceId;
public:
- explicit DestroyVisitorCommand(const vespalib::stringref & instanceId);
+ explicit DestroyVisitorCommand(vespalib::stringref instanceId);
const vespalib::string & getInstanceId() const { return _instanceId; }
diff --git a/storageapi/src/vespa/storageapi/messageapi/maintenancecommand.h b/storageapi/src/vespa/storageapi/messageapi/maintenancecommand.h
index 7e9a41e6220..029365973c5 100644
--- a/storageapi/src/vespa/storageapi/messageapi/maintenancecommand.h
+++ b/storageapi/src/vespa/storageapi/messageapi/maintenancecommand.h
@@ -17,7 +17,7 @@ public:
~MaintenanceCommand();
const vespalib::string& getReason() const { return _reason; };
- void setReason(const vespalib::stringref & reason) { _reason = reason; };
+ void setReason(vespalib::stringref reason) { _reason = reason; };
protected:
vespalib::string _reason;
};
diff --git a/storageapi/src/vespa/storageapi/messageapi/returncode.cpp b/storageapi/src/vespa/storageapi/messageapi/returncode.cpp
index 79a768541b9..68fbca75393 100644
--- a/storageapi/src/vespa/storageapi/messageapi/returncode.cpp
+++ b/storageapi/src/vespa/storageapi/messageapi/returncode.cpp
@@ -16,7 +16,7 @@ ReturnCode & ReturnCode::operator = (const ReturnCode &) = default;
ReturnCode & ReturnCode::operator = (ReturnCode &&) = default;
ReturnCode::~ReturnCode() {}
-ReturnCode::ReturnCode(Result result, const vespalib::stringref & msg)
+ReturnCode::ReturnCode(Result result, vespalib::stringref msg)
: _result(result),
_message(msg)
{}
diff --git a/storageapi/src/vespa/storageapi/messageapi/returncode.h b/storageapi/src/vespa/storageapi/messageapi/returncode.h
index 78f2168e170..ccd95a81aa3 100644
--- a/storageapi/src/vespa/storageapi/messageapi/returncode.h
+++ b/storageapi/src/vespa/storageapi/messageapi/returncode.h
@@ -73,7 +73,7 @@ private:
public:
ReturnCode();
- explicit ReturnCode(Result result, const vespalib::stringref & msg = "");
+ explicit ReturnCode(Result result, vespalib::stringref msg = "");
ReturnCode(const document::DocumentTypeRepo &repo,
document::ByteBuffer& buffer);
ReturnCode(const ReturnCode &);
@@ -87,7 +87,7 @@ public:
size_t getSerializedSize() const override;
const vespalib::string& getMessage() const { return _message; }
- void setMessage(const vespalib::stringref & message) { _message = message; }
+ void setMessage(vespalib::stringref message) { _message = message; }
Result getResult() const { return _result; }
diff --git a/storageapi/src/vespa/storageapi/messageapi/storagemessage.cpp b/storageapi/src/vespa/storageapi/messageapi/storagemessage.cpp
index 380d846dd93..563a2aab7c1 100644
--- a/storageapi/src/vespa/storageapi/messageapi/storagemessage.cpp
+++ b/storageapi/src/vespa/storageapi/messageapi/storagemessage.cpp
@@ -123,7 +123,7 @@ MessageType::MessageType::get(Id id)
}
return *it->second;
}
-MessageType::MessageType(const vespalib::stringref & name, Id id,
+MessageType::MessageType(vespalib::stringref name, Id id,
const MessageType* replyOf)
: _name(name), _id(id), _reply(NULL), _replyOf(replyOf)
{
@@ -163,14 +163,14 @@ std::ostream & operator << (std::ostream & os, const StorageMessageAddress & add
}
static vespalib::string
-createAddress(const vespalib::stringref & cluster, const lib::NodeType& type, uint16_t index)
+createAddress(vespalib::stringref cluster, const lib::NodeType& type, uint16_t index)
{
vespalib::asciistream os;
os << STORAGEADDRESS_PREFIX << cluster << '/' << type.toString() << '/' << index << "/default";
return os.str();
}
-StorageMessageAddress::StorageMessageAddress(const vespalib::stringref & cluster, const lib::NodeType& type,
+StorageMessageAddress::StorageMessageAddress(vespalib::stringref cluster, const lib::NodeType& type,
uint16_t index, Protocol protocol)
: _route(),
_retryEnabled(false),
diff --git a/storageapi/src/vespa/storageapi/messageapi/storagemessage.h b/storageapi/src/vespa/storageapi/messageapi/storagemessage.h
index 6c561f3af21..c81ee51ae22 100644
--- a/storageapi/src/vespa/storageapi/messageapi/storagemessage.h
+++ b/storageapi/src/vespa/storageapi/messageapi/storagemessage.h
@@ -163,7 +163,7 @@ private:
MessageType *_reply;
const MessageType *_replyOf;
- MessageType(const vespalib::stringref & name, Id id, const MessageType* replyOf = 0);
+ MessageType(vespalib::stringref name, Id id, const MessageType* replyOf = 0);
public:
static const MessageType DOCBLOCK;
static const MessageType DOCBLOCK_REPLY;
@@ -280,7 +280,7 @@ private:
public:
StorageMessageAddress(const mbus::Route& route);
- StorageMessageAddress(const vespalib::stringref & clusterName,
+ StorageMessageAddress(vespalib::stringref clusterName,
const lib::NodeType& type, uint16_t index,
Protocol protocol = STORAGE);
~StorageMessageAddress();
diff --git a/streamingvisitors/src/vespa/searchvisitor/searchvisitor.cpp b/streamingvisitors/src/vespa/searchvisitor/searchvisitor.cpp
index f42dfe5af98..333f7257595 100644
--- a/streamingvisitors/src/vespa/searchvisitor/searchvisitor.cpp
+++ b/streamingvisitors/src/vespa/searchvisitor/searchvisitor.cpp
@@ -205,26 +205,26 @@ void SearchVisitor::init(const Parameters & params)
_attrMan.add(_documentIdAttributeBacking);
_attrMan.add(_rankAttributeBacking);
Parameters::ValueRef valueRef;
- if ( params.get("summaryclass", valueRef) ) {
+ if ( params.lookup("summaryclass", valueRef) ) {
_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) ) {
+ if (params.lookup("summarycount", valueRef) ) {
vespalib::string tmp(valueRef.data(), valueRef.size());
wantedSummaryCount = strtoul(tmp.c_str(), nullptr, 0);
LOG(debug, "Received summary count: %ld", wantedSummaryCount);
}
_queryResult->getSearchResult().setWantedHitCount(wantedSummaryCount);
- if (params.get("rankprofile", valueRef) ) {
+ if (params.lookup("rankprofile", valueRef) ) {
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) ) {
+ if (params.lookup("queryflags", valueRef) ) {
vespalib::string tmp(valueRef.data(), valueRef.size());
LOG(debug, "Received query flags: 0x%lx", strtoul(tmp.c_str(), nullptr, 0));
uint32_t queryFlags = strtoul(tmp.c_str(), nullptr, 0);
@@ -232,7 +232,7 @@ void SearchVisitor::init(const Parameters & params)
LOG(debug, "QFLAG_DUMP_FEATURES: %s", _rankController.getDumpFeatures() ? "true" : "false");
}
- if (params.get("rankproperties", valueRef) && valueRef.size() > 0) {
+ if (params.lookup("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 *>(valueRef.data());
@@ -259,7 +259,7 @@ void SearchVisitor::init(const Parameters & params)
LOG(debug, "No rank properties received");
}
- if (params.get("rankprofile", valueRef)) {
+ if (params.lookup("rankprofile", valueRef)) {
vespalib::string tmp(valueRef.data(), valueRef.size());
_summaryGenerator.getDocsumState()._args.SetRankProfile(tmp);
}
@@ -270,26 +270,26 @@ void SearchVisitor::init(const Parameters & params)
}
vespalib::string location;
- if (params.get("location", valueRef)) {
+ if (params.lookup("location", valueRef)) {
location = vespalib::string(valueRef.data(), valueRef.size());
LOG(debug, "Location = '%s'", location.c_str());
_summaryGenerator.getDocsumState()._args.SetLocation(valueRef.size(), (const char*)valueRef.data());
}
Parameters::ValueRef searchClusterBlob;
- if (params.get("searchcluster", searchClusterBlob)) {
+ if (params.lookup("searchcluster", searchClusterBlob)) {
LOG(spam, "Received searchcluster blob of %zd bytes", searchClusterBlob.size());
vespalib::string searchCluster(searchClusterBlob.data(), searchClusterBlob.size());
_vsmAdapter = _env.getVSMAdapter(searchCluster);
- if ( params.get("sort", valueRef) ) {
+ if ( params.lookup("sort", valueRef) ) {
search::uca::UcaConverterFactory ucaFactory;
_sortSpec = search::common::SortSpec(vespalib::string(valueRef.data(), valueRef.size()), ucaFactory);
LOG(debug, "Received sort specification: '%s'", _sortSpec.getSpec().c_str());
}
Parameters::ValueRef queryBlob;
- if ( params.get("query", queryBlob) ) {
+ if ( params.lookup("query", queryBlob) ) {
LOG(spam, "Received query blob of %zu bytes", queryBlob.size());
VISITOR_TRACE(9, vespalib::make_string("Setting up for query blob of %zu bytes", queryBlob.size()));
QueryTermDataFactory addOnFactory;
@@ -329,7 +329,7 @@ void SearchVisitor::init(const Parameters & params)
LOG(warning, "No query received");
}
- if (params.get("aggregation", valueRef) ) {
+ if (params.lookup("aggregation", valueRef) ) {
std::vector<char> newAggrBlob;
newAggrBlob.resize(valueRef.size());
memcpy(&newAggrBlob[0], valueRef.data(), newAggrBlob.size());
@@ -341,7 +341,7 @@ void SearchVisitor::init(const Parameters & params)
LOG(warning, "No searchcluster specified");
}
- if ( params.get("unique", valueRef) ) {
+ if ( params.lookup("unique", valueRef) ) {
LOG(spam, "Received unique specification of %zd bytes", valueRef.size());
} else {
LOG(debug, "No unique specification received");
diff --git a/vdslib/src/vespa/vdslib/container/parameters.cpp b/vdslib/src/vespa/vdslib/container/parameters.cpp
index 6294c35ca08..0803c346b0a 100644
--- a/vdslib/src/vespa/vdslib/container/parameters.cpp
+++ b/vdslib/src/vespa/vdslib/container/parameters.cpp
@@ -111,14 +111,14 @@ Parameters* Parameters::clone() const
return new Parameters(*this);
}
-vespalib::stringref Parameters::get(const vespalib::stringref& id, const vespalib::stringref& def) const
+vespalib::stringref Parameters::get(vespalib::stringref id, vespalib::stringref def) const
{
ParametersMap::const_iterator it = _parameters.find(id);
if (it == _parameters.end()) return def;
return it->second;
}
-bool Parameters::get(const KeyT & id, ValueRef & v ) const
+bool Parameters::lookup(KeyT id, ValueRef & v ) const
{
ParametersMap::const_iterator it = _parameters.find(id);
if (it == _parameters.end()) return false;
@@ -160,17 +160,17 @@ std::string Parameters::toString() const
return ret;
}
-template void vdslib::Parameters::set(const vespalib::stringref &, int32_t);
-template void vdslib::Parameters::set(const vespalib::stringref &, int64_t);
-template void vdslib::Parameters::set(const vespalib::stringref &, uint64_t);
-template void vdslib::Parameters::set(const vespalib::stringref &, double);
-template void vdslib::Parameters::set(const vespalib::stringref &, const char *);
-template void vdslib::Parameters::set(const vespalib::stringref &, vespalib::string);
-template void vdslib::Parameters::set(const vespalib::stringref &, std::string);
-template int32_t vdslib::Parameters::get(const vespalib::stringref &, int32_t) const;
-template int64_t vdslib::Parameters::get(const vespalib::stringref &, int64_t) const;
-template uint64_t vdslib::Parameters::get(const vespalib::stringref &, uint64_t) const;
-template double vdslib::Parameters::get(const vespalib::stringref &, double) const;
-template std::string vdslib::Parameters::get(const vespalib::stringref &, std::string) const;
+template void vdslib::Parameters::set(vespalib::stringref , int32_t);
+template void vdslib::Parameters::set(vespalib::stringref , int64_t);
+template void vdslib::Parameters::set(vespalib::stringref , uint64_t);
+template void vdslib::Parameters::set(vespalib::stringref , double);
+template void vdslib::Parameters::set(vespalib::stringref , const char *);
+template void vdslib::Parameters::set(vespalib::stringref , vespalib::string);
+template void vdslib::Parameters::set(vespalib::stringref , std::string);
+template int32_t vdslib::Parameters::get(vespalib::stringref , int32_t) const;
+template int64_t vdslib::Parameters::get(vespalib::stringref , int64_t) const;
+template uint64_t vdslib::Parameters::get(vespalib::stringref , uint64_t) const;
+template double vdslib::Parameters::get(vespalib::stringref , double) const;
+template std::string vdslib::Parameters::get(vespalib::stringref , std::string) const;
VESPALIB_HASH_MAP_INSTANTIATE(vespalib::string, vdslib::Parameters::Value);
diff --git a/vdslib/src/vespa/vdslib/container/parameters.h b/vdslib/src/vespa/vdslib/container/parameters.h
index ab65932496a..f3ea0543546 100644
--- a/vdslib/src/vespa/vdslib/container/parameters.h
+++ b/vdslib/src/vespa/vdslib/container/parameters.h
@@ -32,7 +32,7 @@ public:
{
public:
Value() { }
- Value(const vespalib::stringref & s) : vespalib::string(s) { }
+ Value(vespalib::stringref s) : vespalib::string(s) { }
Value(const vespalib::string & s) : vespalib::string(s) { }
Value(const void *v, size_t sz) : vespalib::string(v, sz) { }
size_t length() const { return size() - 1; }
@@ -57,10 +57,10 @@ public:
size_t getSerializedSize() const override;
- bool hasValue(const KeyT & id) const { return (_parameters.find(id) != _parameters.end()); }
+ bool hasValue(KeyT id) const { return (_parameters.find(id) != _parameters.end()); }
unsigned int size() const { return _parameters.size(); }
- bool get(const KeyT & id, ValueRef & v ) const;
- void set(const KeyT & id, const void * v, size_t sz) { _parameters[id] = Value(v, sz); }
+ bool lookup(KeyT id, ValueRef & v) const;
+ void set(KeyT id, const void * v, size_t sz) { _parameters[id] = Value(v, sz); }
void print(std::ostream& out, bool verbose, const std::string& indent) const;
@@ -68,8 +68,8 @@ public:
ParametersMap::const_iterator begin() const { return _parameters.begin(); }
ParametersMap::const_iterator end() const { return _parameters.end(); }
/// Convenience from earlier use.
- void set(const KeyT & id, const vespalib::stringref & value) { _parameters[id] = Value(value.data(), value.size()); }
- vespalib::stringref get(const KeyT & id, const vespalib::stringref & def = "") const;
+ void set(KeyT id, vespalib::stringref value) { _parameters[id] = Value(value.data(), value.size()); }
+ vespalib::stringref get(KeyT id, vespalib::stringref def = "") const;
/**
* Set the value identified by the id given. This requires the type to be
* convertible by stringstreams.
@@ -78,7 +78,7 @@ public:
* @param t The value to save. Will be converted to a string.
*/
template<typename T>
- void set(const KeyT & id, T t);
+ void set(KeyT id, T t);
/**
* Get the value identified by the id given, as the same type as the default
@@ -90,7 +90,7 @@ public:
* the default itself if value did not exist.
*/
template<typename T>
- T get(const KeyT & id, T def) const;
+ T get(KeyT id, T def) const;
std::string toString() const;
};
diff --git a/vdslib/src/vespa/vdslib/container/parameters.hpp b/vdslib/src/vespa/vdslib/container/parameters.hpp
index 3647164961d..d7ad1d266cb 100644
--- a/vdslib/src/vespa/vdslib/container/parameters.hpp
+++ b/vdslib/src/vespa/vdslib/container/parameters.hpp
@@ -8,7 +8,7 @@ namespace vdslib {
template<typename T>
void
-Parameters::set(const KeyT & id, T t) {
+Parameters::set(KeyT id, T t) {
vespalib::asciistream ost;
ost << t;
_parameters[id] = ost.str();
@@ -16,9 +16,9 @@ Parameters::set(const KeyT & id, T t) {
template<typename T>
T
-Parameters::get(const KeyT & id, T def) const {
+Parameters::get(KeyT id, T def) const {
vespalib::stringref ref;
- if (!get(id, ref)) return def;
+ if (!lookup(id, ref)) return def;
vespalib::asciistream ist(ref);
T t;
ist >> t;
diff --git a/vdslib/src/vespa/vdslib/state/clusterstate.h b/vdslib/src/vespa/vdslib/state/clusterstate.h
index 26c6f1b95ef..1a8e5297b65 100644
--- a/vdslib/src/vespa/vdslib/state/clusterstate.h
+++ b/vdslib/src/vespa/vdslib/state/clusterstate.h
@@ -62,7 +62,7 @@ public:
void setVersion(uint32_t version) { _version = version; }
void setClusterState(const State& state);
void setNodeState(const Node& node, const NodeState& state);
- void setDescription(const vespalib::stringref & s) { _description = s; }
+ void setDescription(vespalib::stringref s) { _description = s; }
void setDistributionBitCount(uint16_t count) { _distributionBits = count; }
void print(std::ostream& out, bool verbose, const std::string& indent) const override;
diff --git a/vdslib/src/vespa/vdslib/state/diskstate.cpp b/vdslib/src/vespa/vdslib/state/diskstate.cpp
index c963dacff82..0147b422a8e 100644
--- a/vdslib/src/vespa/vdslib/state/diskstate.cpp
+++ b/vdslib/src/vespa/vdslib/state/diskstate.cpp
@@ -20,7 +20,7 @@ DiskState::DiskState()
setState(State::UP);
}
-DiskState::DiskState(const State& state, const vespalib::stringref & description,
+DiskState::DiskState(const State& state, vespalib::stringref description,
double capacity)
: _state(0),
_description(description),
@@ -30,7 +30,7 @@ DiskState::DiskState(const State& state, const vespalib::stringref & description
setCapacity(capacity);
}
-DiskState::DiskState(const vespalib::stringref & serialized)
+DiskState::DiskState(vespalib::stringref serialized)
: _state(&State::UP),
_description(""),
_capacity(1.0)
@@ -79,7 +79,7 @@ DiskState::DiskState(const vespalib::stringref & serialized)
}
void
-DiskState::serialize(vespalib::asciistream & out, const vespalib::stringref & prefix,
+DiskState::serialize(vespalib::asciistream & out, vespalib::stringref prefix,
bool includeDescription, bool useOldFormat) const
{
// Always give node state if not part of a system state
diff --git a/vdslib/src/vespa/vdslib/state/diskstate.h b/vdslib/src/vespa/vdslib/state/diskstate.h
index 0dcde1e7879..cb28e24daac 100644
--- a/vdslib/src/vespa/vdslib/state/diskstate.h
+++ b/vdslib/src/vespa/vdslib/state/diskstate.h
@@ -22,10 +22,10 @@ public:
typedef std::shared_ptr<DiskState> SP;
DiskState();
- DiskState(const State&, const vespalib::stringref & description = "", double capacity = 1.0);
- explicit DiskState(const vespalib::stringref & serialized);
+ DiskState(const State&, vespalib::stringref description = "", double capacity = 1.0);
+ explicit DiskState(vespalib::stringref serialized);
- void serialize(vespalib::asciistream & out, const vespalib::stringref & prefix = "",
+ void serialize(vespalib::asciistream & out, vespalib::stringref prefix = "",
bool includeReason = true, bool useOldFormat = false) const;
const State& getState() const { return *_state; }
@@ -34,7 +34,7 @@ public:
void setState(const State& state);
void setCapacity(double capacity);
- void setDescription(const vespalib::stringref & desc) { _description = desc; }
+ void setDescription(vespalib::stringref desc) { _description = desc; }
void print(std::ostream& out, bool verbose, const std::string& indent) const override;
bool operator==(const DiskState& other) const;
diff --git a/vdslib/src/vespa/vdslib/state/nodestate.cpp b/vdslib/src/vespa/vdslib/state/nodestate.cpp
index d59686dcb1c..22854b7a571 100644
--- a/vdslib/src/vespa/vdslib/state/nodestate.cpp
+++ b/vdslib/src/vespa/vdslib/state/nodestate.cpp
@@ -37,7 +37,7 @@ NodeState::NodeState()
}
NodeState::NodeState(const NodeType& type, const State& state,
- const vespalib::stringref & description,
+ vespalib::stringref description,
double capacity, uint16_t reliability)
: _type(&type),
_state(0),
@@ -78,7 +78,7 @@ namespace {
};
}
-NodeState::NodeState(const vespalib::stringref & serialized, const NodeType* type)
+NodeState::NodeState(vespalib::stringref serialized, const NodeType* type)
: _type(type),
_state(&State::UP),
_description(),
@@ -269,7 +269,7 @@ namespace {
}
void
-NodeState::serialize(vespalib::asciistream & out, const vespalib::stringref & prefix,
+NodeState::serialize(vespalib::asciistream & out, vespalib::stringref prefix,
bool includeDescription, bool includeDiskDescription,
bool useOldFormat) const
{
diff --git a/vdslib/src/vespa/vdslib/state/nodestate.h b/vdslib/src/vespa/vdslib/state/nodestate.h
index edf2a308fa0..74f58663650 100644
--- a/vdslib/src/vespa/vdslib/state/nodestate.h
+++ b/vdslib/src/vespa/vdslib/state/nodestate.h
@@ -43,10 +43,10 @@ public:
NodeState(NodeState &&);
NodeState & operator = (NodeState &&);
NodeState(const NodeType& nodeType, const State&,
- const vespalib::stringref & description = "",
+ vespalib::stringref description = "",
double capacity = 1.0, uint16_t reliability = 1);
/** Set type if you want to verify that content fit with the given type. */
- NodeState(const vespalib::stringref & serialized, const NodeType* nodeType = 0);
+ NodeState(vespalib::stringref serialized, const NodeType* nodeType = 0);
~NodeState();
/**
@@ -54,7 +54,7 @@ public:
* part of the system state. Don't set prefix if you want to be able to
* recreate the nodestate with NodeState(string) function.
*/
- void serialize(vespalib::asciistream & out, const vespalib::stringref & prefix = "",
+ void serialize(vespalib::asciistream & out, vespalib::stringref prefix = "",
bool includeDescription = true,
bool includeDiskDescription = false,
bool useOldFormat = false) const;
@@ -77,7 +77,7 @@ public:
void setReliability(uint16_t reliability);
void setInitProgress(vespalib::Double initProgress);
void setStartTimestamp(uint64_t startTimestamp);
- void setDescription(const vespalib::stringref & desc) { _description = desc; }
+ void setDescription(vespalib::stringref desc) { _description = desc; }
void setDiskCount(uint16_t count);
void setDiskState(uint16_t index, const DiskState&);
diff --git a/vdslib/src/vespa/vdslib/state/nodetype.cpp b/vdslib/src/vespa/vdslib/state/nodetype.cpp
index c7676221e14..915b1548f88 100644
--- a/vdslib/src/vespa/vdslib/state/nodetype.cpp
+++ b/vdslib/src/vespa/vdslib/state/nodetype.cpp
@@ -14,7 +14,7 @@ const NodeType NodeType::STORAGE("storage", 0);
const NodeType NodeType::DISTRIBUTOR("distributor", 1);
const NodeType&
-NodeType::get(const vespalib::stringref & serialized)
+NodeType::get(vespalib::stringref serialized)
{
if (serialized == STORAGE._name) {
return STORAGE;
@@ -26,7 +26,7 @@ NodeType::get(const vespalib::stringref & serialized)
"Unknown node type " + serialized + " given.", VESPA_STRLOC);
}
-NodeType::NodeType(const vespalib::stringref & name, uint16_t enumValue)
+NodeType::NodeType(vespalib::stringref name, uint16_t enumValue)
: _enumValue(enumValue), _name(name)
{
}
diff --git a/vdslib/src/vespa/vdslib/state/nodetype.h b/vdslib/src/vespa/vdslib/state/nodetype.h
index 318cf59218e..35edd83fdac 100644
--- a/vdslib/src/vespa/vdslib/state/nodetype.h
+++ b/vdslib/src/vespa/vdslib/state/nodetype.h
@@ -24,14 +24,14 @@ class NodeType {
uint16_t _enumValue;
vespalib::string _name;
- NodeType(const vespalib::stringref & name, uint16_t enumValue);
+ NodeType(vespalib::stringref name, uint16_t enumValue);
public:
static const NodeType DISTRIBUTOR;
static const NodeType STORAGE;
/** Throws vespalib::IllegalArgumentException if invalid state given. */
- static const NodeType& get(const vespalib::stringref & serialized);
+ static const NodeType& get(vespalib::stringref serialized);
const vespalib::string& serialize() const { return _name; }
operator uint16_t() const { return _enumValue; }
diff --git a/vdslib/src/vespa/vdslib/state/state.cpp b/vdslib/src/vespa/vdslib/state/state.cpp
index 2c756aed7f5..5bf95b5530b 100644
--- a/vdslib/src/vespa/vdslib/state/state.cpp
+++ b/vdslib/src/vespa/vdslib/state/state.cpp
@@ -23,7 +23,7 @@ const State State::UP("Up", "u", 6,
true, true, true, true, true, true);
const State&
-State::get(const vespalib::stringref & serialized)
+State::get(vespalib::stringref serialized)
{
if (serialized.size() == 1) switch(serialized[0]) {
case '-': return UNKNOWN;
@@ -39,7 +39,7 @@ State::get(const vespalib::stringref & serialized)
"Unknown state " + serialized + " given.", VESPA_STRLOC);
}
-State::State(const vespalib::stringref & name, const vespalib::stringref & serialized,
+State::State(vespalib::stringref name, vespalib::stringref serialized,
uint8_t rank, bool validDisk,
bool validDistributorReported, bool validStorageReported,
bool validDistributorWanted, bool validStorageWanted,
diff --git a/vdslib/src/vespa/vdslib/state/state.h b/vdslib/src/vespa/vdslib/state/state.h
index e0857fe8ccd..bec500a082d 100644
--- a/vdslib/src/vespa/vdslib/state/state.h
+++ b/vdslib/src/vespa/vdslib/state/state.h
@@ -26,7 +26,7 @@ class State : public vespalib::Printable {
bool _validClusterState;
State(const State&);
- State(const vespalib::stringref & name, const vespalib::stringref & serialized,
+ State(vespalib::stringref name, vespalib::stringref serialized,
uint8_t rank, bool validDisk,
bool validDistributorReported, bool validStorageReported,
bool validDistributorWanted, bool validStorageWanted,
@@ -45,7 +45,7 @@ public:
static const State UP;
/** Throws vespalib::IllegalArgumentException if invalid state given. */
- static const State& get(const vespalib::stringref & serialized);
+ static const State& get(vespalib::stringref serialized);
const vespalib::string& serialize() const { return _serialized; }
bool validDiskState() const { return _validDiskState; }
diff --git a/vespa-athenz/src/main/java/com/yahoo/vespa/athenz/identityprovider/api/EntityBindingsMapper.java b/vespa-athenz/src/main/java/com/yahoo/vespa/athenz/identityprovider/api/EntityBindingsMapper.java
index 3bfe492a125..641c3001795 100644
--- a/vespa-athenz/src/main/java/com/yahoo/vespa/athenz/identityprovider/api/EntityBindingsMapper.java
+++ b/vespa-athenz/src/main/java/com/yahoo/vespa/athenz/identityprovider/api/EntityBindingsMapper.java
@@ -11,7 +11,10 @@ import com.yahoo.vespa.athenz.identityprovider.api.bindings.VespaUniqueInstanceI
import java.io.IOException;
import java.io.UncheckedIOException;
+import java.nio.file.Files;
import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
import java.util.Base64;
import static com.yahoo.vespa.athenz.identityprovider.api.VespaUniqueInstanceId.fromDottedString;
@@ -116,7 +119,9 @@ public class EntityBindingsMapper {
public static void writeSignedIdentityDocumentToFile(Path file, SignedIdentityDocument document) {
try {
SignedIdentityDocumentEntity entity = EntityBindingsMapper.toSignedIdentityDocumentEntity(document);
- mapper.writeValue(file.toFile(), entity);
+ Path tempFile = Paths.get(file.toAbsolutePath().toString() + ".tmp");
+ mapper.writeValue(tempFile.toFile(), entity);
+ Files.move(tempFile, file, StandardCopyOption.ATOMIC_MOVE);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
diff --git a/vespalib/src/vespa/vespalib/component/version.cpp b/vespalib/src/vespa/vespalib/component/version.cpp
index 3aa8e134e36..fc7ee703e7f 100644
--- a/vespalib/src/vespa/vespalib/component/version.cpp
+++ b/vespalib/src/vespa/vespalib/component/version.cpp
@@ -63,8 +63,8 @@ Version::verifySanity()
}
// Precondition: input.empty() == false
-static int parseInteger(const stringref & input) __attribute__((noinline));
-static int parseInteger(const stringref & input)
+static int parseInteger(stringref input) __attribute__((noinline));
+static int parseInteger(stringref input)
{
const char *s = input.data();
unsigned char firstDigit = s[0];
diff --git a/vespalib/src/vespa/vespalib/data/memory.h b/vespalib/src/vespa/vespalib/data/memory.h
index eae7c8d2f23..07767180b57 100644
--- a/vespalib/src/vespa/vespalib/data/memory.h
+++ b/vespalib/src/vespa/vespalib/data/memory.h
@@ -22,7 +22,7 @@ struct Memory
: data(str.data()), size(str.size()) {}
Memory(const vespalib::string &str)
: data(str.data()), size(str.size()) {}
- Memory(const vespalib::stringref &str_ref)
+ Memory(vespalib::stringref str_ref)
: data(str_ref.data()), size(str_ref.size()) {}
vespalib::string make_string() const;
vespalib::stringref make_stringref() const { return stringref(data, size); }
diff --git a/vespalib/src/vespa/vespalib/io/fileutil.h b/vespalib/src/vespa/vespalib/io/fileutil.h
index 1b493a9ebf1..1507513dbbc 100644
--- a/vespalib/src/vespa/vespalib/io/fileutil.h
+++ b/vespalib/src/vespa/vespalib/io/fileutil.h
@@ -218,7 +218,7 @@ class LazyFile : public File {
public:
typedef std::unique_ptr<LazyFile> UP;
- LazyFile(const vespalib::stringref & filename, int flags,
+ LazyFile(vespalib::stringref filename, int flags,
bool autoCreateDirs = false)
: File(filename),
_flags(flags),
diff --git a/vespalib/src/vespa/vespalib/objects/nbostream.h b/vespalib/src/vespa/vespalib/objects/nbostream.h
index c3127e06133..3109295fbdc 100644
--- a/vespalib/src/vespa/vespalib/objects/nbostream.h
+++ b/vespalib/src/vespa/vespalib/objects/nbostream.h
@@ -71,7 +71,7 @@ public:
return *this;
}
nbostream & operator << (const char * v) { uint32_t sz(strlen(v)); (*this) << sz; write(v, sz); return *this; }
- nbostream & operator << (const vespalib::stringref & v) { uint32_t sz(v.size()); (*this) << sz; write(v.data(), sz); return *this; }
+ nbostream & operator << (vespalib::stringref v) { uint32_t sz(v.size()); (*this) << sz; write(v.data(), sz); return *this; }
nbostream & operator << (const vespalib::string & v) { uint32_t sz(v.size()); (*this) << sz; write(v.c_str(), sz); return *this; }
nbostream & operator >> (vespalib::string & v) {
uint32_t sz; (*this) >> sz;
diff --git a/vespalib/src/vespa/vespalib/stllike/asciistream.cpp b/vespalib/src/vespa/vespalib/stllike/asciistream.cpp
index 7e8570b3d61..9b2cdad822a 100644
--- a/vespalib/src/vespa/vespalib/stllike/asciistream.cpp
+++ b/vespalib/src/vespa/vespalib/stllike/asciistream.cpp
@@ -59,7 +59,7 @@ asciistream::asciistream() :
_precision(6)
{ }
-asciistream::asciistream(const stringref & buf) :
+asciistream::asciistream(stringref buf) :
_rPos(0),
_wbuf(),
_rbuf(buf),
@@ -555,7 +555,7 @@ string asciistream::getline(char delim)
return line;
}
-asciistream asciistream::createFromFile(const stringref & fileName)
+asciistream asciistream::createFromFile(stringref fileName)
{
FastOS_File file(vespalib::string(fileName).c_str());
asciistream is;
@@ -576,7 +576,7 @@ asciistream asciistream::createFromFile(const stringref & fileName)
return is;
}
-asciistream asciistream::createFromDevice(const stringref & fileName)
+asciistream asciistream::createFromDevice(stringref fileName)
{
FastOS_File file(vespalib::string(fileName).c_str());
asciistream is;
diff --git a/vespalib/src/vespa/vespalib/stllike/asciistream.h b/vespalib/src/vespa/vespalib/stllike/asciistream.h
index 9dd73706d0a..c225c371a78 100644
--- a/vespalib/src/vespa/vespalib/stllike/asciistream.h
+++ b/vespalib/src/vespa/vespalib/stllike/asciistream.h
@@ -31,7 +31,7 @@ class asciistream
{
public:
asciistream();
- asciistream(const stringref & buf);
+ asciistream(stringref buf);
~asciistream();
asciistream(const asciistream & rhs);
asciistream & operator = (const asciistream & rhs);
@@ -43,7 +43,7 @@ public:
asciistream & operator << (unsigned char v) { doFill(1); write(&v, 1); return *this; }
asciistream & operator << (const char * v) { if (v != nullptr) { size_t n(strlen(v)); doFill(n); write(v, n); } return *this; }
asciistream & operator << (const string & v) { doFill(v.size()); write(v.data(), v.size()); return *this; }
- asciistream & operator << (const stringref & v) { doFill(v.size()); write(v.data(), v.size()); return *this; }
+ asciistream & operator << (stringref v) { doFill(v.size()); write(v.data(), v.size()); return *this; }
asciistream & operator << (const std::string & v) { doFill(v.size()); write(v.data(), v.size()); return *this; }
asciistream & operator << (int16_t v) { return *this << static_cast<int64_t>(v); }
asciistream & operator << (uint16_t v) { return *this << static_cast<uint64_t>(v); }
@@ -144,8 +144,8 @@ public:
asciistream & operator << (Precision v);
asciistream & operator >> (Precision v);
void eatWhite();
- static asciistream createFromFile(const vespalib::stringref & fileName);
- static asciistream createFromDevice(const vespalib::stringref & fileName);
+ static asciistream createFromFile(stringref fileName);
+ static asciistream createFromDevice(stringref fileName);
string getline(char delim='\n');
std::vector<string> getlines(char delim='\n');
char getFill() const noexcept { return _fill; }
@@ -166,15 +166,15 @@ private:
}
void write(const void * buf, size_t len);
size_t length() const { return _rbuf.size(); }
- size_t _rPos;
- string _wbuf;
- stringref _rbuf;
- Base _base;
- FloatSpec _floatSpec;
+ size_t _rPos;
+ string _wbuf;
+ stringref _rbuf;
+ Base _base;
+ FloatSpec _floatSpec;
FloatModifier _floatModifier;
- uint32_t _width;
- char _fill;
- uint8_t _precision;
+ uint32_t _width;
+ char _fill;
+ uint8_t _precision;
};
ssize_t getline(asciistream & is, vespalib::string & line, char delim='\n');
diff --git a/vespalib/src/vespa/vespalib/stllike/hash_fun.h b/vespalib/src/vespa/vespalib/stllike/hash_fun.h
index 7d7be666136..0342ea4cc69 100644
--- a/vespalib/src/vespa/vespalib/stllike/hash_fun.h
+++ b/vespalib/src/vespa/vespalib/stllike/hash_fun.h
@@ -67,7 +67,7 @@ template<> struct hash<const char *> {
};
template<> struct hash<vespalib::stringref> {
- size_t operator() (const vespalib::stringref & arg) const { return hashValue(arg.data(), arg.size()); }
+ size_t operator() (vespalib::stringref arg) const { return hashValue(arg.data(), arg.size()); }
};
template<> struct hash<vespalib::string> {
diff --git a/vespalib/src/vespa/vespalib/stllike/string.cpp b/vespalib/src/vespa/vespalib/stllike/string.cpp
index 47d424e93aa..4ec324ceef0 100644
--- a/vespalib/src/vespa/vespalib/stllike/string.cpp
+++ b/vespalib/src/vespa/vespalib/stllike/string.cpp
@@ -30,7 +30,7 @@ stringref::rfind(const char * s, size_type e) const {
}
stringref::size_type
-stringref::find(const stringref & s, size_type start) const {
+stringref::find(stringref s, size_type start) const {
const char *buf = begin()+start;
const char *e = end() - s.size();
while (buf <= e) {
@@ -45,7 +45,7 @@ stringref::find(const stringref & s, size_type start) const {
return npos;
}
-std::ostream & operator << (std::ostream & os, const stringref & v)
+std::ostream & operator << (std::ostream & os, stringref v)
{
return os.write(v.data(), v.size());
}
@@ -65,29 +65,29 @@ std::istream & operator >> (std::istream & is, small_string<SS> & v)
return is;
}
-template std::ostream & operator << (std::ostream & os, const vespalib::string & v);
-template std::istream & operator >> (std::istream & is, vespalib::string & v);
+template std::ostream & operator << (std::ostream & os, const string & v);
+template std::istream & operator >> (std::istream & is, string & v);
-vespalib::string
-operator + (const vespalib::stringref & a, const char * b)
+string
+operator + (stringref a, const char * b)
{
- vespalib::string t(a);
+ string t(a);
t += b;
return t;
}
-vespalib::string
-operator + (const char * a, const vespalib::stringref & b)
+string
+operator + (const char * a, stringref b)
{
- vespalib::string t(a);
+ string t(a);
t += b;
return t;
}
-vespalib::string
-operator + (const vespalib::stringref & a, const vespalib::stringref & b)
+string
+operator + (stringref a, stringref b)
{
- vespalib::string t(a);
+ string t(a);
t += b;
return t;
}
@@ -95,8 +95,8 @@ operator + (const vespalib::stringref & a, const vespalib::stringref & b)
template class small_string<48>;
template string operator + (const string & a, const string & b);
-template string operator + (const string & a, const stringref & b);
-template string operator + (const stringref & a, const string & b);
+template string operator + (const string & a, stringref b);
+template string operator + (stringref a, const string & b);
template string operator + (const string & a, const char * b);
template string operator + (const char * a, const string & b);
diff --git a/vespalib/src/vespa/vespalib/stllike/string.h b/vespalib/src/vespa/vespalib/stllike/string.h
index 98ed0929a9b..e787ecc071f 100644
--- a/vespalib/src/vespa/vespalib/stllike/string.h
+++ b/vespalib/src/vespa/vespalib/stllike/string.h
@@ -32,7 +32,7 @@ public:
* Note that the data may not be zero terminated, and a default
* constructed stringref will give a NULL pointer back. If you
* need to make sure data() gives a valid zero-terminated string
- * you should make a vespalib::string from the stringref.
+ * you should make a string from the stringref.
**/
const char * data() const { return _s; }
@@ -71,7 +71,7 @@ public:
* @return index from the start of the string at which the character
* was found, or npos if the character could not be located
*/
- size_type find(const stringref & s, size_type start=0) const;
+ size_type find(stringref s, size_type start=0) const;
/**
* Find the first occurrence of a character, searching from @c start
*
@@ -116,7 +116,7 @@ public:
* was found, or npos if the substring could not be located
*/
size_type rfind(const char * s, size_type e=npos) const;
- int compare(const stringref & s) const { return compare(s.data(), s.size()); }
+ int compare(stringref s) const { return compare(s.data(), s.size()); }
int compare(const char *s, size_type sz) const {
int diff(memcmp(_s, s, std::min(sz, size())));
return (diff != 0) ? diff : (size() - sz);
@@ -125,28 +125,28 @@ public:
operator std::string () const { return std::string(_s, _sz); }
bool operator < (const char * s) const { return compare(s, strlen(s)) < 0; }
bool operator < (const std::string & s) const { return compare(s.data(), s.size()) < 0; }
- bool operator < (const stringref & s) const { return compare(s.data(), s.size()) < 0; }
+ bool operator < (stringref s) const { return compare(s.data(), s.size()) < 0; }
bool operator <= (const char * s) const { return compare(s, strlen(s)) <= 0; }
bool operator <= (const std::string & s) const { return compare(s.data(), s.size()) <= 0; }
- bool operator <= (const stringref & s) const { return compare(s.data(), s.size()) <= 0; }
+ bool operator <= (stringref s) const { return compare(s.data(), s.size()) <= 0; }
bool operator != (const char * s) const { return compare(s, strlen(s)) != 0; }
bool operator != (const std::string & s) const { return compare(s.data(), s.size()) != 0; }
- bool operator != (const stringref & s) const { return compare(s.data(), s.size()) != 0; }
+ bool operator != (stringref s) const { return compare(s.data(), s.size()) != 0; }
bool operator == (const char * s) const { return compare(s, strlen(s)) == 0; }
bool operator == (const std::string & s) const { return compare(s.data(), s.size()) == 0; }
- bool operator == (const stringref & s) const { return compare(s.data(), s.size()) == 0; }
+ bool operator == (stringref s) const { return compare(s.data(), s.size()) == 0; }
bool operator >= (const char * s) const { return compare(s, strlen(s)) >= 0; }
bool operator >= (const std::string & s) const { return compare(s.data(), s.size()) >= 0; }
- bool operator >= (const stringref & s) const { return compare(s.data(), s.size()) >= 0; }
+ bool operator >= (stringref s) const { return compare(s.data(), s.size()) >= 0; }
bool operator > (const char * s) const { return compare(s, strlen(s)) > 0; }
bool operator > (const std::string & s) const { return compare(s.data(), s.size()) > 0; }
- bool operator > (const stringref & s) const { return compare(s.data(), s.size()) > 0; }
+ bool operator > (stringref s) const { return compare(s.data(), s.size()) > 0; }
private:
const char *_s;
size_type _sz;
- friend bool operator == (const std::string & a, const stringref & b) { return b == a; }
- friend bool operator != (const std::string & a, const stringref & b) { return b != a; }
- friend std::ostream & operator << (std::ostream & os, const stringref & v);
+ friend bool operator == (const std::string & a, stringref b) { return b == a; }
+ friend bool operator != (const std::string & a, stringref b) { return b != a; }
+ friend std::ostream & operator << (std::ostream & os, stringref v);
};
@@ -175,7 +175,7 @@ public:
small_string() : _buf(_stack), _sz(0), _bufferSize(StackSize) { _stack[0] = '\0'; }
small_string(const char * s) : _buf(_stack), _sz(s ? strlen(s) : 0) { init(s); }
small_string(const void * s, size_type sz) : _buf(_stack), _sz(sz) { init(s); }
- small_string(const stringref & s) : _buf(_stack), _sz(s.size()) { init(s.data()); }
+ small_string(stringref s) : _buf(_stack), _sz(s.size()) { init(s.data()); }
small_string(const std::string & s) : _buf(_stack), _sz(s.size()) { init(s.data()); }
small_string(const small_string & rhs) noexcept : _buf(_stack), _sz(rhs.size()) { init(rhs.data()); }
small_string(const small_string & rhs, size_type pos, size_type sz=npos) noexcept
@@ -203,7 +203,7 @@ public:
small_string& operator= (const small_string &rhs) {
return assign(rhs.data(), rhs.size());
}
- small_string & operator= (const stringref &rhs) {
+ small_string & operator= (stringref rhs) {
return assign(rhs.data(), rhs.size());
}
small_string& operator= (const char *s) {
@@ -317,23 +317,23 @@ public:
}
small_string & assign(const char * s) { return assign(s, strlen(s)); }
small_string & assign(const void * s, size_type sz);
- small_string & assign(const stringref &s, size_type pos, size_type sz) {
+ small_string & assign(stringref s, size_type pos, size_type sz) {
return assign(s.data() + pos, sz);
}
- small_string & assign(const stringref &rhs) {
+ small_string & assign(stringref rhs) {
if (data() != rhs.data()) assign(rhs.data(), rhs.size());
return *this;
}
small_string & push_back(char c) { return append(&c, 1); }
small_string & append(char c) { return append(&c, 1); }
small_string & append(const char * s) { return append(s, strlen(s)); }
- small_string & append(const stringref & s) { return append(s.data(), s.size()); }
+ small_string & append(stringref s) { return append(s.data(), s.size()); }
small_string & append(const std::string & s) { return append(s.data(), s.size()); }
small_string & append(const small_string & s) { return append(s.data(), s.size()); }
small_string & append(const void * s, size_type sz);
small_string & operator += (char c) { return append(c); }
small_string & operator += (const char * s) { return append(s); }
- small_string & operator += (const stringref & s) { return append(s); }
+ small_string & operator += (stringref s) { return append(s); }
small_string & operator += (const std::string & s) { return append(s); }
small_string & operator += (const small_string & s) { return append(s); }
@@ -355,7 +355,7 @@ public:
}
small_string & insert(iterator p, const_iterator f, const_iterator l) { return insert(p-c_str(), f, l-f); }
- small_string & insert(size_type start, const stringref & v) { return insert(start, v.data(), v.size()); }
+ small_string & insert(size_type start, stringref v) { return insert(start, v.data(), v.size()); }
small_string & insert(size_type start, const void * v, size_type sz);
/**
@@ -446,27 +446,27 @@ public:
bool operator < (const char * s) const { return compare(s, strlen(s)) < 0; }
bool operator < (const std::string & s) const { return compare(s.data(), s.size()) < 0; }
bool operator < (const small_string & s) const { return compare(s.data(), s.size()) < 0; }
- bool operator < (const stringref & s) const { return compare(s.data(), s.size()) < 0; }
+ bool operator < (stringref s) const { return compare(s.data(), s.size()) < 0; }
bool operator <= (const char * s) const { return compare(s, strlen(s)) <= 0; }
bool operator <= (const std::string & s) const { return compare(s.data(), s.size()) <= 0; }
bool operator <= (const small_string & s) const { return compare(s.data(), s.size()) <= 0; }
- bool operator <= (const stringref & s) const { return compare(s.data(), s.size()) <= 0; }
+ bool operator <= (stringref s) const { return compare(s.data(), s.size()) <= 0; }
bool operator == (const char * s) const { return compare(s, strlen(s)) == 0; }
bool operator == (const std::string & s) const { return compare(s.data(), s.size()) == 0; }
bool operator == (const small_string & s) const { return compare(s.data(), s.size()) == 0; }
- bool operator == (const stringref & s) const { return compare(s.data(), s.size()) == 0; }
+ bool operator == (stringref s) const { return compare(s.data(), s.size()) == 0; }
bool operator != (const char * s) const { return compare(s, strlen(s)) != 0; }
bool operator != (const std::string & s) const { return compare(s.data(), s.size()) != 0; }
bool operator != (const small_string & s) const { return compare(s.data(), s.size()) != 0; }
- bool operator != (const stringref & s) const { return compare(s.data(), s.size()) != 0; }
+ bool operator != (stringref s) const { return compare(s.data(), s.size()) != 0; }
bool operator >= (const char * s) const { return compare(s, strlen(s)) >= 0; }
bool operator >= (const std::string & s) const { return compare(s.data(), s.size()) >= 0; }
bool operator >= (const small_string & s) const { return compare(s.data(), s.size()) >= 0; }
- bool operator >= (const stringref & s) const { return compare(s.data(), s.size()) >= 0; }
+ bool operator >= (stringref s) const { return compare(s.data(), s.size()) >= 0; }
bool operator > (const char * s) const { return compare(s, strlen(s)) > 0; }
bool operator > (const std::string & s) const { return compare(s.data(), s.size()) > 0; }
bool operator > (const small_string & s) const { return compare(s.data(), s.size()) > 0; }
- bool operator > (const stringref & s) const { return compare(s.data(), s.size()) > 0; }
+ bool operator > (stringref s) const { return compare(s.data(), s.size()) > 0; }
template<typename T> bool operator != (const T& s) const { return ! operator == (s); }
@@ -572,62 +572,62 @@ const size_t small_string<StackSize>::npos;
typedef small_string<48> string;
template<uint32_t StackSize>
-vespalib::small_string<StackSize>
-operator + (const vespalib::small_string<StackSize> & a, const vespalib::small_string<StackSize> & b);
+small_string<StackSize>
+operator + (const small_string<StackSize> & a, const small_string<StackSize> & b);
template<uint32_t StackSize>
-vespalib::small_string<StackSize>
-operator + (const vespalib::small_string<StackSize> & a, const vespalib::stringref & b);
+small_string<StackSize>
+operator + (const small_string<StackSize> & a, stringref b);
template<uint32_t StackSize>
-vespalib::small_string<StackSize>
-operator + (const vespalib::stringref & a, const vespalib::small_string<StackSize> & b);
+small_string<StackSize>
+operator + (stringref a, const small_string<StackSize> & b);
template<uint32_t StackSize>
-vespalib::small_string<StackSize>
-operator + (const vespalib::small_string<StackSize> & a, const char * b);
+small_string<StackSize>
+operator + (const small_string<StackSize> & a, const char * b);
template<uint32_t StackSize>
-vespalib::small_string<StackSize>
-operator + (const char * a, const vespalib::small_string<StackSize> & b);
+small_string<StackSize>
+operator + (const char * a, const small_string<StackSize> & b);
template<typename T, uint32_t StackSize>
bool
-operator == (const T& a, const vespalib::small_string<StackSize>& b)
+operator == (const T& a, const small_string<StackSize>& b)
{
return b == a;
}
template<typename T, uint32_t StackSize>
bool
-operator != (const T& a, const vespalib::small_string<StackSize>& b)
+operator != (const T& a, const small_string<StackSize>& b)
{
return b != a;
}
template<typename T, uint32_t StackSize>
bool
-operator < (const T& a, const vespalib::small_string<StackSize>& b)
+operator < (const T& a, const small_string<StackSize>& b)
{
return b > a;
}
-vespalib::string operator + (const vespalib::stringref & a, const vespalib::stringref & b);
-vespalib::string operator + (const char * a, const vespalib::stringref & b);
-vespalib::string operator + (const vespalib::stringref & a, const char * b);
+string operator + (stringref a, stringref b);
+string operator + (const char * a, stringref b);
+string operator + (stringref a, const char * b);
-inline bool contains(const stringref & text, const stringref & key) {
+inline bool contains(stringref text, stringref key) {
return text.find(key) != stringref::npos;
}
-inline bool starts_with(const stringref & text, const stringref & key) {
+inline bool starts_with(stringref text, stringref key) {
if (text.size() >= key.size()) {
return memcmp(text.begin(), key.begin(), key.size()) == 0;
}
return false;
}
-inline bool ends_with(const stringref & text, const stringref & key) {
+inline bool ends_with(stringref text, stringref key) {
if (text.size() >= key.size()) {
return memcmp(text.end()-key.size(), key.begin(), key.size()) == 0;
}
@@ -636,9 +636,9 @@ inline bool ends_with(const stringref & text, const stringref & key) {
/**
* Utility function to format an unsigned integer into a new
- * vespalib::string instance.
+ * string instance.
**/
-static inline vespalib::string stringify(uint64_t number)
+static inline string stringify(uint64_t number)
{
char digits[64];
int numdigits = 0;
@@ -646,7 +646,7 @@ static inline vespalib::string stringify(uint64_t number)
digits[numdigits++] = '0' + (number % 10);
number /= 10;
} while (number > 0);
- vespalib::string retval;
+ string retval;
while (numdigits > 0) {
retval.append(digits[--numdigits]);
}
diff --git a/vespalib/src/vespa/vespalib/stllike/string.hpp b/vespalib/src/vespa/vespalib/stllike/string.hpp
index 3ead42ee41e..bf98d82463b 100644
--- a/vespalib/src/vespa/vespalib/stllike/string.hpp
+++ b/vespalib/src/vespa/vespalib/stllike/string.hpp
@@ -156,46 +156,46 @@ small_string<StackSize>::append(const void * s, size_type addSz)
}
template<uint32_t StackSize>
-vespalib::small_string<StackSize>
-operator + (const vespalib::small_string<StackSize> & a, const vespalib::small_string<StackSize> & b)
+small_string<StackSize>
+operator + (const small_string<StackSize> & a, const small_string<StackSize> & b)
{
- vespalib::small_string<StackSize> t(a);
+ small_string<StackSize> t(a);
t += b;
return t;
}
template<uint32_t StackSize>
-vespalib::small_string<StackSize>
-operator + (const vespalib::small_string<StackSize> & a, const vespalib::stringref & b)
+small_string<StackSize>
+operator + (const small_string<StackSize> & a, stringref b)
{
- vespalib::small_string<StackSize> t(a);
+ small_string<StackSize> t(a);
t += b;
return t;
}
template<uint32_t StackSize>
-vespalib::small_string<StackSize>
-operator + (const vespalib::stringref & a, const vespalib::small_string<StackSize> & b)
+small_string<StackSize>
+operator + (stringref a, const small_string<StackSize> & b)
{
- vespalib::small_string<StackSize> t(a);
+ small_string<StackSize> t(a);
t += b;
return t;
}
template<uint32_t StackSize>
-vespalib::small_string<StackSize>
-operator + (const vespalib::small_string<StackSize> & a, const char * b)
+small_string<StackSize>
+operator + (const small_string<StackSize> & a, const char * b)
{
- vespalib::small_string<StackSize> t(a);
+ small_string<StackSize> t(a);
t += b;
return t;
}
template<uint32_t StackSize>
-vespalib::small_string<StackSize>
-operator + (const char * a, const vespalib::small_string<StackSize> & b)
+small_string<StackSize>
+operator + (const char * a, const small_string<StackSize> & b)
{
- vespalib::small_string<StackSize> t(a);
+ small_string<StackSize> t(a);
t += b;
return t;
}
diff --git a/vespalib/src/vespa/vespalib/text/lowercase.cpp b/vespalib/src/vespa/vespalib/text/lowercase.cpp
index bb0908b7158..7296819084b 100644
--- a/vespalib/src/vespa/vespalib/text/lowercase.cpp
+++ b/vespalib/src/vespa/vespalib/text/lowercase.cpp
@@ -6,7 +6,7 @@
namespace vespalib {
vespalib::string
-LowerCase::convert(const vespalib::stringref& input)
+LowerCase::convert(vespalib::stringref input)
{
vespalib::string output;
Utf8Reader r(input);
diff --git a/vespalib/src/vespa/vespalib/text/lowercase.h b/vespalib/src/vespa/vespalib/text/lowercase.h
index c69d37ce2ba..d007ac37b3e 100644
--- a/vespalib/src/vespa/vespalib/text/lowercase.h
+++ b/vespalib/src/vespa/vespalib/text/lowercase.h
@@ -102,7 +102,7 @@ public:
* any bytes that aren't valid UTF-8 with the Unicode REPLACEMENT
* CHARACTER (U+FFFD).
**/
- static vespalib::string convert(const vespalib::stringref& input);
+ static vespalib::string convert(vespalib::stringref input);
};
diff --git a/vespalib/src/vespa/vespalib/text/stringtokenizer.cpp b/vespalib/src/vespa/vespalib/text/stringtokenizer.cpp
index b59101c8780..619decdce02 100644
--- a/vespalib/src/vespa/vespalib/text/stringtokenizer.cpp
+++ b/vespalib/src/vespa/vespalib/text/stringtokenizer.cpp
@@ -7,7 +7,7 @@ namespace {
class AsciiSet
{
public:
- AsciiSet(const vespalib::stringref & s) {
+ AsciiSet(vespalib::stringref s) {
memset(_set, 0, sizeof(_set));
for (size_t i(0), m(s.size()); i < m; i++) {
add(s[i]);
@@ -31,7 +31,7 @@ typedef vespalib::StringTokenizer::TokenList TokenList;
* strip leading and trailing sequences
* of characters contained in the strip set.
**/
-Token stripString(const vespalib::stringref & source,
+Token stripString(vespalib::stringref source,
const AsciiSet & strip)
{
Token::size_type start = 0;
@@ -46,7 +46,7 @@ Token stripString(const vespalib::stringref & source,
}
void parse(TokenList& output,
- const vespalib::stringref & source,
+ vespalib::stringref source,
const AsciiSet & separators,
const AsciiSet & strip)
{
@@ -66,9 +66,9 @@ void parse(TokenList& output,
namespace vespalib {
-StringTokenizer::StringTokenizer(const vespalib::stringref & source,
- const vespalib::stringref & separators,
- const vespalib::stringref & strip)
+StringTokenizer::StringTokenizer(vespalib::stringref source,
+ vespalib::stringref separators,
+ vespalib::stringref strip)
: _tokens()
{
AsciiSet sep(separators);
diff --git a/vespalib/src/vespa/vespalib/text/stringtokenizer.h b/vespalib/src/vespa/vespalib/text/stringtokenizer.h
index 7a2fecc6469..f1111eee7de 100644
--- a/vespalib/src/vespa/vespalib/text/stringtokenizer.h
+++ b/vespalib/src/vespa/vespalib/text/stringtokenizer.h
@@ -41,9 +41,9 @@ public:
* @param separators The characters to be used as token separators
* @param strip Characters to be stripped from both ends of each token
**/
- StringTokenizer(const vespalib::stringref & source,
- const vespalib::stringref & separators = ",",
- const vespalib::stringref & strip = " \t\f\r\n");
+ StringTokenizer(vespalib::stringref source,
+ vespalib::stringref separators = ",",
+ vespalib::stringref strip = " \t\f\r\n");
/** Remove any empty tokens from the token list */
void removeEmptyTokens();
diff --git a/vespalib/src/vespa/vespalib/text/utf8.h b/vespalib/src/vespa/vespalib/text/utf8.h
index 6a25ef4f21e..0c75203fbbe 100644
--- a/vespalib/src/vespa/vespalib/text/utf8.h
+++ b/vespalib/src/vespa/vespalib/text/utf8.h
@@ -176,7 +176,7 @@ public:
* Construct a reader for the given block of data
* @param input data to read UTF-8 from (can be read-only)
**/
- Utf8Reader(const stringref &input)
+ Utf8Reader(stringref input)
: stringref(input), _pos(0)
{}
diff --git a/vespalib/src/vespa/vespalib/util/exception.cpp b/vespalib/src/vespa/vespalib/util/exception.cpp
index fc2edda0c54..318b167d27b 100644
--- a/vespalib/src/vespa/vespalib/util/exception.cpp
+++ b/vespalib/src/vespa/vespalib/util/exception.cpp
@@ -58,7 +58,7 @@ swap(ExceptionPtr &a, ExceptionPtr &b)
//-----------------------------------------------------------------------------
-Exception::Exception(const stringref &msg, const stringref &location,
+Exception::Exception(stringref msg, stringref location,
int skipStack)
: _what(),
_msg(msg),
@@ -69,8 +69,8 @@ Exception::Exception(const stringref &msg, const stringref &location,
{
}
-Exception::Exception(const stringref &msg, const Exception &cause,
- const stringref &location, int skipStack)
+Exception::Exception(stringref msg, const Exception &cause,
+ stringref location, int skipStack)
: _what(),
_msg(msg),
_location(location),
diff --git a/vespalib/src/vespa/vespalib/util/exception.h b/vespalib/src/vespa/vespalib/util/exception.h
index ff5f02f33da..097ecc131c7 100644
--- a/vespalib/src/vespa/vespalib/util/exception.h
+++ b/vespalib/src/vespa/vespalib/util/exception.h
@@ -61,10 +61,10 @@
#define VESPA_DEFINE_EXCEPTION(MyClass, Parent) \
class MyClass : public Parent { \
public: \
- MyClass(const vespalib::stringref &msg, \
- const vespalib::stringref &location = "", int skipStack = 0); \
- MyClass(const vespalib::stringref &msg, const Exception &cause, \
- const vespalib::stringref &location = "", int skipStack = 0); \
+ MyClass(vespalib::stringref msg, \
+ vespalib::stringref location = "", int skipStack = 0); \
+ MyClass(vespalib::stringref msg, const Exception &cause, \
+ vespalib::stringref location = "", int skipStack = 0); \
VESPA_DEFINE_EXCEPTION_SPINE(MyClass) \
};
@@ -77,11 +77,11 @@ public: \
* @param MyClass the name of your class
**/
#define VESPA_IMPLEMENT_EXCEPTION(MyClass, Parent) \
- MyClass::MyClass(const vespalib::stringref &msg, \
- const vespalib::stringref &location, int skipStack) \
+ MyClass::MyClass(vespalib::stringref msg, \
+ vespalib::stringref location, int skipStack) \
: Parent(msg, location, skipStack + 1) {} \
- MyClass::MyClass(const vespalib::stringref &msg, const Exception &cause, \
- const vespalib::stringref &location, int skipStack) \
+ MyClass::MyClass(vespalib::stringref msg, const Exception &cause, \
+ vespalib::stringref location, int skipStack) \
: Parent(msg, cause, location, skipStack + 1) {} \
VESPA_IMPLEMENT_EXCEPTION_SPINE(MyClass)
@@ -186,7 +186,7 @@ public:
* should send (skipStack + 1) to the parent constructor (see
* \ref VESPA_DEFINE_EXCEPTION for subclass implementation).
**/
- Exception(const stringref &msg, const stringref& location = "", int skipStack = 0);
+ Exception(stringref msg, stringref location = "", int skipStack = 0);
/**
* @brief Construct an exception with a message, a causing exception, and a source code location.
* @param msg A user-readable message describing the problem
@@ -198,8 +198,8 @@ public:
* should send (skipStack + 1) to the parent constructor (see
* \ref VESPA_DEFINE_EXCEPTION for subclass implementation).
**/
- Exception(const stringref &msg, const Exception &cause,
- const stringref &location = "", int skipStack = 0);
+ Exception(stringref msg, const Exception &cause,
+ stringref location = "", int skipStack = 0);
Exception(const Exception &);
Exception & operator = (const Exception &);
Exception(Exception &&) = default;
diff --git a/vespalib/src/vespa/vespalib/util/exceptions.cpp b/vespalib/src/vespa/vespalib/util/exceptions.cpp
index fc64aa79ca4..cdfa91c25ac 100644
--- a/vespalib/src/vespa/vespalib/util/exceptions.cpp
+++ b/vespalib/src/vespa/vespalib/util/exceptions.cpp
@@ -70,27 +70,27 @@ SilenceUncaughtException::~SilenceUncaughtException()
}
vespalib::string
-PortListenException::make_message(int port, const vespalib::stringref &protocol,
- const vespalib::stringref &msg)
+PortListenException::make_message(int port, vespalib::stringref protocol,
+ vespalib::stringref msg)
{
return make_string("failed to listen on port %d with protocol %s%s%s",
port, vespalib::string(protocol).c_str(), msg.empty() ? "" : ": ",
vespalib::string(msg).c_str());
}
-PortListenException::PortListenException(int port, const vespalib::stringref &protocol,
- const vespalib::stringref &msg,
- const vespalib::stringref &location, int skipStack)
+PortListenException::PortListenException(int port, vespalib::stringref protocol,
+ vespalib::stringref msg,
+ vespalib::stringref location, int skipStack)
: Exception(make_message(port, protocol, msg), location, skipStack + 1),
_port(port),
_protocol(protocol)
{
}
-PortListenException::PortListenException(int port, const vespalib::stringref &protocol,
+PortListenException::PortListenException(int port, vespalib::stringref protocol,
const Exception &cause,
- const vespalib::stringref &msg,
- const vespalib::stringref &location, int skipStack)
+ vespalib::stringref msg,
+ vespalib::stringref location, int skipStack)
: Exception(make_message(port, protocol, msg), cause, location, skipStack + 1),
_port(port),
_protocol(protocol)
@@ -104,15 +104,15 @@ PortListenException::~PortListenException() {}
//-----------------------------------------------------------------------------
-IoException::IoException(const stringref & msg, Type type,
- const stringref & location, int skipStack)
+IoException::IoException(stringref msg, Type type,
+ stringref location, int skipStack)
: Exception(createMessage(msg, type), location, skipStack+1),
_type(type)
{
}
-IoException::IoException(const stringref & msg, Type type,
- const Exception& cause, const stringref & location,
+IoException::IoException(stringref msg, Type type,
+ const Exception& cause, stringref location,
int skipStack)
: Exception(createMessage(msg, type), cause, location, skipStack+1),
_type(type)
@@ -120,7 +120,7 @@ IoException::IoException(const stringref & msg, Type type,
}
string
-IoException::createMessage(const stringref & msg, Type type)
+IoException::createMessage(stringref msg, Type type)
{
vespalib::asciistream ost;
switch (type) {
diff --git a/vespalib/src/vespa/vespalib/util/exceptions.h b/vespalib/src/vespa/vespalib/util/exceptions.h
index 4349aaa8d78..452781b1afc 100644
--- a/vespalib/src/vespa/vespalib/util/exceptions.h
+++ b/vespalib/src/vespa/vespalib/util/exceptions.h
@@ -97,17 +97,13 @@ private:
int _port;
vespalib::string _protocol;
- vespalib::string make_message(int port, const vespalib::stringref &protocol,
- const vespalib::stringref &msg);
+ vespalib::string make_message(int port, vespalib::stringref protocol, vespalib::stringref msg);
public:
- PortListenException(int port, const vespalib::stringref &protocol,
- const vespalib::stringref &msg = "",
- const vespalib::stringref &location = "", int skipStack = 0);
- PortListenException(int port, const vespalib::stringref &protocol,
- const Exception &cause,
- const vespalib::stringref &msg = "",
- const vespalib::stringref &location = "", int skipStack = 0);
+ PortListenException(int port, vespalib::stringref protocol, vespalib::stringref msg = "",
+ vespalib::stringref location = "", int skipStack = 0);
+ PortListenException(int port, vespalib::stringref protocol, const Exception &cause, vespalib::stringref msg = "",
+ vespalib::stringref location = "", int skipStack = 0);
PortListenException(PortListenException &&) = default;
PortListenException & operator = (PortListenException &&) = default;
PortListenException(const PortListenException &);
@@ -131,14 +127,12 @@ public:
TOO_MANY_OPEN_FILES, DIRECTORY_HAVE_CONTENT, FILE_FULL,
ALREADY_EXISTS };
- IoException(const stringref & msg, Type type, const stringref & location,
- int skipStack = 0);
- IoException(const stringref & msg, Type type, const Exception& cause,
- const stringref & location, int skipStack = 0);
+ IoException(stringref msg, Type type, stringref location, int skipStack = 0);
+ IoException(stringref msg, Type type, const Exception& cause, stringref location, int skipStack = 0);
VESPA_DEFINE_EXCEPTION_SPINE(IoException);
- static string createMessage(const stringref & msg, Type type);
+ static string createMessage(stringref msg, Type type);
Type getType() const { return _type; }
diff --git a/vespalib/src/vespa/vespalib/util/regexp.cpp b/vespalib/src/vespa/vespalib/util/regexp.cpp
index e1aa4e9b189..684ed1b8fd8 100644
--- a/vespalib/src/vespa/vespalib/util/regexp.cpp
+++ b/vespalib/src/vespa/vespalib/util/regexp.cpp
@@ -24,7 +24,7 @@ Regexp::Flags::enableICASE()
}
bool
-Regexp::compile(const vespalib::stringref & re, Flags flags)
+Regexp::compile(vespalib::stringref re, Flags flags)
{
re_set_syntax(flags.flags());
regex_t *preg = (regex_t *)_data;
@@ -45,7 +45,7 @@ Regexp::compile(const vespalib::stringref & re, Flags flags)
}
-Regexp::Regexp(const vespalib::stringref & re, Flags flags)
+Regexp::Regexp(vespalib::stringref re, Flags flags)
: _valid(false),
_data(new regex_t)
{
@@ -53,7 +53,7 @@ Regexp::Regexp(const vespalib::stringref & re, Flags flags)
}
bool
-Regexp::match(const vespalib::stringref & s) const
+Regexp::match(vespalib::stringref s) const
{
if ( ! valid() ) { return false; }
regex_t *preg = const_cast<regex_t *>(static_cast<const regex_t *>(_data));
@@ -64,7 +64,7 @@ Regexp::match(const vespalib::stringref & s) const
return pos >= 0;
}
-vespalib::string Regexp::replace(const vespalib::stringref & s, const vespalib::stringref & replacement) const
+vespalib::string Regexp::replace(vespalib::stringref s, vespalib::stringref replacement) const
{
if ( ! valid() ) { return s; }
regex_t *preg = const_cast<regex_t *>(static_cast<const regex_t *>(_data));
@@ -92,7 +92,7 @@ Regexp::~Regexp()
namespace {
-bool has_option(const vespalib::stringref & re) {
+bool has_option(vespalib::stringref re) {
return (re.find('|') != re.npos);
}
@@ -105,7 +105,7 @@ bool maybe_none(char c) {
const vespalib::string special("^|()[]{}.*?+\\$");
bool is_special(char c) { return special.find(c) != special.npos; }
-vespalib::string escape(const vespalib::stringref &str) {
+vespalib::string escape(vespalib::stringref str) {
vespalib::string result;
for (char c: str) {
if (is_special(c)) {
@@ -119,7 +119,7 @@ vespalib::string escape(const vespalib::stringref &str) {
} // namespace vespalib::<unnamed>
vespalib::string
-Regexp::get_prefix(const vespalib::stringref & re)
+Regexp::get_prefix(vespalib::stringref re)
{
vespalib::string prefix;
if ((re.size() > 0) && (re.data()[0] == '^') && !has_option(re)) {
@@ -136,19 +136,19 @@ Regexp::get_prefix(const vespalib::stringref & re)
}
vespalib::string
-Regexp::make_from_prefix(const vespalib::stringref &prefix)
+Regexp::make_from_prefix(vespalib::stringref prefix)
{
return "^" + escape(prefix);
}
vespalib::string
-Regexp::make_from_suffix(const vespalib::stringref &suffix)
+Regexp::make_from_suffix(vespalib::stringref suffix)
{
return escape(suffix) + "$";
}
vespalib::string
-Regexp::make_from_substring(const vespalib::stringref &substring)
+Regexp::make_from_substring(vespalib::stringref substring)
{
return escape(substring);
}
diff --git a/vespalib/src/vespa/vespalib/util/regexp.h b/vespalib/src/vespa/vespalib/util/regexp.h
index 31db95c5d7e..6a97b72cdda 100644
--- a/vespalib/src/vespa/vespalib/util/regexp.h
+++ b/vespalib/src/vespa/vespalib/util/regexp.h
@@ -38,7 +38,7 @@ public:
* @throw IllegalArgumentException if the RE is invalid.
* @param re Regular expression.
**/
- Regexp(const vespalib::stringref & re, Flags=Flags());
+ Regexp(vespalib::stringref re, Flags=Flags());
~Regexp();
@@ -54,7 +54,7 @@ public:
* @param s text to search for a match.
* @return true if a match was found.
**/
- bool match(const vespalib::stringref & s) const;
+ bool match(vespalib::stringref s) const;
/**
* Will replace all occurrences of this pattern is string 's' with 'replacement'.
@@ -63,7 +63,7 @@ public:
* @param replacement text to replace the pattern.
* @return modified string.
**/
- vespalib::string replace(const vespalib::stringref & s, const vespalib::stringref & replacement) const;
+ vespalib::string replace(vespalib::stringref s, vespalib::stringref replacement) const;
/**
* Look at the given regular expression and identify the prefix
@@ -75,7 +75,7 @@ public:
* @param re Regular expression.
* @return prefix that must be present in matching strings
**/
- static vespalib::string get_prefix(const vespalib::stringref & re);
+ static vespalib::string get_prefix(vespalib::stringref re);
/**
* Make a regexp matching strings with the given prefix.
@@ -83,7 +83,7 @@ public:
* @param prefix the prefix
* @return the regexp
**/
- static vespalib::string make_from_prefix(const vespalib::stringref &prefix);
+ static vespalib::string make_from_prefix(vespalib::stringref prefix);
/**
* Make a regexp matching strings with the given suffix.
@@ -91,7 +91,7 @@ public:
* @param suffix the suffix
* @return the regexp
**/
- static vespalib::string make_from_suffix(const vespalib::stringref &suffix);
+ static vespalib::string make_from_suffix(vespalib::stringref suffix);
/**
* Make a regexp matching strings with the given substring.
@@ -99,12 +99,12 @@ public:
* @param substring the substring
* @return the regexp
**/
- static vespalib::string make_from_substring(const vespalib::stringref &substring);
+ static vespalib::string make_from_substring(vespalib::stringref substring);
private:
bool _valid;
void *_data;
- bool compile(const vespalib::stringref & re, Flags flags);
+ bool compile(vespalib::stringref re, Flags flags);
};
} // namespace vespalib