accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r1302914 - /incubator/accumulo/branches/1.4/src/examples/wikisearch/query/src/main/java/org/apache/accumulo/examples/wikisearch/iterator/EvaluatingIterator.java
Date Tue, 20 Mar 2012 14:32:51 GMT
Author: ecn
Date: Tue Mar 20 14:32:50 2012
New Revision: 1302914

URL: http://svn.apache.org/viewvc?rev=1302914&view=rev
Log:
ACCUMULO-474: memoize ColumnVisibility objects to decrease memory usage

Modified:
    incubator/accumulo/branches/1.4/src/examples/wikisearch/query/src/main/java/org/apache/accumulo/examples/wikisearch/iterator/EvaluatingIterator.java

Modified: incubator/accumulo/branches/1.4/src/examples/wikisearch/query/src/main/java/org/apache/accumulo/examples/wikisearch/iterator/EvaluatingIterator.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/branches/1.4/src/examples/wikisearch/query/src/main/java/org/apache/accumulo/examples/wikisearch/iterator/EvaluatingIterator.java?rev=1302914&r1=1302913&r2=1302914&view=diff
==============================================================================
--- incubator/accumulo/branches/1.4/src/examples/wikisearch/query/src/main/java/org/apache/accumulo/examples/wikisearch/iterator/EvaluatingIterator.java
(original)
+++ incubator/accumulo/branches/1.4/src/examples/wikisearch/query/src/main/java/org/apache/accumulo/examples/wikisearch/iterator/EvaluatingIterator.java
Tue Mar 20 14:32:50 2012
@@ -30,12 +30,14 @@ import org.apache.accumulo.core.iterator
 import org.apache.accumulo.core.security.ColumnVisibility;
 import org.apache.accumulo.examples.wikisearch.parser.EventFields;
 import org.apache.accumulo.examples.wikisearch.parser.EventFields.FieldValue;
+import org.apache.commons.collections.map.LRUMap;
 import org.apache.hadoop.io.Text;
 
 
 public class EvaluatingIterator extends AbstractEvaluatingIterator {
   
   public static final String NULL_BYTE_STRING = "\u0000";
+  LRUMap visibilityMap = new LRUMap();
   
   public EvaluatingIterator() {
     super();
@@ -78,7 +80,20 @@ public class EvaluatingIterator extends 
     String fieldName = colq.substring(0, idx);
     String fieldValue = colq.substring(idx + 1);
     
-    event.put(fieldName, new FieldValue(new ColumnVisibility(key.getColumnVisibility().getBytes()),
fieldValue.getBytes()));
+    event.put(fieldName, new FieldValue(getColumnVisibility(key), fieldValue.getBytes()));
+  }
+
+  /**
+   * @param key
+   * @return
+   */
+  public ColumnVisibility getColumnVisibility(Key key) {
+    ColumnVisibility result = (ColumnVisibility) visibilityMap.get(key.getColumnVisibility());
+    if (result != null) 
+      return result;
+    result = new ColumnVisibility(key.getColumnVisibility().getBytes());
+    visibilityMap.put(key.getColumnVisibility(), result);
+    return result;
   }
   
   /**



Mime
View raw message