incubator-accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r1200521 - in /incubator/accumulo/trunk/contrib/accumulo_sample/query/src/main/java: iterator/FieldIndexIterator.java logic/AbstractQueryLogic.java logic/ContentLogic.java
Date Thu, 10 Nov 2011 20:13:25 GMT
Author: ecn
Date: Thu Nov 10 20:13:25 2011
New Revision: 1200521

URL: http://svn.apache.org/viewvc?rev=1200521&view=rev
Log:
ACCUMULO-92 remove LGPL dependencies

Modified:
    incubator/accumulo/trunk/contrib/accumulo_sample/query/src/main/java/iterator/FieldIndexIterator.java
    incubator/accumulo/trunk/contrib/accumulo_sample/query/src/main/java/logic/AbstractQueryLogic.java
    incubator/accumulo/trunk/contrib/accumulo_sample/query/src/main/java/logic/ContentLogic.java

Modified: incubator/accumulo/trunk/contrib/accumulo_sample/query/src/main/java/iterator/FieldIndexIterator.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/contrib/accumulo_sample/query/src/main/java/iterator/FieldIndexIterator.java?rev=1200521&r1=1200520&r2=1200521&view=diff
==============================================================================
--- incubator/accumulo/trunk/contrib/accumulo_sample/query/src/main/java/iterator/FieldIndexIterator.java
(original)
+++ incubator/accumulo/trunk/contrib/accumulo_sample/query/src/main/java/iterator/FieldIndexIterator.java
Thu Nov 10 20:13:25 2011
@@ -75,9 +75,6 @@ public class FieldIndexIterator extends 
         functions.put("f", QueryFunctions.class);
         engine.setFunctions(functions);
     }
-    // Wrapping iterator only accesses its private source in setSource and getSource
-    // Since this class overrides these methods, it's safest to keep the source declaration
here
-    private SortedKeyValueIterator<Key, Value> source;
 
     public static void setLogLevel(Level l) {
         log.setLevel(l);
@@ -124,7 +121,7 @@ public class FieldIndexIterator extends 
     }
 
     public FieldIndexIterator(FieldIndexIterator other, IteratorEnvironment env) {
-        source = other.getSource().deepCopy(env);
+        setSource(other.getSource().deepCopy(env));
         //Set a default KeyParser
         keyParser = createDefaultKeyParser();
     }
@@ -134,23 +131,7 @@ public class FieldIndexIterator extends 
         return parser;
     }
 
-    //-------------------------------------------------------------------------
-    //-------------  Overrides
-    @Override
-    public void init(SortedKeyValueIterator<Key, Value> source, Map<String, String>
options, IteratorEnvironment env) throws IOException {
-        super.init(source, options, env);
-        source = super.getSource();
-    }
-
-    @Override
-    protected void setSource(SortedKeyValueIterator<Key, Value> source) {
-        this.source = source;
-    }
 
-    @Override
-    protected SortedKeyValueIterator<Key, Value> getSource() {
-        return source;
-    }
 
     @Override
     public SortedKeyValueIterator<Key, Value> deepCopy(IteratorEnvironment env) {
@@ -181,18 +162,18 @@ public class FieldIndexIterator extends 
             currentRow = topKey.getRow();
         }
 
-        source.next();
+        getSource().next();
         while (true) {
             log.debug("next(), Range: " + range);
-            if (source.hasTop()) {
-                Key k = source.getTopKey();
+            if (getSource().hasTop()) {
+                Key k = getSource().getTopKey();
                 if (range.contains(k)) {
                     if (matches(k)) {
                         topKey = k;
-                        topValue = source.getTopValue();
+                        topValue = getSource().getTopValue();
                         return;
                     } else {
-                        source.next();
+                    	getSource().next();
                     }
 
                 } else {
@@ -229,7 +210,7 @@ public class FieldIndexIterator extends 
                     if (log.isDebugEnabled()) {
                         log.debug("next, range: " + range);
                     }
-                    source.seek(range, EMPTY_COL_FAMS, false);
+                    getSource().seek(range, EMPTY_COL_FAMS, false);
                 }
             } else {
                 topKey = null;
@@ -290,23 +271,23 @@ public class FieldIndexIterator extends 
             if (log.isDebugEnabled()) {
                 log.debug("seek, incoming range: " + range);
             }
-            source.seek(range, columnFamilies, inclusive);
+            getSource().seek(range, columnFamilies, inclusive);
 
             while (topKey == null) {
-                if (source.hasTop()) {
+                if (getSource().hasTop()) {
                     if (log.isDebugEnabled()) {
-                        log.debug("seek, source has top: " + source.getTopKey());
+                        log.debug("seek, source has top: " + getSource().getTopKey());
                     }
-                    Key k = source.getTopKey();
+                    Key k = getSource().getTopKey();
                     if (range.contains(k)) {
                         if (matches(k)) {
                             topKey = k;
-                            topValue = source.getTopValue();
+                            topValue = getSource().getTopValue();
                             if (log.isDebugEnabled()) {
                                 log.debug("seek, source has top in valid range");
                             }
                         } else {
-                            source.next();
+                        	getSource().next();
                         }
                     } else {
                         if (log.isDebugEnabled()) {
@@ -353,7 +334,7 @@ public class FieldIndexIterator extends 
                             log.debug("currentRow: " + currentRow);
                             log.debug("seek, range: " + range);
                         }
-                        source.seek(range, columnFamilies, inclusive);
+                        getSource().seek(range, columnFamilies, inclusive);
                     }
                 } else {
                     if (log.isDebugEnabled()) {
@@ -621,18 +602,18 @@ public class FieldIndexIterator extends 
         }
         Key fakeKey = new Key(new Text(currentRow + NULL_BYTE));
         Range fakeRange = new Range(fakeKey, fakeKey);
-        source.seek(fakeRange, EMPTY_COL_FAMS, false);
-        if (source.hasTop()) {
-            return source.getTopKey().getRow();
+        getSource().seek(fakeRange, EMPTY_COL_FAMS, false);
+        if (getSource().hasTop()) {
+            return getSource().getTopKey().getRow();
         } else {
             return null;
         }
     }
 
     private Text getFirstRow() throws IOException {
-        source.seek(new Range(), EMPTY_COL_FAMS, false);
-        if (source.hasTop()) {
-            return source.getTopKey().getRow();
+    	getSource().seek(new Range(), EMPTY_COL_FAMS, false);
+        if (getSource().hasTop()) {
+            return getSource().getTopKey().getRow();
         } else {
             throw new IOException();
         }
@@ -668,22 +649,22 @@ public class FieldIndexIterator extends 
         range = r;
         setTopKey(null);
         setTopValue(null);
-        source.seek(range, EMPTY_COL_FAMS, false);
+        getSource().seek(range, EMPTY_COL_FAMS, false);
         while (topKey == null) {
-            if (source.hasTop()) {
+            if (getSource().hasTop()) {
                 if (log.isDebugEnabled()) {
-                    log.debug("jump, source has top: " + source.getTopKey());
+                    log.debug("jump, source has top: " + getSource().getTopKey());
                 }
-                Key k = source.getTopKey();
+                Key k = getSource().getTopKey();
                 if (range.contains(k)) {
                     if (matches(k)) {
                         topKey = k;
-                        topValue = source.getTopValue();
+                        topValue = getSource().getTopValue();
                         if (log.isDebugEnabled()) {
                             log.debug("jump, source has top in valid range");
                         }
                     } else {
-                        source.next();
+                    	getSource().next();
                     }
                 } else {
                     if (log.isDebugEnabled()) {
@@ -740,7 +721,7 @@ public class FieldIndexIterator extends 
                     if (log.isDebugEnabled()) {
                         log.debug("jump, new build range: " + range);
                     }
-                    source.seek(range, EMPTY_COL_FAMS, false);
+                    getSource().seek(range, EMPTY_COL_FAMS, false);
                 }
             } else {
                 if (log.isDebugEnabled()) {

Modified: incubator/accumulo/trunk/contrib/accumulo_sample/query/src/main/java/logic/AbstractQueryLogic.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/contrib/accumulo_sample/query/src/main/java/logic/AbstractQueryLogic.java?rev=1200521&r1=1200520&r2=1200521&view=diff
==============================================================================
--- incubator/accumulo/trunk/contrib/accumulo_sample/query/src/main/java/logic/AbstractQueryLogic.java
(original)
+++ incubator/accumulo/trunk/contrib/accumulo_sample/query/src/main/java/logic/AbstractQueryLogic.java
Thu Nov 10 20:13:25 2011
@@ -466,7 +466,6 @@ public abstract class AbstractQueryLogic
         StopWatch fullScanQuery = new StopWatch();
         StopWatch processResults = new StopWatch();
 
-
         abstractQueryLogic.start();
         
         StopWatch parseQuery = new StopWatch();
@@ -778,6 +777,8 @@ public abstract class AbstractQueryLogic
                     
                     bs.addScanIterator(si);
 
+                    processResults.start();
+                    processResults.suspend();
                     long count = 0;
                     for (Entry<Key, Value> entry : bs) {
                         count++;

Modified: incubator/accumulo/trunk/contrib/accumulo_sample/query/src/main/java/logic/ContentLogic.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/contrib/accumulo_sample/query/src/main/java/logic/ContentLogic.java?rev=1200521&r1=1200520&r2=1200521&view=diff
==============================================================================
--- incubator/accumulo/trunk/contrib/accumulo_sample/query/src/main/java/logic/ContentLogic.java
(original)
+++ incubator/accumulo/trunk/contrib/accumulo_sample/query/src/main/java/logic/ContentLogic.java
Thu Nov 10 20:13:25 2011
@@ -30,7 +30,6 @@ import org.jboss.util.Base64;
 import sample.Document;
 import sample.Field;
 import sample.Results;
-import util.RegionTimer;
 import org.apache.accumulo.core.client.Connector;
 import org.apache.accumulo.core.client.Scanner;
 import org.apache.accumulo.core.client.TableNotFoundException;
@@ -74,10 +73,6 @@ public class ContentLogic {
         Authorizations auths = new Authorizations(StringUtils.join(authorizations, "|"));
 
 		
-        RegionTimer timer = new RegionTimer("ContentLogic: " + query);
-        String section = "1) parse query";
-        timer.enter(section);
-
 		Matcher match = queryPattern.matcher(query);
 		if (!match.matches()) {
 			throw new IllegalArgumentException("Query does not match the pattern: DOCUMENT:partitionId/wikitype/uid,
your query: " + query.toString());
@@ -88,7 +83,6 @@ public class ContentLogic {
 			
 			log.debug("Received pieces: " + partitionId + ", " + wikitype + ", " + id);
 			
-			timer.change(section = "2) creating range");
 			//Create the Range
 			Key startKey = new Key(partitionId, WikipediaMapper.DOCUMENT_COLUMN_FAMILY, wikitype+NULL_BYTE+id);
 			Key endKey = new Key(partitionId, WikipediaMapper.DOCUMENT_COLUMN_FAMILY, wikitype+NULL_BYTE+id+NULL_BYTE);
@@ -96,14 +90,11 @@ public class ContentLogic {
 			
 			log.debug("Setting range: " + r);
 
-			timer.change(section = "3) querying table");
 			try {
 				Scanner scanner = connector.createScanner(this.getTableName(), auths);
 				scanner.setRange(r);
 				//This should in theory only match one thing.
-				timer.change(section = "4) process results");
 				for (Entry<Key,Value> entry : scanner) {
-					timer.enter("1) handle result");
 					Document doc = new Document();
 					doc.setId(id);
 					Field val = new Field();
@@ -111,16 +102,12 @@ public class ContentLogic {
 					val.setFieldValue(new String(Base64.decode(entry.getValue().toString())));
 					doc.getFields().add(val);
 					results.getResults().add(doc);
-					timer.exit("1) handle result");
 				}
 			} catch (TableNotFoundException e) {
 				throw new RuntimeException("Table not found: " + this.getTableName(), e);
 			}
 			
 		}
-		timer.exit(section);
-		log.info(timer.toString());
-		timer = null;
 		return results;
 	}
 



Mime
View raw message