public void OpenClosed_Valid() { var range = RowRange.OpenClosed("a", "z"); Assert.True(range.StartKeyClosed.IsEmpty); Assert.Equal("a", range.StartKeyOpen.ToStringUtf8()); Assert.Equal("z", range.EndKeyClosed.ToStringUtf8()); Assert.True(range.EndKeyOpen.IsEmpty); range = RowRange.OpenClosed(null, new BigtableByteString(0x12, 0xFE)); Assert.True(range.StartKeyClosed.IsEmpty); Assert.True(range.StartKeyOpen.IsEmpty); Assert.Equal(new byte[] { 0x12, 0xFE }, range.EndKeyClosed.ToByteArray()); Assert.True(range.EndKeyOpen.IsEmpty); range = RowRange.OpenClosed(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.OpenClosed(null, null); Assert.True(range.StartKeyClosed.IsEmpty); Assert.True(range.StartKeyOpen.IsEmpty); Assert.True(range.EndKeyClosed.IsEmpty); Assert.True(range.EndKeyOpen.IsEmpty); }
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 TestRowsLimit() { BigtableByteString startKeyOpenOriginal = "row050"; BigtableByteString lastFoundKey = "row125"; ReadRowsRequest originalRequest = CreateRowRangeRequest(RowRange.OpenClosed(startKeyOpenOriginal, null)); originalRequest.RowsLimit = 100; ReadRowsRequest updatedRequest = CreateRowRangeRequest(RowRange.OpenClosed(lastFoundKey, null)); updatedRequest.RowsLimit = 25; BigtableReadRowsRequestManager underTest = new BigtableReadRowsRequestManager(originalRequest); Assert.Equal(originalRequest, underTest.BuildUpdatedRequest()); underTest.LastFoundKey = lastFoundKey; underTest.IncrementRowsReadSoFar(75); Assert.Equal(updatedRequest, underTest.BuildUpdatedRequest()); }