Search in sources :

Example 6 with AMutableInt64

use of org.apache.asterix.om.base.AMutableInt64 in project asterixdb by apache.

the class BuiltinClassAdFunctions method doSplitTime.

public static boolean doSplitTime(Value time, ClassAd splitClassAd, ClassAdObjectPool objectPool) throws HyracksDataException {
    boolean did_conversion;
    AMutableInt64 integer = objectPool.int64Pool.get();
    integer.setValue(0);
    AMutableDouble real = objectPool.doublePool.get();
    real.setValue(0);
    ClassAdTime asecs = objectPool.classAdTimePool.get();
    ClassAdTime rsecs = objectPool.classAdTimePool.get();
    ClassAd classad = objectPool.classAdPool.get();
    did_conversion = true;
    if (time.isIntegerValue(integer)) {
        asecs.setValue(integer.getLongValue());
        asecs.makeLocalAbsolute();
        absTimeToClassAd(asecs, splitClassAd);
    } else if (time.isRealValue(real)) {
        asecs.setValue((long) real.getDoubleValue());
        asecs.makeAbsolute(true);
        absTimeToClassAd(asecs, splitClassAd);
    } else if (time.isAbsoluteTimeValue(asecs)) {
        absTimeToClassAd(asecs, splitClassAd);
    } else if (time.isRelativeTimeValue(rsecs)) {
        relTimeToClassAd((rsecs.getRelativeTime() / 1000.0), splitClassAd);
    } else if (time.isClassAdValue(classad)) {
        splitClassAd = objectPool.classAdPool.get();
        splitClassAd.copyFrom(classad);
    } else {
        did_conversion = false;
    }
    return did_conversion;
}
Also used : AMutableDouble(org.apache.asterix.om.base.AMutableDouble) AMutableInt64(org.apache.asterix.om.base.AMutableInt64)

Example 7 with AMutableInt64

use of org.apache.asterix.om.base.AMutableInt64 in project asterixdb by apache.

the class NumericRoundHalfToEven2Descriptor method createEvaluatorFactory.

@Override
public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
    return new IScalarEvaluatorFactory() {

        private static final long serialVersionUID = 1L;

        @Override
        public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws HyracksDataException {
            return new IScalarEvaluator() {

                private ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();

                private DataOutput out = resultStorage.getDataOutput();

                private IPointable argValue = new VoidPointable();

                private IPointable argPrecision = new VoidPointable();

                private IScalarEvaluator eval = args[0].createScalarEvaluator(ctx);

                private IScalarEvaluator precision = args[1].createScalarEvaluator(ctx);

                private AMutableDouble aDouble = new AMutableDouble(0);

                private AMutableFloat aFloat = new AMutableFloat(0);

                private AMutableInt64 aInt64 = new AMutableInt64(0);

                private AMutableInt32 aInt32 = new AMutableInt32(0);

                private AMutableInt16 aInt16 = new AMutableInt16((short) 0);

                private AMutableInt8 aInt8 = new AMutableInt8((byte) 0);

                @SuppressWarnings("rawtypes")
                private ISerializerDeserializer serde;

                private int getPrecision() throws HyracksDataException {
                    byte[] bytes = argPrecision.getByteArray();
                    int offset = argPrecision.getStartOffset();
                    if (bytes[offset] == ATypeTag.SERIALIZED_INT8_TYPE_TAG) {
                        return AInt8SerializerDeserializer.getByte(bytes, offset + 1);
                    } else if (bytes[offset] == ATypeTag.SERIALIZED_INT16_TYPE_TAG) {
                        return AInt16SerializerDeserializer.getShort(bytes, offset + 1);
                    } else if (bytes[offset] == ATypeTag.SERIALIZED_INT32_TYPE_TAG) {
                        return AInt32SerializerDeserializer.getInt(bytes, offset + 1);
                    } else if (bytes[offset] == ATypeTag.SERIALIZED_INT64_TYPE_TAG) {
                        return (int) AInt64SerializerDeserializer.getLong(bytes, offset + 1);
                    } else {
                        throw new TypeMismatchException(getIdentifier(), 1, bytes[offset], ATypeTag.SERIALIZED_INT8_TYPE_TAG, ATypeTag.SERIALIZED_INT16_TYPE_TAG, ATypeTag.SERIALIZED_INT32_TYPE_TAG, ATypeTag.SERIALIZED_INT64_TYPE_TAG);
                    }
                }

                @SuppressWarnings("unchecked")
                @Override
                public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException {
                    resultStorage.reset();
                    eval.evaluate(tuple, argValue);
                    precision.evaluate(tuple, argPrecision);
                    byte[] data = argValue.getByteArray();
                    int offset = argValue.getStartOffset();
                    if (data[offset] == ATypeTag.SERIALIZED_INT8_TYPE_TAG) {
                        serde = SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.AINT8);
                        byte val = AInt8SerializerDeserializer.getByte(data, offset + 1);
                        aInt8.setValue(val);
                        serde.serialize(aInt8, out);
                    } else if (data[offset] == ATypeTag.SERIALIZED_INT16_TYPE_TAG) {
                        serde = SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.AINT16);
                        short val = AInt16SerializerDeserializer.getShort(data, offset + 1);
                        aInt16.setValue(val);
                        serde.serialize(aInt16, out);
                    } else if (data[offset] == ATypeTag.SERIALIZED_INT32_TYPE_TAG) {
                        serde = SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.AINT32);
                        int val = AInt32SerializerDeserializer.getInt(data, offset + 1);
                        aInt32.setValue(val);
                        serde.serialize(aInt32, out);
                    } else if (data[offset] == ATypeTag.SERIALIZED_INT64_TYPE_TAG) {
                        serde = SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.AINT64);
                        long val = AInt64SerializerDeserializer.getLong(data, offset + 1);
                        aInt64.setValue(val);
                        serde.serialize(aInt64, out);
                    } else if (data[offset] == ATypeTag.SERIALIZED_FLOAT_TYPE_TAG) {
                        serde = SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.AFLOAT);
                        float val = AFloatSerializerDeserializer.getFloat(data, offset + 1);
                        if (Float.isNaN(val) || Float.isInfinite(val) || Float.compare(val, -0.0F) == 0 || Float.compare(val, 0.0F) == 0) {
                            aFloat.setValue(val);
                            serde.serialize(aFloat, out);
                        } else {
                            BigDecimal r = new BigDecimal(Float.toString(val));
                            aFloat.setValue(r.setScale(getPrecision(), BigDecimal.ROUND_HALF_EVEN).floatValue());
                            serde.serialize(aFloat, out);
                        }
                    } else if (data[offset] == ATypeTag.SERIALIZED_DOUBLE_TYPE_TAG) {
                        serde = SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.ADOUBLE);
                        double val = ADoubleSerializerDeserializer.getDouble(data, offset + 1);
                        if (Double.isNaN(val) || Double.isInfinite(val) || Double.compare(val, -0.0D) == 0 || Double.compare(val, 0.0D) == 0) {
                            aDouble.setValue(val);
                            serde.serialize(aDouble, out);
                        } else {
                            BigDecimal r = new BigDecimal(Double.toString(val));
                            aDouble.setValue(r.setScale(getPrecision(), BigDecimal.ROUND_HALF_EVEN).doubleValue());
                            serde.serialize(aDouble, out);
                        }
                    } else {
                        throw new TypeMismatchException(getIdentifier(), 0, data[offset], ATypeTag.SERIALIZED_INT8_TYPE_TAG, ATypeTag.SERIALIZED_INT16_TYPE_TAG, ATypeTag.SERIALIZED_INT32_TYPE_TAG, ATypeTag.SERIALIZED_INT64_TYPE_TAG, ATypeTag.SERIALIZED_FLOAT_TYPE_TAG, ATypeTag.SERIALIZED_DOUBLE_TYPE_TAG);
                    }
                    result.set(resultStorage);
                }
            };
        }
    };
}
Also used : DataOutput(java.io.DataOutput) AMutableInt8(org.apache.asterix.om.base.AMutableInt8) TypeMismatchException(org.apache.asterix.runtime.exceptions.TypeMismatchException) IPointable(org.apache.hyracks.data.std.api.IPointable) IScalarEvaluator(org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator) ISerializerDeserializer(org.apache.hyracks.api.dataflow.value.ISerializerDeserializer) BigDecimal(java.math.BigDecimal) IScalarEvaluatorFactory(org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory) ArrayBackedValueStorage(org.apache.hyracks.data.std.util.ArrayBackedValueStorage) IHyracksTaskContext(org.apache.hyracks.api.context.IHyracksTaskContext) VoidPointable(org.apache.hyracks.data.std.primitive.VoidPointable) AMutableDouble(org.apache.asterix.om.base.AMutableDouble) IFrameTupleReference(org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference) AMutableInt16(org.apache.asterix.om.base.AMutableInt16) AMutableInt64(org.apache.asterix.om.base.AMutableInt64) AMutableInt32(org.apache.asterix.om.base.AMutableInt32) AMutableFloat(org.apache.asterix.om.base.AMutableFloat)

Example 8 with AMutableInt64

use of org.apache.asterix.om.base.AMutableInt64 in project asterixdb by apache.

the class StringToCodePointDescriptor method createEvaluatorFactory.

@Override
public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
    return new IScalarEvaluatorFactory() {

        private static final long serialVersionUID = 1L;

        @Override
        public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws HyracksDataException {
            return new IScalarEvaluator() {

                protected final ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();

                protected final DataOutput out = resultStorage.getDataOutput();

                protected final IPointable argPtr = new VoidPointable();

                protected final IScalarEvaluator stringEval = args[0].createScalarEvaluator(ctx);

                protected final AOrderedListType intListType = new AOrderedListType(BuiltinType.AINT64, null);

                private OrderedListBuilder listBuilder = new OrderedListBuilder();

                private ArrayBackedValueStorage inputVal = new ArrayBackedValueStorage();

                @SuppressWarnings("unchecked")
                private final ISerializerDeserializer<AInt64> int64Serde = SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.AINT64);

                private final AMutableInt64 aInt64 = new AMutableInt64(0);

                @Override
                public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException {
                    try {
                        resultStorage.reset();
                        stringEval.evaluate(tuple, argPtr);
                        byte[] serString = argPtr.getByteArray();
                        int offset = argPtr.getStartOffset();
                        if (serString[offset] == ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
                            int len = UTF8StringUtil.getUTFLength(serString, offset + 1);
                            int start = offset + 1 + UTF8StringUtil.getNumBytesToStoreLength(len);
                            int pos = 0;
                            listBuilder.reset(intListType);
                            while (pos < len) {
                                int codePoint = UTF8StringUtil.UTF8ToCodePoint(serString, start + pos);
                                pos += UTF8StringUtil.charSize(serString, start + pos);
                                inputVal.reset();
                                aInt64.setValue(codePoint);
                                int64Serde.serialize(aInt64, inputVal.getDataOutput());
                                listBuilder.addItem(inputVal);
                            }
                            listBuilder.write(out, true);
                        } else {
                            throw new TypeMismatchException(getIdentifier(), 0, serString[offset], ATypeTag.SERIALIZED_STRING_TYPE_TAG);
                        }
                        result.set(resultStorage);
                    } catch (IOException e1) {
                        throw new HyracksDataException(e1);
                    }
                }
            };
        }
    };
}
Also used : DataOutput(java.io.DataOutput) OrderedListBuilder(org.apache.asterix.builders.OrderedListBuilder) AOrderedListType(org.apache.asterix.om.types.AOrderedListType) TypeMismatchException(org.apache.asterix.runtime.exceptions.TypeMismatchException) IPointable(org.apache.hyracks.data.std.api.IPointable) IOException(java.io.IOException) IScalarEvaluator(org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator) ISerializerDeserializer(org.apache.hyracks.api.dataflow.value.ISerializerDeserializer) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) IScalarEvaluatorFactory(org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory) ArrayBackedValueStorage(org.apache.hyracks.data.std.util.ArrayBackedValueStorage) IHyracksTaskContext(org.apache.hyracks.api.context.IHyracksTaskContext) VoidPointable(org.apache.hyracks.data.std.primitive.VoidPointable) IFrameTupleReference(org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference) AMutableInt64(org.apache.asterix.om.base.AMutableInt64)

Example 9 with AMutableInt64

use of org.apache.asterix.om.base.AMutableInt64 in project asterixdb by apache.

the class StringLengthDescriptor method createEvaluatorFactory.

@Override
public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
    return new IScalarEvaluatorFactory() {

        private static final long serialVersionUID = 1L;

        @Override
        public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws HyracksDataException {
            return new IScalarEvaluator() {

                private AMutableInt64 result = new AMutableInt64(0);

                private ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();

                private DataOutput out = resultStorage.getDataOutput();

                private IPointable inputArg = new VoidPointable();

                private IScalarEvaluator eval = args[0].createScalarEvaluator(ctx);

                @SuppressWarnings("unchecked")
                private ISerializerDeserializer<AInt64> int64Serde = SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.AINT64);

                @Override
                public void evaluate(IFrameTupleReference tuple, IPointable resultPointable) throws HyracksDataException {
                    try {
                        resultStorage.reset();
                        eval.evaluate(tuple, inputArg);
                        byte[] serString = inputArg.getByteArray();
                        int offset = inputArg.getStartOffset();
                        if (serString[offset] == ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
                            int len = UTF8StringUtil.getUTFLength(serString, offset + 1);
                            result.setValue(len);
                            int64Serde.serialize(result, out);
                        } else {
                            throw new TypeMismatchException(getIdentifier(), 0, serString[offset], ATypeTag.SERIALIZED_STRING_TYPE_TAG);
                        }
                        resultPointable.set(resultStorage);
                    } catch (IOException e1) {
                        throw new HyracksDataException(e1);
                    }
                }
            };
        }
    };
}
Also used : DataOutput(java.io.DataOutput) TypeMismatchException(org.apache.asterix.runtime.exceptions.TypeMismatchException) IPointable(org.apache.hyracks.data.std.api.IPointable) IOException(java.io.IOException) IScalarEvaluator(org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator) ISerializerDeserializer(org.apache.hyracks.api.dataflow.value.ISerializerDeserializer) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) IScalarEvaluatorFactory(org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory) ArrayBackedValueStorage(org.apache.hyracks.data.std.util.ArrayBackedValueStorage) IHyracksTaskContext(org.apache.hyracks.api.context.IHyracksTaskContext) VoidPointable(org.apache.hyracks.data.std.primitive.VoidPointable) IFrameTupleReference(org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference) AMutableInt64(org.apache.asterix.om.base.AMutableInt64)

Example 10 with AMutableInt64

use of org.apache.asterix.om.base.AMutableInt64 in project asterixdb by apache.

the class ClassAdUnitTester method testClassad.

/*********************************************************************
     * Function: test_classad
     * Purpose: Test the ClassAd class.
     * @param objectPool
     *
     * @throws IOException
     *********************************************************************/
public static void testClassad(Parameters parameters, Results results, ClassAdObjectPool objectPool) throws IOException {
    ClassAdParser parser = new ClassAdParser(objectPool);
    boolean haveAttribute;
    boolean success;
    System.out.println("Testing the ClassAd class...");
    String input_basic = "[ A = 3; B = 4.0; C = \"babyzilla\"; D = true; E = {1}; F = [ AA = 3; ]; G =\"deleteme\";]";
    ClassAd basic = new ClassAd(objectPool);
    AMutableInt64 i = new AMutableInt64(0);
    MutableBoolean b = new MutableBoolean();
    AMutableDouble r = new AMutableDouble(0);
    AMutableCharArrayString s = new AMutableCharArrayString();
    ClassAd c = new ClassAd(objectPool);
    // ExprList *l;
    basic = parser.parseClassAd(input_basic);
    /* ----- Test EvaluateAttr* ----- */
    haveAttribute = basic.evaluateAttrInt("A", i);
    test("Have attribute A", (haveAttribute == true), "test_classad 1", results);
    test("A is 3", (i.getLongValue() == 3), "test_classad 2", results);
    haveAttribute = basic.evaluateAttrReal("B", r);
    test("Have attribute B", (haveAttribute == true), "test_classad 3", results);
    test("B is 4.0", (r.getDoubleValue() == 4.0), "test_classad 4", results);
    haveAttribute = basic.evaluateAttrString("C", s);
    test("Have attribute C", (haveAttribute == true), "test_classad 5", results);
    test("C is 'babyzilla'", (s.compareTo("babyzilla") == 0), "test_classad 6", results);
    haveAttribute = basic.evaluateAttrBool("D", b);
    test("Have attribute D", (haveAttribute == true), "test_classad 7", results);
    test("D is true", (b.booleanValue() == true), "test_classad 8", results);
    /* ----- Test basic insert and delete ----- */
    success = basic.insertAttr("new", 4);
    test("InsertAttr claims to have worked", (success == true), "test_classad 9", results);
    haveAttribute = basic.evaluateAttrInt("new", i);
    test("Have new attribute", (haveAttribute == true), "test_classad 10", results);
    test("new attribute is 4", i.getLongValue() == 4, "test_classad 11", results);
    success = basic.delete("new");
    test("Delete claims to have worked", (success == true), "test_classad 12", results);
    haveAttribute = basic.evaluateAttrInt("new", i);
    test("New attribute was deleted", (haveAttribute == false), "test_classad 13", results);
    success = basic.delete("G");
    test("DELETE claims to have worked", (success == true), "test_classad 14", results);
    haveAttribute = basic.evaluateAttrString("G", s);
    test("Attribute G was deleted", (haveAttribute == false), "test_classad 15", results);
    basic = null;
    /* ----- Test GetExternalReferences ----- */
    String inputRef = "[ Rank=Member(\"LCG-2_1_0\",other.Environment) ? other.Time/seconds : other.Time/minutes; minutes=60; ]";
    TreeSet<String> refs = new TreeSet<String>();
    ExprTree rank;
    c = parser.parseClassAd(inputRef);
    test("Made classad_ref", (c != null), "Test GetExternalReferences 1", results);
    if (c != null) {
        rank = c.lookup("Rank");
        test("Rank exists", (rank != null), "Test GetExternalReferences 2", results);
        if (rank != null) {
            boolean haveReferences;
            if ((haveReferences = c.getExternalReferences(rank, refs, true))) {
                test("have_references", (haveReferences == true), "Test GetExternalReferences 3", results);
                if (haveReferences) {
                    boolean haveEnvironment;
                    boolean haveTime;
                    boolean haveSeconds;
                    boolean haveOther;
                    haveEnvironment = false;
                    haveTime = false;
                    haveSeconds = false;
                    haveOther = false;
                    for (String entry : refs) {
                        if (entry.compareTo("other.Environment") == 0) {
                            haveEnvironment = true;
                        } else if (entry.compareTo("other.Time") == 0) {
                            haveTime = true;
                        } else if (entry.compareTo("seconds") == 0) {
                            haveSeconds = true;
                        } else {
                            haveOther = true;
                        }
                    }
                    test("Have external reference to Environment", (haveEnvironment == true), "Test GetExternalReferences 4", results);
                    test("Have external reference to Time", (haveTime == true), "Test GetExternalReferences 5", results);
                    test("Have external reference to seconds", (haveSeconds == true), "Test GetExternalReferences 6", results);
                    test("Have no other external references", (haveOther != true), "Test GetExternalReferences 7", results);
                }
            }
        }
        c = null;
    }
    // This ClassAd may cause problems. Perhaps a memory leak.
    // This test is only useful when run under valgrind.
    String memoryProblemClassad = "[ Updates = [status = \"request_completed\"; timestamp = absTime(\"2004-12-16T18:10:59-0600]\")] ]";
    c = parser.parseClassAd(memoryProblemClassad);
    /* ----- Test Parsing multiple ClassAds ----- */
    String twoClassads = "[ a = 3; ][ b = 4; ]";
    ClassAd classad1 = new ClassAd(objectPool);
    ClassAd classad2 = new ClassAd(objectPool);
    AMutableInt32 offset = new AMutableInt32(0);
    parser.parseClassAd(twoClassads, classad1, offset);
    test("Have good offset #1", offset.getIntegerValue() == 10, "Test Parsing multiple ClassAds 1", results);
    parser.parseClassAd(twoClassads, classad2, offset);
    test("Have good offset #2", offset.getIntegerValue() == 20, "Test Parsing multiple ClassAds 2", results);
    /* ----- Test chained ClassAds ----- */
    // classad1 and classad2 from above test are used.
    ClassAd classad3 = new ClassAd(objectPool);
    classad1.chainToAd(classad2);
    test("classad1's parent is classad2", classad1.getChainedParentAd().equals(classad2), "Test chained ClassAds 1", results);
    haveAttribute = classad1.evaluateAttrInt("b", i);
    test("chain has attribute b from parent", (haveAttribute == true), "Test chained ClassAds 2", results);
    test("chain attribute b from parent is 4", (i.getLongValue() == 4), "Test chained ClassAds 3", results);
    haveAttribute = classad1.evaluateAttrInt("a", i);
    test("chain has attribute a from self", (haveAttribute == true), "Test chained ClassAds 4", results);
    test("chain attribute a is 3", (i.getLongValue() == 3), "Test chained ClassAds 5", results);
    // Now we modify classad2 (parent) to contain "a".
    success = classad2.insertAttr("a", 7);
    test("insert a into parent", (success == true), "Test chained ClassAds 6", results);
    haveAttribute = classad1.evaluateAttrInt("a", i);
    test("chain has attribute a from self (overriding parent)", (haveAttribute == true), "Test chained ClassAds 7", results);
    test("chain attribute a is 3 (overriding parent)", (i.getLongValue() == 3), "Test chained ClassAds 8", results);
    haveAttribute = classad2.evaluateAttrInt("a", i);
    test("chain parent has attribute a", (haveAttribute == true), "Test chained ClassAds 9", results);
    test("chain parent attribute a is 7", (i.getLongValue() == 7), "Test chained ClassAds 10", results);
    success = classad3.copyFromChain(classad1);
    test("copy from chain succeeded", (success == true), "Test chained ClassAds 11", results);
    haveAttribute = classad3.evaluateAttrInt("b", i);
    test("copy of chain has attribute b", (haveAttribute == true), "Test chained ClassAds 12", results);
    test("copy of chain has attribute b==4", (i.getLongValue() == 4), "Test chained ClassAds 13", results);
    success = classad3.insertAttr("c", 6);
    test("insert into copy of chain succeeded", (success == true), "Test chained ClassAds 14", results);
    classad3.copyFromChain(classad1);
    haveAttribute = classad3.evaluateAttrInt("c", i);
    test("copy of chain is clean", (haveAttribute == false), "Test chained ClassAds 15", results);
    classad3.insertAttr("c", 6);
    success = classad3.updateFromChain(classad1);
    test("update from chain succeeded", (success == true), "Test chained ClassAds 16", results);
    haveAttribute = classad3.evaluateAttrInt("c", i);
    test("update from chain is merged", (haveAttribute == true), "Test chained ClassAds 17", results);
    test("update from chain has attribute c==6", (i.getLongValue() == 6), "Test chained ClassAds 18", results);
}
Also used : ClassAdParser(org.apache.asterix.external.library.ClassAdParser) ClassAd(org.apache.asterix.external.classad.ClassAd) TreeSet(java.util.TreeSet) MutableBoolean(org.apache.commons.lang3.mutable.MutableBoolean) AMutableDouble(org.apache.asterix.om.base.AMutableDouble) ExprTree(org.apache.asterix.external.classad.ExprTree) AMutableString(org.apache.asterix.om.base.AMutableString) AMutableCharArrayString(org.apache.asterix.external.classad.AMutableCharArrayString) AMutableInt64(org.apache.asterix.om.base.AMutableInt64) AMutableInt32(org.apache.asterix.om.base.AMutableInt32) AMutableCharArrayString(org.apache.asterix.external.classad.AMutableCharArrayString)

Aggregations

AMutableInt64 (org.apache.asterix.om.base.AMutableInt64)41 ISerializerDeserializer (org.apache.hyracks.api.dataflow.value.ISerializerDeserializer)27 IHyracksTaskContext (org.apache.hyracks.api.context.IHyracksTaskContext)26 IPointable (org.apache.hyracks.data.std.api.IPointable)26 IFrameTupleReference (org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference)26 ArrayBackedValueStorage (org.apache.hyracks.data.std.util.ArrayBackedValueStorage)25 IScalarEvaluator (org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator)24 IScalarEvaluatorFactory (org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory)24 VoidPointable (org.apache.hyracks.data.std.primitive.VoidPointable)24 DataOutput (java.io.DataOutput)23 TypeMismatchException (org.apache.asterix.runtime.exceptions.TypeMismatchException)22 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)17 AMutableDouble (org.apache.asterix.om.base.AMutableDouble)16 IOException (java.io.IOException)11 MutableBoolean (org.apache.commons.lang3.mutable.MutableBoolean)8 AMutableInt32 (org.apache.asterix.om.base.AMutableInt32)7 GregorianCalendarSystem (org.apache.asterix.om.base.temporal.GregorianCalendarSystem)7 AMutableFloat (org.apache.asterix.om.base.AMutableFloat)6 AMutableInt16 (org.apache.asterix.om.base.AMutableInt16)5 AMutableInt8 (org.apache.asterix.om.base.AMutableInt8)5