/** * Get a {@link TypeName#BYTES} value by field name, {@link IllegalStateException} is thrown if * schema doesn't match. */ @Nullable public byte[] getBytes(String fieldName) { return getBytes(getSchema().indexOf(fieldName)); }
/** * Get a {@link TypeName#FLOAT} value by field name, {@link IllegalStateException} is thrown if * schema doesn't match. */ @Nullable public Float getFloat(String fieldName) { return getFloat(getSchema().indexOf(fieldName)); }
/** * Get an array value by field name, {@link IllegalStateException} is thrown if schema doesn't * match. */ @Nullable public <T> List<T> getArray(String fieldName) { return getArray(getSchema().indexOf(fieldName)); }
/** * Get a {@link TypeName#DOUBLE} value by field name, {@link IllegalStateException} is thrown if * schema doesn't match. */ @Nullable public Double getDouble(String fieldName) { return getDouble(getSchema().indexOf(fieldName)); }
/** * Get a {@link TypeName#STRING} value by field name, {@link IllegalStateException} is thrown if * schema doesn't match. */ @Nullable public String getString(String fieldName) { return getString(getSchema().indexOf(fieldName)); }
/** Get value by field name, {@link ClassCastException} is thrown if type doesn't match. */ @Nullable @SuppressWarnings("TypeParameterUnusedInFormals") public <T> T getValue(String fieldName) { return getValue(getSchema().indexOf(fieldName)); }
/** * Get a {@link TypeName#BYTE} value by field name, {@link IllegalStateException} is thrown if * schema doesn't match. */ @Nullable public Byte getByte(String fieldName) { return getByte(getSchema().indexOf(fieldName)); }
/** * Get a {@link TypeName#INT16} value by field name, {@link IllegalStateException} is thrown if * schema doesn't match. */ @Nullable public Short getInt16(String fieldName) { return getInt16(getSchema().indexOf(fieldName)); }
/** * Get a {@link TypeName#INT32} value by field name, {@link IllegalStateException} is thrown if * schema doesn't match. */ @Nullable public Integer getInt32(String fieldName) { return getInt32(getSchema().indexOf(fieldName)); }
/** * Get a {@link TypeName#INT64} value by field name, {@link IllegalStateException} is thrown if * schema doesn't match. */ @Nullable public Long getInt64(String fieldName) { return getInt64(getSchema().indexOf(fieldName)); }
/** * Get a {@link TypeName#DATETIME} value by field name, {@link IllegalStateException} is thrown if * schema doesn't match. */ @Nullable public ReadableDateTime getDateTime(String fieldName) { return getDateTime(getSchema().indexOf(fieldName)); }
/** * Get a MAP value by field name, {@link IllegalStateException} is thrown if schema doesn't match. */ @Nullable public <T1, T2> Map<T1, T2> getMap(String fieldName) { return getMap(getSchema().indexOf(fieldName)); }
/** * Get a {@link TypeName#DECIMAL} value by field name, {@link IllegalStateException} is thrown if * schema doesn't match. */ @Nullable public BigDecimal getDecimal(String fieldName) { return getDecimal(getSchema().indexOf(fieldName)); }
/** * Get a {@link TypeName#BOOLEAN} value by field name, {@link IllegalStateException} is thrown if * schema doesn't match. */ @Nullable public Boolean getBoolean(String fieldName) { return getBoolean(getSchema().indexOf(fieldName)); }
/** * Get a {@link TypeName#ROW} value by field name, {@link IllegalStateException} is thrown if * schema doesn't match. */ @Nullable public Row getRow(String fieldName) { return getRow(getSchema().indexOf(fieldName)); }
@Override public Row apply(T input) { Row row = toRowFunction.apply(input); return Select.selectRow( row, fieldAggregation.fieldsToAggregate, row.getSchema(), fieldAggregation.inputSubSchema); } }
private SqlTypeName getFieldType(Row row, String fieldName) { Schema.Field field = row.getSchema().getField(fieldName); return CalciteUtils.toSqlTypeName(field.getType()); } }
private static void unnestRow(Row input, Row.Builder output) { for (int i = 0; i < input.getSchema().getFieldCount(); ++i) { Field field = input.getSchema().getField(i); if (field.getType().getTypeName().isCompositeType()) { unnestRow(input.getRow(i), output); } else { output.addValue(input.getValue(i)); } } } /** A {@link PTransform} that unnests nested row. */
@Override public int hashCode() { int h = 1; for (int i = 0; i < getFieldCount(); i++) { h = 31 * h + Equals.deepHashCode(getValue(i), getSchema().getField(i).getType()); } return h; }
/** Return the estimated serialized size of a give row object. */ public static long estimatedSizeBytes(Row row) { Schema schema = row.getSchema(); int fieldCount = schema.getFieldCount(); int bitmapSize = (((fieldCount - 1) >> 6) + 1) * 8; int fieldsSize = 0; for (int i = 0; i < schema.getFieldCount(); ++i) { fieldsSize += (int) estimatedSizeBytes(schema.getField(i).getType(), row.getValue(i)); } return (long) bitmapSize + fieldsSize; }