You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by th...@apache.org on 2021/11/26 16:15:08 UTC
[jackrabbit-oak] branch OAK-9625 updated: Undo whitespace changes
This is an automated email from the ASF dual-hosted git repository.
thomasm pushed a commit to branch OAK-9625
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
The following commit(s) were added to refs/heads/OAK-9625 by this push:
new 708c3d7 Undo whitespace changes
708c3d7 is described below
commit 708c3d7386180aa3316ba43243b591ec27730769
Author: thomasm <th...@apache.org>
AuthorDate: Fri Nov 26 17:15:02 2021 +0100
Undo whitespace changes
---
.../org/apache/jackrabbit/oak/query/QueryImpl.java | 104 ++++++++++-----------
.../apache/jackrabbit/oak/query/SQL2Parser.java | 28 +++---
.../oak/query/ast/AstElementFactory.java | 10 +-
.../jackrabbit/oak/query/ast/AstVisitor.java | 3 +-
.../jackrabbit/oak/query/ast/AstVisitorBase.java | 8 +-
5 files changed, 76 insertions(+), 77 deletions(-)
diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryImpl.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryImpl.java
index 029bc14..4e7153c 100644
--- a/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryImpl.java
+++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryImpl.java
@@ -113,7 +113,7 @@ import com.google.common.collect.Ordering;
*/
public class QueryImpl implements Query {
- public static final UnsupportedOperationException TOO_MANY_UNION =
+ public static final UnsupportedOperationException TOO_MANY_UNION =
new UnsupportedOperationException("Too many union queries");
public final static int MAX_UNION = Integer.getInteger("oak.sql2MaxUnion", 1000);
@@ -135,17 +135,17 @@ public class QueryImpl implements Query {
SourceImpl source;
private String statement;
final HashMap<String, PropertyValue> bindVariableMap = new HashMap<String, PropertyValue>();
-
+
/**
* The map of indexes (each selector uses one index)
*/
final HashMap<String, Integer> selectorIndexes = new HashMap<String, Integer>();
-
+
/**
* The list of selectors of this query. For a join, there can be multiple selectors.
*/
final ArrayList<SelectorImpl> selectors = new ArrayList<SelectorImpl>();
-
+
ConstraintImpl constraint;
/**
@@ -154,7 +154,7 @@ public class QueryImpl implements Query {
* purposes.
*/
private boolean traversalEnabled = true;
-
+
/**
* The query option to be used for this query.
*/
@@ -162,13 +162,13 @@ public class QueryImpl implements Query {
private OrderingImpl[] orderings;
private ColumnImpl[] columns;
-
+
/**
* The columns that make a row distinct. This is all columns
* except for "jcr:score".
*/
private boolean[] distinctColumns;
-
+
private boolean explain, measure;
private boolean distinct;
private long limit = Long.MAX_VALUE;
@@ -176,7 +176,7 @@ public class QueryImpl implements Query {
private long size = -1;
private boolean prepared;
private ExecutionContext context;
-
+
/**
* whether the object has been initialised or not
*/
@@ -185,7 +185,7 @@ public class QueryImpl implements Query {
private boolean isSortedByIndex;
private final NamePathMapper namePathMapper;
-
+
private double estimatedCost;
private final QueryEngineSettings settings;
@@ -228,7 +228,7 @@ public class QueryImpl implements Query {
bindVariableMap.put(node.getBindVariableName(), null);
return true;
}
-
+
@Override
public boolean visit(ChildNodeImpl node) {
node.setQuery(query);
@@ -295,14 +295,14 @@ public class QueryImpl implements Query {
node.bindSelector(source);
return super.visit(node);
}
-
+
@Override
public boolean visit(SimilarImpl node) {
node.setQuery(query);
node.bindSelector(source);
return super.visit(node);
}
-
+
@Override
public boolean visit(SpellcheckImpl node) {
node.setQuery(query);
@@ -357,7 +357,7 @@ public class QueryImpl implements Query {
node.bindSelector(source);
return true;
}
-
+
@Override
public boolean visit(PropertyInexistenceImpl node) {
node.setQuery(query);
@@ -426,7 +426,7 @@ public class QueryImpl implements Query {
node.setQuery(query);
return super.visit(node);
}
-
+
@Override
public boolean visit(AndImpl node) {
node.setQuery(query);
@@ -461,7 +461,7 @@ public class QueryImpl implements Query {
}
distinctColumns[i] = distinct;
}
-
+
init = true;
}
@@ -506,7 +506,7 @@ public class QueryImpl implements Query {
public void setMeasure(boolean measure) {
this.measure = measure;
}
-
+
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
@@ -519,7 +519,7 @@ public class QueryImpl implements Query {
/**
* If one of the indexes wants a warning to be logged due to path mismatch,
* then get the warning message. Otherwise, return null.
- *
+ *
* @return null (in the normal case) or the list of index plan names (if
* some index wants a warning to be logged)
*/
@@ -572,7 +572,7 @@ public class QueryImpl implements Query {
}
}
}
-
+
@Override
public Iterator<ResultRowImpl> getRows() {
prepare();
@@ -697,7 +697,7 @@ public class QueryImpl implements Query {
public String getPlan() {
return source.getPlan(context.getBaseState());
}
-
+
@Override
public String getIndexCostInfo() {
return source.getIndexCostInfo(context.getBaseState());
@@ -765,7 +765,7 @@ public class QueryImpl implements Query {
source = result;
isSortedByIndex = canSortByIndex();
}
-
+
private static SourceImpl buildJoin(SourceImpl result, SourceImpl last, List<JoinConditionImpl> conditions) {
if (result == null) {
return last;
@@ -787,12 +787,12 @@ public class QueryImpl implements Query {
// no join condition was found
return null;
}
-
+
/**
* <b>!Test purpose only! <b>
- *
+ *
* this creates a filter for the given query
- *
+ *
*/
Filter createFilter(boolean preparing) {
return source.createFilter(preparing);
@@ -1010,7 +1010,7 @@ public class QueryImpl implements Query {
public int getColumnIndex(String columnName) {
return getColumnIndex(columns, columnName);
}
-
+
static int getColumnIndex(ColumnImpl[] columns, String columnName) {
for (int i = 0, size = columns.length; i < size; i++) {
ColumnImpl c = columns[i];
@@ -1036,7 +1036,7 @@ public class QueryImpl implements Query {
for (int i = 0; i < list.length; i++) {
list[i] = selectors.get(i).getSelectorName();
}
- // reverse names to that for xpath,
+ // reverse names to that for xpath,
// the first selector is the same as the node iterator
Collections.reverse(Arrays.asList(list));
return list;
@@ -1082,7 +1082,7 @@ public class QueryImpl implements Query {
// current index is below the minimum cost of the next index.
List<? extends QueryIndex> queryIndexes = MINIMAL_COST_ORDERING
.sortedCopy(indexProvider.getQueryIndexes(rootState));
- List<OrderEntry> sortOrder = getSortOrder(filter);
+ List<OrderEntry> sortOrder = getSortOrder(filter);
for (int i = 0; i < queryIndexes.size(); i++) {
QueryIndex index = queryIndexes.get(i);
double minCost = index.getMinimumCost();
@@ -1115,7 +1115,7 @@ public class QueryImpl implements Query {
filter, sortOrder, rootState);
cost = Double.POSITIVE_INFINITY;
for (IndexPlan p : ipList) {
-
+
long entryCount = p.getEstimatedEntryCount();
if (p.getSupportsPathRestriction()) {
entryCount = scaleEntryCount(rootState, filter, entryCount);
@@ -1214,7 +1214,7 @@ public class QueryImpl implements Query {
return new SelectorExecutionPlan(filter.getSelector(), bestIndex,
bestPlan, bestCost);
}
-
+
private long scaleEntryCount(NodeState rootState, FilterImpl filter, long count) {
PathRestriction r = filter.getPathRestriction();
if (r != PathRestriction.ALL_CHILDREN) {
@@ -1235,14 +1235,14 @@ public class QueryImpl implements Query {
totalNodesCount = 1;
}
// same logic as for the property index (see ContentMirrorStoreStrategy):
-
+
// assume nodes in the index are evenly distributed in the repository (old idea)
long countScaledDown = (long) ((double) count / totalNodesCount * filterPathCount);
// assume 80% of the indexed nodes are in this subtree
long mostNodesFromThisSubtree = (long) (filterPathCount * 0.8);
// count can at most be the assumed subtree size
count = Math.min(count, mostNodesFromThisSubtree);
- // this in theory should not have any effect,
+ // this in theory should not have any effect,
// except if the above estimates are incorrect,
// so this is just for safety feature
count = Math.max(count, countScaledDown);
@@ -1253,7 +1253,7 @@ public class QueryImpl implements Query {
public boolean isPotentiallySlow() {
return potentiallySlowTraversalQuery;
}
-
+
@Override
public void verifyNotPotentiallySlow() {
if (potentiallySlowTraversalQuery) {
@@ -1284,7 +1284,7 @@ public class QueryImpl implements Query {
}
}
}
-
+
private List<OrderEntry> getSortOrder(FilterImpl filter) {
if (orderings == null) {
return null;
@@ -1303,7 +1303,7 @@ public class QueryImpl implements Query {
}
return sortOrder;
}
-
+
private void logDebug(String msg) {
if (isInternal) {
LOG.trace(msg);
@@ -1346,7 +1346,7 @@ public class QueryImpl implements Query {
/**
* Validate the path is syntactically correct, and convert it to an Oak
* internal path (including namespace remapping if needed).
- *
+ *
* @param path the path
* @return the the converted path
*/
@@ -1396,7 +1396,7 @@ public class QueryImpl implements Query {
public long getSize() {
return size;
}
-
+
@Override
public long getSize(SizePrecision precision, long max) {
// Note: DISTINCT is ignored
@@ -1424,10 +1424,10 @@ public class QueryImpl implements Query {
public ExecutionContext getExecutionContext() {
return context;
}
-
+
/**
* Add two values, but don't let it overflow or underflow.
- *
+ *
* @param x the first value
* @param y the second value
* @return the sum, or Long.MIN_VALUE for underflow, or Long.MAX_VALUE for
@@ -1443,7 +1443,7 @@ public class QueryImpl implements Query {
@Override
public Query buildAlternativeQuery() {
Query result = this;
-
+
if (constraint != null) {
Set<ConstraintImpl> unionList;
try {
@@ -1476,14 +1476,14 @@ public class QueryImpl implements Query {
// re-composing the statement for better debug messages
left.statement = recomposeStatement(left);
}
-
+
result = newAlternativeUnionQuery(left, right);
}
}
-
+
return result;
}
-
+
private static String recomposeStatement(@NotNull QueryImpl query) {
checkNotNull(query);
String original = query.getStatement();
@@ -1492,7 +1492,7 @@ public class QueryImpl implements Query {
final String where = " WHERE ";
final String orderBy = " ORDER BY ";
int whereOffset = where.length();
-
+
if (query.getConstraint() == null) {
recomputed.append(original);
} else {
@@ -1504,18 +1504,18 @@ public class QueryImpl implements Query {
}
return recomputed.toString();
}
-
+
/**
* Convenience method for creating a UnionQueryImpl with proper settings.
- *
+ *
* @param left the first subquery
* @param right the second subquery
* @return the union query
*/
private UnionQueryImpl newAlternativeUnionQuery(@NotNull Query left, @NotNull Query right) {
UnionQueryImpl u = new UnionQueryImpl(
- false,
- checkNotNull(left, "`left` cannot be null"),
+ false,
+ checkNotNull(left, "`left` cannot be null"),
checkNotNull(right, "`right` cannot be null"),
this.settings);
u.setExplain(explain);
@@ -1525,20 +1525,20 @@ public class QueryImpl implements Query {
u.setOrderings(orderings);
return u;
}
-
+
@Override
public Query copyOf() {
if (isInit()) {
throw new IllegalStateException("QueryImpl cannot be cloned once initialised.");
}
-
+
List<ColumnImpl> cols = newArrayList();
for (ColumnImpl c : columns) {
cols.add((ColumnImpl) copyElementAndCheckReference(c));
}
-
+
QueryImpl copy = new QueryImpl(
- this.statement,
+ this.statement,
(SourceImpl) copyElementAndCheckReference(this.source),
this.constraint,
cols.toArray(new ColumnImpl[0]),
@@ -1551,7 +1551,7 @@ public class QueryImpl implements Query {
copy.distinct = this.distinct;
copy.queryOptions = this.queryOptions;
- return copy;
+ return copy;
}
@Override
@@ -1576,5 +1576,5 @@ public class QueryImpl implements Query {
public QueryExecutionStats getQueryExecutionStats() {
return stats;
}
-
+
}
diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/query/SQL2Parser.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/query/SQL2Parser.java
index 0f5df2e..468f5d0 100644
--- a/oak-core/src/main/java/org/apache/jackrabbit/oak/query/SQL2Parser.java
+++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/query/SQL2Parser.java
@@ -65,7 +65,7 @@ import org.slf4j.LoggerFactory;
* language (here named SQL-1) is also supported.
*/
public class SQL2Parser {
-
+
private static final Logger LOG = LoggerFactory.getLogger(SQL2Parser.class);
// Character types, used during the tokenizer phase
@@ -109,16 +109,16 @@ public class SQL2Parser {
private boolean supportSQL1;
private NamePathMapper namePathMapper;
-
+
private final QueryEngineSettings settings;
-
+
private boolean literalUsageLogged;
private final QueryExecutionStats stats;
/**
* Create a new parser. A parser can be re-used, but it is not thread safe.
- *
+ *
* @param namePathMapper the name-path mapper to use
* @param nodeTypes the nodetypes
* @param settings the query engine settings
@@ -210,10 +210,10 @@ public class SQL2Parser {
return q;
}
-
+
/**
* as {@link #parse(String, boolean)} by providing {@code true} to the initialisation flag.
- *
+ *
* @param query
* @return the parsed query
* @throws ParseException
@@ -221,7 +221,7 @@ public class SQL2Parser {
public Query parse(final String query) throws ParseException {
return parse(query, true);
}
-
+
private QueryImpl parseSelect() throws ParseException {
read("SELECT");
boolean distinct = readIf("DISTINCT");
@@ -290,7 +290,7 @@ public class SQL2Parser {
return factory.selector(nodeTypeInfo, selectorName);
}
-
+
private String readLabel() throws ParseException {
String label = readName();
if (!label.matches("[a-zA-Z0-9_]*") || label.isEmpty() || label.length() > 128) {
@@ -509,7 +509,7 @@ public class SQL2Parser {
private PropertyExistenceImpl getPropertyExistence(PropertyValueImpl p) throws ParseException {
return factory.propertyExistence(p.getSelectorName(), p.getPropertyName());
}
-
+
private PropertyInexistenceImpl getPropertyInexistence(PropertyValueImpl p) throws ParseException {
return factory.propertyInexistence(p.getSelectorName(), p.getPropertyName());
}
@@ -621,7 +621,7 @@ public class SQL2Parser {
} else {
selectorName = getOnlySelectorName();
}
- c = factory.spellcheck(selectorName, parseStaticOperand());
+ c = factory.spellcheck(selectorName, parseStaticOperand());
} else if ("SUGGEST".equalsIgnoreCase(functionName)) {
String selectorName;
if (currentTokenType == IDENTIFIER) {
@@ -946,7 +946,7 @@ public class SQL2Parser {
}
return list;
}
-
+
private boolean readOptionalAlias(ColumnOrWildcard column) throws ParseException {
if (readIf("AS")) {
column.columnName = readName();
@@ -1105,7 +1105,7 @@ public class SQL2Parser {
type = CHAR_SPECIAL_1;
break;
}
- types[i] = type = CHAR_IGNORE;
+ types[i] = type = CHAR_IGNORE;
startLoop = i;
i += 2;
checkRunOver(i, len, startLoop);
@@ -1113,7 +1113,7 @@ public class SQL2Parser {
i++;
checkRunOver(i, len, startLoop);
}
- i++;
+ i++;
break;
case '[':
types[i] = type = CHAR_BRACKETED;
@@ -1461,7 +1461,7 @@ public class SQL2Parser {
/**
* Whether the given statement is an internal query.
- *
+ *
* @param statement the statement
* @return true for an internal query
*/
diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/AstElementFactory.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/AstElementFactory.java
index d3a3841..e3371a3 100644
--- a/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/AstElementFactory.java
+++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/AstElementFactory.java
@@ -136,7 +136,7 @@ public class AstElementFactory {
public PropertyExistenceImpl propertyExistence(String selectorName, String propertyName) {
return new PropertyExistenceImpl(selectorName, propertyName);
}
-
+
public PropertyInexistenceImpl propertyInexistence(String selectorName, String propertyName) {
return new PropertyInexistenceImpl(selectorName, propertyName);
}
@@ -186,27 +186,27 @@ public class AstElementFactory {
public ConstraintImpl suggest(String selectorName, StaticOperandImpl expression) {
return new SuggestImpl(selectorName, expression);
}
-
+
/**
* <p>
* as the {@link AstElement#copyOf()} can return {@code this} is the cloning is not implemented
* by the subclass, this method add some spice around it by checking for this case and tracking
* a DEBUG message in the logs.
* </p>
- *
+ *
* @param e the element to be cloned. Cannot be null.
* @return same as {@link AstElement#copyOf()}
*/
@NotNull
public static AstElement copyElementAndCheckReference(@NotNull final AstElement e) {
AstElement clone = checkNotNull(e).copyOf();
-
+
if (clone == e && LOG.isDebugEnabled()) {
LOG.debug(
"Failed to clone the AstElement. Returning same reference; the client may fail. {} - {}",
e.getClass().getName(), e);
}
-
+
return clone;
}
diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/AstVisitor.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/AstVisitor.java
index af3044a..b35f772 100644
--- a/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/AstVisitor.java
+++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/AstVisitor.java
@@ -88,9 +88,8 @@ public interface AstVisitor {
boolean visit(NativeFunctionImpl node);
boolean visit(SimilarImpl node);
-
+
boolean visit(SpellcheckImpl node);
boolean visit(SuggestImpl suggest);
-
}
\ No newline at end of file
diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/AstVisitorBase.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/AstVisitorBase.java
index 6d2a545..ed54ee4 100644
--- a/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/AstVisitorBase.java
+++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/AstVisitorBase.java
@@ -43,7 +43,7 @@ public abstract class AstVisitorBase implements AstVisitor {
node.getOperand2().accept(this);
return true;
}
-
+
/**
* Calls accept on the all operands in the "in" node.
*/
@@ -64,7 +64,7 @@ public abstract class AstVisitorBase implements AstVisitor {
node.getFullTextSearchExpression().accept(this);
return true;
}
-
+
/**
* Calls accept on the static operand in the native search constraint.
*/
@@ -73,7 +73,7 @@ public abstract class AstVisitorBase implements AstVisitor {
node.getNativeSearchExpression().accept(this);
return true;
}
-
+
/**
* Calls accept on the static operand in the similar search constraint.
*/
@@ -82,7 +82,7 @@ public abstract class AstVisitorBase implements AstVisitor {
node.getPathExpression().accept(this);
return true;
}
-
+
/**
* Calls accept on the static operand in the spellcheck search constraint.
*/