You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by bu...@apache.org on 2016/05/24 01:31:25 UTC
[07/22] incubator-asterixdb git commit: ASTERIXDB-1228: Add MISSING
into the data model.
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/AbstractSubBinaryEvaluator.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/AbstractSubBinaryEvaluator.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/AbstractSubBinaryEvaluator.java
new file mode 100644
index 0000000..8b5c512
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/AbstractSubBinaryEvaluator.java
@@ -0,0 +1,98 @@
+/*
+ * 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.asterix.runtime.evaluators.functions.binary;
+
+import java.io.IOException;
+
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.hierachy.ATypeHierarchy;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.data.std.api.IPointable;
+import org.apache.hyracks.data.std.primitive.ByteArrayPointable;
+import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+import org.apache.hyracks.util.encoding.VarLenIntEncoderDecoder;
+
+public abstract class AbstractSubBinaryEvaluator extends AbstractBinaryScalarEvaluator {
+
+ private ByteArrayPointable byteArrayPointable = new ByteArrayPointable();
+ private byte[] metaBuffer = new byte[5];
+ protected final String functionName;
+
+ private static final ATypeTag[] EXPECTED_INPUT_TAGS = { ATypeTag.BINARY, ATypeTag.INT32 };
+
+ public AbstractSubBinaryEvaluator(IHyracksTaskContext context, IScalarEvaluatorFactory[] copyEvaluatorFactories,
+ String functionName) throws AlgebricksException {
+ super(context, copyEvaluatorFactories);
+ this.functionName = functionName;
+ }
+
+ @Override
+ public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+ resultStorage.reset();
+ for (int i = 0; i < pointables.length; ++i) {
+ evaluators[i].evaluate(tuple, pointables[i]);
+ }
+
+ try {
+ ATypeTag argTag0 = ATypeTag.VALUE_TYPE_MAPPING[pointables[0].getByteArray()[pointables[0]
+ .getStartOffset()]];
+ ATypeTag argTag1 = ATypeTag.VALUE_TYPE_MAPPING[pointables[1].getByteArray()[pointables[1]
+ .getStartOffset()]];
+ checkTypeMachingThrowsIfNot(functionName, EXPECTED_INPUT_TAGS, argTag0, argTag1);
+
+ byteArrayPointable.set(pointables[0].getByteArray(), pointables[0].getStartOffset() + 1,
+ pointables[0].getLength() - 1);
+ byte[] startBytes = pointables[1].getByteArray();
+ int offset = pointables[1].getStartOffset();
+
+ int subStart;
+
+ // strange SQL index convention
+ subStart = ATypeHierarchy.getIntegerValue(startBytes, offset) - 1;
+
+ int totalLength = byteArrayPointable.getContentLength();
+ int subLength = getSubLength(tuple);
+
+ if (subStart < 0) {
+ subStart = 0;
+ }
+
+ if (subStart >= totalLength || subLength < 0) {
+ subLength = 0;
+ } else if (subLength > totalLength // for the IntMax case
+ || subStart + subLength > totalLength) {
+ subLength = totalLength - subStart;
+ }
+
+ dataOutput.write(ATypeTag.BINARY.serialize());
+ int metaLength = VarLenIntEncoderDecoder.encode(subLength, metaBuffer, 0);
+ dataOutput.write(metaBuffer, 0, metaLength);
+ dataOutput.write(byteArrayPointable.getByteArray(), byteArrayPointable.getContentStartOffset() + subStart,
+ subLength);
+ } catch (IOException e) {
+ throw new AlgebricksException(e);
+ }
+ result.set(resultStorage);
+ }
+
+ protected abstract int getSubLength(IFrameTupleReference tuple) throws AlgebricksException;
+}
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/BinaryConcatDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/BinaryConcatDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/BinaryConcatDescriptor.java
index 2747260..b06203b 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/BinaryConcatDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/BinaryConcatDescriptor.java
@@ -22,10 +22,13 @@ package org.apache.asterix.runtime.evaluators.functions.binary;
import java.io.IOException;
import org.apache.asterix.common.exceptions.AsterixException;
+import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
+import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
import org.apache.asterix.runtime.evaluators.common.AsterixListAccessor;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
@@ -33,6 +36,7 @@ import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
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.hyracks.api.dataflow.value.ISerializerDeserializer;
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.data.std.api.IPointable;
import org.apache.hyracks.data.std.primitive.ByteArrayPointable;
@@ -66,11 +70,16 @@ public class BinaryConcatDescriptor extends AbstractScalarFunctionDynamicDescrip
private final AsterixListAccessor listAccessor = new AsterixListAccessor();
private final byte[] metaBuffer = new byte[5];
+ @SuppressWarnings("unchecked")
+ private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
+ .getSerializerDeserializer(BuiltinType.ANULL);
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
resultStorage.reset();
- ATypeTag typeTag = evaluateTuple(tuple, 0);
+ evaluators[0].evaluate(tuple, pointables[0]);
+ ATypeTag typeTag = ATypeTag.VALUE_TYPE_MAPPING[pointables[0].getByteArray()[pointables[0]
+ .getStartOffset()]];
if (typeTag != ATypeTag.UNORDEREDLIST && typeTag != ATypeTag.ORDEREDLIST) {
throw new AlgebricksException(getIdentifier().getName()
+ ": expects input type ORDEREDLIST/UNORDEREDLIST, but got " + typeTag);
@@ -113,8 +122,17 @@ public class BinaryConcatDescriptor extends AbstractScalarFunctionDynamicDescrip
}
result.set(resultStorage);
}
- };
+ private boolean serializeNullIfAnyNull(ATypeTag... tags) throws HyracksDataException {
+ for (ATypeTag typeTag : tags) {
+ if (typeTag == ATypeTag.NULL) {
+ nullSerde.serialize(ANull.NULL, dataOutput);
+ return true;
+ }
+ }
+ return false;
+ }
+ };
}
};
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/BinaryLengthDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/BinaryLengthDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/BinaryLengthDescriptor.java
index 9e9aab4..0a50c24 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/BinaryLengthDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/BinaryLengthDescriptor.java
@@ -69,12 +69,10 @@ public class BinaryLengthDescriptor extends AbstractScalarFunctionDynamicDescrip
public void evaluate(IFrameTupleReference tuple, IPointable resultPointable)
throws AlgebricksException {
resultStorage.reset();
- ATypeTag tag = evaluateTuple(tuple, 0);
+ evaluators[0].evaluate(tuple, pointables[0]);
+ ATypeTag tag = ATypeTag.VALUE_TYPE_MAPPING[pointables[0].getByteArray()[pointables[0]
+ .getStartOffset()]];
try {
- if (serializeNullIfAnyNull(tag)) {
- resultPointable.set(resultStorage);
- return;
- }
checkTypeMachingThrowsIfNot(getIdentifier().getName(), EXPECTED_TAGS, tag);
int len = ByteArrayPointable.getContentLength(pointables[0].getByteArray(),
pointables[0].getStartOffset() + 1);
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/FindBinaryDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/FindBinaryDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/FindBinaryDescriptor.java
index c7b4843..94ec311 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/FindBinaryDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/FindBinaryDescriptor.java
@@ -19,24 +19,15 @@
package org.apache.asterix.runtime.evaluators.functions.binary;
-import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
-import org.apache.asterix.om.base.AInt64;
-import org.apache.asterix.om.base.AMutableInt64;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
-import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
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.hyracks.api.dataflow.value.ISerializerDeserializer;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.data.std.api.IPointable;
-import org.apache.hyracks.data.std.primitive.ByteArrayPointable;
import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
public class FindBinaryDescriptor extends AbstractScalarFunctionDynamicDescriptor {
@@ -53,8 +44,6 @@ public class FindBinaryDescriptor extends AbstractScalarFunctionDynamicDescripto
return AsterixBuiltinFunctions.FIND_BINARY;
}
- private static final ATypeTag[] EXPECTED_INPUT_TAG = { ATypeTag.BINARY, ATypeTag.BINARY };
-
@Override
public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args)
throws AlgebricksException {
@@ -63,7 +52,7 @@ public class FindBinaryDescriptor extends AbstractScalarFunctionDynamicDescripto
@Override
public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws AlgebricksException {
- return new AbstractFindBinaryCopyEvaluator(ctx, args, getIdentifier().getName()) {
+ return new AbstractFindBinaryEvaluator(ctx, args, getIdentifier().getName()) {
@Override
protected int getFromOffset(IFrameTupleReference tuple) throws AlgebricksException {
return 0;
@@ -73,93 +62,4 @@ public class FindBinaryDescriptor extends AbstractScalarFunctionDynamicDescripto
};
}
- static abstract class AbstractFindBinaryCopyEvaluator extends AbstractBinaryScalarEvaluator {
-
- public AbstractFindBinaryCopyEvaluator(IHyracksTaskContext context,
- IScalarEvaluatorFactory[] copyEvaluatorFactories, String functionName) throws AlgebricksException {
- super(context, copyEvaluatorFactories);
- this.functionName = functionName;
- }
-
- protected String functionName;
- protected AMutableInt64 result = new AMutableInt64(-1);
- protected final ByteArrayPointable textPtr = new ByteArrayPointable();
- protected final ByteArrayPointable wordPtr = new ByteArrayPointable();
-
- @SuppressWarnings("unchecked")
- protected ISerializerDeserializer<AInt64> intSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.AINT64);
-
- @Override
- public void evaluate(IFrameTupleReference tuple, IPointable resultPointable) throws AlgebricksException {
- resultStorage.reset();
- ATypeTag textTag = evaluateTuple(tuple, 0);
- ATypeTag wordTag = evaluateTuple(tuple, 1);
- int fromOffset = getFromOffset(tuple);
-
- try {
- if (serializeNullIfAnyNull(textTag, wordTag)) {
- resultPointable.set(resultStorage);
- return;
- }
- checkTypeMachingThrowsIfNot(functionName, EXPECTED_INPUT_TAG, textTag, wordTag);
-
- textPtr.set(pointables[0].getByteArray(), pointables[0].getStartOffset() + 1,
- pointables[0].getLength() - 1);
- wordPtr.set(pointables[1].getByteArray(), pointables[0].getStartOffset() + 1,
- pointables[1].getLength() - 1);
- result.setValue(1 + indexOf(textPtr.getByteArray(), textPtr.getContentStartOffset(),
- textPtr.getContentLength(), wordPtr.getByteArray(), wordPtr.getContentStartOffset(),
- wordPtr.getContentLength(), fromOffset));
- intSerde.serialize(result, dataOutput);
- } catch (HyracksDataException e) {
- throw new AlgebricksException(e);
- }
- resultPointable.set(resultStorage);
- }
-
- protected abstract int getFromOffset(IFrameTupleReference tuple) throws AlgebricksException;
- }
-
- // copy from String.indexOf(String)
- static int indexOf(byte[] source, int sourceOffset, int sourceCount, byte[] target, int targetOffset,
- int targetCount, int fromIndex) {
- if (fromIndex >= sourceCount) {
- return (targetCount == 0 ? sourceCount : -1);
- }
- if (fromIndex < 0) {
- fromIndex = 0;
- }
- if (targetCount == 0) {
- return fromIndex;
- }
-
- byte first = target[targetOffset];
- int max = sourceOffset + (sourceCount - targetCount);
-
- for (int i = sourceOffset + fromIndex; i <= max; i++) {
- /* Look for first character. */
- if (source[i] != first) {
- while (++i <= max && source[i] != first) {
- ;
- }
- }
-
- /* Found first character, now look at the rest of v2 */
- if (i <= max) {
- int j = i + 1;
- int end = j + targetCount - 1;
- for (int k = targetOffset + 1; j < end && source[j] == target[k]; j++, k++) {
- ;
- }
-
- if (j == end) {
- /* Found whole string. */
- return i - sourceOffset;
- }
- }
- }
- return -1;
- }
-
}
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/FindBinaryFromDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/FindBinaryFromDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/FindBinaryFromDescriptor.java
index 6b8ee38..5ed3773 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/FindBinaryFromDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/FindBinaryFromDescriptor.java
@@ -55,11 +55,9 @@ public class FindBinaryFromDescriptor extends AbstractScalarFunctionDynamicDescr
@Override
public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws AlgebricksException {
- return new FindBinaryDescriptor.AbstractFindBinaryCopyEvaluator(ctx, args,
- getIdentifier().getName()) {
+ return new AbstractFindBinaryEvaluator(ctx, args, getIdentifier().getName()) {
@Override
protected int getFromOffset(IFrameTupleReference tuple) throws AlgebricksException {
- evaluateTuple(tuple, 2);
int getFrom = 0;
try {
getFrom = ATypeHierarchy.getIntegerValue(pointables[2].getByteArray(),
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/ParseBinaryDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/ParseBinaryDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/ParseBinaryDescriptor.java
index a067557..2488710 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/ParseBinaryDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/ParseBinaryDescriptor.java
@@ -43,8 +43,8 @@ import org.apache.hyracks.util.bytes.HexParser;
public class ParseBinaryDescriptor extends AbstractScalarFunctionDynamicDescriptor {
private static final long serialVersionUID = 1L;
- static final UTF8StringPointable HEX_FORMAT = UTF8StringPointable.generateUTF8Pointable("hex");
- static final UTF8StringPointable BASE64_FORMAT = UTF8StringPointable.generateUTF8Pointable("base64");
+ private static final UTF8StringPointable HEX_FORMAT = UTF8StringPointable.generateUTF8Pointable("hex");
+ private static final UTF8StringPointable BASE64_FORMAT = UTF8StringPointable.generateUTF8Pointable("base64");
public final static IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
@Override
@@ -84,14 +84,15 @@ public class ParseBinaryDescriptor extends AbstractScalarFunctionDynamicDescript
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
resultStorage.reset();
- ATypeTag binaryTag = evaluateTuple(tuple, 0);
- ATypeTag formatTag = evaluateTuple(tuple, 1);
+ evaluators[0].evaluate(tuple, pointables[0]);
+ evaluators[1].evaluate(tuple, pointables[1]);
try {
- if (serializeNullIfAnyNull(binaryTag, formatTag)) {
- result.set(resultStorage);
- return;
- }
+ ATypeTag binaryTag = ATypeTag.VALUE_TYPE_MAPPING[pointables[0].getByteArray()[pointables[0]
+ .getStartOffset()]];
+
+ ATypeTag formatTag = ATypeTag.VALUE_TYPE_MAPPING[pointables[1].getByteArray()[pointables[1]
+ .getStartOffset()]];
checkTypeMachingThrowsIfNot(getIdentifier().getName(), EXPECTED_INPUT_TAGS, binaryTag,
formatTag);
stringPointable.set(pointables[0].getByteArray(), pointables[0].getStartOffset() + 1,
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/PrintBinaryDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/PrintBinaryDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/PrintBinaryDescriptor.java
index 92b9ec1..2dc1e34 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/PrintBinaryDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/PrintBinaryDescriptor.java
@@ -19,9 +19,6 @@
package org.apache.asterix.runtime.evaluators.functions.binary;
-import static org.apache.asterix.runtime.evaluators.functions.binary.ParseBinaryDescriptor.BASE64_FORMAT;
-import static org.apache.asterix.runtime.evaluators.functions.binary.ParseBinaryDescriptor.HEX_FORMAT;
-
import java.io.IOException;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
@@ -45,6 +42,8 @@ import org.apache.hyracks.util.string.UTF8StringWriter;
public class PrintBinaryDescriptor extends AbstractScalarFunctionDynamicDescriptor {
private static final long serialVersionUID = 1L;
+ private static final UTF8StringPointable HEX_FORMAT = UTF8StringPointable.generateUTF8Pointable("hex");
+ private static final UTF8StringPointable BASE64_FORMAT = UTF8StringPointable.generateUTF8Pointable("base64");
@Override
public FunctionIdentifier getIdentifier() {
@@ -78,14 +77,14 @@ public class PrintBinaryDescriptor extends AbstractScalarFunctionDynamicDescript
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
resultStorage.reset();
- ATypeTag arg0Tag = evaluateTuple(tuple, 0);
- ATypeTag arg1Tag = evaluateTuple(tuple, 1);
+ evaluators[0].evaluate(tuple, pointables[0]);
+ evaluators[1].evaluate(tuple, pointables[1]);
try {
- if (serializeNullIfAnyNull(arg0Tag, arg1Tag)) {
- result.set(resultStorage);
- return;
- }
+ ATypeTag arg0Tag = ATypeTag.VALUE_TYPE_MAPPING[pointables[0].getByteArray()[pointables[0]
+ .getStartOffset()]];
+ ATypeTag arg1Tag = ATypeTag.VALUE_TYPE_MAPPING[pointables[1].getByteArray()[pointables[1]
+ .getStartOffset()]];
checkTypeMachingThrowsIfNot(getIdentifier().getName(), EXPECTED_INPUT_TAGS, arg0Tag,
arg1Tag);
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/SubBinaryFromDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/SubBinaryFromDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/SubBinaryFromDescriptor.java
index 4d435ab..129cd54 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/SubBinaryFromDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/SubBinaryFromDescriptor.java
@@ -52,8 +52,7 @@ public class SubBinaryFromDescriptor extends AbstractScalarFunctionDynamicDescri
@Override
public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws AlgebricksException {
- return new SubBinaryFromToDescriptor.AbstractSubBinaryCopyEvaluator(ctx, args,
- getIdentifier().getName()) {
+ return new AbstractSubBinaryEvaluator(ctx, args, getIdentifier().getName()) {
@Override
protected int getSubLength(IFrameTupleReference tuple) throws AlgebricksException {
return Integer.MAX_VALUE;
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/SubBinaryFromToDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/SubBinaryFromToDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/SubBinaryFromToDescriptor.java
index 20fdeed..bb23877 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/SubBinaryFromToDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/SubBinaryFromToDescriptor.java
@@ -19,12 +19,9 @@
package org.apache.asterix.runtime.evaluators.functions.binary;
-import java.io.IOException;
-
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
-import org.apache.asterix.om.types.ATypeTag;
import org.apache.asterix.om.types.hierachy.ATypeHierarchy;
import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
@@ -33,10 +30,7 @@ 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.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.data.std.api.IPointable;
-import org.apache.hyracks.data.std.primitive.ByteArrayPointable;
import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
-import org.apache.hyracks.util.encoding.VarLenIntEncoderDecoder;
public class SubBinaryFromToDescriptor extends AbstractScalarFunctionDynamicDescriptor {
private static final long serialVersionUID = 1L;
@@ -60,10 +54,10 @@ public class SubBinaryFromToDescriptor extends AbstractScalarFunctionDynamicDesc
@Override
public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws AlgebricksException {
- return new AbstractSubBinaryCopyEvaluator(ctx, args, getIdentifier().getName()) {
+
+ return new AbstractSubBinaryEvaluator(ctx, args, getIdentifier().getName()) {
@Override
protected int getSubLength(IFrameTupleReference tuple) throws AlgebricksException {
- evaluateTuple(tuple, 2);
int subLength = 0;
try {
subLength = ATypeHierarchy.getIntegerValue(pointables[2].getByteArray(),
@@ -78,70 +72,4 @@ public class SubBinaryFromToDescriptor extends AbstractScalarFunctionDynamicDesc
}
};
}
-
- static abstract class AbstractSubBinaryCopyEvaluator extends AbstractBinaryScalarEvaluator {
- public AbstractSubBinaryCopyEvaluator(IHyracksTaskContext context,
- IScalarEvaluatorFactory[] copyEvaluatorFactories, String functionName) throws AlgebricksException {
- super(context, copyEvaluatorFactories);
- this.functionName = functionName;
- }
-
- private ByteArrayPointable byteArrayPointable = new ByteArrayPointable();
- private byte[] metaBuffer = new byte[5];
- protected final String functionName;
-
- static final ATypeTag[] EXPECTED_INPUT_TAGS = { ATypeTag.BINARY, ATypeTag.INT32 };
-
- @Override
- public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
- resultStorage.reset();
- ATypeTag argTag0 = evaluateTuple(tuple, 0);
- ATypeTag argTag1 = evaluateTuple(tuple, 1);
-
- try {
- if (serializeNullIfAnyNull(argTag0, argTag1)) {
- result.set(resultStorage);
- return;
- }
- checkTypeMachingThrowsIfNot(functionName, EXPECTED_INPUT_TAGS, argTag0, argTag1);
-
- byteArrayPointable.set(pointables[0].getByteArray(), pointables[0].getStartOffset() + 1,
- pointables[0].getLength() - 1);
- byte[] startBytes = pointables[1].getByteArray();
- int offset = pointables[1].getStartOffset();
-
- int subStart = 0;
-
- // strange SQL index convention
- subStart = ATypeHierarchy.getIntegerValue(startBytes, offset) - 1;
-
- int totalLength = byteArrayPointable.getContentLength();
- int subLength = getSubLength(tuple);
-
- if (subStart < 0) {
- subStart = 0;
- }
-
- if (subStart >= totalLength || subLength < 0) {
- subLength = 0;
- } else if (subLength > totalLength // for the IntMax case
- || subStart + subLength > totalLength) {
- subLength = totalLength - subStart;
- }
-
- dataOutput.write(ATypeTag.BINARY.serialize());
- int metaLength = VarLenIntEncoderDecoder.encode(subLength, metaBuffer, 0);
- dataOutput.write(metaBuffer, 0, metaLength);
- dataOutput.write(byteArrayPointable.getByteArray(),
- byteArrayPointable.getContentStartOffset() + subStart, subLength);
- } catch (HyracksDataException e) {
- throw new AlgebricksException(e);
- } catch (IOException e) {
- throw new AlgebricksException(e);
- }
- result.set(resultStorage);
- }
-
- protected abstract int getSubLength(IFrameTupleReference tuple) throws AlgebricksException;
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessByIndexEvalFactory.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessByIndexEvalFactory.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessByIndexEvalFactory.java
index dd70d1e..f3257ca 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessByIndexEvalFactory.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessByIndexEvalFactory.java
@@ -23,12 +23,9 @@ import java.io.IOException;
import org.apache.asterix.common.exceptions.AsterixException;
import org.apache.asterix.dataflow.data.nontagged.serde.ARecordSerializerDeserializer;
-import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.types.ARecordType;
import org.apache.asterix.om.types.ATypeTag;
import org.apache.asterix.om.types.AUnionType;
-import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.EnumDeserializer;
import org.apache.asterix.om.types.IAType;
import org.apache.asterix.om.util.NonTaggedFormatUtil;
@@ -37,7 +34,6 @@ import org.apache.hyracks.algebricks.common.exceptions.NotImplementedException;
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.hyracks.api.dataflow.value.ISerializerDeserializer;
import org.apache.hyracks.data.std.api.IPointable;
import org.apache.hyracks.data.std.primitive.IntegerPointable;
import org.apache.hyracks.data.std.primitive.VoidPointable;
@@ -71,14 +67,11 @@ public class FieldAccessByIndexEvalFactory implements IScalarEvaluatorFactory {
private IPointable inputArg1 = new VoidPointable();
private IScalarEvaluator eval0 = recordEvalFactory.createScalarEvaluator(ctx);
private IScalarEvaluator eval1 = fieldIndexEvalFactory.createScalarEvaluator(ctx);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
private int fieldIndex;
private int fieldValueOffset;
private int fieldValueLength;
private IAType fieldValueType;
- private ATypeTag fieldValueTypeTag = ATypeTag.NULL;
+ private ATypeTag fieldValueTypeTag;
/*
* inputArg0: the record
@@ -94,12 +87,6 @@ public class FieldAccessByIndexEvalFactory implements IScalarEvaluatorFactory {
byte[] serRecord = inputArg0.getByteArray();
int offset = inputArg0.getStartOffset();
- if (serRecord[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- }
-
if (serRecord[offset] != ATypeTag.SERIALIZED_RECORD_TYPE_TAG) {
throw new AlgebricksException("Field accessor is not defined for values of type "
+ EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(serRecord[offset]));
@@ -119,7 +106,7 @@ public class FieldAccessByIndexEvalFactory implements IScalarEvaluatorFactory {
if (fieldValueType.getTypeTag().equals(ATypeTag.UNION)) {
if (((AUnionType) fieldValueType).isNullableType()) {
- fieldValueTypeTag = ((AUnionType) fieldValueType).getNullableType().getTypeTag();
+ fieldValueTypeTag = ((AUnionType) fieldValueType).getActualType().getTypeTag();
fieldValueLength = NonTaggedFormatUtil.getFieldValueLength(serRecord, fieldValueOffset,
fieldValueTypeTag, false);
out.writeByte(fieldValueTypeTag.serialize());
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessByNameEvalFactory.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessByNameEvalFactory.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessByNameEvalFactory.java
index d11c91e..62779f3 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessByNameEvalFactory.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessByNameEvalFactory.java
@@ -23,18 +23,14 @@ import java.io.IOException;
import org.apache.asterix.common.exceptions.AsterixException;
import org.apache.asterix.dataflow.data.nontagged.serde.ARecordSerializerDeserializer;
-import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.EnumDeserializer;
import org.apache.asterix.om.util.NonTaggedFormatUtil;
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.hyracks.api.dataflow.value.ISerializerDeserializer;
import org.apache.hyracks.data.std.api.IPointable;
import org.apache.hyracks.data.std.primitive.VoidPointable;
import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
@@ -64,12 +60,9 @@ public class FieldAccessByNameEvalFactory implements IScalarEvaluatorFactory {
private IPointable inputArg1 = new VoidPointable();
private IScalarEvaluator eval0 = recordEvalFactory.createScalarEvaluator(ctx);
private IScalarEvaluator eval1 = fldNameEvalFactory.createScalarEvaluator(ctx);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
private int fieldValueOffset;
private int fieldValueLength;
- private ATypeTag fieldValueTypeTag = ATypeTag.NULL;
+ private ATypeTag fieldValueTypeTag;
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
@@ -81,12 +74,6 @@ public class FieldAccessByNameEvalFactory implements IScalarEvaluatorFactory {
int serRecordOffset = inputArg0.getStartOffset();
int serRecordLen = inputArg0.getLength();
- if (serRecord[serRecordOffset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- }
-
if (serRecord[serRecordOffset] != ATypeTag.SERIALIZED_RECORD_TYPE_TAG) {
throw new AlgebricksException(AsterixBuiltinFunctions.FIELD_ACCESS_BY_NAME.getName()
+ ": expects input type NULL or RECORD, but got "
@@ -98,7 +85,7 @@ public class FieldAccessByNameEvalFactory implements IScalarEvaluatorFactory {
fieldValueOffset = ARecordSerializerDeserializer.getFieldOffsetByName(serRecord, serRecordOffset,
serRecordLen, serFldName, serFldNameOffset);
if (fieldValueOffset < 0) {
- out.writeByte(ATypeTag.SERIALIZED_NULL_TYPE_TAG);
+ out.writeByte(ATypeTag.SERIALIZED_MISSING_TYPE_TAG);
result.set(resultStorage);
return;
}
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessNestedEvalFactory.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessNestedEvalFactory.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessNestedEvalFactory.java
index 7d30743..92e40cc 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessNestedEvalFactory.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessNestedEvalFactory.java
@@ -25,6 +25,7 @@ import java.util.List;
import org.apache.asterix.common.exceptions.AsterixException;
import org.apache.asterix.dataflow.data.nontagged.serde.ARecordSerializerDeserializer;
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
+import org.apache.asterix.om.base.AMissing;
import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.AString;
import org.apache.asterix.om.types.ARecordType;
@@ -35,7 +36,6 @@ import org.apache.asterix.om.types.EnumDeserializer;
import org.apache.asterix.om.types.IAType;
import org.apache.asterix.om.types.runtime.RuntimeRecordTypeInfo;
import org.apache.asterix.om.util.NonTaggedFormatUtil;
-import org.apache.commons.lang.NotImplementedException;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
@@ -79,6 +79,9 @@ public class FieldAccessNestedEvalFactory implements IScalarEvaluatorFactory {
@SuppressWarnings("unchecked")
private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ANULL);
+ @SuppressWarnings("unchecked")
+ private final ISerializerDeserializer<AMissing> missingSerde = AqlSerializerDeserializerProvider.INSTANCE
+ .getSerializerDeserializer(BuiltinType.AMISSING);
{
generateFieldsPointables();
@@ -115,11 +118,6 @@ public class FieldAccessNestedEvalFactory implements IScalarEvaluatorFactory {
int start = offset;
int len = inputArg0.getLength();
- if (serRecord[start] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- }
if (serRecord[start] != ATypeTag.SERIALIZED_RECORD_TYPE_TAG) {
throw new AlgebricksException("Field accessor is not defined for values of type "
+ EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(serRecord[start]));
@@ -133,7 +131,7 @@ public class FieldAccessNestedEvalFactory implements IScalarEvaluatorFactory {
IAType subType = recordType;
recTypeInfos[0].reset(recordType);
- ATypeTag subTypeTag = ATypeTag.NULL;
+ ATypeTag subTypeTag = ATypeTag.MISSING;
boolean openField = false;
int pathIndex = 0;
@@ -141,7 +139,7 @@ public class FieldAccessNestedEvalFactory implements IScalarEvaluatorFactory {
for (; pathIndex < fieldPointables.length; pathIndex++) {
if (subType.getTypeTag().equals(ATypeTag.UNION)) {
//enforced SubType
- subType = ((AUnionType) subType).getNullableType();
+ subType = ((AUnionType) subType).getActualType();
if (subType.getTypeTag().serialize() != ATypeTag.SERIALIZED_RECORD_TYPE_TAG) {
throw new AlgebricksException(
"Field accessor is not defined for values of type " + subTypeTag);
@@ -161,7 +159,8 @@ public class FieldAccessNestedEvalFactory implements IScalarEvaluatorFactory {
subFieldIndex, nullBitmapSize, ((ARecordType) subType).isOpen());
if (subFieldOffset == 0) {
// the field is null, we checked the null bit map
- out.writeByte(ATypeTag.SERIALIZED_NULL_TYPE_TAG);
+ // any path after null will return null.
+ nullSerde.serialize(ANull.NULL, out);
result.set(resultStorage);
return;
}
@@ -171,14 +170,9 @@ public class FieldAccessNestedEvalFactory implements IScalarEvaluatorFactory {
recTypeInfos[pathIndex + 1].reset((ARecordType) subType);
}
if (subType.getTypeTag().equals(ATypeTag.UNION)) {
- if (((AUnionType) subType).isNullableType()) {
- subTypeTag = ((AUnionType) subType).getNullableType().getTypeTag();
- subFieldLength = NonTaggedFormatUtil.getFieldValueLength(serRecord, subFieldOffset,
- subTypeTag, false);
- } else {
- // union .. the general case
- throw new NotImplementedException();
- }
+ subTypeTag = ((AUnionType) subType).getActualType().getTypeTag();
+ subFieldLength = NonTaggedFormatUtil.getFieldValueLength(serRecord, subFieldOffset,
+ subTypeTag, false);
} else {
subTypeTag = subType.getTypeTag();
subFieldLength = NonTaggedFormatUtil.getFieldValueLength(serRecord, subFieldOffset,
@@ -192,17 +186,12 @@ public class FieldAccessNestedEvalFactory implements IScalarEvaluatorFactory {
subRecordTmpStream.write(serRecord, subFieldOffset, subFieldLength);
serRecord = subRecordTmpStream.getByteArray();
start = 0;
-
- // type check
- if (serRecord[start] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- }
- if (serRecord[start] != ATypeTag.SERIALIZED_RECORD_TYPE_TAG) {
- throw new AlgebricksException("Field accessor is not defined for values of type "
- + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(serRecord[start]));
- }
+ }
+ // type check
+ if (pathIndex < fieldPointables.length - 1
+ && serRecord[start] != ATypeTag.SERIALIZED_RECORD_TYPE_TAG) {
+ throw new AlgebricksException("Field accessor is not defined for values of type "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(serRecord[start]));
}
}
@@ -212,7 +201,7 @@ public class FieldAccessNestedEvalFactory implements IScalarEvaluatorFactory {
subFieldOffset = ARecordSerializerDeserializer.getFieldOffsetByName(serRecord, start, len,
fieldPointables[pathIndex].getByteArray(), fieldPointables[pathIndex].getStartOffset());
if (subFieldOffset < 0) {
- out.writeByte(ATypeTag.SERIALIZED_NULL_TYPE_TAG);
+ out.writeByte(ATypeTag.SERIALIZED_MISSING_TYPE_TAG);
result.set(resultStorage);
return;
}
@@ -221,21 +210,22 @@ public class FieldAccessNestedEvalFactory implements IScalarEvaluatorFactory {
subFieldLength = NonTaggedFormatUtil.getFieldValueLength(serRecord, subFieldOffset, subTypeTag,
true) + 1;
- if (pathIndex < fieldPointables.length - 1) {
- //setup next iteration
- start = subFieldOffset;
- len = subFieldLength;
+ if (pathIndex >= fieldPointables.length - 1) {
+ continue;
+ }
+ //setup next iteration
+ start = subFieldOffset;
+ len = subFieldLength;
- // type check
- if (serRecord[start] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- }
- if (serRecord[start] != ATypeTag.SERIALIZED_RECORD_TYPE_TAG) {
- throw new AlgebricksException("Field accessor is not defined for values of type "
- + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(serRecord[start]));
- }
+ // type check
+ if (serRecord[start] == ATypeTag.SERIALIZED_MISSING_TYPE_TAG) {
+ missingSerde.serialize(AMissing.MISSING, out);
+ result.set(resultStorage);
+ return;
+ }
+ if (serRecord[start] != ATypeTag.SERIALIZED_RECORD_TYPE_TAG) {
+ throw new AlgebricksException("Field accessor is not defined for values of type "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(serRecord[start]));
}
}
// emit the final result.
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/GetRecordFieldValueEvalFactory.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/GetRecordFieldValueEvalFactory.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/GetRecordFieldValueEvalFactory.java
index 71ce3a9..80e5fa5 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/GetRecordFieldValueEvalFactory.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/GetRecordFieldValueEvalFactory.java
@@ -23,11 +23,8 @@ import java.io.IOException;
import org.apache.asterix.common.exceptions.AsterixException;
import org.apache.asterix.dataflow.data.nontagged.serde.ARecordSerializerDeserializer;
-import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.types.ARecordType;
import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.EnumDeserializer;
import org.apache.asterix.om.types.runtime.RuntimeRecordTypeInfo;
import org.apache.asterix.om.util.NonTaggedFormatUtil;
@@ -35,7 +32,6 @@ 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.hyracks.api.dataflow.value.ISerializerDeserializer;
import org.apache.hyracks.data.std.api.IPointable;
import org.apache.hyracks.data.std.primitive.VoidPointable;
import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
@@ -67,10 +63,6 @@ public class GetRecordFieldValueEvalFactory implements IScalarEvaluatorFactory {
private final IPointable inputArg1 = new VoidPointable();
private final IScalarEvaluator recordEval = recordEvalFactory.createScalarEvaluator(ctx);
private final IScalarEvaluator fieldNameEval = fldNameEvalFactory.createScalarEvaluator(ctx);
-
- @SuppressWarnings("unchecked")
- private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
private final RuntimeRecordTypeInfo recTypeInfo = new RuntimeRecordTypeInfo();
{
@@ -85,21 +77,12 @@ public class GetRecordFieldValueEvalFactory implements IScalarEvaluatorFactory {
byte[] serFldName = inputArg1.getByteArray();
int serFldNameOffset = inputArg1.getStartOffset();
int serFldNameLen = inputArg1.getLength();
- if (serFldName[serFldNameOffset] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- }
recordEval.evaluate(tuple, inputArg0);
byte[] serRecord = inputArg0.getByteArray();
int serRecordOffset = inputArg0.getStartOffset();
int serRecordLen = inputArg0.getLength();
- if (serRecord[serRecordOffset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- }
+
if (serRecord[serRecordOffset] != ATypeTag.SERIALIZED_RECORD_TYPE_TAG) {
throw new AlgebricksException("Field accessor is not defined for values of type "
+ EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(serRecord[serRecordOffset]));
@@ -134,7 +117,7 @@ public class GetRecordFieldValueEvalFactory implements IScalarEvaluatorFactory {
subFieldOffset = ARecordSerializerDeserializer.getFieldOffsetByName(serRecord, serRecordOffset,
serRecordLen, serFldName, serFldNameOffset);
if (subFieldOffset < 0) {
- out.writeByte(ATypeTag.SERIALIZED_NULL_TYPE_TAG);
+ out.writeByte(ATypeTag.SERIALIZED_MISSING_TYPE_TAG);
result.set(resultStorage);
return;
}
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/GetRecordFieldsEvalFactory.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/GetRecordFieldsEvalFactory.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/GetRecordFieldsEvalFactory.java
index a24906d..0471b74 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/GetRecordFieldsEvalFactory.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/GetRecordFieldsEvalFactory.java
@@ -22,19 +22,14 @@ import java.io.DataOutput;
import java.io.IOException;
import org.apache.asterix.common.exceptions.AsterixException;
-import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.pointables.nonvisitor.ARecordPointable;
import org.apache.asterix.om.types.ARecordType;
import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.EnumDeserializer;
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.hyracks.api.dataflow.value.ISerializerDeserializer;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.data.std.api.IPointable;
import org.apache.hyracks.data.std.primitive.VoidPointable;
import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
@@ -56,10 +51,6 @@ public class GetRecordFieldsEvalFactory implements IScalarEvaluatorFactory {
public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws AlgebricksException {
return new IScalarEvaluator() {
- @SuppressWarnings("unchecked")
- private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
-
private final ARecordPointable recordPointable = (ARecordPointable) ARecordPointable.FACTORY
.createPointable();
private IPointable inputArg0 = new VoidPointable();
@@ -76,16 +67,6 @@ public class GetRecordFieldsEvalFactory implements IScalarEvaluatorFactory {
int offset = inputArg0.getStartOffset();
int len = inputArg0.getLength();
- if (data[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- try {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- } catch (HyracksDataException e) {
- throw new AlgebricksException(e);
- }
- }
-
if (data[offset] != ATypeTag.SERIALIZED_RECORD_TYPE_TAG) {
throw new AlgebricksException("Field accessor is not defined for values of type "
+ EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(data[offset]));
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordAddFieldsDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordAddFieldsDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordAddFieldsDescriptor.java
index eee240b..6565935 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordAddFieldsDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordAddFieldsDescriptor.java
@@ -26,8 +26,6 @@ import org.apache.asterix.builders.RecordBuilder;
import org.apache.asterix.common.exceptions.AsterixException;
import org.apache.asterix.dataflow.data.nontagged.comparators.ListItemBinaryComparatorFactory;
import org.apache.asterix.dataflow.data.nontagged.hash.ListItemBinaryHashFunctionFactory;
-import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
@@ -36,11 +34,10 @@ import org.apache.asterix.om.pointables.ARecordVisitablePointable;
import org.apache.asterix.om.pointables.PointableAllocator;
import org.apache.asterix.om.pointables.base.DefaultOpenFieldType;
import org.apache.asterix.om.pointables.base.IVisitablePointable;
-import org.apache.asterix.om.typecomputer.impl.TypeComputerUtils;
+import org.apache.asterix.om.typecomputer.impl.TypeComputeUtils;
import org.apache.asterix.om.types.AOrderedListType;
import org.apache.asterix.om.types.ARecordType;
import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.EnumDeserializer;
import org.apache.asterix.om.types.IAType;
import org.apache.asterix.om.types.runtime.RuntimeRecordTypeInfo;
@@ -54,7 +51,6 @@ import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import org.apache.hyracks.api.context.IHyracksTaskContext;
import org.apache.hyracks.api.dataflow.value.IBinaryComparator;
import org.apache.hyracks.api.dataflow.value.IBinaryHashFunction;
-import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.data.std.api.IPointable;
import org.apache.hyracks.data.std.primitive.VoidPointable;
@@ -76,9 +72,9 @@ public class RecordAddFieldsDescriptor extends AbstractScalarFunctionDynamicDesc
private IAType inputFieldListItemType;
public void reset(IAType outType, IAType inType0, IAType inType1) {
- outRecType = TypeComputerUtils.extractRecordType(outType);
- inRecType = TypeComputerUtils.extractRecordType(inType0);
- inListType = TypeComputerUtils.extractOrderedListType(inType1);
+ outRecType = TypeComputeUtils.extractRecordType(outType);
+ inRecType = TypeComputeUtils.extractRecordType(inType0);
+ inListType = TypeComputeUtils.extractOrderedListType(inType1);
inputFieldListItemType = inListType.getItemType();
if (inputFieldListItemType == null || inputFieldListItemType.getTypeTag() == ATypeTag.ANY) {
inputFieldListItemType = DefaultOpenFieldType.NESTED_OPEN_RECORD_TYPE;
@@ -91,9 +87,6 @@ public class RecordAddFieldsDescriptor extends AbstractScalarFunctionDynamicDesc
return new IScalarEvaluatorFactory() {
private static final long serialVersionUID = 1L;
- @SuppressWarnings("unchecked")
- private final ISerializerDeserializer<ANull> nullSerDe = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
@Override
public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws AlgebricksException {
@@ -134,7 +127,6 @@ public class RecordAddFieldsDescriptor extends AbstractScalarFunctionDynamicDesc
.createBinaryComparator();
private BinaryHashMap hashMap = new BinaryHashMap(TABLE_SIZE, TABLE_FRAME_SIZE, putHashFunc,
getHashFunc, cmp);
-
private ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
private DataOutput out = resultStorage.getDataOutput();
@@ -146,18 +138,6 @@ public class RecordAddFieldsDescriptor extends AbstractScalarFunctionDynamicDesc
eval0.evaluate(tuple, argPtr0);
eval1.evaluate(tuple, argPtr1);
- if (argPtr0.getByteArray()[argPtr0.getStartOffset()] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
- || argPtr1.getByteArray()[argPtr1
- .getStartOffset()] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- try {
- nullSerDe.serialize(ANull.NULL, out);
- } catch (HyracksDataException e) {
- throw new AlgebricksException(e);
- }
- result.set(resultStorage);
- return;
- }
-
// Make sure we get a valid record
if (argPtr0.getByteArray()[argPtr0.getStartOffset()] != ATypeTag.SERIALIZED_RECORD_TYPE_TAG) {
throw new AlgebricksException("Expected an ordederlist of type " + inRecType + " but "
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordMergeDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordMergeDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordMergeDescriptor.java
index 0f11a48..2f54c9e 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordMergeDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordMergeDescriptor.java
@@ -25,8 +25,6 @@ import java.util.List;
import org.apache.asterix.builders.RecordBuilder;
import org.apache.asterix.common.exceptions.AsterixException;
-import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
@@ -34,10 +32,9 @@ import org.apache.asterix.om.pointables.ARecordVisitablePointable;
import org.apache.asterix.om.pointables.PointableAllocator;
import org.apache.asterix.om.pointables.base.DefaultOpenFieldType;
import org.apache.asterix.om.pointables.base.IVisitablePointable;
-import org.apache.asterix.om.typecomputer.impl.TypeComputerUtils;
+import org.apache.asterix.om.typecomputer.impl.TypeComputeUtils;
import org.apache.asterix.om.types.ARecordType;
import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
import org.apache.asterix.om.types.runtime.RuntimeRecordTypeInfo;
import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
@@ -48,8 +45,6 @@ import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
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.hyracks.api.dataflow.value.ISerializerDeserializer;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.data.std.api.IPointable;
import org.apache.hyracks.data.std.primitive.VoidPointable;
import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
@@ -78,9 +73,9 @@ public class RecordMergeDescriptor extends AbstractScalarFunctionDynamicDescript
private ARecordType inRecType1;
public void reset(IAType outType, IAType inType0, IAType inType1) {
- outRecType = TypeComputerUtils.extractRecordType(outType);
- inRecType0 = TypeComputerUtils.extractRecordType(inType0);
- inRecType1 = TypeComputerUtils.extractRecordType(inType1);
+ outRecType = TypeComputeUtils.extractRecordType(outType);
+ inRecType0 = TypeComputeUtils.extractRecordType(inType0);
+ inRecType1 = TypeComputeUtils.extractRecordType(inType1);
}
@Override
@@ -90,10 +85,6 @@ public class RecordMergeDescriptor extends AbstractScalarFunctionDynamicDescript
private static final long serialVersionUID = 1L;
- @SuppressWarnings("unchecked")
- private final ISerializerDeserializer<ANull> nullSerDe = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
-
@Override
public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws AlgebricksException {
final PointableAllocator pa = new PointableAllocator();
@@ -123,17 +114,6 @@ public class RecordMergeDescriptor extends AbstractScalarFunctionDynamicDescript
eval0.evaluate(tuple, argPtr0);
eval1.evaluate(tuple, argPtr1);
- if (argPtr0.getByteArray()[argPtr0.getStartOffset()] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
- || argPtr1.getByteArray()[argPtr1.getStartOffset()] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- try {
- nullSerDe.serialize(ANull.NULL, out);
- } catch (HyracksDataException e) {
- throw new AlgebricksException(e);
- }
- result.set(resultStorage);
- return;
- }
-
vp0.set(argPtr0);
vp1.set(argPtr1);
@@ -151,7 +131,7 @@ public class RecordMergeDescriptor extends AbstractScalarFunctionDynamicDescript
private void mergeFields(ARecordType combinedType, ARecordVisitablePointable leftRecord,
ARecordVisitablePointable rightRecord, boolean openFromParent, int nestedLevel)
- throws IOException, AsterixException, AlgebricksException {
+ throws IOException, AsterixException, AlgebricksException {
if (rbStack.size() < (nestedLevel + 1)) {
rbStack.add(new RecordBuilder());
}
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordRemoveFieldsEvalFactory.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordRemoveFieldsEvalFactory.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordRemoveFieldsEvalFactory.java
index 57c6d01..68865c3 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordRemoveFieldsEvalFactory.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordRemoveFieldsEvalFactory.java
@@ -28,8 +28,6 @@ import java.util.List;
import org.apache.asterix.builders.RecordBuilder;
import org.apache.asterix.common.exceptions.AsterixException;
-import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.pointables.AListVisitablePointable;
import org.apache.asterix.om.pointables.ARecordVisitablePointable;
@@ -39,7 +37,6 @@ import org.apache.asterix.om.pointables.base.IVisitablePointable;
import org.apache.asterix.om.types.AOrderedListType;
import org.apache.asterix.om.types.ARecordType;
import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.EnumDeserializer;
import org.apache.asterix.om.types.runtime.RuntimeRecordTypeInfo;
import org.apache.asterix.runtime.evaluators.functions.PointableHelper;
@@ -47,7 +44,6 @@ 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.hyracks.api.dataflow.value.ISerializerDeserializer;
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.data.std.api.IPointable;
import org.apache.hyracks.data.std.primitive.VoidPointable;
@@ -56,9 +52,6 @@ import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
class RecordRemoveFieldsEvalFactory implements IScalarEvaluatorFactory {
private static final long serialVersionUID = 1L;
- @SuppressWarnings("unchecked")
- private final ISerializerDeserializer<ANull> nullSerDe = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
private IScalarEvaluatorFactory inputRecordEvalFactory;
private IScalarEvaluatorFactory removeFieldPathsFactory;
private ARecordType requiredRecType;
@@ -103,16 +96,6 @@ class RecordRemoveFieldsEvalFactory implements IScalarEvaluatorFactory {
eval0.evaluate(tuple, inputArg0);
eval1.evaluate(tuple, inputArg1);
- if (inputArg0.getByteArray()[inputArg0.getStartOffset()] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- try {
- nullSerDe.serialize(ANull.NULL, out);
- } catch (HyracksDataException e) {
- throw new AlgebricksException(e);
- }
- result.set(resultStorage);
- return;
- }
-
if (inputArg0.getByteArray()[inputArg0.getStartOffset()] != ATypeTag.SERIALIZED_RECORD_TYPE_TAG) {
throw new AlgebricksException(
AsterixBuiltinFunctions.REMOVE_FIELDS.getName() + ": expects input type " + inputRecType
@@ -146,7 +129,7 @@ class RecordRemoveFieldsEvalFactory implements IScalarEvaluatorFactory {
private void processRecord(ARecordType requiredType, ARecordVisitablePointable srp,
AListVisitablePointable inputList, int nestedLevel)
- throws IOException, AsterixException, AlgebricksException {
+ throws IOException, AsterixException, AlgebricksException {
if (rbStack.size() < (nestedLevel + 1)) {
rbStack.add(new RecordBuilder());
}
@@ -177,7 +160,7 @@ class RecordRemoveFieldsEvalFactory implements IScalarEvaluatorFactory {
private void addKeptFieldToSubRecord(ARecordType requiredType, IVisitablePointable fieldNamePointable,
IVisitablePointable fieldValuePointable, IVisitablePointable fieldTypePointable,
AListVisitablePointable inputList, int nestedLevel)
- throws IOException, AsterixException, AlgebricksException {
+ throws IOException, AsterixException, AlgebricksException {
runtimeRecordTypeInfo.reset(requiredType);
int pos = runtimeRecordTypeInfo.getFieldIndex(fieldNamePointable.getByteArray(),
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AbstractIntervalLogicFuncDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AbstractIntervalLogicFuncDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AbstractIntervalLogicFuncDescriptor.java
index 1cd3919..413459b 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AbstractIntervalLogicFuncDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AbstractIntervalLogicFuncDescriptor.java
@@ -22,7 +22,6 @@ import java.io.DataOutput;
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.ABoolean;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.pointables.nonvisitor.AIntervalPointable;
import org.apache.asterix.om.types.ATypeTag;
import org.apache.asterix.om.types.BuiltinType;
@@ -42,9 +41,6 @@ import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
public abstract class AbstractIntervalLogicFuncDescriptor extends AbstractScalarFunctionDynamicDescriptor {
private final static long serialVersionUID = 1L;
- /* (non-Javadoc)
- * @see org.apache.asterix.runtime.base.IScalarFunctionDynamicDescriptor#createEvaluatorFactory(org.apache.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory[])
- */
@Override
public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args)
throws AlgebricksException {
@@ -73,9 +69,6 @@ public abstract class AbstractIntervalLogicFuncDescriptor extends AbstractScalar
// possible output types
@SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
- @SuppressWarnings("unchecked")
private ISerializerDeserializer<ABoolean> booleanSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ABOOLEAN);
@@ -86,13 +79,6 @@ public abstract class AbstractIntervalLogicFuncDescriptor extends AbstractScalar
eval1.evaluate(tuple, argPtr1);
try {
- if (argPtr0.getTag() == ATypeTag.SERIALIZED_NULL_TYPE_TAG
- || argPtr1.getTag() == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- }
-
if (argPtr0.getTag() != ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG
|| argPtr1.getTag() != ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG) {
throw new AlgebricksException(getIdentifier().getName()
@@ -109,7 +95,7 @@ public abstract class AbstractIntervalLogicFuncDescriptor extends AbstractScalar
+ ": failed to compare intervals with different internal time type.");
}
- ABoolean res = (compareIntervals(il, interval0, interval1)) ? ABoolean.TRUE : ABoolean.FALSE;
+ ABoolean res = compareIntervals(il, interval0, interval1) ? ABoolean.TRUE : ABoolean.FALSE;
booleanSerde.serialize(res, out);
} catch (HyracksDataException hex) {
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AdjustDateTimeForTimeZoneDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AdjustDateTimeForTimeZoneDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AdjustDateTimeForTimeZoneDescriptor.java
index 6c445e2..1ce0c9c 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AdjustDateTimeForTimeZoneDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AdjustDateTimeForTimeZoneDescriptor.java
@@ -21,8 +21,6 @@ package org.apache.asterix.runtime.evaluators.functions.temporal;
import java.io.DataOutput;
import org.apache.asterix.dataflow.data.nontagged.serde.ADateTimeSerializerDeserializer;
-import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.temporal.ATimeParserFactory;
import org.apache.asterix.om.base.temporal.GregorianCalendarSystem;
import org.apache.asterix.om.base.temporal.GregorianCalendarSystem.Fields;
@@ -30,7 +28,6 @@ import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.EnumDeserializer;
import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
@@ -38,7 +35,6 @@ import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
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.hyracks.api.dataflow.value.ISerializerDeserializer;
import org.apache.hyracks.data.std.api.IPointable;
import org.apache.hyracks.data.std.primitive.UTF8StringPointable;
import org.apache.hyracks.data.std.primitive.VoidPointable;
@@ -80,10 +76,6 @@ public class AdjustDateTimeForTimeZoneDescriptor extends AbstractScalarFunctionD
private IScalarEvaluator eval1 = args[1].createScalarEvaluator(ctx);
// possible output types
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
-
private GregorianCalendarSystem calInstance = GregorianCalendarSystem.getInstance();
private final UTF8StringPointable utf8Ptr = new UTF8StringPointable();
@@ -102,13 +94,6 @@ public class AdjustDateTimeForTimeZoneDescriptor extends AbstractScalarFunctionD
int len1 = argPtr1.getLength();
try {
- if (bytes0[offset0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
- || bytes1[offset1] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- }
-
if (bytes0[offset0] != ATypeTag.SERIALIZED_DATETIME_TYPE_TAG) {
throw new AlgebricksException(
FID.getName() + ": expects type DATETIME/NULL for parameter 0 but got "