public void Open_Valid() { var range = RowRange.Open("a", "z"); Assert.True(range.StartKeyClosed.IsEmpty); Assert.Equal("a", range.StartKeyOpen.ToStringUtf8()); Assert.True(range.EndKeyClosed.IsEmpty); Assert.Equal("z", range.EndKeyOpen.ToStringUtf8()); range = RowRange.Open(null, new BigtableByteString(0x12, 0xFE)); Assert.True(range.StartKeyClosed.IsEmpty); Assert.True(range.StartKeyOpen.IsEmpty); Assert.True(range.EndKeyClosed.IsEmpty); Assert.Equal(new byte[] { 0x12, 0xFE }, range.EndKeyOpen.ToByteArray()); range = RowRange.Open(ByteString.CopyFrom(0x00, 0x01, 0xFF), null); Assert.True(range.StartKeyClosed.IsEmpty); Assert.Equal(new byte[] { 0x00, 0x01, 0xFF }, range.StartKeyOpen.ToByteArray()); Assert.True(range.EndKeyClosed.IsEmpty); Assert.True(range.EndKeyOpen.IsEmpty); range = RowRange.Open(null, null); Assert.True(range.StartKeyClosed.IsEmpty); Assert.True(range.StartKeyOpen.IsEmpty); Assert.True(range.EndKeyClosed.IsEmpty); Assert.True(range.EndKeyOpen.IsEmpty); }
public void FromRowRanges_Valid() { var set = RowSet.FromRowRanges(RowRange.Closed("a", "d"), RowRange.Open("x", "z")); Assert.Equal(0, set.RowKeys.Count); Assert.Equal(new[] { RowRange.Closed("a", "d"), RowRange.Open("x", "z") }, set.RowRanges); }
public void TestFilterRowsRowRangesKeyInMiddle() { BigtableByteString key1 = "row1"; BigtableByteString key2 = "row2"; BigtableByteString key3 = "row3"; BigtableByteString lastFoundKey = "row1a"; RowSet fullRowSet = RowSet.FromRowKeys(key1, key2, key3); fullRowSet.RowRanges.Add(new[] { RowRange.OpenClosed(null, key1), // should be filtered out RowRange.Open(null, key1), // should be filtered out RowRange.Open(key1, key2), // should be converted (lastFoundKey, key2) RowRange.ClosedOpen(key1, key2), // should be converted (lastFoundKey, key2) RowRange.Closed(key1, key2), // should be converted (lastFoundKey, key2] RowRange.Open(key2, key3), // should stay RowRange.ClosedOpen(key2, key3) // should stay }); RowSet filteredRowSet = RowSet.FromRowKeys(key2, key3); filteredRowSet.RowRanges.Add(new[] { RowRange.Open(lastFoundKey, key2), // should be converted (lastFoundKey, key2) RowRange.Open(lastFoundKey, key2), // should be converted (lastFoundKey, key2) RowRange.OpenClosed(lastFoundKey, key2), // should be converted (lastFoundKey, key2] RowRange.Open(key2, key3), // should stay RowRange.ClosedOpen(key2, key3) // should stay }); ReadRowsRequest originalRequest = new ReadRowsRequest { Rows = fullRowSet }; ReadRowsRequest filteredRequest = new ReadRowsRequest { Rows = filteredRowSet }; BigtableReadRowsRequestManager underTest = new BigtableReadRowsRequestManager(originalRequest); Assert.Equal(originalRequest, underTest.BuildUpdatedRequest()); underTest.LastFoundKey = lastFoundKey; ReadRowsRequest originalRequestClone = originalRequest.Clone(); // Assert that originalRequest and originalRequestClone are different objects. Assert.False(ReferenceEquals(originalRequest, originalRequestClone)); // Assert that originalRequest and originalRequestClone have same value before calling BuildUpdatedRequest. Assert.Equal(originalRequest, originalRequestClone); Assert.Equal(filteredRequest, underTest.BuildUpdatedRequest()); // Assert that BuildUpdatedRequest did not modify the original RowSet. Assert.Equal(originalRequest, originalRequestClone); }
public void TestFilterRowsTestAllRange() { BigtableByteString key1 = "row1"; ReadRowsRequest originalRequest = CreateRowRangeRequest(RowRange.ClosedOpen(null, null)); BigtableReadRowsRequestManager underTest = new BigtableReadRowsRequestManager(originalRequest); underTest.LastFoundKey = key1; Assert.Equal(CreateRowRangeRequest(RowRange.Open(key1, null)), underTest.BuildUpdatedRequest()); }
public void TestDefaultRequest() { BigtableByteString lastFoundKey = "row015"; ReadRowsRequest originalRequest = new ReadRowsRequest(); BigtableReadRowsRequestManager underTest = new BigtableReadRowsRequestManager(originalRequest); Assert.Equal(originalRequest, underTest.BuildUpdatedRequest()); underTest.LastFoundKey = lastFoundKey; Assert.Equal(CreateRowRangeRequest(RowRange.Open(lastFoundKey, null)), underTest.BuildUpdatedRequest()); }
public void TestFilterRowsUnsignedRange() { BigtableByteString key1 = new byte[] { 0x7f }; BigtableByteString key2 = new byte[] { 0x80 }; ReadRowsRequest originalRequest = CreateRowRangeRequest(RowRange.ClosedOpen(key1, null)); BigtableReadRowsRequestManager underTest = new BigtableReadRowsRequestManager(originalRequest); underTest.LastFoundKey = key2; Assert.Equal(CreateRowRangeRequest(RowRange.Open(key2, null)), underTest.BuildUpdatedRequest()); }
public void TestRowsLimitOnlyRequest() { BigtableByteString lastFoundKey = "row015"; ReadRowsRequest originalRequest = new ReadRowsRequest { RowsLimit = 1000 }; BigtableReadRowsRequestManager underTest = new BigtableReadRowsRequestManager(originalRequest); Assert.Equal(originalRequest, underTest.BuildUpdatedRequest()); underTest.LastFoundKey = lastFoundKey; underTest.IncrementRowsReadSoFar(10); ReadRowsRequest updatedRequest = CreateRowRangeRequest(RowRange.Open(lastFoundKey, null)); updatedRequest.RowsLimit = 990; Assert.Equal(updatedRequest, underTest.BuildUpdatedRequest()); }