@Test public void testIndexingIntoColumns() { SpannerRowMetadata rowMetadata = createRowMetadata(TypeCode.STRING, TypeCode.INT64, TypeCode.BOOL); List<Value> rawSpannerRow = createRawSpannerRow("Hello", 25L, true); SpannerRow row = new SpannerRow(rawSpannerRow, rowMetadata); assertThat(row.get("column_2", Boolean.class)).isEqualTo(true); assertThat(row.get("column_0", String.class)).isEqualTo("Hello"); assertThat(row.get(1, Long.class)).isEqualTo(25L); }
@Override public <T> T get(int columnIndex, Class<T> returnType) { Value spannerValue = this.values.get(columnIndex); Type spannerType = (Type) this.rowMetadata.getColumnMetadata(columnIndex) .getNativeTypeMetadata(); T decodedValue = codecs.decode(spannerValue, spannerType, returnType); return decodedValue; }
SpannerRow implements Row { @Override public <T> T get(int columnIndex, Class<T> returnType) { Value spannerValue = this.values.get(columnIndex); Type spannerType = (Type) this.rowMetadata.getColumnMetadata(columnIndex) .getNativeTypeMetadata(); T decodedValue = codecs.decode(spannerValue, spannerType, returnType); return decodedValue; } }
SpannerRow implements Row { @Override public <T> T get(int columnIndex, Class<T> returnType) { Value spannerValue = this.values.get(columnIndex); Type spannerType = (Type) this.rowMetadata.getColumnMetadata(columnIndex) .getNativeTypeMetadata(); T decodedValue = codecs.decode(spannerValue, spannerType, returnType); return decodedValue; } SpannerRow(List<Value> values, SpannerRowMetadata rowMetadata); }
SpannerRow implements Row { @Override public <T> T get(int columnIndex, Class<T> returnType) { Value spannerValue = this.values.get(columnIndex); Type spannerType = (Type) this.rowMetadata.getColumnMetadata(columnIndex) .getNativeTypeMetadata(); T decodedValue = codecs.decode(spannerValue, spannerType, returnType); return decodedValue; } SpannerRow(List<Value> values, SpannerRowMetadata rowMetadata); @Override T get(int columnIndex, Class<T> returnType); @Override T get(String columnName, Class<T> returnType); List<Value> getValues(); SpannerRowMetadata getRowMetadata(); }
SpannerRow implements Row { @Override public <T> T get(int columnIndex, Class<T> returnType) { Value spannerValue = this.values.get(columnIndex); Type spannerType = (Type) this.rowMetadata.getColumnMetadata(columnIndex) .getNativeTypeMetadata(); T decodedValue = codecs.decode(spannerValue, spannerType, returnType); return decodedValue; } SpannerRow(List<Value> values, SpannerRowMetadata rowMetadata); @Override T get(int columnIndex, Class<T> returnType); @Override T get(String columnName, Class<T> returnType); List<Value> getValues(); SpannerRowMetadata getRowMetadata();  }