private void checkNonNullStruct(int columnIndex, Object columnNameForError) { Type actualType = getColumnType(columnIndex); checkState( actualType.getCode() == Code.STRUCT, "Column %s is not of correct type: expected STRUCT<...> but was %s", columnNameForError, actualType); checkNonNull(columnIndex, columnNameForError); }
private void assertRow(Struct actualRow, JSONArray expectedRow) throws Exception { assertThat(actualRow.getColumnCount()).isEqualTo(expectedRow.length()); for (int i = 0; i < expectedRow.length(); i++) { switch (actualRow.getColumnType(i).getCode()) { case BOOL: assertThat(actualRow.getBoolean(i)).isEqualTo(expectedRow.getBoolean(i)); break; case STRING: assertThat(actualRow.getString(i)).isEqualTo(expectedRow.getString(i)); break; case INT64: assertThat(actualRow.getLong(i)).isEqualTo(expectedRow.getLong(i)); break; case FLOAT64: assertThat(actualRow.getDouble(i)).isEqualTo(expectedRow.getDouble(i)); break; case BYTES: assertThat(actualRow.getBytes(i)) .isEqualTo(ByteArray.fromBase64(expectedRow.getString(i))); break; case ARRAY: Type elementType = actualRow.getColumnType(i).getArrayElementType(); assertArray(getRawList(actualRow, i, elementType), expectedRow.getJSONArray(i)); break; default: Assert.fail("Unexpected type code:" + actualRow.getColumnType(i).getCode()); } } }
private Object getAsObject(int columnIndex) { Type type = getColumnType(columnIndex); if (isNull(columnIndex)) { return null;
private Value getValue(int fieldIndex) { Type fieldType = value.getColumnType(fieldIndex); switch (fieldType.getCode()) { case BOOL:
switch (row.getColumnType(i).getCode()) { case BOOL: sum += 1;
public Object getSingleValue(int colIndex) { Type colType = this.struct.getColumnType(colIndex); Class sourceType = getSingleItemTypeCode(colType); BiFunction readFunction = singleItemReadMethodMappingIntCol.get(sourceType); if (readFunction == null) { // This case should only occur if the POJO field is non-Iterable, but the // column type // is ARRAY of STRUCT, TIMESTAMP, DATE, BYTES, or STRING. This use-case is not // supported. return null; } return readFunction.apply(this.struct, colIndex); }
Object getSingleValue(String colName) { Type colType = this.struct.getColumnType(colName); Class sourceType = getSingleItemTypeCode(colType); BiFunction readFunction = singleItemReadMethodMapping.get(sourceType); if (readFunction == null) { // This case should only occur if the POJO field is non-Iterable, but the column type // is ARRAY of STRUCT, TIMESTAMP, DATE, BYTES, or STRING. This use-case is not supported. return null; } return readFunction.apply(this.struct, colName); }
Object getSingleValue(String colName) { Type colType = this.struct.getColumnType(colName); Class sourceType = getSingleItemTypeCode(colType); BiFunction readFunction = singleItemReadMethodMapping.get(sourceType); if (readFunction == null) { // This case should only occur if the POJO field is non-Iterable, but the column type // is ARRAY of STRUCT, TIMESTAMP, DATE, BYTES, or STRING. This use-case is not supported. return null; } return readFunction.apply(this.struct, colName); }
public Object getSingleValue(int colIndex) { Type colType = this.struct.getColumnType(colIndex); Class sourceType = getSingleItemTypeCode(colType); BiFunction readFunction = singleItemReadMethodMappingIntCol.get(sourceType); if (readFunction == null) { // This case should only occur if the POJO field is non-Iterable, but the // column type // is ARRAY of STRUCT, TIMESTAMP, DATE, BYTES, or STRING. This use-case is not // supported. return null; } return readFunction.apply(this.struct, colIndex); }
private void checkNonNullStruct(int columnIndex, Object columnNameForError) { Type actualType = getColumnType(columnIndex); checkState( actualType.getCode() == Code.STRUCT, "Column %s is not of correct type: expected STRUCT<...> but was %s", columnNameForError, actualType); checkNonNull(columnIndex, columnNameForError); }
List getListValue(String colName) { if (this.struct.getColumnType(colName).getCode() != Code.ARRAY) { throw new SpannerDataException("Column is not an ARRAY type: " + colName); } Type.Code innerTypeCode = this.struct.getColumnType(colName).getArrayElementType().getCode(); Class clazz = SpannerTypeMapper.getSimpleJavaClassFor(innerTypeCode); BiFunction<Struct, String, List> readMethod = readIterableMapping.get(clazz); return readMethod.apply(this.struct, colName); }
List getListValue(String colName) { if (this.struct.getColumnType(colName).getCode() != Code.ARRAY) { throw new SpannerDataException("Column is not an ARRAY type: " + colName); } Type.Code innerTypeCode = this.struct.getColumnType(colName).getArrayElementType().getCode(); Class clazz = SpannerTypeMapper.getSimpleJavaClassFor(innerTypeCode); BiFunction<Struct, String, List> readMethod = readIterableMapping.get(clazz); return readMethod.apply(this.struct, colName); }
Code code = currentRow.getColumnType(columnName).getArrayElementType().getCode(); switch (code) { case BOOL:
private Object getAsObject(int columnIndex) { Type type = getColumnType(columnIndex); if (isNull(columnIndex)) { return null;
private Value getValue(int fieldIndex) { Type fieldType = value.getColumnType(fieldIndex); switch (fieldType.getCode()) { case BOOL: