@@ -29,20 +29,6 @@ namespace cloud {
2929namespace bigtable {
3030namespace emulator {
3131
32- // FIXME: Workaround our current incorrect ordering of
33- // timestamps. Remove when that is fixed and they are in decreasing
34- // order, at which point we can just pick the first element.
35- std::map<std::chrono::milliseconds, std::string>::iterator latest (
36- std::map<std::chrono::milliseconds, std::string>& cells_not_empty) {
37- assert (!cells_not_empty.empty ());
38-
39- auto first_it = cells_not_empty.begin ();
40- auto last_it = std::prev (cells_not_empty.end ());
41- auto latest_it = first_it->first >= last_it->first ? first_it : last_it;
42-
43- return latest_it;
44- }
45-
4632StatusOr<ReadModifyWriteCellResult> ColumnRow::ReadModifyWrite (
4733 std::int64_t inc_value) {
4834 auto system_ms = std::chrono::duration_cast<std::chrono::milliseconds>(
@@ -56,10 +42,7 @@ StatusOr<ReadModifyWriteCellResult> ColumnRow::ReadModifyWrite(
5642 absl::nullopt };
5743 }
5844
59- // FIXME: Workaround our current incorrect ordering of
60- // timestamps. Remove when that is fixed and they are in decreasing
61- // order, at which point we can just pick the first element.
62- auto latest_it = latest (cells_);
45+ auto latest_it = cells_.begin ();
6346
6447 auto maybe_old_value =
6548 google::cloud::internal::DecodeBigEndian<std::int64_t >(latest_it->second );
@@ -97,10 +80,7 @@ ReadModifyWriteCellResult ColumnRow::ReadModifyWrite(
9780 absl::nullopt };
9881 }
9982
100- // FIXME: Workaround our current incorrect ordering of
101- // timestamps. Remove when that is fixed and they are in decreasing
102- // order, at which point we can just pick the first element.
103- auto latest_it = latest (cells_);
83+ auto latest_it = cells_.begin ();
10484
10585 auto value = latest_it->second + append_value;
10686
@@ -159,14 +139,21 @@ StatusOr<absl::optional<std::string>> ColumnRow::UpdateCell(
159139std::vector<Cell> ColumnRow::DeleteTimeRange (
160140 ::google::bigtable::v2::TimestampRange const & time_range) {
161141 std::vector<Cell> deleted_cells;
162- for (auto cell_it = cells_.lower_bound (
163- std::chrono::duration_cast<std::chrono::milliseconds>(
164- std::chrono::microseconds (time_range.start_timestamp_micros ())));
142+ absl::optional<std::int64_t > maybe_end_micros =
143+ time_range.end_timestamp_micros ();
144+ if (maybe_end_micros.value_or (0 ) == 0 ) {
145+ maybe_end_micros.reset ();
146+ }
147+ for (auto cell_it =
148+ maybe_end_micros
149+ ? upper_bound (
150+ std::chrono::duration_cast<std::chrono::milliseconds>(
151+ std::chrono::microseconds (*maybe_end_micros)))
152+ : begin ();
165153 cell_it != cells_.end () &&
166- (time_range.end_timestamp_micros () == 0 ||
167- cell_it->first < std::chrono::duration_cast<std::chrono::milliseconds>(
154+ cell_it->first >= std::chrono::duration_cast<std::chrono::milliseconds>(
168155 std::chrono::microseconds (
169- time_range.end_timestamp_micros () )));) {
156+ time_range.start_timestamp_micros ( )));) {
170157 Cell cell = {std::move (cell_it->first ), std::move (cell_it->second )};
171158 deleted_cells.emplace_back (std::move (cell));
172159 cells_.erase (cell_it++);
@@ -346,9 +333,9 @@ FilteredColumnFamilyStream::FilteredColumnFamilyStream(
346333 row_ranges_ (std::move(row_set)),
347334 column_ranges_(StringRangeSet::All()),
348335 timestamp_ranges_(TimestampRangeSet::All()),
349- rows_(RangeFilteredMapView<ColumnFamily, StringRangeSet>(column_family,
350- *row_ranges_),
351- std::cref(row_regexes_)) {}
336+ rows_(
337+ StringRangeFilteredMapView<ColumnFamily>(column_family, *row_ranges_),
338+ std::cref(row_regexes_)) {}
352339
353340bool FilteredColumnFamilyStream::ApplyFilter (
354341 InternalFilter const & internal_filter) {
@@ -404,7 +391,7 @@ void FilteredColumnFamilyStream::InitializeIfNeeded() const {
404391
405392bool FilteredColumnFamilyStream::PointToFirstCellAfterColumnChange () const {
406393 for (; column_it_.value () != columns_.value ().end (); ++(column_it_.value ())) {
407- cells_ = RangeFilteredMapView <ColumnRow, TimestampRangeSet >(
394+ cells_ = TimestampRangeFilteredMapView <ColumnRow>(
408395 column_it_.value ()->second , timestamp_ranges_);
409396 cell_it_ = cells_.value ().begin ();
410397 if (cell_it_.value () != cells_.value ().end ()) {
@@ -416,10 +403,9 @@ bool FilteredColumnFamilyStream::PointToFirstCellAfterColumnChange() const {
416403
417404bool FilteredColumnFamilyStream::PointToFirstCellAfterRowChange () const {
418405 for (; (*row_it_) != rows_.end (); ++(*row_it_)) {
419- columns_ = RegexFiteredMapView<
420- RangeFilteredMapView<ColumnFamilyRow, StringRangeSet>>(
421- RangeFilteredMapView<ColumnFamilyRow, StringRangeSet>(
422- (*row_it_)->second , column_ranges_),
406+ columns_ = RegexFiteredMapView<StringRangeFilteredMapView<ColumnFamilyRow>>(
407+ StringRangeFilteredMapView<ColumnFamilyRow>((*row_it_)->second ,
408+ column_ranges_),
423409 column_regexes_);
424410 column_it_ = columns_.value ().begin ();
425411 if (PointToFirstCellAfterColumnChange ()) {
0 commit comments