use of org.polymap.recordstore.QueryExpression.Greater in project polymap4-core by Polymap4.
the class NumericValueCoder method searchQuery.
public Query searchQuery(QueryExpression exp) {
// EQUALS
if (exp instanceof QueryExpression.Equal) {
Equal equalExp = (QueryExpression.Equal) exp;
if (equalExp.value instanceof Number) {
String key = equalExp.key;
Number value = (Number) equalExp.value;
if (equalExp.value instanceof Integer) {
return NumericRangeQuery.newIntRange(key, value.intValue(), value.intValue(), true, true);
} else if (equalExp.value instanceof Long) {
return NumericRangeQuery.newLongRange(key, value.longValue(), value.longValue(), true, true);
} else if (equalExp.value instanceof Float) {
return NumericRangeQuery.newFloatRange(key, value.floatValue(), value.floatValue(), true, true);
} else if (equalExp.value instanceof Double) {
return NumericRangeQuery.newDoubleRange(key, value.doubleValue(), value.doubleValue(), true, true);
} else {
throw new RuntimeException("Unknown Number type: " + value.getClass());
}
}
} else // GREATER
if (exp instanceof QueryExpression.Greater) {
Greater greaterExp = (QueryExpression.Greater) exp;
if (greaterExp.value instanceof Number) {
String key = greaterExp.key;
Number value = (Number) greaterExp.value;
if (greaterExp.value instanceof Integer) {
return NumericRangeQuery.newIntRange(key, value.intValue(), null, false, false);
} else if (greaterExp.value instanceof Long) {
return NumericRangeQuery.newLongRange(key, value.longValue(), null, false, false);
} else if (greaterExp.value instanceof Float) {
return NumericRangeQuery.newFloatRange(key, value.floatValue(), null, false, false);
} else if (greaterExp.value instanceof Double) {
return NumericRangeQuery.newDoubleRange(key, value.doubleValue(), null, false, false);
} else {
throw new RuntimeException("Unknown Number type: " + value.getClass());
}
}
} else // GREATER OR EQUAL
if (exp instanceof QueryExpression.GreaterOrEqual) {
GreaterOrEqual greaterExp = (QueryExpression.GreaterOrEqual) exp;
if (greaterExp.value instanceof Number) {
String key = greaterExp.key;
Number value = (Number) greaterExp.value;
if (greaterExp.value instanceof Integer) {
return NumericRangeQuery.newIntRange(key, value.intValue(), null, true, false);
} else if (greaterExp.value instanceof Long) {
return NumericRangeQuery.newLongRange(key, value.longValue(), null, true, false);
} else if (greaterExp.value instanceof Float) {
return NumericRangeQuery.newFloatRange(key, value.floatValue(), null, true, false);
} else if (greaterExp.value instanceof Double) {
return NumericRangeQuery.newDoubleRange(key, value.doubleValue(), null, true, false);
} else {
throw new RuntimeException("Unknown Number type: " + value.getClass());
}
}
} else // LESS
if (exp instanceof QueryExpression.Less) {
Less lessExp = (QueryExpression.Less) exp;
if (lessExp.value instanceof Number) {
String key = lessExp.key;
Number value = (Number) lessExp.value;
if (lessExp.value instanceof Integer) {
return NumericRangeQuery.newIntRange(key, null, value.intValue(), false, false);
} else if (lessExp.value instanceof Long) {
return NumericRangeQuery.newLongRange(key, null, value.longValue(), false, false);
} else if (lessExp.value instanceof Float) {
return NumericRangeQuery.newFloatRange(key, null, value.floatValue(), false, false);
} else if (lessExp.value instanceof Double) {
return NumericRangeQuery.newDoubleRange(key, null, value.doubleValue(), false, false);
} else {
throw new RuntimeException("Unknown Number type: " + value.getClass());
}
}
} else // LESS or equal
if (exp instanceof QueryExpression.LessOrEqual) {
LessOrEqual lessExp = (QueryExpression.LessOrEqual) exp;
if (lessExp.value instanceof Number) {
String key = lessExp.key;
Number value = (Number) lessExp.value;
if (lessExp.value instanceof Integer) {
return NumericRangeQuery.newIntRange(key, null, value.intValue(), false, true);
} else if (lessExp.value instanceof Long) {
return NumericRangeQuery.newLongRange(key, null, value.longValue(), false, true);
} else if (lessExp.value instanceof Float) {
return NumericRangeQuery.newFloatRange(key, null, value.floatValue(), false, true);
} else if (lessExp.value instanceof Double) {
return NumericRangeQuery.newDoubleRange(key, null, value.doubleValue(), false, true);
} else {
throw new RuntimeException("Unknown Number type: " + value.getClass());
}
}
} else // MATCHES
if (exp instanceof QueryExpression.Match) {
Match matchExp = (Match) exp;
if (matchExp.value instanceof Number) {
throw new UnsupportedOperationException("MATCHES not supported for Number values.");
}
}
return null;
}
use of org.polymap.recordstore.QueryExpression.Greater in project polymap4-core by Polymap4.
the class GeometryValueCoder method searchQuery.
public Query searchQuery(QueryExpression exp) {
// BBOX
if (exp instanceof QueryExpression.BBox) {
// return !(other.minx > maxx ||
// other.maxx < minx ||
// other.miny > maxy ||
// other.maxy < miny);
// -> !maxx < other.minx && !mixx > other.maxx
// -> maxx > other.minx && minx < other.maxx
BBox bbox = (QueryExpression.BBox) exp;
BooleanQuery result = new BooleanQuery();
// maxx > bbox.getMinX
result.add(numeric.searchQuery(new Greater(bbox.key + FIELD_MAXX, bbox.minX)), BooleanClause.Occur.MUST);
// minx < bbox.getMaxX
result.add(numeric.searchQuery(new Less(bbox.key + FIELD_MINX, bbox.maxX)), BooleanClause.Occur.MUST);
// maxy > bbox.getMinY
result.add(numeric.searchQuery(new Greater(bbox.key + FIELD_MAXY, bbox.minY)), BooleanClause.Occur.MUST);
// miny < bbox.getMaxY
result.add(numeric.searchQuery(new Less(bbox.key + FIELD_MINY, bbox.maxY)), BooleanClause.Occur.MUST);
return result;
}
// }
return null;
}
Aggregations