From 4bee76f6cfe96e7c4abc20fa31ca0b4f387b1f9c Mon Sep 17 00:00:00 2001 From: Christine Poerschke Date: Mon, 26 Sep 2016 19:09:00 +0100 Subject: [PATCH] Remove LTRException, move FeatureException. (#82) * Remove hardly used LTRException. Also param name tweaks for FeatureException and ModelException. * Relocate FeatureException from ltr.util to ltr.feature package. --- .../{util => feature}/FeatureException.java | 12 +++---- .../apache/solr/ltr/feature/FeatureStore.java | 1 - .../solr/ltr/feature/LTRScoringAlgorithm.java | 1 - .../solr/ltr/feature/impl/SolrFeature.java | 2 +- .../solr/ltr/feature/impl/ValueFeature.java | 2 +- .../solr/ltr/rest/ManagedFeatureStore.java | 2 +- .../apache/solr/ltr/util/LTRException.java | 31 ------------------- .../apache/solr/ltr/util/ModelException.java | 6 ++-- .../org/apache/solr/ltr/TestRerankBase.java | 2 +- .../solr/ltr/feature/TestFeatureMetadata.java | 1 - .../solr/ltr/feature/TestFeatureStore.java | 1 - .../ltr/feature/impl/TestRankingFeature.java | 2 +- .../ltr/feature/impl/TestValueFeature.java | 2 +- 13 files changed, 15 insertions(+), 50 deletions(-) rename solr/contrib/ltr/src/java/org/apache/solr/ltr/{util => feature}/FeatureException.java (77%) delete mode 100644 solr/contrib/ltr/src/java/org/apache/solr/ltr/util/LTRException.java diff --git a/solr/contrib/ltr/src/java/org/apache/solr/ltr/util/FeatureException.java b/solr/contrib/ltr/src/java/org/apache/solr/ltr/feature/FeatureException.java similarity index 77% rename from solr/contrib/ltr/src/java/org/apache/solr/ltr/util/FeatureException.java rename to solr/contrib/ltr/src/java/org/apache/solr/ltr/feature/FeatureException.java index db3381c7b6ae..6c8f82762f0b 100644 --- a/solr/contrib/ltr/src/java/org/apache/solr/ltr/util/FeatureException.java +++ b/solr/contrib/ltr/src/java/org/apache/solr/ltr/feature/FeatureException.java @@ -14,18 +14,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.solr.ltr.util; +package org.apache.solr.ltr.feature; -public class FeatureException extends LTRException { +public class FeatureException extends RuntimeException { private static final long serialVersionUID = 1L; - public FeatureException(String msg) { - super(msg); + public FeatureException(String message) { + super(message); } - public FeatureException(String msg, Exception parent) { - super(msg, parent); + public FeatureException(String message, Exception cause) { + super(message, cause); } } diff --git a/solr/contrib/ltr/src/java/org/apache/solr/ltr/feature/FeatureStore.java b/solr/contrib/ltr/src/java/org/apache/solr/ltr/feature/FeatureStore.java index e9912b6955ff..9fa37bc98045 100644 --- a/solr/contrib/ltr/src/java/org/apache/solr/ltr/feature/FeatureStore.java +++ b/solr/contrib/ltr/src/java/org/apache/solr/ltr/feature/FeatureStore.java @@ -21,7 +21,6 @@ import java.util.LinkedHashMap; import java.util.List; import org.apache.solr.ltr.ranking.Feature; -import org.apache.solr.ltr.util.FeatureException; public class FeatureStore { diff --git a/solr/contrib/ltr/src/java/org/apache/solr/ltr/feature/LTRScoringAlgorithm.java b/solr/contrib/ltr/src/java/org/apache/solr/ltr/feature/LTRScoringAlgorithm.java index c832de382749..6d9cfcdc58d5 100644 --- a/solr/contrib/ltr/src/java/org/apache/solr/ltr/feature/LTRScoringAlgorithm.java +++ b/solr/contrib/ltr/src/java/org/apache/solr/ltr/feature/LTRScoringAlgorithm.java @@ -26,7 +26,6 @@ import org.apache.solr.ltr.feature.norm.Normalizer; import org.apache.solr.ltr.feature.norm.impl.IdentityNormalizer; import org.apache.solr.ltr.ranking.Feature; -import org.apache.solr.ltr.util.FeatureException; /** * Contains all the data needed for loading a model. diff --git a/solr/contrib/ltr/src/java/org/apache/solr/ltr/feature/impl/SolrFeature.java b/solr/contrib/ltr/src/java/org/apache/solr/ltr/feature/impl/SolrFeature.java index bfa8d610cc79..4c440b119a0b 100644 --- a/solr/contrib/ltr/src/java/org/apache/solr/ltr/feature/impl/SolrFeature.java +++ b/solr/contrib/ltr/src/java/org/apache/solr/ltr/feature/impl/SolrFeature.java @@ -33,8 +33,8 @@ import org.apache.solr.common.params.CommonParams; import org.apache.solr.common.util.NamedList; import org.apache.solr.core.SolrCore; +import org.apache.solr.ltr.feature.FeatureException; import org.apache.solr.ltr.ranking.Feature; -import org.apache.solr.ltr.util.FeatureException; import org.apache.solr.request.LocalSolrQueryRequest; import org.apache.solr.request.SolrQueryRequest; import org.apache.solr.search.QParser; diff --git a/solr/contrib/ltr/src/java/org/apache/solr/ltr/feature/impl/ValueFeature.java b/solr/contrib/ltr/src/java/org/apache/solr/ltr/feature/impl/ValueFeature.java index d50a16dde009..6f7c67ff7a2d 100644 --- a/solr/contrib/ltr/src/java/org/apache/solr/ltr/feature/impl/ValueFeature.java +++ b/solr/contrib/ltr/src/java/org/apache/solr/ltr/feature/impl/ValueFeature.java @@ -24,8 +24,8 @@ import org.apache.lucene.search.DocIdSetIterator; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.Query; +import org.apache.solr.ltr.feature.FeatureException; import org.apache.solr.ltr.ranking.Feature; -import org.apache.solr.ltr.util.FeatureException; import org.apache.solr.ltr.util.LTRUtils; import org.apache.solr.request.SolrQueryRequest; diff --git a/solr/contrib/ltr/src/java/org/apache/solr/ltr/rest/ManagedFeatureStore.java b/solr/contrib/ltr/src/java/org/apache/solr/ltr/rest/ManagedFeatureStore.java index 6e8ac5426a8a..7913ec6a1819 100644 --- a/solr/contrib/ltr/src/java/org/apache/solr/ltr/rest/ManagedFeatureStore.java +++ b/solr/contrib/ltr/src/java/org/apache/solr/ltr/rest/ManagedFeatureStore.java @@ -27,10 +27,10 @@ import org.apache.solr.common.SolrException.ErrorCode; import org.apache.solr.common.util.NamedList; import org.apache.solr.core.SolrResourceLoader; +import org.apache.solr.ltr.feature.FeatureException; import org.apache.solr.ltr.feature.FeatureStore; import org.apache.solr.ltr.ranking.Feature; import org.apache.solr.ltr.util.CommonLTRParams; -import org.apache.solr.ltr.util.FeatureException; import org.apache.solr.response.SolrQueryResponse; import org.apache.solr.rest.BaseSolrResource; import org.apache.solr.rest.ManagedResource; diff --git a/solr/contrib/ltr/src/java/org/apache/solr/ltr/util/LTRException.java b/solr/contrib/ltr/src/java/org/apache/solr/ltr/util/LTRException.java deleted file mode 100644 index 3fa732d7a630..000000000000 --- a/solr/contrib/ltr/src/java/org/apache/solr/ltr/util/LTRException.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.solr.ltr.util; - -public class LTRException extends RuntimeException { - - private static final long serialVersionUID = 1L; - - public LTRException(String message) { - super(message); - } - - public LTRException(String message, Exception parent) { - super(message, parent); - } - -} diff --git a/solr/contrib/ltr/src/java/org/apache/solr/ltr/util/ModelException.java b/solr/contrib/ltr/src/java/org/apache/solr/ltr/util/ModelException.java index 79e3f13ee4bd..f720b6b9d053 100644 --- a/solr/contrib/ltr/src/java/org/apache/solr/ltr/util/ModelException.java +++ b/solr/contrib/ltr/src/java/org/apache/solr/ltr/util/ModelException.java @@ -16,7 +16,7 @@ */ package org.apache.solr.ltr.util; -public class ModelException extends LTRException { +public class ModelException extends RuntimeException { private static final long serialVersionUID = 1L; @@ -24,8 +24,8 @@ public ModelException(String message) { super(message); } - public ModelException(String message, Exception parent) { - super(message, parent); + public ModelException(String message, Exception cause) { + super(message, cause); } } diff --git a/solr/contrib/ltr/src/test/org/apache/solr/ltr/TestRerankBase.java b/solr/contrib/ltr/src/test/org/apache/solr/ltr/TestRerankBase.java index a4a8e860fa13..435ff1152a01 100644 --- a/solr/contrib/ltr/src/test/org/apache/solr/ltr/TestRerankBase.java +++ b/solr/contrib/ltr/src/test/org/apache/solr/ltr/TestRerankBase.java @@ -38,6 +38,7 @@ import org.apache.solr.common.util.ContentStream; import org.apache.solr.common.util.ContentStreamBase; import org.apache.solr.core.SolrResourceLoader; +import org.apache.solr.ltr.feature.FeatureException; import org.apache.solr.ltr.feature.LTRScoringAlgorithm; import org.apache.solr.ltr.feature.impl.ValueFeature; import org.apache.solr.ltr.feature.impl.ValueFeature.ValueFeatureWeight; @@ -46,7 +47,6 @@ import org.apache.solr.ltr.rest.ManagedFeatureStore; import org.apache.solr.ltr.rest.ManagedModelStore; import org.apache.solr.ltr.util.CommonLTRParams; -import org.apache.solr.ltr.util.FeatureException; import org.apache.solr.ltr.util.ModelException; import org.apache.solr.request.SolrQueryRequestBase; import org.apache.solr.response.SolrQueryResponse; diff --git a/solr/contrib/ltr/src/test/org/apache/solr/ltr/feature/TestFeatureMetadata.java b/solr/contrib/ltr/src/test/org/apache/solr/ltr/feature/TestFeatureMetadata.java index 1f1fdac298b9..76e2dc258534 100644 --- a/solr/contrib/ltr/src/test/org/apache/solr/ltr/feature/TestFeatureMetadata.java +++ b/solr/contrib/ltr/src/test/org/apache/solr/ltr/feature/TestFeatureMetadata.java @@ -23,7 +23,6 @@ import org.apache.solr.ltr.feature.impl.OriginalScoreFeature; import org.apache.solr.ltr.ranking.Feature; import org.apache.solr.ltr.rest.ManagedFeatureStore; -import org.apache.solr.ltr.util.FeatureException; import org.apache.solr.common.SolrException; import org.apache.solr.common.SolrException.ErrorCode; import org.junit.AfterClass; diff --git a/solr/contrib/ltr/src/test/org/apache/solr/ltr/feature/TestFeatureStore.java b/solr/contrib/ltr/src/test/org/apache/solr/ltr/feature/TestFeatureStore.java index 0a6e4a8cdcd0..b16b9fb14a75 100644 --- a/solr/contrib/ltr/src/test/org/apache/solr/ltr/feature/TestFeatureStore.java +++ b/solr/contrib/ltr/src/test/org/apache/solr/ltr/feature/TestFeatureStore.java @@ -24,7 +24,6 @@ import org.apache.solr.ltr.feature.impl.ValueFeature; import org.apache.solr.ltr.ranking.Feature; import org.apache.solr.ltr.rest.ManagedFeatureStore; -import org.apache.solr.ltr.util.FeatureException; import org.junit.BeforeClass; import org.junit.Test; diff --git a/solr/contrib/ltr/src/test/org/apache/solr/ltr/feature/impl/TestRankingFeature.java b/solr/contrib/ltr/src/test/org/apache/solr/ltr/feature/impl/TestRankingFeature.java index 9982907fd241..8ab586fba816 100644 --- a/solr/contrib/ltr/src/test/org/apache/solr/ltr/feature/impl/TestRankingFeature.java +++ b/solr/contrib/ltr/src/test/org/apache/solr/ltr/feature/impl/TestRankingFeature.java @@ -85,7 +85,7 @@ public void testRankingSolrFeature() throws Exception { query.add("rq", "{!ltr model=powdesS-model reRankDocs=4}"); assertJQ("/query" + query.toQueryString(), - "/error/msg/=='org.apache.solr.ltr.util.FeatureException: " + + "/error/msg/=='org.apache.solr.ltr.feature.FeatureException: " + "java.lang.UnsupportedOperationException: " + "Unable to extract feature for powdesS'"); // aftertest(); diff --git a/solr/contrib/ltr/src/test/org/apache/solr/ltr/feature/impl/TestValueFeature.java b/solr/contrib/ltr/src/test/org/apache/solr/ltr/feature/impl/TestValueFeature.java index 5bb34a7b519a..58ec8727895a 100644 --- a/solr/contrib/ltr/src/test/org/apache/solr/ltr/feature/impl/TestValueFeature.java +++ b/solr/contrib/ltr/src/test/org/apache/solr/ltr/feature/impl/TestValueFeature.java @@ -19,8 +19,8 @@ import org.apache.lucene.util.LuceneTestCase.SuppressCodecs; import org.apache.solr.client.solrj.SolrQuery; import org.apache.solr.ltr.TestRerankBase; +import org.apache.solr.ltr.feature.FeatureException; import org.apache.solr.ltr.ranking.RankSVMModel; -import org.apache.solr.ltr.util.FeatureException; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test;