incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [12/39] git commit: Starting to build a way to store the fields on the file system.
Date Mon, 12 Aug 2013 15:48:51 GMT
Starting to build a way to store the fields on the file system.


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

Branch: refs/heads/master
Commit: 416c6e2e92eb7b8f931983f72c9bc35b55668609
Parents: 193c0e6
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Wed Jul 3 21:04:43 2013 -0400
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Wed Jul 3 21:04:43 2013 -0400

----------------------------------------------------------------------
 .../apache/blur/analysis/BaseFieldManager.java  | 39 ++++++++++++++------
 .../org/apache/blur/analysis/FieldManager.java  |  3 +-
 .../apache/blur/analysis/HdfsFieldManager.java  |  7 ++++
 3 files changed, 37 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/416c6e2e/blur-query/src/main/java/org/apache/blur/analysis/BaseFieldManager.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/analysis/BaseFieldManager.java b/blur-query/src/main/java/org/apache/blur/analysis/BaseFieldManager.java
index 0bf4b3b..b2f005d 100644
--- a/blur-query/src/main/java/org/apache/blur/analysis/BaseFieldManager.java
+++ b/blur-query/src/main/java/org/apache/blur/analysis/BaseFieldManager.java
@@ -52,7 +52,7 @@ public abstract class BaseFieldManager extends FieldManager {
 
   private final Map<String, Set<String>> _columnToSubColumn = new ConcurrentHashMap<String,
Set<String>>();
   private final Map<String, FieldTypeDefinition> _fieldNameToDefMap = new ConcurrentHashMap<String,
FieldTypeDefinition>();
-  
+
   // This is loaded at object creation and never changed again.
   private final Map<String, Class<? extends FieldTypeDefinition>> _typeMap =
new ConcurrentHashMap<String, Class<? extends FieldTypeDefinition>>();
   private final Analyzer _baseAnalyzerForQuery;
@@ -181,7 +181,7 @@ public abstract class BaseFieldManager extends FieldManager {
   }
 
   private FieldTypeDefinition getFieldTypeDefinition(String family, Column column, String
subName) {
-    return _fieldNameToDefMap.get(getSubColumnName(family, column, subName));
+    return getFieldTypeDefinition(getSubColumnName(family, column, subName));
   }
 
   private String getSubColumnName(String family, Column column, String subName) {
@@ -201,16 +201,17 @@ public abstract class BaseFieldManager extends FieldManager {
   }
 
   private FieldTypeDefinition getFieldTypeDefinition(String family, Column column) {
-    return _fieldNameToDefMap.get(getColumnName(family, column));
+    return getFieldTypeDefinition(getColumnName(family, column));
   }
 
   @Override
-  public void addColumnDefinition(String family, String columnName, String subColumnName,
boolean fieldLessIndexing,
+  public boolean addColumnDefinition(String family, String columnName, String subColumnName,
boolean fieldLessIndexing,
       String fieldType, Map<String, String> props) {
     String baseFieldName = family + "." + columnName;
     String fieldName;
     if (subColumnName != null) {
-      if (!_fieldNameToDefMap.containsKey(baseFieldName)) {
+      FieldTypeDefinition primeFieldTypeDefinition = getFieldTypeDefinition(baseFieldName);
+      if (primeFieldTypeDefinition == null) {
         throw new IllegalArgumentException("Base column of [" + baseFieldName
             + "] not found, please add base before adding sub column.");
       }
@@ -222,14 +223,17 @@ public abstract class BaseFieldManager extends FieldManager {
     } else {
       fieldName = baseFieldName;
     }
+    FieldTypeDefinition fieldTypeDefinition = getFieldTypeDefinition(fieldName);
+    if (fieldTypeDefinition != null) {
+      return false;
+    }
     if (!tryToStore(fieldName, fieldLessIndexing, fieldType, props)) {
-      
+      return false;
     }
     Class<? extends FieldTypeDefinition> clazz = _typeMap.get(fieldType);
     if (clazz == null) {
       throw new IllegalArgumentException("FieldType of [" + fieldType + "] was not found.");
     }
-    FieldTypeDefinition fieldTypeDefinition;
     try {
       fieldTypeDefinition = clazz.newInstance();
     } catch (InstantiationException e) {
@@ -250,11 +254,15 @@ public abstract class BaseFieldManager extends FieldManager {
       Set<String> subColumnNames = _columnToSubColumn.put(baseFieldName, getConcurrentSet());
       subColumnNames.add(subColumnName);
     }
+    return true;
   }
 
   protected abstract boolean tryToStore(String fieldName, boolean fieldLessIndexing, String
fieldType,
       Map<String, String> props);
 
+  protected abstract void tryToLoad(String field, Map<String, FieldTypeDefinition>
fieldNameToDefMap,
+      Map<String, Set<String>> columnToSubColumn);
+
   private Set<String> getConcurrentSet() {
     return Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>());
   }
@@ -262,12 +270,16 @@ public abstract class BaseFieldManager extends FieldManager {
   @Override
   public boolean isValidColumnDefinition(String family, String columnName) {
     String fieldName = getColumnName(family, columnName);
-    return _fieldNameToDefMap.containsKey(fieldName);
+    FieldTypeDefinition fieldTypeDefinition = getFieldTypeDefinition(fieldName);
+    if (fieldTypeDefinition == null) {
+      return false;
+    }
+    return true;
   }
 
   @Override
   public Analyzer getAnalyzerForIndex(String fieldName) {
-    FieldTypeDefinition fieldTypeDefinition = _fieldNameToDefMap.get(fieldName);
+    FieldTypeDefinition fieldTypeDefinition = getFieldTypeDefinition(fieldName);
     if (fieldTypeDefinition == null) {
       throw new AnalyzerNotFoundException(fieldName);
     }
@@ -276,7 +288,7 @@ public abstract class BaseFieldManager extends FieldManager {
 
   @Override
   public Analyzer getAnalyzerForQuery(String fieldName) {
-    FieldTypeDefinition fieldTypeDefinition = _fieldNameToDefMap.get(fieldName);
+    FieldTypeDefinition fieldTypeDefinition = getFieldTypeDefinition(fieldName);
     if (fieldTypeDefinition == null) {
       throw new AnalyzerNotFoundException(fieldName);
     }
@@ -367,7 +379,12 @@ public abstract class BaseFieldManager extends FieldManager {
 
   @Override
   public FieldTypeDefinition getFieldTypeDefinition(String field) {
-    return _fieldNameToDefMap.get(field);
+    FieldTypeDefinition fieldTypeDefinition = _fieldNameToDefMap.get(field);
+    if (fieldTypeDefinition == null) {
+      tryToLoad(field, _fieldNameToDefMap, _columnToSubColumn);
+      fieldTypeDefinition = _fieldNameToDefMap.get(field);
+    }
+    return fieldTypeDefinition;
   }
 
   public String getFieldLessFieldName() {

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/416c6e2e/blur-query/src/main/java/org/apache/blur/analysis/FieldManager.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/analysis/FieldManager.java b/blur-query/src/main/java/org/apache/blur/analysis/FieldManager.java
index 3981759..2cb7aea 100644
--- a/blur-query/src/main/java/org/apache/blur/analysis/FieldManager.java
+++ b/blur-query/src/main/java/org/apache/blur/analysis/FieldManager.java
@@ -52,8 +52,9 @@ public abstract class FieldManager {
    *          the field type name, required.
    * @param props
    *          the configuration properties for this column and type.
+   * @return 
    */
-  public abstract void addColumnDefinition(String family, String columnName, String subColumnName,
+  public abstract boolean addColumnDefinition(String family, String columnName, String subColumnName,
       boolean fieldLessIndexing, String fieldType, Map<String, String> props);
 
   /**

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/416c6e2e/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 ed07209..3d5d5c2 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
@@ -20,6 +20,7 @@ import java.io.IOException;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Properties;
+import java.util.Set;
 
 import org.apache.blur.log.Log;
 import org.apache.blur.log.LogFactory;
@@ -79,4 +80,10 @@ public class HdfsFieldManager extends BaseFieldManager {
     return null;
   }
 
+  @Override
+  protected void tryToLoad(String field, Map<String, FieldTypeDefinition> fieldNameToDefMap,
+      Map<String, Set<String>> columnToSubColumn) {
+    
+  }
+
 }


Mime
View raw message