use of com.google.cloud.spanner.Mutation in project beam by apache.
the class MutationUtilsTest method testCreateDeleteMutationFromRow.
@Test
public void testCreateDeleteMutationFromRow() {
Mutation expectedMutation = createDeleteMutation();
Mutation mutation = beamRowToMutationFn(Mutation.Op.DELETE, TABLE).apply(KEY_ROW);
assertEquals(expectedMutation, mutation);
}
use of com.google.cloud.spanner.Mutation in project beam by apache.
the class MutationUtilsTest method testCreateInsertMutationFromRow.
@Test
public void testCreateInsertMutationFromRow() {
Mutation expectedMutation = createMutation(Mutation.Op.INSERT);
Mutation mutation = beamRowToMutationFn(Mutation.Op.INSERT, TABLE).apply(WRITE_ROW);
assertEquals(expectedMutation, mutation);
}
use of com.google.cloud.spanner.Mutation in project beam by apache.
the class MutationUtilsTest method testCreateInsertMutationFromRowWithNulls.
@Test
public void testCreateInsertMutationFromRowWithNulls() {
Mutation expectedMutation = createMutationNulls(Mutation.Op.INSERT);
Mutation mutation = beamRowToMutationFn(Mutation.Op.INSERT, TABLE).apply(WRITE_ROW_NULLS);
assertEquals(expectedMutation, mutation);
}
use of com.google.cloud.spanner.Mutation in project beam by apache.
the class MutationSizeEstimatorTest method group.
@Test
public void group() throws Exception {
Mutation int64 = Mutation.newInsertOrUpdateBuilder("test").set("one").to(1).build();
Mutation float64 = Mutation.newInsertOrUpdateBuilder("test").set("one").to(2.9).build();
Mutation bool = Mutation.newInsertOrUpdateBuilder("test").set("one").to(false).build();
MutationGroup group = MutationGroup.create(int64, float64, bool);
assertThat(MutationSizeEstimator.sizeOf(group), is(17L));
}
use of com.google.cloud.spanner.Mutation in project beam by apache.
the class MutationSizeEstimatorTest method nullPrimitiveArrays.
@Test
public void nullPrimitiveArrays() throws Exception {
Mutation int64 = Mutation.newInsertOrUpdateBuilder("test").set("one").toInt64Array((long[]) null).build();
Mutation float64 = Mutation.newInsertOrUpdateBuilder("test").set("one").toFloat64Array((double[]) null).build();
Mutation bool = Mutation.newInsertOrUpdateBuilder("test").set("one").toBoolArray((boolean[]) null).build();
Mutation numeric = Mutation.newInsertOrUpdateBuilder("test").set("one").toNumericArray((Iterable<BigDecimal>) null).build();
Mutation json = Mutation.newInsertOrUpdateBuilder("test").set("one").toJsonArray(null).build();
assertThat(MutationSizeEstimator.sizeOf(int64), is(0L));
assertThat(MutationSizeEstimator.sizeOf(float64), is(0L));
assertThat(MutationSizeEstimator.sizeOf(bool), is(0L));
assertThat(MutationSizeEstimator.sizeOf(numeric), is(0L));
assertThat(MutationSizeEstimator.sizeOf(json), is(0L));
}
Aggregations