Updated Branches: refs/heads/master db3a0eba3 -> 5e074f458
Some refactoring. Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/5e074f45 Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/5e074f45 Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/5e074f45 Branch: refs/heads/master Commit: 5e074f458b9fb9e75898a7c3cf0c3f5bfc05e38b Parents: db3a0eb Author: Aaron McCurry <[email protected]> Authored: Tue Aug 13 09:50:42 2013 -0400 Committer: Aaron McCurry <[email protected]> Committed: Tue Aug 13 09:50:42 2013 -0400 ---------------------------------------------------------------------- .../type/CustomFieldTypeDefinition.java | 74 ++++++++++++++++++++ .../type/SpatialFieldTypeDefinition.java | 60 ++-------------- 2 files changed, 79 insertions(+), 55 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5e074f45/blur-query/src/main/java/org/apache/blur/analysis/type/CustomFieldTypeDefinition.java ---------------------------------------------------------------------- diff --git a/blur-query/src/main/java/org/apache/blur/analysis/type/CustomFieldTypeDefinition.java b/blur-query/src/main/java/org/apache/blur/analysis/type/CustomFieldTypeDefinition.java new file mode 100644 index 0000000..c91c9eb --- /dev/null +++ b/blur-query/src/main/java/org/apache/blur/analysis/type/CustomFieldTypeDefinition.java @@ -0,0 +1,74 @@ +package org.apache.blur.analysis.type; + +/** + * 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. + */ +import org.apache.blur.analysis.FieldTypeDefinition; +import org.apache.lucene.analysis.Analyzer; +import org.apache.lucene.analysis.core.KeywordAnalyzer; +import org.apache.lucene.document.FieldType; + +public abstract class CustomFieldTypeDefinition extends FieldTypeDefinition { + + private static final String NOT_SUPPORTED = "Not supported"; + private final Analyzer _queryAnalyzer = new KeywordAnalyzer(); + + @Override + public final FieldType getStoredFieldType() { + throw new RuntimeException(NOT_SUPPORTED); + } + + @Override + public final FieldType getNotStoredFieldType() { + throw new RuntimeException(NOT_SUPPORTED); + } + + @Override + public final Analyzer getAnalyzerForIndex() { + throw new RuntimeException(NOT_SUPPORTED); + } + + @Override + public final Analyzer getAnalyzerForQuery() { + return _queryAnalyzer; + } + + @Override + public final boolean checkSupportForFuzzyQuery() { + return false; + } + + @Override + public final boolean checkSupportForWildcardQuery() { + return false; + } + + @Override + public final boolean checkSupportForPrefixQuery() { + return false; + } + + @Override + public final boolean isNumeric() { + return false; + } + + @Override + public final boolean checkSupportForCustomQuery() { + return true; + } + +} http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5e074f45/blur-query/src/main/java/org/apache/blur/analysis/type/SpatialFieldTypeDefinition.java ---------------------------------------------------------------------- diff --git a/blur-query/src/main/java/org/apache/blur/analysis/type/SpatialFieldTypeDefinition.java b/blur-query/src/main/java/org/apache/blur/analysis/type/SpatialFieldTypeDefinition.java index fa36cfe..7197144 100644 --- a/blur-query/src/main/java/org/apache/blur/analysis/type/SpatialFieldTypeDefinition.java +++ b/blur-query/src/main/java/org/apache/blur/analysis/type/SpatialFieldTypeDefinition.java @@ -20,13 +20,9 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import org.apache.blur.analysis.FieldTypeDefinition; import org.apache.blur.analysis.type.spatial.SpatialArgsParser; import org.apache.blur.thrift.generated.Column; -import org.apache.lucene.analysis.Analyzer; -import org.apache.lucene.analysis.core.KeywordAnalyzer; import org.apache.lucene.document.Field; -import org.apache.lucene.document.FieldType; import org.apache.lucene.document.StoredField; import org.apache.lucene.search.Query; import org.apache.lucene.spatial.SpatialStrategy; @@ -39,7 +35,7 @@ import com.spatial4j.core.context.SpatialContext; import com.spatial4j.core.io.ShapeReadWriter; import com.spatial4j.core.shape.Shape; -public class SpatialFieldTypeDefinition extends FieldTypeDefinition { +public class SpatialFieldTypeDefinition extends CustomFieldTypeDefinition { private static final String MAX_LEVELS = "maxLevels"; public static final String NAME = "spatial"; @@ -47,7 +43,6 @@ public class SpatialFieldTypeDefinition extends FieldTypeDefinition { private SpatialStrategy _strategy; private SpatialContext _ctx; private ShapeReadWriter<SpatialContext> _shapeReadWriter; - private final Analyzer _queryAnalyzer = new KeywordAnalyzer(); @Override public String getName() { @@ -82,10 +77,6 @@ public class SpatialFieldTypeDefinition extends FieldTypeDefinition { return fields; } - private String cleanup(Shape shape) { - return _shapeReadWriter.writeShape(shape); - } - @Override public Iterable<? extends Field> getFieldsForSubColumn(String family, Column column, String subName) { String name = getName(family, column.getName(), subName); @@ -100,59 +91,18 @@ public class SpatialFieldTypeDefinition extends FieldTypeDefinition { return fields; } - private Shape getShape(Column column) { - return _shapeReadWriter.readShape(column.getValue()); - } - @Override public Query getCustomQuery(String text) { SpatialArgs args = SpatialArgsParser.parse(text, _shapeReadWriter); return _strategy.makeQuery(args); } - @Override - public FieldType getStoredFieldType() { - throw new RuntimeException("Not supported"); - } - - @Override - public FieldType getNotStoredFieldType() { - throw new RuntimeException("Not supported"); - } - - @Override - public Analyzer getAnalyzerForIndex() { - throw new RuntimeException("Not supported"); - } - - @Override - public Analyzer getAnalyzerForQuery() { - return _queryAnalyzer; - } - - @Override - public boolean checkSupportForFuzzyQuery() { - return false; - } - - @Override - public boolean checkSupportForWildcardQuery() { - return false; - } - - @Override - public boolean checkSupportForPrefixQuery() { - return false; + private Shape getShape(Column column) { + return _shapeReadWriter.readShape(column.getValue()); } - @Override - public boolean isNumeric() { - return false; + private String cleanup(Shape shape) { + return _shapeReadWriter.writeShape(shape); } - @Override - public boolean checkSupportForCustomQuery() { - return true; - } - }
