You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@vxquery.apache.org by pr...@apache.org on 2016/07/12 17:37:16 UTC

vxquery git commit: Implement opext:keys-or-members method

Repository: vxquery
Updated Branches:
  refs/heads/master 1c8547387 -> 1acfe1fec


Implement opext:keys-or-members method


Project: http://git-wip-us.apache.org/repos/asf/vxquery/repo
Commit: http://git-wip-us.apache.org/repos/asf/vxquery/commit/1acfe1fe
Tree: http://git-wip-us.apache.org/repos/asf/vxquery/tree/1acfe1fe
Diff: http://git-wip-us.apache.org/repos/asf/vxquery/diff/1acfe1fe

Branch: refs/heads/master
Commit: 1acfe1fecf593be342ecfaa7760706e3fa60b772
Parents: 1c85473
Author: riyafa <ri...@gmail.com>
Authored: Tue Jul 12 17:50:08 2016 +0530
Committer: riyafa <ri...@gmail.com>
Committed: Tue Jul 12 17:50:08 2016 +0530

----------------------------------------------------------------------
 .../vxquery/functions/builtin-operators.xml     |  6 +-
 .../json/KeysOrMembersScalarEvaluator.java      | 58 ++++++++++++++++++++
 .../KeysOrMembersScalarEvaluatorFactory.java    | 39 +++++++++++++
 .../functions/json/KeysScalarEvaluator.java     | 56 -------------------
 .../json/KeysScalarEvaluatorFactory.java        | 39 -------------
 .../xmlquery/translator/XMLQueryTranslator.java |  2 +-
 6 files changed, 101 insertions(+), 99 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/vxquery/blob/1acfe1fe/vxquery-core/src/main/java/org/apache/vxquery/functions/builtin-operators.xml
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/functions/builtin-operators.xml b/vxquery-core/src/main/java/org/apache/vxquery/functions/builtin-operators.xml
index f323e47..bb710a9 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/functions/builtin-operators.xml
+++ b/vxquery-core/src/main/java/org/apache/vxquery/functions/builtin-operators.xml
@@ -655,11 +655,11 @@
         <runtime type="scalar" class="org.apache.vxquery.runtime.functions.json.ValueScalarEvaluatorFactory"/>
     </operator>
 
-    <!-- jdm:keys($o as object()) as xs:string* -->
-    <operator name="jdm:keys">
+    <!-- opext:keys-or-members($o as json-item()) as xs:string* -->
+    <operator name="opext:keys-or-members">
         <param name="expr" type="json-item()"/>
         <return type="xs:string*"/>
-        <runtime type="scalar" class="org.apache.vxquery.runtime.functions.json.KeysScalarEvaluatorFactory"/>
+        <runtime type="scalar" class="org.apache.vxquery.runtime.functions.json.KeysOrMembersScalarEvaluatorFactory"/>
     </operator>
 
     <!-- opext:subtract($arg1 as xs:anyAtomicType?, $arg2 as xs:anyAtomicType?) as xs:anyAtomicType? -->

http://git-wip-us.apache.org/repos/asf/vxquery/blob/1acfe1fe/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/KeysOrMembersScalarEvaluator.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/KeysOrMembersScalarEvaluator.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/KeysOrMembersScalarEvaluator.java
new file mode 100644
index 0000000..1b90282
--- /dev/null
+++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/KeysOrMembersScalarEvaluator.java
@@ -0,0 +1,58 @@
+/*
+* 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.vxquery.runtime.functions.json;
+
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.data.std.api.IPointable;
+import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
+import org.apache.vxquery.datamodel.accessors.jsonitem.ObjectPointable;
+import org.apache.vxquery.datamodel.values.ValueTag;
+import org.apache.vxquery.exceptions.ErrorCode;
+import org.apache.vxquery.exceptions.SystemException;
+import org.apache.vxquery.runtime.functions.base.AbstractTaggedValueArgumentScalarEvaluator;
+
+import java.io.IOException;
+
+public class KeysOrMembersScalarEvaluator extends AbstractTaggedValueArgumentScalarEvaluator {
+    protected final IHyracksTaskContext ctx;
+    private final ObjectPointable op;
+
+    public KeysOrMembersScalarEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[] args) {
+        super(args);
+        this.ctx = ctx;
+        op = (ObjectPointable) ObjectPointable.FACTORY.createPointable();
+    }
+
+    @Override
+    protected void evaluate(TaggedValuePointable[] args, IPointable result) throws SystemException {
+        TaggedValuePointable tvp1 = args[0];
+        if (!((tvp1.getTag() == ValueTag.OBJECT_TAG) || (tvp1.getTag() == ValueTag.ARRAY_TAG))) {
+            throw new SystemException(ErrorCode.FORG0006);
+        }
+        if (tvp1.getTag() == ValueTag.OBJECT_TAG) {
+            try {
+                tvp1.getValue(op);
+                op.getKeys(result);
+            } catch (IOException e) {
+                throw new SystemException(ErrorCode.SYSE0001, e);
+
+            }
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/vxquery/blob/1acfe1fe/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/KeysOrMembersScalarEvaluatorFactory.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/KeysOrMembersScalarEvaluatorFactory.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/KeysOrMembersScalarEvaluatorFactory.java
new file mode 100644
index 0000000..d664318
--- /dev/null
+++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/KeysOrMembersScalarEvaluatorFactory.java
@@ -0,0 +1,39 @@
+/*
+* 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.vxquery.runtime.functions.json;
+
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.vxquery.runtime.functions.base.AbstractTaggedValueArgumentScalarEvaluatorFactory;
+
+public class KeysOrMembersScalarEvaluatorFactory extends AbstractTaggedValueArgumentScalarEvaluatorFactory {
+
+    private static final long serialVersionUID = 1L;
+
+    public KeysOrMembersScalarEvaluatorFactory(IScalarEvaluatorFactory[] args) {
+        super(args);
+    }
+
+    @Override
+    protected IScalarEvaluator createEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[] args)
+            throws AlgebricksException {
+        return new KeysOrMembersScalarEvaluator(ctx, args);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/vxquery/blob/1acfe1fe/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/KeysScalarEvaluator.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/KeysScalarEvaluator.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/KeysScalarEvaluator.java
deleted file mode 100644
index ad58cb3..0000000
--- a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/KeysScalarEvaluator.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
-* 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.vxquery.runtime.functions.json;
-
-import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
-import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.data.std.api.IPointable;
-import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
-import org.apache.vxquery.datamodel.accessors.jsonitem.ObjectPointable;
-import org.apache.vxquery.datamodel.values.ValueTag;
-import org.apache.vxquery.exceptions.ErrorCode;
-import org.apache.vxquery.exceptions.SystemException;
-import org.apache.vxquery.runtime.functions.base.AbstractTaggedValueArgumentScalarEvaluator;
-
-import java.io.IOException;
-
-public class KeysScalarEvaluator extends AbstractTaggedValueArgumentScalarEvaluator {
-    protected final IHyracksTaskContext ctx;
-    private final ObjectPointable op;
-
-    public KeysScalarEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[] args) {
-        super(args);
-        this.ctx = ctx;
-        op = (ObjectPointable) ObjectPointable.FACTORY.createPointable();
-    }
-
-    @Override
-    protected void evaluate(TaggedValuePointable[] args, IPointable result) throws SystemException {
-        TaggedValuePointable tvp1 = args[0];
-        if (!(tvp1.getTag() == ValueTag.OBJECT_TAG)) {
-            throw new SystemException(ErrorCode.FORG0006);
-        }
-        try {
-            tvp1.getValue(op);
-            op.getKeys(result);
-        } catch (IOException e) {
-            throw new SystemException(ErrorCode.SYSE0001, e);
-
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/vxquery/blob/1acfe1fe/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/KeysScalarEvaluatorFactory.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/KeysScalarEvaluatorFactory.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/KeysScalarEvaluatorFactory.java
deleted file mode 100644
index 30bf850..0000000
--- a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/KeysScalarEvaluatorFactory.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
-* 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.vxquery.runtime.functions.json;
-
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
-import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
-import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.vxquery.runtime.functions.base.AbstractTaggedValueArgumentScalarEvaluatorFactory;
-
-public class KeysScalarEvaluatorFactory extends AbstractTaggedValueArgumentScalarEvaluatorFactory {
-
-    private static final long serialVersionUID = 1L;
-
-    public KeysScalarEvaluatorFactory(IScalarEvaluatorFactory[] args) {
-        super(args);
-    }
-
-    @Override
-    protected IScalarEvaluator createEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[] args)
-            throws AlgebricksException {
-        return new KeysScalarEvaluator(ctx, args);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/vxquery/blob/1acfe1fe/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/translator/XMLQueryTranslator.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/translator/XMLQueryTranslator.java b/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/translator/XMLQueryTranslator.java
index 8e18651..a635951 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/translator/XMLQueryTranslator.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/translator/XMLQueryTranslator.java
@@ -1561,7 +1561,7 @@ public class XMLQueryTranslator {
                                     }
                                 }
                                 if (arguments.size() == 0) {
-                                    ctxExpr = sfce(BuiltinOperators.KEYS, expr);
+                                    ctxExpr = sfce(BuiltinOperators.KEYS_OR_MEMBERS, expr);
                                 }
                             } else {
                                 predicates = postfixNode.getArgs();