@@ -590,6 +590,15 @@ func (s *server) ReadRows(req *btpb.ReadRowsRequest, stream btpb.Bigtable_ReadRo
590
590
return nil
591
591
}
592
592
593
+ func (s * server ) GetPartitionsByTableName (name string ) []* btpb.RowRange {
594
+ table , ok := s .tables [name ]
595
+ if ! ok {
596
+ return nil
597
+ }
598
+ return table .rowRanges ()
599
+
600
+ }
601
+
593
602
// streamRow filters the given row and sends it via the given stream.
594
603
// Returns true if at least one cell matched the filter and was streamed, false otherwise.
595
604
func streamRow (stream btpb.Bigtable_ReadRowsServer , r * row , f * btpb.RowFilter , s * btpb.ReadIterationStats , ff * btpb.FeatureFlags ) error {
@@ -1461,6 +1470,7 @@ type table struct {
1461
1470
counter uint64 // increment by 1 when a new family is created
1462
1471
families map [string ]* columnFamily // keyed by plain family name
1463
1472
rows * btree.BTree // indexed by row key
1473
+ partitions []* btpb.RowRange // partitions used in change stream
1464
1474
isProtected bool // whether this table has deletion protection
1465
1475
}
1466
1476
@@ -1475,10 +1485,56 @@ func newTable(ctr *btapb.CreateTableRequest) *table {
1475
1485
c ++
1476
1486
}
1477
1487
}
1488
+
1489
+ // Hard code the partitions for testing purpose.
1490
+ rowRanges := []* btpb.RowRange {
1491
+ {
1492
+ StartKey : & btpb.RowRange_StartKeyClosed {StartKeyClosed : []byte ("a" )},
1493
+ EndKey : & btpb.RowRange_EndKeyClosed {EndKeyClosed : []byte ("b" )},
1494
+ },
1495
+ {
1496
+ StartKey : & btpb.RowRange_StartKeyClosed {StartKeyClosed : []byte ("c" )},
1497
+ EndKey : & btpb.RowRange_EndKeyClosed {EndKeyClosed : []byte ("d" )},
1498
+ },
1499
+ {
1500
+ StartKey : & btpb.RowRange_StartKeyClosed {StartKeyClosed : []byte ("e" )},
1501
+ EndKey : & btpb.RowRange_EndKeyClosed {EndKeyClosed : []byte ("f" )},
1502
+ },
1503
+ {
1504
+ StartKey : & btpb.RowRange_StartKeyClosed {StartKeyClosed : []byte ("g" )},
1505
+ EndKey : & btpb.RowRange_EndKeyClosed {EndKeyClosed : []byte ("h" )},
1506
+ },
1507
+ {
1508
+ StartKey : & btpb.RowRange_StartKeyClosed {StartKeyClosed : []byte ("i" )},
1509
+ EndKey : & btpb.RowRange_EndKeyClosed {EndKeyClosed : []byte ("j" )},
1510
+ },
1511
+ {
1512
+ StartKey : & btpb.RowRange_StartKeyClosed {StartKeyClosed : []byte ("k" )},
1513
+ EndKey : & btpb.RowRange_EndKeyClosed {EndKeyClosed : []byte ("l" )},
1514
+ },
1515
+ {
1516
+ StartKey : & btpb.RowRange_StartKeyClosed {StartKeyClosed : []byte ("m" )},
1517
+ EndKey : & btpb.RowRange_EndKeyClosed {EndKeyClosed : []byte ("n" )},
1518
+ },
1519
+ {
1520
+ StartKey : & btpb.RowRange_StartKeyClosed {StartKeyClosed : []byte ("o" )},
1521
+ EndKey : & btpb.RowRange_EndKeyClosed {EndKeyClosed : []byte ("p" )},
1522
+ },
1523
+ {
1524
+ StartKey : & btpb.RowRange_StartKeyClosed {StartKeyClosed : []byte ("q" )},
1525
+ EndKey : & btpb.RowRange_EndKeyClosed {EndKeyClosed : []byte ("r" )},
1526
+ },
1527
+ {
1528
+ StartKey : & btpb.RowRange_StartKeyClosed {StartKeyClosed : []byte ("s" )},
1529
+ EndKey : & btpb.RowRange_EndKeyClosed {EndKeyClosed : []byte ("z" )},
1530
+ },
1531
+ }
1532
+
1478
1533
return & table {
1479
1534
families : fams ,
1480
1535
counter : c ,
1481
1536
rows : btree .New (btreeDegree ),
1537
+ partitions : rowRanges ,
1482
1538
isProtected : ctr .GetTable ().GetDeletionProtection (),
1483
1539
}
1484
1540
}
@@ -1577,6 +1633,10 @@ func (t *table) gcReadOnly() (toDelete []btree.Item) {
1577
1633
return toDelete
1578
1634
}
1579
1635
1636
+ func (t * table ) rowRanges () []* btpb.RowRange {
1637
+ return t .partitions
1638
+ }
1639
+
1580
1640
type byRowKey []* row
1581
1641
1582
1642
func (b byRowKey ) Len () int { return len (b ) }
0 commit comments