case SKIP:
return oldValue;
case REPLACE:
return newValue;
case FAIL:
throw new RecordException("Failure while doing query. The destination specified already contains a value and no collision behavior was provdied.", null);
case OBJECTIFY:
SimpleMapValue n = new SimpleMapValue();
n.setByName("old", oldValue);
n.setByName("new", newValue);
return n;
case ARRAYIFY:
SimpleArrayValue a = new SimpleArrayValue();
a.addToArray(0, oldValue);
a.addToArray(1, newValue);
return a;
case MERGE_OVERRIDE:
MajorType oldT = oldValue.getDataType();
MajorType newT = newValue.getDataType();
if(oldT.getMinorType() == MinorType.REPEATMAP && newT.getMinorType() == MinorType.REPEATMAP){
oldValue.getAsContainer().getAsMap().merge(newValue.getAsContainer().getAsMap());
return oldValue;
}else if(oldT.getMode() == DataMode.REPEATED && newT.getMode() == DataMode.REPEATED){
logger.debug("Merging two arrays. {} and {}", oldValue, newValue);
oldValue.getAsContainer().getAsArray().append(newValue.getAsContainer().getAsArray());
return oldValue;
}else if(oldT.getMode() == DataMode.REPEATED || newT.getMode() == DataMode.REPEATED || oldT.getMinorType() == MinorType.REPEATMAP || newT.getMinorType() == MinorType.REPEATMAP){
throw new RecordException(String.format("Failure while doing query. You requested a merge of values that were incompatibile. Examples include merging an array and a map or merging a map/array with a scalar. Merge Types were %s and %s.", oldT, newT), null);
}else{
// scalar type, just override the value.
return newValue;
}
default: