incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [4/4] git commit: Making the multivalue field checking logic more forgiving for users that are upgrading from older versions.
Date Wed, 04 Mar 2015 13:54:32 GMT
Making the multivalue field checking logic more forgiving for users that are upgrading from
older versions.


Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/b97e31f9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/b97e31f9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/b97e31f9

Branch: refs/heads/master
Commit: b97e31f9353c13cb6beb15658ec9dc4a436804af
Parents: cd4d44d
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Wed Mar 4 08:54:25 2015 -0500
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Wed Mar 4 08:54:25 2015 -0500

----------------------------------------------------------------------
 .../blur/analysis/FieldTypeDefinition.java      |  3 ++-
 .../apache/blur/analysis/HdfsFieldManager.java  | 24 +++++++++++++++--
 .../type/MultiValuedNotAllowedException.java    | 27 ++++++++++++++++++++
 .../spatial/BaseSpatialFieldTypeDefinition.java |  3 ++-
 4 files changed, 53 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/b97e31f9/blur-query/src/main/java/org/apache/blur/analysis/FieldTypeDefinition.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/analysis/FieldTypeDefinition.java b/blur-query/src/main/java/org/apache/blur/analysis/FieldTypeDefinition.java
index ce724f5..4fc6452 100644
--- a/blur-query/src/main/java/org/apache/blur/analysis/FieldTypeDefinition.java
+++ b/blur-query/src/main/java/org/apache/blur/analysis/FieldTypeDefinition.java
@@ -21,6 +21,7 @@ import java.util.Collection;
 import java.util.Iterator;
 import java.util.Map;
 
+import org.apache.blur.analysis.type.MultiValuedNotAllowedException;
 import org.apache.blur.thrift.generated.Column;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.lucene.analysis.Analyzer;
@@ -247,7 +248,7 @@ public abstract class FieldTypeDefinition {
 
   public void setMultiValueField(boolean multiValueField) {
     if (multiValueField && isSortEnable()) {
-      throw new RuntimeException("Field [" + getFieldName() + "] with type [" + getName()
+      throw new MultiValuedNotAllowedException("Field [" + getFieldName() + "] with type
[" + getName()
           + "] can not be sortable and multi valued.");
     }
     _multiValueField = multiValueField;

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/b97e31f9/blur-query/src/main/java/org/apache/blur/analysis/HdfsFieldManager.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/analysis/HdfsFieldManager.java b/blur-query/src/main/java/org/apache/blur/analysis/HdfsFieldManager.java
index dac34fc..3620d7b 100644
--- a/blur-query/src/main/java/org/apache/blur/analysis/HdfsFieldManager.java
+++ b/blur-query/src/main/java/org/apache/blur/analysis/HdfsFieldManager.java
@@ -28,6 +28,7 @@ import java.util.UUID;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 
+import org.apache.blur.analysis.type.MultiValuedNotAllowedException;
 import org.apache.blur.log.Log;
 import org.apache.blur.log.LogFactory;
 import org.apache.blur.trace.Trace;
@@ -204,8 +205,27 @@ public class HdfsFieldManager extends BaseFieldManager {
       }
       String fieldType = properties.getProperty(FIELD_TYPE);
       Map<String, String> props = toMap(properties);
-      FieldTypeDefinition fieldTypeDefinition = newFieldTypeDefinition(fieldName, fieldLessIndexing,
fieldType,
-          sortenabled, multiValueField, props);
+
+      if (mvfProp == null) {
+        if (multiValueField && sortenabled) {
+          // @TODO hack because we use to not have multivalue in the schema
+          LOG.warn("Changing field [{0}] to be NOT multiValueField.", fieldName);
+          multiValueField = false;
+        }
+      }
+      FieldTypeDefinition fieldTypeDefinition;
+      try {
+        fieldTypeDefinition = newFieldTypeDefinition(fieldName, fieldLessIndexing, fieldType,
sortenabled,
+            multiValueField, props);
+      } catch (MultiValuedNotAllowedException e) {
+        if (mvfProp == null) {
+          multiValueField = false;
+          fieldTypeDefinition = newFieldTypeDefinition(fieldName, fieldLessIndexing, fieldType,
sortenabled,
+              multiValueField, props);
+        } else {
+          throw e;
+        }
+      }
       fieldTypeDefinition.setFamily(properties.getProperty(FAMILY));
       fieldTypeDefinition.setColumnName(properties.getProperty(COLUMN_NAME));
       fieldTypeDefinition.setSubColumnName(properties.getProperty(SUB_COLUMN_NAME));

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/b97e31f9/blur-query/src/main/java/org/apache/blur/analysis/type/MultiValuedNotAllowedException.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/analysis/type/MultiValuedNotAllowedException.java
b/blur-query/src/main/java/org/apache/blur/analysis/type/MultiValuedNotAllowedException.java
new file mode 100644
index 0000000..559a4f4
--- /dev/null
+++ b/blur-query/src/main/java/org/apache/blur/analysis/type/MultiValuedNotAllowedException.java
@@ -0,0 +1,27 @@
+/**
+ * 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.blur.analysis.type;
+
+public class MultiValuedNotAllowedException extends RuntimeException {
+
+  private static final long serialVersionUID = 1045410245256531843L;
+
+  public MultiValuedNotAllowedException(String message) {
+    super(message);
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/b97e31f9/blur-query/src/main/java/org/apache/blur/analysis/type/spatial/BaseSpatialFieldTypeDefinition.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/analysis/type/spatial/BaseSpatialFieldTypeDefinition.java
b/blur-query/src/main/java/org/apache/blur/analysis/type/spatial/BaseSpatialFieldTypeDefinition.java
index 560c5ca..f442232 100644
--- a/blur-query/src/main/java/org/apache/blur/analysis/type/spatial/BaseSpatialFieldTypeDefinition.java
+++ b/blur-query/src/main/java/org/apache/blur/analysis/type/spatial/BaseSpatialFieldTypeDefinition.java
@@ -21,6 +21,7 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.blur.analysis.type.CustomFieldTypeDefinition;
+import org.apache.blur.analysis.type.MultiValuedNotAllowedException;
 import org.apache.blur.thrift.generated.Column;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.document.StoredField;
@@ -178,7 +179,7 @@ public abstract class BaseSpatialFieldTypeDefinition extends CustomFieldTypeDefi
     if (!multiValueField) {
       super.setMultiValueField(multiValueField);
     } else {
-      throw new RuntimeException("Field type [" + getName() + "] can not multi valued.");
+      throw new MultiValuedNotAllowedException("Field type [" + getName() + "] can not multi
valued.");
     }
   }
 


Mime
View raw message