Added recordType deep copying to avoid race condition
Change-Id: Ia06e3114ffa3b593eedab0b9537e5f2b14abb8be
Reviewed-on: http://fulliautomatix.ics.uci.edu:8443/37
Reviewed-by: Yingyi Bu <buyingyi@gmail.com>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/CastRecordDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/CastRecordDescriptor.java
index d8d4257..fbdbaf3 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/CastRecordDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/CastRecordDescriptor.java
@@ -16,6 +16,7 @@
import java.io.DataOutput;
+import edu.uci.ics.asterix.common.exceptions.AsterixException;
import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
@@ -68,15 +69,22 @@
final DataOutput out = output.getDataOutput();
final ArrayBackedValueStorage recordBuffer = new ArrayBackedValueStorage();
final ICopyEvaluator recEvaluator = recordEvalFactory.createEvaluator(recordBuffer);
+ final ARecordType clonedRecType;
+ try {
+ clonedRecType = new ARecordType(reqType.getTypeName(), reqType.getFieldNames(),
+ reqType.getFieldTypes(), reqType.isOpen());
+ } catch (AsterixException e) {
+ throw new AlgebricksException(e);
+ }
return new ICopyEvaluator() {
// pointable allocator
private PointableAllocator allocator = new PointableAllocator();
final IVisitablePointable recAccessor = allocator.allocateRecordValue(inputType);
- final IVisitablePointable resultAccessor = allocator.allocateRecordValue(reqType);
+ final IVisitablePointable resultAccessor = allocator.allocateRecordValue(clonedRecType);
final ACastVisitor castVisitor = new ACastVisitor();
final Triple<IVisitablePointable, IAType, Boolean> arg = new Triple<IVisitablePointable, IAType, Boolean>(
- resultAccessor, reqType, Boolean.FALSE);
+ resultAccessor, clonedRecType, Boolean.FALSE);
@Override
public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {