Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@ public static RowMutationEntry create(@Nonnull ByteString key) {
return new RowMutationEntry(key, Mutation.create());
}

/**
* Creates new instance of mutation builder which allows server timestamp for setCell operations.
*
* <p>NOTE: This functionality is intended for advanced usage.
*
* @see Mutation#createUnsafe() for more explanation.
*/
@InternalApi("For internal usage only")
public static RowMutationEntry createUnsafe(@Nonnull ByteString key) {
return new RowMutationEntry(key, Mutation.createUnsafe());
}

/** {@inheritDoc} */
@Override
public RowMutationEntry setCell(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,31 @@ public void multipleMutationTest() {
.setDeleteFromRow(Mutation.DeleteFromRow.newBuilder().build())
.build());
}

@Test
public void unsafeMutationTest() {
ByteString rowKey = ByteString.copyFromUtf8("row-key");
RowMutationEntry rowMutationEntry =
RowMutationEntry.createUnsafe(rowKey)
.setCell("family-1", "qualifier-1", 10_000L, "fake-values")
.deleteFamily("family-2");

MutateRowsRequest.Entry entry = rowMutationEntry.toProto();
assertThat(entry.getMutationsCount()).isEqualTo(2);
assertThat(entry.getMutationsList())
.isEqualTo(
ImmutableList.of(
Mutation.newBuilder()
.setSetCell(
Mutation.SetCell.newBuilder()
.setFamilyName("family-1")
.setColumnQualifier(ByteString.copyFromUtf8("qualifier-1"))
.setTimestampMicros(10_000L)
.setValue(ByteString.copyFromUtf8("fake-values")))
.build(),
Mutation.newBuilder()
.setDeleteFromFamily(
Mutation.DeleteFromFamily.newBuilder().setFamilyName("family-2"))
.build()));
}
}