@Override public List<Long> getLongList(String columnName) { return getCurrentRowAsStruct().getLongList(columnName); }
@Override public List<Long> getLongList(int columnIndex) { return getCurrentRowAsStruct().getLongList(columnIndex); }
@Test public void bindInt64ArrayEmpty() { Struct row = execute( Statement.newBuilder("SELECT @v").bind("v").toInt64Array(Arrays.<Long>asList()), Type.array(Type.int64())); assertThat(row.isNull(0)).isFalse(); assertThat(row.getLongList(0)).containsExactly(); }
@Test public void bindInt64Array() { Struct row = execute( Statement.newBuilder("SELECT @v").bind("v").toInt64Array(asList(null, 1L, 2L)), Type.array(Type.int64())); assertThat(row.isNull(0)).isFalse(); assertThat(row.getLongList(0)).containsExactly(null, 1L, 2L).inOrder(); }
@Test public void writeInt64ArrayEmpty() { write(baseInsert().set("Int64ArrayValue").toInt64Array(new long[] {}).build()); Struct row = readLastRow("Int64ArrayValue"); assertThat(row.isNull(0)).isFalse(); assertThat(row.getLongList(0)).containsExactly(); }
@Test public void writeInt64Array() { write(baseInsert().set("Int64ArrayValue").toInt64Array(Arrays.asList(1L, 2L, null)).build()); Struct row = readLastRow("Int64ArrayValue"); assertThat(row.isNull(0)).isFalse(); assertThat(row.getLongList(0)).containsExactly(1L, 2L, null).inOrder(); expectedException.expect(NullPointerException.class); row.getLongArray(0); }
private List<?> getRawList(Struct actualRow, int index, Type elementType) throws Exception { List<?> rawList = null; switch (elementType.getCode()) { case BOOL: rawList = actualRow.getBooleanList(index); break; case STRING: rawList = actualRow.getStringList(index); break; case BYTES: rawList = actualRow.getBytesList(index); break; case INT64: rawList = actualRow.getLongList(index); break; case FLOAT64: rawList = actualRow.getDoubleList(index); break; case STRUCT: rawList = actualRow.getStructList(index); break; default: Assert.fail("Unexpected type code:" + elementType.getCode()); } return rawList; }
@Override public List<Long> getLongList(String columnName) { return getCurrentRowAsStruct().getLongList(columnName); }
@Override public List<Long> getLongList(int columnIndex) { return getCurrentRowAsStruct().getLongList(columnIndex); }
break; case LONG: builder.set(field, nullValue ? null : row.getLongList(fieldName)); break; case DOUBLE: