Search in sources :

Example 6 with ByteStringRange

use of com.google.cloud.bigtable.data.v2.models.Range.ByteStringRange in project java-bigtable by googleapis.

the class RangeTest method byteStringChangeEndTest.

@Test
public void byteStringChangeEndTest() {
    ByteStringRange range = ByteStringRange.create(ByteString.copyFromUtf8("a"), ByteString.copyFromUtf8("z")).endClosed(ByteString.copyFromUtf8("y"));
    assertThat(range.getStartBound()).isEqualTo(BoundType.CLOSED);
    assertThat(range.getStart()).isEqualTo(ByteString.copyFromUtf8("a"));
    assertThat(range.getEndBound()).isEqualTo(BoundType.CLOSED);
    assertThat(range.getEnd()).isEqualTo(ByteString.copyFromUtf8("y"));
    range = range.endOpen(ByteString.copyFromUtf8("x"));
    assertThat(range.getEndBound()).isEqualTo(BoundType.OPEN);
    assertThat(range.getEnd()).isEqualTo(ByteString.copyFromUtf8("x"));
    assertThat(range.endOpen(ByteString.EMPTY).getEndBound()).isEqualTo(BoundType.UNBOUNDED);
    assertThat(range.endClosed(ByteString.EMPTY).getEndBound()).isEqualTo(BoundType.UNBOUNDED);
}
Also used : ByteStringRange(com.google.cloud.bigtable.data.v2.models.Range.ByteStringRange) Test(org.junit.Test)

Example 7 with ByteStringRange

use of com.google.cloud.bigtable.data.v2.models.Range.ByteStringRange in project java-bigtable by googleapis.

the class RangeTest method byteStringCloneTest.

@Test
public void byteStringCloneTest() {
    ByteStringRange range = ByteStringRange.create("a", "original");
    ByteStringRange rangeSame = range.endClosed("sameInstance");
    ByteStringRange rangeClone = range.clone().endClosed("cloneInstance");
    assertThat(range.getEnd().toStringUtf8()).isEqualTo("sameInstance");
    assertThat(rangeSame.getEnd().toStringUtf8()).isEqualTo("sameInstance");
    assertThat(rangeClone.getEnd().toStringUtf8()).isEqualTo("cloneInstance");
}
Also used : ByteStringRange(com.google.cloud.bigtable.data.v2.models.Range.ByteStringRange) Test(org.junit.Test)

Example 8 with ByteStringRange

use of com.google.cloud.bigtable.data.v2.models.Range.ByteStringRange in project java-bigtable by googleapis.

the class RangeTest method byteStringChangeEndStringTest.

@Test
public void byteStringChangeEndStringTest() {
    ByteStringRange range = ByteStringRange.create("a", "z").endClosed("y");
    assertThat(range.getStartBound()).isEqualTo(BoundType.CLOSED);
    assertThat(range.getStart()).isEqualTo(ByteString.copyFromUtf8("a"));
    assertThat(range.getEndBound()).isEqualTo(BoundType.CLOSED);
    assertThat(range.getEnd()).isEqualTo(ByteString.copyFromUtf8("y"));
    range = range.endOpen("x");
    assertThat(range.getEndBound()).isEqualTo(BoundType.OPEN);
    assertThat(range.getEnd()).isEqualTo(ByteString.copyFromUtf8("x"));
    assertThat(range.endOpen("").getEndBound()).isEqualTo(BoundType.UNBOUNDED);
    assertThat(range.endClosed("").getEndBound()).isEqualTo(BoundType.UNBOUNDED);
}
Also used : ByteStringRange(com.google.cloud.bigtable.data.v2.models.Range.ByteStringRange) Test(org.junit.Test)

Example 9 with ByteStringRange

use of com.google.cloud.bigtable.data.v2.models.Range.ByteStringRange in project java-bigtable by googleapis.

the class RowSetUtilTest method singleRangeUnbounded1BoundTest.

@Test
public void singleRangeUnbounded1BoundTest() {
    RowSet rowSet = RowSet.newBuilder().addRowRanges(RowRange.newBuilder().setStartKeyClosed(ByteString.copyFromUtf8("a"))).build();
    ByteStringRange actual = RowSetUtil.getBound(rowSet);
    assertThat(actual).isEqualTo(ByteStringRange.unbounded().startClosed("a"));
}
Also used : RowSet(com.google.bigtable.v2.RowSet) ByteStringRange(com.google.cloud.bigtable.data.v2.models.Range.ByteStringRange) Test(org.junit.Test)

Example 10 with ByteStringRange

use of com.google.cloud.bigtable.data.v2.models.Range.ByteStringRange in project java-bigtable by googleapis.

the class RowSetUtilTest method singleRangeUnbounded2BoundTest.

@Test
public void singleRangeUnbounded2BoundTest() {
    RowSet rowSet = RowSet.newBuilder().addRowRanges(RowRange.newBuilder().setEndKeyClosed(ByteString.copyFromUtf8("z"))).build();
    ByteStringRange actual = RowSetUtil.getBound(rowSet);
    assertThat(actual).isEqualTo(ByteStringRange.unbounded().endClosed("z"));
}
Also used : RowSet(com.google.bigtable.v2.RowSet) ByteStringRange(com.google.cloud.bigtable.data.v2.models.Range.ByteStringRange) Test(org.junit.Test)

Aggregations

ByteStringRange (com.google.cloud.bigtable.data.v2.models.Range.ByteStringRange)22 Test (org.junit.Test)20 RowSet (com.google.bigtable.v2.RowSet)10 RowRange (com.google.bigtable.v2.RowRange)1 RowKeyWrapper (com.google.cloud.bigtable.hbase.util.RowKeyWrapper)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ByteString (com.google.protobuf.ByteString)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ObjectInputStream (java.io.ObjectInputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1