From 416f332070b29dd3cc48fd73ab8e92e35e8a22c1 Mon Sep 17 00:00:00 2001 From: Todd Gruben Date: Wed, 10 Jun 2020 13:12:38 -0500 Subject: [PATCH] Optimize row.Includes --- row.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/row.go b/row.go index 8d2c121d2..eea6871f0 100644 --- a/row.go +++ b/row.go @@ -510,14 +510,10 @@ func (r *Row) Columns() []uint64 { // Includes returns true if the row contains the given column. func (r *Row) Includes(col uint64) bool { - // TODO: improve the efficiency of this method by - // performing the column filter at the bitmap level - // rather than iterating through the results here. + shard := col / ShardWidth for i := range r.segments { - for _, c := range r.segments[i].Columns() { - if c == col { - return true - } + if r.segments[i].shard == shard { + return r.segments[i].data.Contains(col) } } return false