/** * For Calcite 1.5, we made the mistake of using array length to determine when the value for a * column is a scalar or an array. This method performs the old parsing for backwards * compatibility. * * @param column The protobuf ColumnValue object * @return The parsed value for this column */ static Object parseOldStyleColumn(Common.ColumnValue column) { if (column.getValueCount() > 1) { List<Object> array = new ArrayList<>(column.getValueCount()); for (Common.TypedValue columnValue : column.getValueList()) { array.add(getScalarValue(columnValue)); } return array; } else { return getScalarValue(column.getValue(0)); } }
/** * Parses the value for a ColumnValue using the separated array and scalar attributes. * * @param column The protobuf ColumnValue object * @return The parse value for this column */ static Object parseColumn(Common.ColumnValue column) { // Verify that we have one or the other (scalar or array) validateColumnValue(column); if (!ProtobufService.hasField(column, column.getDescriptorForType(), Common.ColumnValue.SCALAR_VALUE_FIELD_NUMBER)) { // Array List<Object> array = new ArrayList<>(column.getArrayValueCount()); for (Common.TypedValue arrayValue : column.getArrayValueList()) { array.add(getScalarValue(arrayValue)); } return array; } else { // Scalar return getScalarValue(column.getScalarValue()); } }