You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by GitBox <gi...@apache.org> on 2021/11/29 17:15:47 UTC

[GitHub] [jackrabbit-oak] fabriziofortino commented on a change in pull request #427: OAK-9625 Support ordered index for first value of a multi-valued property, node name, and path

fabriziofortino commented on a change in pull request #427:
URL: https://github.com/apache/jackrabbit-oak/pull/427#discussion_r758563101



##########
File path: oak-core/src/main/java/org/apache/jackrabbit/oak/query/SQL2Parser.java
##########
@@ -676,6 +676,12 @@ private DynamicOperandImpl parseExpressionFunction(String functionName) throws P
             } else {
                 op = factory.nodeLocalName(readName());
             }
+        } else if ("PATH".equalsIgnoreCase(functionName)) {

Review comment:
       I think you should add `PATH` and `FIRST` in the `getSyntaxError ` at line 707

##########
File path: oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/PathImpl.java
##########
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.jackrabbit.oak.query.ast;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+import javax.jcr.PropertyType;
+
+import org.apache.jackrabbit.oak.api.PropertyValue;
+import org.apache.jackrabbit.oak.api.Type;
+import org.apache.jackrabbit.oak.query.index.FilterImpl;
+import org.apache.jackrabbit.oak.plugins.memory.PropertyValues;
+import org.apache.jackrabbit.oak.spi.query.QueryConstants;
+import org.apache.jackrabbit.oak.spi.query.QueryIndex.OrderEntry;
+
+/**
+ * The function "path(..)".
+ */
+public class PathImpl extends DynamicOperandImpl {
+
+    private final String selectorName;
+    private SelectorImpl selector;
+
+    public PathImpl(String selectorName) {
+        this.selectorName = selectorName;
+    }
+
+    @Override
+    boolean accept(AstVisitor v) {
+        return v.visit(this);
+    }
+
+    @Override
+    public String toString() {
+        return "path(" + quote(selectorName) + ')';
+    }
+
+    public void bindSelector(SourceImpl source) {
+        selector = source.getExistingSelector(selectorName);
+    }
+
+    @Override
+    public PropertyExistenceImpl getPropertyExistence() {
+        return null;
+    }
+
+    @Override
+    public Set<SelectorImpl> getSelectors() {
+        return Collections.singleton(selector);
+    }
+
+    @Override
+    public PropertyValue currentProperty() {
+        String path = selector.currentPath();
+        if (path == null) {
+            return null;
+        }
+        return PropertyValues.newString(path);
+    }
+
+    @Override
+    public void restrict(FilterImpl f, Operator operator, PropertyValue v) {
+        if (v == null) {
+            return;
+        }
+        if (operator == Operator.NOT_EQUAL && v != null) {

Review comment:
       `v != null` is always true and can be removed

##########
File path: oak-core/src/main/java/org/apache/jackrabbit/oak/query/xpath/XPathToSQL2Converter.java
##########
@@ -731,6 +731,11 @@ private Expression parseFunction(String functionName) throws ParseException {
             f.params.add(parseExpression());
             read(")");
             return f;
+        } else if ("jcr:first".equals(functionName)) {

Review comment:
       you should add these new cases in the `getSyntaxError` at line 808




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org