@Override public ByteArray getBytes(String columnName) { return getCurrentRowAsStruct().getBytes(columnName); }
return Value.string(value.getString(fieldIndex)); case BYTES: return Value.bytes(value.getBytes(fieldIndex)); case FLOAT64: return Value.float64(value.getDouble(fieldIndex));
case BYTES: builder.set( field, nullValue ? null : ByteBuffer.wrap(row.getBytes(fieldName).toByteArray())); break; case STRING:
@Override public ByteArray getBytes(int columnIndex) { return getCurrentRowAsStruct().getBytes(columnIndex); }
return Value.string(value.getString(fieldIndex)); case BYTES: return Value.bytes(value.getBytes(fieldIndex)); case FLOAT64: return Value.float64(value.getDouble(fieldIndex));
@Test public void writeBytes() { ByteArray data = ByteArray.copyFrom("V1"); write(baseInsert().set("BytesValue").to(data).build()); Struct row = readLastRow("BytesValue"); assertThat(row.isNull(0)).isFalse(); assertThat(row.getBytes(0)).isEqualTo(data); }
@Test public void bindBytes() { Struct row = execute( Statement.newBuilder("SELECT @v").bind("v").to(ByteArray.copyFrom("xyz")), Type.bytes()); assertThat(row.isNull(0)).isFalse(); assertThat(row.getBytes(0)).isEqualTo(ByteArray.copyFrom("xyz")); }
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()); } } }
break; case BYTES: sum += row.getBytes(i).length(); break; case STRING:
@Override public ByteArray getBytes(int columnIndex) { return getCurrentRowAsStruct().getBytes(columnIndex); }
@Override public ByteArray getBytes(String columnName) { return getCurrentRowAsStruct().getBytes(columnName); }
return nullSafeColumnParser( (currentRow, columnName) -> Base64.getEncoder().encodeToString(currentRow.getBytes(columnName).toByteArray())); case DATE: return nullSafeColumnParser(