@Override public int hashCode() { int result = getType().hashCode(); for (int i = 0; i < getColumnCount(); ++i) { result = 31 * result + Objects.hashCode(getAsObject(i)); } return result; }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof Struct)) { return false; } Struct that = (Struct) o; if (!getType().equals(that.getType())) { return false; } for (int i = 0; i < getColumnCount(); ++i) { if (!Objects.equals(getAsObject(i), that.getAsObject(i))) { return false; } } return true; }
@Override com.google.protobuf.Value valueToProto() { checkNotNull(); ListValue.Builder struct = ListValue.newBuilder(); for (int fieldIndex = 0; fieldIndex < value.getColumnCount(); ++fieldIndex) { if (value.isNull(fieldIndex)) { struct.addValues(NULL_PROTO); } else { struct.addValues(getValue(fieldIndex).toProto()); } } return com.google.protobuf.Value.newBuilder().setListValue(struct).build(); } }
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()); } } }
Struct row = c.element(); long sum = 0; for (int i = 0; i < row.getColumnCount(); i++) { if (row.isNull(i)) { continue;
@Override public int hashCode() { int result = getType().hashCode(); for (int i = 0; i < getColumnCount(); ++i) { result = 31 * result + Objects.hashCode(getAsObject(i)); } return result; }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof Struct)) { return false; } Struct that = (Struct) o; if (!getType().equals(that.getType())) { return false; } for (int i = 0; i < getColumnCount(); ++i) { if (!Objects.equals(getAsObject(i), that.getAsObject(i))) { return false; } } return true; }
@Override com.google.protobuf.Value valueToProto() { checkNotNull(); ListValue.Builder struct = ListValue.newBuilder(); for (int fieldIndex = 0; fieldIndex < value.getColumnCount(); ++fieldIndex) { if (value.isNull(fieldIndex)) { struct.addValues(NULL_PROTO); } else { struct.addValues(getValue(fieldIndex).toProto()); } } return com.google.protobuf.Value.newBuilder().setListValue(struct).build(); } }