DRILL-1393: Set record count before clearing SV2 in RecordBatchData
DRILL-1526: Move casting logic to utility methods.