You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rya.apache.org by pu...@apache.org on 2015/12/04 17:46:38 UTC
[26/49] incubator-rya git commit: RYA-7 POM and License Clean-up for
Apache Move
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/80faf06d/partition/common-query/src/main/java/ss/cloudbase/core/iterators/conversion/Operation.java
----------------------------------------------------------------------
diff --git a/partition/common-query/src/main/java/ss/cloudbase/core/iterators/conversion/Operation.java b/partition/common-query/src/main/java/ss/cloudbase/core/iterators/conversion/Operation.java
deleted file mode 100644
index c93c085..0000000
--- a/partition/common-query/src/main/java/ss/cloudbase/core/iterators/conversion/Operation.java
+++ /dev/null
@@ -1,109 +0,0 @@
-package ss.cloudbase.core.iterators.conversion;
-
-public class Operation {
- protected static final char[] ops = new char[] {'+', '-', '*', '/', '%', '^'};
- protected String field;
- protected char op;
- protected double operand;
-
- public Operation(String config) {
- if (config.startsWith("conversion.")) {
- config = config.substring("conversion.".length());
- }
-
- String[] parts = config.split("\\s");
- if (parts.length == 3) {
- field = parts[0];
- op = parts[1].charAt(0);
- if (!checkOp(op)) {
- throw new IllegalArgumentException("Operator '" + op + "' is not among the supported operators: " + getOps());
- }
- try {
- operand = Double.parseDouble(parts[2]);
- } catch (NumberFormatException e) {
- throw new IllegalArgumentException("Operand '" + parts[2] + "' could not be parsed as a number.");
- }
- } else {
- throw new IllegalArgumentException("'" + config + "' was not in the format 'field op value'");
- }
- }
-
- public String getField() {
- return field;
- }
-
- public char getOp() {
- return op;
- }
-
- public double getOperand() {
- return operand;
- }
-
- public String execute(String value) {
- if (value == null) {
- return value;
- }
-
- double v = Double.NaN;
-
- try {
- v = Double.parseDouble(value);
- } catch (NumberFormatException e) {
- // we'll attempt to convert hex strings
- try {
- v = Integer.parseInt(value, 16);
- } catch (NumberFormatException e1) {
- return value;
- }
- }
-
- switch (op) {
- case '+':
- v += operand;
- break;
- case '-':
- v -= operand;
- break;
- case '*':
- v *= operand;
- break;
- case '/':
- v /= operand;
- break;
- case '%':
- v %= operand;
- break;
- case '^':
- v = Math.pow(v, operand);
- break;
- }
-
- return "" + v;
- }
-
- protected String getOps() {
- StringBuilder sb = new StringBuilder();
- boolean first = true;
-
- for (char c: ops) {
- if (first) {
- sb.append(c);
- first = false;
- } else {
- sb.append(',');
- sb.append(c);
- }
- }
- return sb.toString();
- }
-
- protected boolean checkOp(char op) {
- for (char c: ops) {
- if (op == c) {
- return true;
- }
- }
- return false;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/80faf06d/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/CBConverter.java
----------------------------------------------------------------------
diff --git a/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/CBConverter.java b/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/CBConverter.java
deleted file mode 100644
index 7d6bedd..0000000
--- a/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/CBConverter.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-package ss.cloudbase.core.iterators.filter;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.apache.log4j.Logger;
-
-import cloudbase.core.data.Key;
-import cloudbase.core.data.Value;
-
-/**
- *
- * @author rashah
- */
-public class CBConverter {
-
- /** The string that separates the key/value pairs in the row value. */
- public static final String OPTION_PAIR_DELIMITER = "pairDelimiter";
- /**
- * The string that separates the key and the value(s) within a pair in the
- * row value.
- */
- public static final String OPTION_VALUE_DELIMITER = "valueDelimiter";
- /**
- * Contains the pair delimiter provided through the
- * <code>OPTION_PAIR_DELIMITER</code> option.
- */
- protected String pairDelimiter = "\u0000";
- /**
- * Contains the value delimiter provided through the
- * <code>OPTION_VALUE_DELIMITER</code> option.
- */
- protected String valueDelimiter = "\uFFFD";
- private static Logger LOG = Logger.getLogger(CBConverter.class);
-
- public CBConverter() {
- }
-
- public Map<String, String> toMap(Key CBKey, Value CBValue) {
- LOG.trace("Convert");
-
- Map<String, String> return_value = new HashMap<String, String>();
-
- String value = CBValue.toString();
-
- // Determine the start/end of the value.
- int valueStartIndex = 0;
- int valueEndIndex = value.length();
-
- int vLen = valueDelimiter.length();
- int fLen = pairDelimiter.length();
- LOG.debug(vLen + ", " + fLen + ", CBValue = " + CBValue.toString());
- // Parse each of the values from the row value.
- while (valueStartIndex < valueEndIndex) {
- int vIndex = value.indexOf(valueDelimiter, valueStartIndex);
-
- // If an "equals" sign was found, parse the key and value.
- if (vIndex != -1) {
- String key = value.substring(valueStartIndex, vIndex).trim();
- int v = value.indexOf(valueDelimiter, vIndex + vLen);
- if (v == -1) {
- v = valueEndIndex;
- }
- int f = value.indexOf(pairDelimiter, vIndex + vLen);
- if (f == -1) {
- f = valueEndIndex;
- }
-
- int fIndex = Math.min(f, v);
- String val = value.substring(vIndex + 1, fIndex).trim();
- valueStartIndex = f;
- valueStartIndex += fLen;
- return_value.put(key, val);
- LOG.debug("Key {" + key + "} Value {" + val + "}");
- }
- }
-
- return return_value;
- }
-
- public Value toValue(Map<String, String> record) {
- StringBuilder sb = new StringBuilder();
- boolean first = true;
-
- for (Entry<String, String> e: record.entrySet()) {
- if (first) {
- first = false;
- } else {
- sb.append(pairDelimiter);
- }
- sb.append(e.getKey());
- sb.append(valueDelimiter);
- sb.append(e.getValue());
- }
-
- return new Value(sb.toString().getBytes());
- }
-
- public void init(Map<String, String> options) {
- LOG.trace("Init");
-
- pairDelimiter = options.get(OPTION_PAIR_DELIMITER);
- if (pairDelimiter == null || pairDelimiter.length() == 0) {
- pairDelimiter = "\u0000";
- }
-
- valueDelimiter = options.get(OPTION_VALUE_DELIMITER);
- if (valueDelimiter == null || valueDelimiter.length() == 0) {
- valueDelimiter = "\uFFFD";
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/80faf06d/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/general/GVDateFilter.java
----------------------------------------------------------------------
diff --git a/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/general/GVDateFilter.java b/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/general/GVDateFilter.java
deleted file mode 100644
index 9063f12..0000000
--- a/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/general/GVDateFilter.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-package ss.cloudbase.core.iterators.filter.general;
-
-import ss.cloudbase.core.iterators.filter.CBConverter;
-
-import java.util.Map;
-
-import org.apache.log4j.Logger;
-
-import cloudbase.core.data.Key;
-import cloudbase.core.data.Value;
-import cloudbase.core.iterators.filter.Filter;
-import java.sql.Timestamp;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-
-/**
- * This filter will take an incoming frequency and match that to a range
- * contained within the cloudbase record
- *
- * @author Raju Shah
- */
-public class GVDateFilter implements Filter
-{
-
- private static final Logger LOG = Logger.getLogger(GVDateFilter.class);
- /** The string that indicates the key name in the row value. */
- public static final String OPTIONInTimestamp = "InDate";
- protected String TimeStamp_S = "2011-03-03 20:44:28.633";
- protected Timestamp TimeStamp_T = Timestamp.valueOf(TimeStamp_S);
- public static final String OPTIONGVTimeStartField = "date-start";
- protected String DateStartField = "date-start";
- public static final String OPTIONGVTimeEndField = "date-end";
- protected String DateEndField = "date-end";
- public static final String OPTIONRBActive = "RBCurrentlyActive";
- protected String RBActive = "version";
- CBConverter cbconvertor = new CBConverter();
-
- public long GetUSecFromString(String Time_S)
- {
- long return_value = 0;
- Date d = null;
- Calendar c = Calendar.getInstance();
- SimpleDateFormat df_long = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
- SimpleDateFormat df_med = new SimpleDateFormat("yyyy-MM-dd");
-
- try
- {
- d = df_long.parse(Time_S);
- }
- catch (Exception e)
- {
- try
- {
- d = df_med.parse(Time_S);
- }
- catch (Exception e1)
- {
- System.out.println("Don't like it [" + Time_S + "]");
- return return_value;
- }
- }
- c.setTime(d);
- return_value = c.getTimeInMillis();
-
- return return_value;
- }
-
- /**
- * Whether or not to accept this key/value entry. A map of row keys and values is parsed and then sent off to the process function to be evaluated.
- * @param key The cloudbase entry key
- * @param value The cloudbase entry value
- * @return True if the entry should be included in the results, false otherwise
- */
- @Override
- public boolean accept(Key CBKey, Value CBValue)
- {
- LOG.trace("accept");
-
- boolean return_value = false;
-
- Map<String, String> CBRecord = cbconvertor.toMap(CBKey, CBValue);
-
- // Get the Date Strings
- String sStart = (String) CBRecord.get(DateStartField);
- Timestamp tStart = new Timestamp(0);
- String sEnd = (String) CBRecord.get(DateEndField);
- Timestamp tEnd = new Timestamp(0);
-
- //Get Active Strings
- String rbActive = (String) CBRecord.get(RBActive);
-
- //LOGIC
- //1) If The signal is NOT ACTIVE (I.E. the active flag is specified and off) PUNT
- if ( ((rbActive != null) && rbActive.equals("0")) )
- {
- return return_value;
- }
- //1) Remaining signals are either specified ACTIVE or NOT INDICATED
-
-
- //LOGIC
- //2) Next check if both start and end are specified, then it must be inbetween
- if ((sStart != null) && (sEnd != null))
- {
- tStart.setTime(GetUSecFromString(sStart));
- tEnd.setTime(GetUSecFromString(sEnd));
- if (tStart.before(TimeStamp_T) && TimeStamp_T.before(tEnd))
- {
- return_value = true;
- }
- return return_value;
- }
-
-
- //LOGIC
- //3) If the start date is specified then just check against start date
- if (sStart != null)
- {
- tStart.setTime(GetUSecFromString(sStart));
- if (tStart.before(TimeStamp_T))
- {
- return_value = true;
- }
- return return_value;
- }
-
- //LOGIC
- //4) Return false for all others - Start Date must be present
-
-
- return return_value;
- }
-
- @Override
- public void init(Map<String, String> options)
- {
- LOG.trace("init");
- cbconvertor.init(options);
-
- DateStartField = options.get(OPTIONGVTimeStartField);
- if (DateStartField == null || DateStartField.length() == 0)
- {
- DateStartField = "date-start";
- }
-
-
- DateEndField = options.get(OPTIONGVTimeEndField);
- if (DateEndField == null || DateEndField.length() == 0)
- {
- DateEndField = "date-end";
- }
-
-
- TimeStamp_S = options.get(OPTIONInTimestamp);
- if (TimeStamp_S == null || TimeStamp_S.length() == 0)
- {
- TimeStamp_S = "2011-03-03T20:44:28.633Z";
- }
- TimeStamp_T.setTime(GetUSecFromString(TimeStamp_S));
-
-
- LOG.debug("Creating Time Filter, does " + TimeStamp_S + " = " + TimeStamp_T.toString());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/80faf06d/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/general/GVFrequencyFilter.java
----------------------------------------------------------------------
diff --git a/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/general/GVFrequencyFilter.java b/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/general/GVFrequencyFilter.java
deleted file mode 100644
index f4c2edc..0000000
--- a/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/general/GVFrequencyFilter.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-package ss.cloudbase.core.iterators.filter.general;
-
-import ss.cloudbase.core.iterators.filter.CBConverter;
-
-import java.util.Map;
-
-import org.apache.log4j.Logger;
-
-import cloudbase.core.data.Key;
-import cloudbase.core.data.Value;
-import cloudbase.core.iterators.filter.Filter;
-
-/**
- * This filter will take an incoming frequency and match that to a range
- * contained within the cloudbase record
- *
- * @author Raju Shah
- */
-public class GVFrequencyFilter implements Filter
-{
-
- private static final Logger LOG = Logger.getLogger(GVFrequencyFilter.class);
- /** The string that indicates the key name in the row value. */
- public static final String OPTIONFrequency = "frequency";
- protected String Frequency_S = "0.0";
- protected Double Frequency_D = Double.parseDouble(Frequency_S);
- // Initially the values in Global Vision are just Center Freq and BW
- // On the second revision we may change that to the actual ranges so
- // the numerical computations below can be optimized out. Then we can just use the normal OGC filters
- //public static final String OPTIONGVFrequencyStart = "Frequency_Start";
- //public static final String OPTIONGVFrequencyEnd = "Frequency_End";
- public static final String OPTIONGVCenterFrequency = "frequency";
- public static final String OPTIONGVBandwidth = "bandwidth";
- CBConverter cbconvertor = new CBConverter();
-
- /**
- * Whether or not to accept this key/value entry. A map of row keys and values is parsed and then sent off to the process function to be evaluated.
- * @param key The cloudbase entry key
- * @param value The cloudbase entry value
- * @return True if the entry should be included in the results, false otherwise
- */
- @Override
- public boolean accept(Key CBKey, Value CBValue)
- {
- LOG.trace("Accept");
-
- boolean return_value = false;
- Map<String, String> CBRecord = cbconvertor.toMap(CBKey, CBValue);
-
- try
- {
- String s1 = (String) CBRecord.get(OPTIONGVCenterFrequency);
- String s2 = (String) CBRecord.get(OPTIONGVBandwidth);
-
- Double d1 = Double.parseDouble(s1);
- Double d2 = Double.parseDouble(s2);
-
- if (((d1 - (0.5 * d2)) <= Frequency_D) && (Frequency_D <= (d1 + (0.5 * d2))))
- {
- return_value = true;
- }
-
- }
- catch (Exception e)
- {
- return_value = false;
- }
-
- return return_value;
- }
-
- @Override
- public void init(Map<String, String> options)
- {
- LOG.trace("Init");
-
- cbconvertor.init(options);
-
- Frequency_S = options.get(OPTIONFrequency);
- if (Frequency_S == null || Frequency_S.length() == 0)
- {
- Frequency_S = "0.0";
- }
-
-
- Frequency_D = Double.parseDouble(Frequency_S);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/80faf06d/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/jts/JTSFilter.java
----------------------------------------------------------------------
diff --git a/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/jts/JTSFilter.java b/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/jts/JTSFilter.java
deleted file mode 100644
index 625b48a..0000000
--- a/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/jts/JTSFilter.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * This is a filter for some basic Geo Functionality for data stored in a WKT format
- */
-package ss.cloudbase.core.iterators.filter.jts;
-
-import ss.cloudbase.core.iterators.filter.CBConverter;
-
-import java.util.Map;
-
-import org.apache.log4j.Logger;
-
-import cloudbase.core.data.Key;
-import cloudbase.core.data.Value;
-import cloudbase.core.iterators.filter.Filter;
-
-import com.vividsolutions.jts.io.WKTReader;
-import com.vividsolutions.jts.io.ParseException;
-import com.vividsolutions.jts.geom.Geometry;
-import com.vividsolutions.jts.geom.Point;
-import com.vividsolutions.jts.geom.Coordinate;
-import com.vividsolutions.jts.geom.CoordinateSequence;
-import com.vividsolutions.jts.geom.GeometryFactory;
-import com.vividsolutions.jts.geom.impl.CoordinateArraySequenceFactory;
-
-/**
- * @author Raju Shah
- */
-public class JTSFilter implements Filter
-{
-
- private static final Logger logger = Logger.getLogger(JTSFilter.class);
- /** The string that indicates the key name in the row value. */
- public static final String OPTIONGeometryKeyName = "GeometryKeyName";
- protected String GeometryKeyName = "geometry-contour";
- /** The string that is the centerpoint - Latitude. */
- public static final String OPTIONCenterPointLat = "latitude";
- protected String CenterPointLat = "0.0";
- /** The string that is the centerpoint - Longitude. */
- public static final String OPTIONCenterPointLon = "longitude";
- protected String CenterPointLon = "0.0";
- public static final String OPTIONBeamIDName = "BeamID";
- protected String BeamIDKeyName = "beam-globalviewid";
- /** The string that is the centerpoint - Latitude. */
- /** The compare type for the geometric point **/
- protected Point p = null;
- CBConverter cbconvertor = new CBConverter();
-
- /**
- * Whether or not to accept this key/value entry. A map of row keys and values is parsed and then sent off to the process function to be evaluated.
- * @param key The cloudbase entry key
- * @param value The cloudbase entry value
- * @return True if the entry should be included in the results, false otherwise
- */
- @Override
- public boolean accept(Key CBKey, Value CBValue)
- {
- boolean return_value = false;
- Map<String, String> CBRecord = cbconvertor.toMap(CBKey, CBValue);
-
- String s = (String) CBRecord.get(GeometryKeyName);
-
- // I expect the field to exist
- if ((s == null) || (s.length() < 1))
- {
- return return_value;
- }
-
- // If the object cotains the word POLYGON or MULTIPOLYGON then it should be good
- if (s.contains("POLYGON"))
- {
- //convert that string into a geometry
- WKTReader reader = new WKTReader();
- try
- {
- Geometry WKTgeometry = reader.read(s);
-
- //See if the two geometries overlap
- return_value = p.coveredBy(WKTgeometry);
- }
- catch (Exception e)
- {
- try
- {
- String beamid = (String) CBRecord.get(BeamIDKeyName);
- logger.debug("Bad Beam ID ["+beamid + "]");
- //See if the two geometries overlap
- }
- catch (Exception ex)
- {
- }
-
- //logger.error(e, e);
- return return_value;
- }
- }
- else
- {
- String start_s = "SDO_ORDINATE_ARRAY(";
- int start_index = s.indexOf(start_s);
- if (start_index != -1)
- {
- start_index += start_s.length();
-
- int end_index = s.indexOf(")", start_index);
-
- if (end_index == -1)
- {
- return false;
- }
- s = s.substring(start_index, end_index);
- //System.out.println("{" + s + "}");
-
- //remove every other ,
- // want to search for -70.838, 39.967, and replace with -70.838 39.967,
- start_index = 1;
- end_index = s.length();
- while ((start_index < (end_index - 1)) && (start_index > 0))
- {
- start_index = s.indexOf(",", start_index);
- char[] temp = s.toCharArray();
- temp[start_index] = ' ';
- s = new String(temp);
- //skip the next one
- start_index = s.indexOf(",", start_index) + 1;
- }
- //System.out.println("<" + s + ">");
-
- //convert that string into a geometry
- WKTReader reader = new WKTReader();
- try
- {
- Geometry WKTgeometry = reader.read("POLYGON((" + s + "))");
-
- //See if the two geometries overlap
- return_value = p.coveredBy(WKTgeometry);
- }
- catch (Exception e)
- {
- //logger.error(e, e);
- return return_value;
- }
- }
- }
- return return_value;
- }
-
- @Override
- public void init(Map<String, String> options)
- {
- cbconvertor.init(options);
-
- GeometryKeyName = options.get(OPTIONGeometryKeyName);
- if (GeometryKeyName == null || GeometryKeyName.length() == 0)
- {
- GeometryKeyName = "geometry-contour";
- }
-
-
- CenterPointLat = options.get(OPTIONCenterPointLat);
- if (CenterPointLat == null || CenterPointLat.length() == 0)
- {
- CenterPointLat = "0.0";
- }
-
-
- CenterPointLon = options.get(OPTIONCenterPointLon);
- if (CenterPointLon == null || CenterPointLon.length() == 0)
- {
- CenterPointLon = "0.0";
- }
-
- BeamIDKeyName = options.get(OPTIONBeamIDName);
- if (BeamIDKeyName == null || BeamIDKeyName.length() == 0)
- {
- BeamIDKeyName = "beam-globalviewid";
- }
-
- Double CenterPointLatD = Double.parseDouble(CenterPointLat);
- Double CenterPointLonD = Double.parseDouble(CenterPointLon);
-
- Coordinate[] coordinates =
- {
- new Coordinate(CenterPointLonD, CenterPointLatD)
- };
-
- CoordinateSequence cs = CoordinateArraySequenceFactory.instance().create(coordinates);
- GeometryFactory gf = new GeometryFactory();
-
- p = new Point(cs, gf);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/80faf06d/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/OGCFilter.java
----------------------------------------------------------------------
diff --git a/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/OGCFilter.java b/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/OGCFilter.java
deleted file mode 100644
index 7bf622d..0000000
--- a/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/OGCFilter.java
+++ /dev/null
@@ -1,241 +0,0 @@
-package ss.cloudbase.core.iterators.filter.ogc;
-
-import java.io.IOException;
-import java.io.StringReader;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.apache.log4j.Logger;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-import ss.cloudbase.core.iterators.filter.ogc.operation.IOperation;
-
-import cloudbase.core.data.Key;
-import cloudbase.core.data.Value;
-import cloudbase.core.iterators.filter.Filter;
-import cloudbase.start.classloader.CloudbaseClassLoader;
-
-/**
- * The OGCFilter class provides a basic implementation of the
- * <a href="http://www.opengeospatial.org/standards/filter">OGC Filter Encoding specification</a>.
- * This allows for arbitrary queries to be passed via XML and executed in a distributed fashion across tablet servers. The following
- * code sets up a basic FilteringIterator that uses this filter (note that this jar must be present in each
- * of the tablet servers' classpaths to work):
- *
- * <code>
- * <pre>
- * cloudbase.core.client.Scanner reader;
- * // set up the reader ...
- *
- * // we're going to parse a row formated like key:value|key:value|key:value and return all of the rows
- * // where the key "city" starts with "new"
- * String filter = "<PropertyIsLike><PropertyName>city</PropertyName><Literal>new*</Literal></PropertyIsLike>";
- *
- * reader.setScanIterators(50, FilteringIterator.class.getName(), "myIterator");
- * reader.setScanIteratorOption("myIterator", "0", OGCFilter.class.getName());
- * reader.setScanIteratorOption("myIterator", "0." + OGCFilter.OPTION_PAIR_DELIMITER, "\\|");
- * reader.setScanIteratorOption("myIterator", "0." + OGCFilter.OPTION_VALUE_DELIMITER, ":");
- * reader.setScanIteratorOption("myIterator", "0." + OGCFilter.OPTION_FILTER, filter);
- * <pre>
- * </code>
- *
- * @author William Wall
- */
-public class OGCFilter implements Filter {
- private static final Logger logger = Logger.getLogger(OGCFilter.class);
-
- /** The string that separates the key/value pairs in the row value. */
- public static final String OPTION_PAIR_DELIMITER = "pairDelimiter";
-
- /** The string that separates the key and the value(s) within a pair in the row value. */
- public static final String OPTION_VALUE_DELIMITER = "valueDelimiter";
-
- /** The OGC Filter Encoding XML as a string */
- public static final String OPTION_FILTER = "filter";
-
- /** Specifies the column name for the column family. If this option is not included, the column family is not included in the row. */
- public static final String OPTION_COLF_NAME = "colfName";
-
- /** Specifies the column name for the column qualifier. If this option is not included, the column qualifier is not included in the row. */
- public static final String OPTION_COLQ_NAME = "colqName";
-
- /** Specifies the compare type for the filter. Defaults to "auto". **/
- public static final String OPTION_COMPARE_TYPE = "compareType";
-
- public static final String TYPE_NUMERIC = "numeric";
-
- public static final String TYPE_STRING = "string";
-
- public static final String TYPE_AUTO = "auto";
-
- /** Contains the pair delimiter provided through the <code>OPTION_PAIR_DELIMITER</code> option. */
- protected String pairDelimiter;
-
- /** Contains the value delimiter provided through the <code>OPTION_VALUE_DELIMITER</code> option. */
- protected String valueDelimiter;
-
- /** Contains the column family column name provided through the <code>OPTION_COLF_NAME</code> option. */
- protected String colfName;
-
- /** Contains the column qualifier column name provided through the <code>OPTION_COLQ_NAME</code> option. */
- protected String colqName;
-
- /** The root operation of the query tree **/
- protected IOperation root;
-
- /** The compare type for the query tree **/
- protected String compareType;
-
- /**
- * Whether or not to accept this key/value entry. A map of row keys and values is parsed and then sent off to the process function to be evaluated.
- * @param key The cloudbase entry key
- * @param value The cloudbase entry value
- * @return True if the entry should be included in the results, false otherwise
- */
- @Override
- public boolean accept(Key key, Value value) {
- if (root != null) {
- Map<String, String> row = getRow(key, value);
- if (root != null) {
- return root.execute(row);
- }
- }
- return false;
- }
-
- public boolean accept(Map<String, String> record) {
- if (root != null) {
- return root.execute(record);
- }
- return false;
- }
-
- /**
- * Parses the cloudbase value into a map of key/value pairs. If the <code>OPTION_COLF_NAME</code>
- * or <code>OPTION_COLQ_NAME</code> options were used, then they will also be added to the row map.
- * By default, pairs are delimited by the first unicode character ("\u0000") and values by the last unicode
- * character ("\uFFFD"). See the <code>OPTION_PAIR_DELIMITER</code> and <code>OPTION_VALUE_DELIMITER</code>
- * options to change these values.
- *
- * @param cbKey The cloudbase entry key
- * @param cbValue The cloudbase entry value
- * @return A map that represents this row
- */
- protected Map<String, String> getRow(Key cbKey, Value cbValue) {
- //TODO: This should really be replaced by CBValueFormatter.parse(value.toString()), but I'm hesitant to require
- // more jars (common-data and google-collections) to be in the cloudbase/lib directory. Also, what do we do with
- // a field with multiple values? Should we just assume that if any value in that field matches then the row
- // matches? Or should they all have to match?
-
- String value = cbValue.toString();
- Map<String, String> row = new HashMap<String, String>();
-
- if (colfName != null) {
- row.put(colfName, cbKey.getColumnFamily().toString());
- }
- if (colqName != null) {
- row.put(colqName, cbKey.getColumnQualifier().toString());
- }
-
- // Determine the start/end of the value.
- int valueStartIndex = 0;
- int valueEndIndex = value.length();
-
- int vLen = valueDelimiter.length();
- int fLen = pairDelimiter.length();
-
- // Parse each of the values from the row value.
- while (valueStartIndex < valueEndIndex) {
- int vIndex = value.indexOf(valueDelimiter, valueStartIndex);
-
- // If an "equals" sign was found, parse the key and value.
- if (vIndex != -1) {
- String key = value.substring(valueStartIndex, vIndex).trim();
- int v = value.indexOf(valueDelimiter, vIndex + vLen);
- if (v == -1) {
- v = valueEndIndex;
- }
- int f = value.indexOf(pairDelimiter, vIndex + vLen);
- if (f == -1) {
- f = valueEndIndex;
- }
-
- int fIndex = Math.min(f,v);
- String val = value.substring(vIndex + 1, fIndex).trim();
- valueStartIndex = f;
- valueStartIndex += fLen;
- row.put(key, val);
- }
- }
-
- return row;
- }
-
- @Override
- public void init(Map<String, String> options) {
- pairDelimiter = options.get(OPTION_PAIR_DELIMITER);
- if (pairDelimiter == null || pairDelimiter.length() == 0) {
- pairDelimiter = "\u0000";
- }
-
- valueDelimiter = options.get(OPTION_VALUE_DELIMITER);
- if (valueDelimiter == null || valueDelimiter.length() == 0) {
- valueDelimiter = "\uFFFD";
- }
-
- compareType = options.get(OPTION_COMPARE_TYPE);
- if (compareType == null || compareType.length() == 0) {
- compareType = TYPE_AUTO;
- }
-
- colfName = options.get(OPTION_COLF_NAME);
- colqName = options.get(OPTION_COLQ_NAME);
-
- try {
- DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- InputSource is = new InputSource();
- is.setCharacterStream(new StringReader(options.get(OPTION_FILTER)));
- Document doc = builder.parse(is);
- Node filter = doc.getDocumentElement();
- if (filter.getNodeName().equalsIgnoreCase("filter")) {
- filter = filter.getFirstChild();
- }
- root = createOperationTree(filter);
- } catch (IOException e) {
- logger.error(e,e);
- } catch (SAXException e) {
- logger.error(e,e);
- } catch (ParserConfigurationException e) {
- logger.error(e,e);
- }
- }
-
- /**
- * Creates the operation tree from the filter XML
- * @param node The filter XML node to parse
- * @return The root IOperation
- */
- protected IOperation createOperationTree(Node node) {
- try {
- // instantiate the operation and initialize it
- Class<? extends IOperation> clazz = CloudbaseClassLoader.loadClass(IOperation.class.getPackage().getName() + "." + node.getNodeName(), IOperation.class);
- IOperation op = clazz.newInstance();
- op.init(node, compareType);
- return op;
- } catch (ClassNotFoundException e) {
- logger.warn("Operation not supported: " + node.getNodeName());
- } catch (InstantiationException e) {
- logger.error(e,e);
- } catch (IllegalAccessException e) {
- logger.error(e,e);
- }
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/80faf06d/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/AbstractComparisonOp.java
----------------------------------------------------------------------
diff --git a/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/AbstractComparisonOp.java b/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/AbstractComparisonOp.java
deleted file mode 100644
index 46b1cf9..0000000
--- a/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/AbstractComparisonOp.java
+++ /dev/null
@@ -1,80 +0,0 @@
-package ss.cloudbase.core.iterators.filter.ogc.operation;
-
-import java.util.List;
-import java.util.Map;
-
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import ss.cloudbase.core.iterators.filter.ogc.OGCFilter;
-
-
-
-/**
- * This class provides a simple init method for setting up most of the variables
- * needed to do a comparison operation between two values.
- *
- * @author William Wall
- */
-public abstract class AbstractComparisonOp {
- protected String name, literal, value;
- protected boolean isNumeric = false;
- protected double literalNum, valueNum;
- protected String compareType;
-
- public void init(Node node, String compareType) {
- this.compareType = compareType;
- Node child;
- NodeList children = node.getChildNodes();
- for (int i = 0; i < children.getLength(); i++) {
- child = children.item(i);
- if (child.getNodeName().equalsIgnoreCase("PropertyName")) {
- name = child.getTextContent();
- } else {
- literal = child.getTextContent();
- }
- }
-
- if (compareType.equalsIgnoreCase(OGCFilter.TYPE_NUMERIC) || compareType.equalsIgnoreCase(OGCFilter.TYPE_AUTO)) {
- literalNum = parseNumeric(literal);
- isNumeric = !Double.isNaN(literalNum);
- }
- }
-
- public List<IOperation> getChildren() {
- return null;
- }
-
- protected boolean checkRowNumeric(String s) {
- if (isNumeric) {
- valueNum = parseNumeric(s);
- return valueNum != Double.NaN;
- }
- return false;
- }
-
- public String getValue(Map<String, String> row) {
- String value = row.get(name);
-
- // nulls will be lexicographically equal to ""
- if (value == null) {
- value = "";
- }
- return value;
- }
-
- public static double parseNumeric(String s) {
- // see if the string can be parsed as a double or an integer
- double val = Double.NaN;
- try {
- val = Double.parseDouble(s);
- } catch (Exception e) {
- try {
- val = new Double(Integer.parseInt(s));
- } catch (Exception e2) {
-
- }
- }
- return val;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/80faf06d/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/AbstractLogicalOp.java
----------------------------------------------------------------------
diff --git a/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/AbstractLogicalOp.java b/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/AbstractLogicalOp.java
deleted file mode 100644
index 0400f61..0000000
--- a/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/AbstractLogicalOp.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package ss.cloudbase.core.iterators.filter.ogc.operation;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import cloudbase.start.classloader.CloudbaseClassLoader;
-
-public class AbstractLogicalOp {
- private static final Logger logger = Logger.getLogger(AbstractLogicalOp.class);
-
- List<IOperation> children = new ArrayList<IOperation>();
-
- public void init(Node node, String compareType) {
- Node child;
- NodeList children = node.getChildNodes();
- for (int i = 0; i < children.getLength(); i++) {
- child = children.item(i);
- try {
- Class<? extends IOperation> clazz = CloudbaseClassLoader.loadClass(IOperation.class.getPackage().getName() + "." + child.getNodeName(), IOperation.class);
- IOperation op = clazz.newInstance();
- op.init(child, compareType);
- this.children.add(op);
- } catch (ClassNotFoundException e) {
- logger.warn("Operation not supported: " + node.getNodeName());
- } catch (InstantiationException e) {
- logger.error(e,e);
- } catch (IllegalAccessException e) {
- logger.error(e,e);
- }
- }
- }
-
- public List<IOperation> getChildren() {
- return children;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/80faf06d/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/And.java
----------------------------------------------------------------------
diff --git a/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/And.java b/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/And.java
deleted file mode 100644
index b192b19..0000000
--- a/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/And.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package ss.cloudbase.core.iterators.filter.ogc.operation;
-
-import java.util.Map;
-
-/**
- * Executes a logical AND on all the child operations.
- *
- * <code>
- * <pre>
- * <And>
- * <PropertyIsEqualTo>...
- * <PropertyIsLessThan>...
- * </And>
- * </pre>
- * </code>
- *
- * @author William Wall
- */
-public class And extends AbstractLogicalOp implements IOperation {
- @Override
- public boolean execute(Map<String, String> row) {
- boolean result = true;
- for (int i = 0; i < children.size(); i++) {
- result = children.get(i).execute(row);
- if (!result) break;
- }
- return result;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/80faf06d/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/BBOX.java
----------------------------------------------------------------------
diff --git a/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/BBOX.java b/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/BBOX.java
deleted file mode 100644
index 8596338..0000000
--- a/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/BBOX.java
+++ /dev/null
@@ -1,125 +0,0 @@
-package ss.cloudbase.core.iterators.filter.ogc.operation;
-
-import java.awt.Rectangle;
-import java.awt.Shape;
-import java.awt.geom.Point2D;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.log4j.Logger;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-
-/**
- * Tests a row to see if it falls within the given shape. The shape should be
- * defined in degrees. There is no need to send a property name since all the
- * rows contain either lonself/latself or lon/lat fields.
- *
- * Example:
- * <pre>
- * <BBOX>
- * <gml:Envelope>
- * <!-- coordinates are in lon/lat order -->
- * <gml:LowerCorner>13.09 31.5899</gml:LowerCorner>
- * <gml:UpperCorner>35.725 42.8153</gml:UpperCorner>
- * </gml:Envelope>
- * </BBOX>
- * </pre>
- *
- * @author William Wall
- */
-public class BBOX implements IOperation {
- private static final Logger logger = Logger.getLogger(BBOX.class);
-
- Shape shape;
-
- // longitude column names in order of priority
- protected static final String[] LON_NAMES = {
- "lonself",
- "lon",
- "long",
- "longitude"
- };
-
- // latitude column names in order of priority
- protected static final String[] LAT_NAMES = {
- "latself",
- "lat",
- "latitude"
- };
-
- @Override
- public boolean execute(Map<String, String> row) {
- Point2D p = BBOX.getPoint(row);
-
- if (p != null && shape != null) {
- if (shape.contains(p)) {
- return true;
- } else {
- // attempt to normalize the point into the shape in the event that the shape
- // bounds are outside of -180 to 180
- Rectangle bounds = shape.getBounds();
- while (p.getX() < bounds.getMinX()) {
- p.setLocation(p.getX() + 360, p.getY());
- }
- while (p.getX() > bounds.getMaxX()) {
- p.setLocation(p.getX() - 360, p.getY());
- }
-
- return shape.contains(p);
- }
- }
-
- return false;
- }
-
- @Override
- public List<IOperation> getChildren() {
- return null;
- }
-
- @Override
- public void init(Node node, String compareType) {
- NodeList children = node.getChildNodes();
- for (int i = 0; i < children.getLength(); i++) {
- shape = ShapeFactory.getShape(children.item(i));
- if (shape != null) {
- break;
- }
- }
-
- }
-
- /**
- * Gets a point that represents the location of this row. See
- * @param row
- * @return The point object as (x - Longitude, y - Latitude)
- */
- protected static Point2D getPoint(Map<String, String> row) {
- Point2D.Double p = new Point2D.Double();
- p.x = getDegree(row, LON_NAMES);
- p.y = getDegree(row, LAT_NAMES);
- return p;
- }
-
- protected static double getDegree(Map<String, String> row, String[] cols) {
- double num = Double.NaN;
- String value;
- for (int i = 0; i < cols.length; i++) {
- if (row.containsKey(cols[i])) {
- value = row.get(cols[i]);
- if (value != null && !value.equals("-")) {
- try {
- num = Double.parseDouble(value);
- break;
- } catch (NumberFormatException e) {
- logger.warn("Could not parse degree value from " + cols[i] + " = " + value);
- }
- }
- }
- }
-
- return num;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/80faf06d/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/IOperation.java
----------------------------------------------------------------------
diff --git a/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/IOperation.java b/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/IOperation.java
deleted file mode 100644
index 6ad8ebe..0000000
--- a/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/IOperation.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package ss.cloudbase.core.iterators.filter.ogc.operation;
-
-import java.util.List;
-import java.util.Map;
-
-import org.w3c.dom.Node;
-
-public interface IOperation {
-
- /**
- * Sets up the operation from the filter XML node
- * @param node The node
- * @param compareType The compare type. Defaults to "auto", but you can force it to be "numeric" or "string".
- */
- public void init(Node node, String compareType);
-
- /**
- * Executes the operation indicated by the given node in the query
- * tree.
- * @param row The key/value pairs for the current row
- * @return The boolean evaluation of the operation
- */
- public boolean execute(Map<String, String> row);
-
- /**
- * Returns the nodes children. This is only applicable to logical
- * operations (AND, OR, NOT).
- */
- public List<IOperation> getChildren();
-}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/80faf06d/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/Not.java
----------------------------------------------------------------------
diff --git a/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/Not.java b/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/Not.java
deleted file mode 100644
index 74826a8..0000000
--- a/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/Not.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package ss.cloudbase.core.iterators.filter.ogc.operation;
-
-import java.util.Map;
-
-/**
- * Executes a logical NOT on the child operations. If there is a single child, then
- * the operation is NOT. If more than one child exists, this operation defaults to
- * NOR behavior. For NAND behavior, make a single AND child of NOT.
- *
- * <code>
- * <pre>
- * <Not>
- * <PropertyIsEqualTo>...
- * </Not>
- * </pre>
- * </code>
- *
- * @author William Wall
- *
- */
-public class Not extends AbstractLogicalOp implements IOperation {
-
- @Override
- public boolean execute(Map<String, String> row) {
- // For typical NOT behavior, a NOT group should have one child. If it has more than one child, it behaves
- // like NOR. NAND/NOR behavior can be implemented by giving the Not group a child group of AND/OR.
- boolean result = true;
- for (int i = 0; i < children.size(); i++) {
- result = !children.get(i).execute(row);
- // in the case that there are multiple children, treat them as NOR
- if (!result) break;
- }
- return result;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/80faf06d/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/Or.java
----------------------------------------------------------------------
diff --git a/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/Or.java b/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/Or.java
deleted file mode 100644
index 0a3dd6e..0000000
--- a/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/Or.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package ss.cloudbase.core.iterators.filter.ogc.operation;
-
-import java.util.Map;
-
-/**
- * Executes a logical OR on the child operations.
- *
- * <code>
- * <pre>
- * <Or>
- * <PropertyIsEqualTo>...
- * <PropertyIsLessThan>...
- * </Or>
- * </pre>
- * </code>
- *
- * @author William Wall
- */
-public class Or extends AbstractLogicalOp implements IOperation {
- @Override
- public boolean execute(Map<String, String> row) {
- boolean result = false;
- for (int i = 0; i < children.size(); i++) {
- result = children.get(i).execute(row);
- if (result) break;
- }
- return result;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/80faf06d/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/PropertyIsBetween.java
----------------------------------------------------------------------
diff --git a/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/PropertyIsBetween.java b/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/PropertyIsBetween.java
deleted file mode 100644
index 2c9d86c..0000000
--- a/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/PropertyIsBetween.java
+++ /dev/null
@@ -1,76 +0,0 @@
-package ss.cloudbase.core.iterators.filter.ogc.operation;
-
-import java.util.List;
-import java.util.Map;
-
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import ss.cloudbase.core.iterators.filter.ogc.OGCFilter;
-
-
-/**
- * An operation that determines if the row's value is between the given
- * boundary values.
- *
- * Example:
- * <pre>
- * <PropertyIsBetween>
- * <PropertyName>height</PropertyName>
- * <LowerBoundary><Literal>180</Literal></LowerBoundary>
- * <UpperBoundary><Literal>200</Literal></UpperBoundary>
- * </PropertyIsBetween>
- * </pre>
- *
- * @author William Wall
- */
-public class PropertyIsBetween implements IOperation {
- String name;
- String lower, upper, value;
- double lowerNum, upperNum, valueNum;
- boolean isNumeric = false;
-
- @Override
- public boolean execute(Map<String, String> row) {
- if (isNumeric) {
- valueNum = AbstractComparisonOp.parseNumeric(row.get(name));
- if (valueNum != Double.NaN) {
- return lowerNum <= valueNum && valueNum <= upperNum;
- }
- }
-
- value = row.get(name);
- if (value == null) {
- value = "";
- }
-
- return value.compareTo(lower) > -1 && value.compareTo(upper) < 1;
- }
-
- @Override
- public List<IOperation> getChildren() {
- return null;
- }
-
- @Override
- public void init(Node node, String compareType) {
- Node child;
- NodeList children = node.getChildNodes();
- for (int i = 0; i < children.getLength(); i++) {
- child = children.item(i);
- if (child.getNodeName().equalsIgnoreCase("PropertyName")) {
- name = child.getTextContent();
- } else if (child.getNodeName().equalsIgnoreCase("LowerBoundary")) {
- lower = child.getTextContent();
- } else if (child.getNodeName().equalsIgnoreCase("UpperBoundary")) {
- upper = child.getTextContent();
- }
- }
-
- if (compareType.equalsIgnoreCase(OGCFilter.TYPE_NUMERIC) || compareType.equalsIgnoreCase(OGCFilter.TYPE_AUTO)) {
- upperNum = AbstractComparisonOp.parseNumeric(upper);
- lowerNum = AbstractComparisonOp.parseNumeric(lower);
- isNumeric = !Double.isNaN(upperNum) && !Double.isNaN(lowerNum);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/80faf06d/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/PropertyIsEqualTo.java
----------------------------------------------------------------------
diff --git a/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/PropertyIsEqualTo.java b/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/PropertyIsEqualTo.java
deleted file mode 100644
index 93fa3f5..0000000
--- a/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/PropertyIsEqualTo.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package ss.cloudbase.core.iterators.filter.ogc.operation;
-
-import java.util.Map;
-
-/**
- * An operation to see whether the values are equal or not.
- *
- * Example:
- * <pre>
- * <PropertyIsEqualTo>
- * <PropertyName>user</PropertyIsEqualTo>
- * <Literal>CmdrTaco</Literal>
- * </PropertyIsEqualTo>
- * </pre>
- *
- * @author William Wall
- */
-public class PropertyIsEqualTo extends AbstractComparisonOp implements IOperation {
-
- @Override
- public boolean execute(Map<String, String> row) {
- value = getValue(row);
-
- if (checkRowNumeric(value)) {
- return valueNum == literalNum;
- }
-
- return value.equals(literal);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/80faf06d/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/PropertyIsGreaterThan.java
----------------------------------------------------------------------
diff --git a/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/PropertyIsGreaterThan.java b/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/PropertyIsGreaterThan.java
deleted file mode 100644
index 8eb9ec0..0000000
--- a/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/PropertyIsGreaterThan.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package ss.cloudbase.core.iterators.filter.ogc.operation;
-
-import java.util.Map;
-
-/**
- * An operation to see if the row value is greater than the given value.
- *
- * Example:
- * <pre>
- * <PropertyIsGreaterThan>
- * <PropertyName>height</PropertyName>
- * <Literal>200</Literal>
- * </PropertyIsGreaterThan>
- * </pre>
- * @author William Wall
- */
-public class PropertyIsGreaterThan extends AbstractComparisonOp implements IOperation {
-
- @Override
- public boolean execute(Map<String, String> row) {
- value = getValue(row);
-
- if (checkRowNumeric(value)) {
- return valueNum > literalNum;
- }
-
- return value.compareTo(literal) > 0;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/80faf06d/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/PropertyIsGreaterThanOrEqualTo.java
----------------------------------------------------------------------
diff --git a/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/PropertyIsGreaterThanOrEqualTo.java b/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/PropertyIsGreaterThanOrEqualTo.java
deleted file mode 100644
index 17fb1dc..0000000
--- a/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/PropertyIsGreaterThanOrEqualTo.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package ss.cloudbase.core.iterators.filter.ogc.operation;
-
-import java.util.Map;
-
-/**
- * An operation to see if the row value is greater than or equal to the given value.
- *
- * Example:
- * <pre>
- * <PropertyIsGreaterThanOrEqualTo>
- * <PropertyName>height</PropertyName>
- * <Literal>100</Literal>
- * </PropertyIsGreaterThanOrEqualTo>
- * </pre>
- * @author William Wall
- */
-public class PropertyIsGreaterThanOrEqualTo extends AbstractComparisonOp implements IOperation {
-
- @Override
- public boolean execute(Map<String, String> row) {
- value = getValue(row);
-
- if (checkRowNumeric(value)) {
- return valueNum >= literalNum;
- }
-
- return value.compareTo(literal) > -1;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/80faf06d/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/PropertyIsLessThan.java
----------------------------------------------------------------------
diff --git a/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/PropertyIsLessThan.java b/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/PropertyIsLessThan.java
deleted file mode 100644
index f094c99..0000000
--- a/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/PropertyIsLessThan.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package ss.cloudbase.core.iterators.filter.ogc.operation;
-
-import java.util.Map;
-
-/**
- * An operation to see if the row value is less than the given value.
- *
- * Example:
- * <pre>
- * <PropertyIsLessThan>
- * <PropertyName>height</PropertyName>
- * <Literal>180</Literal>
- * </PropertyIsLessThan>
- * </pre>
- *
- * @author William Wall
- */
-public class PropertyIsLessThan extends AbstractComparisonOp implements IOperation {
-
- @Override
- public boolean execute(Map<String, String> row) {
- value = getValue(row);
-
- if (checkRowNumeric(value)) {
- return valueNum < literalNum;
- }
-
- return value.compareTo(literal) < 0;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/80faf06d/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/PropertyIsLessThanOrEqualTo.java
----------------------------------------------------------------------
diff --git a/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/PropertyIsLessThanOrEqualTo.java b/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/PropertyIsLessThanOrEqualTo.java
deleted file mode 100644
index 9b01aae..0000000
--- a/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/PropertyIsLessThanOrEqualTo.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package ss.cloudbase.core.iterators.filter.ogc.operation;
-
-import java.util.Map;
-
-/**
- * An operation to see if the row value is less than or equal to the given value.
- *
- * <pre>
- * <PropertyIsLessThanOrEqualTo>
- * <PropertyName>height</PropertyName>
- * <Literal>100</Literal>
- * </PropertyIsLessThanOrEqualTo>
- * </pre>
- *
- * @author William Wall
- */
-public class PropertyIsLessThanOrEqualTo extends AbstractComparisonOp implements IOperation {
-
- @Override
- public boolean execute(Map<String, String> row) {
- value = getValue(row);
-
- if (checkRowNumeric(value)) {
- return valueNum <= literalNum;
- }
-
- return value.compareTo(literal) < 1;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/80faf06d/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/PropertyIsLike.java
----------------------------------------------------------------------
diff --git a/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/PropertyIsLike.java b/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/PropertyIsLike.java
deleted file mode 100644
index ad38951..0000000
--- a/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/PropertyIsLike.java
+++ /dev/null
@@ -1,144 +0,0 @@
-package ss.cloudbase.core.iterators.filter.ogc.operation;
-
-import java.util.List;
-import java.util.Map;
-
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * An operation that determines if the row value is like the given value. This
- * operation supports wildcards (*).
- *
- * Example:
- *
- * <pre>
- * <PropertyIsLike>
- * <PropertyName>city</PropertyName>
- * <Literal>new*</Literal>
- * </PropertyIsLike>
- * </pre>
- *
- * @author William Wall
- *
- */
-public class PropertyIsLike implements IOperation {
- String pattern;
- String name;
-
- @Override
- public boolean execute(Map<String, String> row) {
- String value = row.get(name);
- if (value == null) {
- value = "";
- }
-
- return value.matches(pattern);
- }
-
- @Override
- public List<IOperation> getChildren() {
- return null;
- }
-
- @Override
- public void init(Node node, String compareType) {
- Node child;
- NodeList children = node.getChildNodes();
- for (int i = 0; i < children.getLength(); i++) {
- child = children.item(i);
- if (child.getNodeName().equalsIgnoreCase("PropertyName")) {
- name = child.getTextContent();
- } else {
- pattern = child.getTextContent();
- }
- }
-
- pattern = convertToRegex(node, pattern);
- }
-
- /**
- * Converts the pattern, wild card, single and escape characters to the
- * regular expression equivalents. Everything else in the pattern is treated
- * as a regex literal.
- *
- * @param node The PropertyIsLike node
- * @param likePattern The initial like pattern
- *
- * @return the equivalent regular expression string.
- */
- public String convertToRegex(Node node, String likePattern) {
- // Convert the pattern to a regular expression.
- StringBuilder regex = new StringBuilder();
-
- NamedNodeMap attr = node.getAttributes();
-
- String wildCard = "*";
- if (attr.getNamedItem("wildCard") != null) {
- wildCard = attr.getNamedItem("wildCard").toString();
- }
-
- String escapeChar = "\\";
- if (attr.getNamedItem("escapeChar") != null) {
- escapeChar = attr.getNamedItem("escapeChar").toString();
- }
-
- String singleChar = ".";
- if (attr.getNamedItem("singleChar") != null) {
- singleChar = attr.getNamedItem("singleChar").toString();
- }
-
- int escapeCharIndex = likePattern.indexOf(escapeChar);
-
- // These are required in WFS but we'll handle null values here.
- int wildCardIndex = wildCard == null ? -1 : likePattern.indexOf(wildCard);
- int singleCharIndex = singleChar == null ? -1 : likePattern.indexOf(singleChar);
- for (int index = 0; index < likePattern.length(); index++) {
- char ch = likePattern.charAt(index);
- if (index == escapeCharIndex) {
- escapeCharIndex = likePattern.indexOf(escapeChar, escapeCharIndex + escapeChar.length());
-
- // If there are consecutive escape characters, skip to the
- // next one to save it in the regex.
- if (index + 1 == escapeCharIndex) {
- escapeCharIndex = likePattern.indexOf(escapeChar, escapeCharIndex + escapeChar.length());
- } else if (index + 1 == wildCardIndex) {
- wildCardIndex = likePattern.indexOf(wildCard, wildCardIndex + wildCard.length());
- } else if (index + 1 == singleCharIndex) {
- singleCharIndex = likePattern.indexOf(singleChar, singleCharIndex + singleChar.length());
- } else {
- // This is an undefined condition, just skip the escape
- // character.
- }
- }
-
- // Insert the regular expression equivalent of a wild card.
- else if (index == wildCardIndex) {
- regex.append(".*");
- index += wildCard.length() - 1;
- wildCardIndex = likePattern.indexOf(wildCard, wildCardIndex + wildCard.length());
- }
-
- // Insert the regular expression equivalent of the single char.
- else if (index == singleCharIndex) {
- regex.append(".");
- index += singleChar.length() - 1;
- singleCharIndex = likePattern.indexOf(singleChar, singleCharIndex + singleChar.length());
- }
-
- // Handle certain characters in a special manner.
- else if (('[' == ch) || (']' == ch) || ('\\' == ch) || ('^' == ch)) {
- regex.append('\\').append(ch);
- }
-
- // Force everything else to be literals.
- else {
- regex.append('[').append(ch).append(']');
- }
- }
-
- // add case insensitive flag and start match at beginning of the string
- return "(?i)^" + regex.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/80faf06d/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/PropertyIsNotEqualTo.java
----------------------------------------------------------------------
diff --git a/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/PropertyIsNotEqualTo.java b/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/PropertyIsNotEqualTo.java
deleted file mode 100644
index b62e6c6..0000000
--- a/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/PropertyIsNotEqualTo.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package ss.cloudbase.core.iterators.filter.ogc.operation;
-
-import java.util.Map;
-
-/**
- * An operation that determines if the row value is not equal to the given value.
- *
- * Example:
- * <pre>
- * <PropertyIsNotEqualTo>
- * <PropertyName>weather</PropertyName>
- * <Literal>rainy</Literal>
- * </PropertyIsNotEqualTo>
- * </pre>
- *
- * @author William Wall
- *
- */
-public class PropertyIsNotEqualTo extends AbstractComparisonOp implements IOperation {
- @Override
- public boolean execute(Map<String, String> row) {
- value = getValue(row);
-
- if (checkRowNumeric(value)) {
- return valueNum != literalNum;
- }
-
- return !value.equals(literal);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/80faf06d/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/PropertyIsNull.java
----------------------------------------------------------------------
diff --git a/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/PropertyIsNull.java b/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/PropertyIsNull.java
deleted file mode 100644
index d5d67c2..0000000
--- a/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/PropertyIsNull.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package ss.cloudbase.core.iterators.filter.ogc.operation;
-
-import java.util.List;
-import java.util.Map;
-
-import org.w3c.dom.Node;
-
-/**
- * An operation to determine if the row value is null. Nulls and empty strings will both match.
- *
- * Example:
- * <pre>
- * <PropertyIsNull>
- * <PropertyName>socialSkills</PropertyName>
- * </PropertyIsNull>
- * </pre>
- *
- * @author William Wall
- */
-public class PropertyIsNull implements IOperation {
- String name;
-
- @Override
- public boolean execute(Map<String, String> row) {
- String value = row.get(name);
- return value == null || value.length() == 0;
- }
-
- @Override
- public List<IOperation> getChildren() {
- return null;
- }
-
- @Override
- public void init(Node node, String compareType) {
- name = node.getTextContent();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/80faf06d/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/ShapeFactory.java
----------------------------------------------------------------------
diff --git a/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/ShapeFactory.java b/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/ShapeFactory.java
deleted file mode 100644
index 10fea78..0000000
--- a/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/operation/ShapeFactory.java
+++ /dev/null
@@ -1,133 +0,0 @@
-package ss.cloudbase.core.iterators.filter.ogc.operation;
-
-import java.awt.Rectangle;
-import java.awt.Shape;
-import java.awt.geom.Ellipse2D;
-import java.awt.geom.Path2D;
-import java.awt.geom.Point2D;
-
-import org.apache.log4j.Logger;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import ss.cloudbase.core.iterators.filter.ogc.util.GeoUtil;
-
-
-public class ShapeFactory {
- private static final Logger logger = Logger.getLogger(ShapeFactory.class);
-
- public static Shape getShape(Node node) {
- if (node.getNodeName().equalsIgnoreCase("gml:Envelope")) {
- return parseEnvelope(node);
- } else if (node.getNodeName().equalsIgnoreCase("gml:Polygon")) {
- return parsePolygon(node);
- } else if (node.getNodeName().equalsIgnoreCase("gml:CircleByCenterPoint")) {
- return parseCircle(node);
- }
-
- logger.warn("No parser implemented for: " + node.getLocalName());
- return null;
- }
-
- protected static Shape parseEnvelope(Node node) {
- Rectangle rect = null;
-
- Node child;
- NodeList children = node.getChildNodes();
- for (int i = 0; i < children.getLength(); i++) {
- child = children.item(i);
- String[] parts = child.getTextContent().split("\\s");
-
- if (parts.length == 2) {
- double lon = Double.parseDouble(parts[0]);
- double lat = Double.parseDouble(parts[1]);
-
- if (rect == null) {
- rect = new Rectangle();
- rect.setFrame(lon, lat, 0, 0);
- } else {
- rect.add(lon, lat);
- }
- }
- }
-
- // If the rectangle width is greater than 180 degrees, the user most likely
- // meant to use the inverse BBOX (where the east value is less than the west).
- // This is for clients that wrap coordinates rather than use absolute coordinates.
- if (rect.getWidth() > 180) {
- rect.setFrame(rect.getMaxX(), rect.getMaxY(), 360 - rect.getWidth(), rect.getHeight());
- }
-
- return rect;
- }
-
- protected static Shape parsePolygon(Node node) {
- Path2D poly = null;
-
- String text = node.getTextContent();
- String[] list = text.split("\\s");
-
- for (int i = 1; i < list.length; i += 2) {
- double lon = Double.parseDouble(list[i-1]);
- double lat = Double.parseDouble(list[i]);
- if (poly == null) {
- poly = new Path2D.Double();
- poly.moveTo(lon, lat);
- } else {
- poly.lineTo(lon, lat);
- }
- }
-
- return poly;
- }
-
- protected static Shape parseCircle(Node node) {
- Ellipse2D circle = null;
-
- double radius = Double.NaN, lon = Double.NaN, lat = Double.NaN;
- String units = null;
-
- Node child;
- NodeList children = node.getChildNodes();
- try {
- for (int i = 0; i < children.getLength(); i++) {
- child = children.item(i);
- if (child.getNodeName().equalsIgnoreCase("gml:radius")) {
- radius = Double.parseDouble(child.getTextContent());
- units = child.getAttributes().getNamedItem("uom").getTextContent();
- } else {
- String[] list = child.getTextContent().split("\\s");
- lon = Double.parseDouble(list[0]);
- lat = Double.parseDouble(list[1]);
- }
- }
-
- radius = convertToKM(radius, units);
- Point2D center = new Point2D.Double(lon, lat);
- Point2D end = GeoUtil.calculateEndLocation(center, radius, lat > 0 ? 180: 0);
-
- radius = Math.abs(end.getY() - lat);
- circle = new Ellipse2D.Double();
- circle.setFrameFromCenter(center, new Point2D.Double(center.getX() + radius, center.getY() + radius));
- } catch (NumberFormatException e) {
-
- } catch (ArrayIndexOutOfBoundsException e) {
-
- }
-
- return circle;
- }
-
- private static double convertToKM(double radius, String units) {
- if (units.equalsIgnoreCase("km")) {
- return radius;
- } else if (units.equalsIgnoreCase("m")) {
- return radius / 1000;
- } else if (units.equalsIgnoreCase("mi")) {
- return 0.621371192 * radius;
- } else if (units.equalsIgnoreCase("ft")) {
- return radius / 3280.8399;
- }
- return radius;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/80faf06d/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/util/GeoUtil.java
----------------------------------------------------------------------
diff --git a/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/util/GeoUtil.java b/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/util/GeoUtil.java
deleted file mode 100644
index 95259fa..0000000
--- a/partition/common-query/src/main/java/ss/cloudbase/core/iterators/filter/ogc/util/GeoUtil.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package ss.cloudbase.core.iterators.filter.ogc.util;
-
-import java.awt.geom.Point2D;
-
-public class GeoUtil {
- /**
- * Calculates an ending location from a point, distance, and bearing
- * @param point The start point
- * @param distance The distance from the start point in kilometers
- * @param bearing The bearing (in degrees) where north is 0
- * @return The resulting point
- */
- public static Point2D calculateEndLocation(Point2D point, double distance, double bearing) {
- double r = 6371; // earth's mean radius in km
-
- double lon1 = Math.toRadians(point.getX());
- double lat1 = Math.toRadians(point.getY());
- bearing = Math.toRadians(bearing);
-
- double lat2 = Math.asin( Math.sin(lat1) * Math.cos(distance/r) + Math.cos(lat1) * Math.sin(distance/r) * Math.cos(bearing) );
- double lon2 = lon1 + Math.atan2(Math.sin(bearing) * Math.sin(distance/r) * Math.cos(lat1), Math.cos(distance/r) - Math.sin(lat1) * Math.sin(lat2));
-
- lon2 = (lon2+Math.PI)%(2*Math.PI) - Math.PI; // normalise to -180...+180
-
- if (Double.isNaN(lat2) || Double.isNaN(lon2)) return null;
-
- lon2 = Math.toDegrees(lon2);
- lat2 = Math.toDegrees(lat2);
-
- return new Point2D.Double(lon2, lat2);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/80faf06d/partition/common-query/src/test/java/GVDateFilterTest.java
----------------------------------------------------------------------
diff --git a/partition/common-query/src/test/java/GVDateFilterTest.java b/partition/common-query/src/test/java/GVDateFilterTest.java
deleted file mode 100644
index 8ea5578..0000000
--- a/partition/common-query/src/test/java/GVDateFilterTest.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-import java.util.Map.Entry;
-
-import org.apache.hadoop.io.Text;
-import org.junit.Test;
-
-import ss.cloudbase.core.iterators.GMDenIntersectingIterator;
-import ss.cloudbase.core.iterators.filter.general.GVDateFilter;
-
-import cloudbase.core.client.Connector;
-import cloudbase.core.client.Scanner;
-import cloudbase.core.client.TableNotFoundException;
-import cloudbase.core.data.Key;
-import cloudbase.core.data.Range;
-import cloudbase.core.data.Value;
-import cloudbase.core.iterators.FilteringIterator;
-import cloudbase.core.security.Authorizations;
-
-/**
- *
- * @author rashah
- */
-public class GVDateFilterTest
-{
-
- private Connector cellLevelConn;
- private Connector serializedConn;
- private static final String TABLE = "partition";
- private static final Authorizations AUTHS = new Authorizations("ALPHA,BETA,GAMMA".split(","));
-
-
-
- protected Connector getSerializedConnector()
- {
- if (serializedConn == null)
- {
- serializedConn = SampleGVData.initConnector();
- SampleGVData.writeDenSerialized(serializedConn, SampleGVData.sampleData());
- }
- return serializedConn;
- }
-
-
-
- protected Scanner getSerializedScanner()
- {
- Connector c = getSerializedConnector();
- try
- {
- return c.createScanner(TABLE, AUTHS);
- }
- catch (TableNotFoundException e)
- {
- return null;
- }
- }
-
- protected Scanner setUpGVDFFilter(Scanner s, String timesta)
- {
- try
- {
-
- s.setScanIterators(50, FilteringIterator.class.getName(), "gvdf");
- s.setScanIteratorOption("gvdf", "0", GVDateFilter.class.getName());
- s.setScanIteratorOption("gvdf", "0." + GVDateFilter.OPTIONInTimestamp, timesta);
-
- }
- catch (IOException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return s;
- }
-
- protected String checkSerialized(Scanner s)
- {
- StringBuilder sb = new StringBuilder();
- boolean first = true;
- for (Entry<Key, Value> e : s)
- {
-
- if (!first)
- {
- sb.append(",");
- }
- else
- {
- first = false;
- }
-
- String colq = e.getKey().getColumnQualifier().toString();
-
- sb.append(colq);
- }
- return sb.toString();
- }
-
-
- @Test
- public void testNoResults()
- {
-
- Scanner s = setUpGVDFFilter(getSerializedScanner(), "2008-03-03T20:44:28.633Z");
- s.setRange(new Range());
-
- assertTrue(checkSerialized(s).equals(""));
- }
-
-
- @Test
- public void testOneResult()
- {
-
- Scanner s = setUpGVDFFilter(getSerializedScanner(), "2011-03-03T20:44:28.633Z");
- s.setRange(new Range());
-
- System.out.println(checkSerialized(s));
-
- assertTrue(checkSerialized(s).equals("03"));
- }
-
- @Test
- public void testTwoResults()
- {
-
- Scanner s = setUpGVDFFilter(getSerializedScanner(), "2009-03-03T20:44:28.633Z");
- s.setRange(new Range());
-
- assertTrue(checkSerialized(s).equals("04,01"));
- }
-
- @Test
- public void testThreeResults()
- {
-
- Scanner s = setUpGVDFFilter(getSerializedScanner(), "2010-03-01T20:44:28.633Z");
- s.setRange(new Range());
-
- assertTrue(checkSerialized(s).equals("04,01,03"));
- }
-
- @Test
- public void testDummyTest()
- {
- assertTrue(true);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/80faf06d/partition/common-query/src/test/java/GVFrequencyFilterTest.java
----------------------------------------------------------------------
diff --git a/partition/common-query/src/test/java/GVFrequencyFilterTest.java b/partition/common-query/src/test/java/GVFrequencyFilterTest.java
deleted file mode 100644
index 25c602a..0000000
--- a/partition/common-query/src/test/java/GVFrequencyFilterTest.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-import java.util.Map.Entry;
-
-import org.apache.hadoop.io.Text;
-import org.junit.Test;
-
-import ss.cloudbase.core.iterators.GMDenIntersectingIterator;
-import ss.cloudbase.core.iterators.filter.general.GVFrequencyFilter;
-
-import cloudbase.core.client.Connector;
-import cloudbase.core.client.Scanner;
-import cloudbase.core.client.TableNotFoundException;
-import cloudbase.core.data.Key;
-import cloudbase.core.data.Range;
-import cloudbase.core.data.Value;
-import cloudbase.core.iterators.FilteringIterator;
-import cloudbase.core.security.Authorizations;
-
-/**
- *
- * @author rashah
- */
-public class GVFrequencyFilterTest
-{
-
- private Connector cellLevelConn;
- private Connector serializedConn;
- private static final String TABLE = "partition";
- private static final Authorizations AUTHS = new Authorizations("ALPHA,BETA,GAMMA".split(","));
-
-
-
- protected Connector getSerializedConnector()
- {
- if (serializedConn == null)
- {
- serializedConn = SampleGVData.initConnector();
- SampleGVData.writeDenSerialized(serializedConn, SampleGVData.sampleData());
- }
- return serializedConn;
- }
-
-
-
- protected Scanner getSerializedScanner()
- {
- Connector c = getSerializedConnector();
- try
- {
- return c.createScanner(TABLE, AUTHS);
- }
- catch (TableNotFoundException e)
- {
- return null;
- }
- }
-
- protected Scanner setUpGVDFFilter(Scanner s, String Frequency)
- {
- try
- {
- s.clearScanIterators();
-
- s.setScanIterators(50, FilteringIterator.class.getName(), "gvff");
- s.setScanIteratorOption("gvff", "0", GVFrequencyFilter.class.getName());
- s.setScanIteratorOption("gvff", "0." + GVFrequencyFilter.OPTIONFrequency, Frequency);
-
- }
- catch (IOException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return s;
- }
-
- protected String checkSerialized(Scanner s)
- {
- StringBuilder sb = new StringBuilder();
- boolean first = true;
- for (Entry<Key, Value> e : s)
- {
-
- if (!first)
- {
- sb.append(",");
- }
- else
- {
- first = false;
- }
-
- String colq = e.getKey().getColumnQualifier().toString();
-
- //System.out.println(e.getKey()+"\t"+e.getValue());
-
- sb.append(colq);
- }
- return sb.toString();
- }
-
- @Test
- public void testNoMatch()
- {
-
- Scanner s = setUpGVDFFilter(getSerializedScanner(), "2000000000");
- s.setRange(new Range());
-
- assertTrue(checkSerialized(s).isEmpty());
- }
-
- @Test
- public void testSingleMatch()
- {
- Scanner s = setUpGVDFFilter(getSerializedScanner(), "1500000000");
- s.setRange(new Range());
-
- assertTrue(checkSerialized(s).equals("01"));
- }
-
-
- @Test
- public void testDoubleMatch()
- {
- Scanner s = setUpGVDFFilter(getSerializedScanner(), "1200000000");
- s.setRange(new Range());
-
- assertTrue(checkSerialized(s).equals("01,03"));
- }
-
- @Test
- public void testDummyTest()
- {
- assertTrue(true);
- }
-
-}