Skip to content

MB-72376: Introducing New Geo-Shape Indexes - #432

Merged
Likith101 merged 15 commits into
masterfrom
geo
Aug 6, 2026
Merged

MB-72376: Introducing New Geo-Shape Indexes#432
Likith101 merged 15 commits into
masterfrom
geo

Conversation

@Likith101

@Likith101 Likith101 commented Jun 26, 2026

Copy link
Copy Markdown
Member
  • Introducing a new geo shape index section and section specific cache
  • Added methods to get the geoData from a segment
  • Separate ewma from vector cache to be reused within geo cache

}

// Append bounding box bytes, shape bytes and the document score
g.boundingBoxes = append(g.boundingBoxes, f.EncodedBoundingBox())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since these structures are called once for every doc, can you prealloc the slice capacity to numDocs?

Comment thread section_geo_shape_v2_index.go Outdated
}

func (g *geoShapeV2IndexSectionOpaque) persist(w *FileWriter) error {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can you drop these kind of empty lines?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think there are some funcs that have these kind of empty new lines. so can you please keep them consistent in all funcs?

Comment thread section_geo_shape_v2_index.go Outdated
func (g *geoShapeV2IndexSection) Merge(opaque map[int]resetable, segments []*SegmentBase,
drops []*roaring.Bitmap, fieldsInv []string, newDocNumsIn [][]uint64, w *FileWriter,
closeCh chan struct{}) error {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove new line

Comment thread section_geo_shape_v2_index.go Outdated
// Assign merged geo docIDs and build, per segment, a direct
// oldGeoDocID -> mergedGeoDocID slice
segRemaps, numDocs := buildGeoDocRemaps(indexInfos, mergedContent)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: maybe you can remove these kind of new lines?


// Each segment's inner and cross cells are already stored sorted
// So instead of concatenating every segment's cells and sorting the whole
// set, we k-way merge the pre-sorted per-segment runs while.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does the comment need to be updated?

shapes: make([][]byte, 0, totalDocs),
}

// Assign merged geo docIDs and build, per segment, a direct

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just to clarify - geoDocIDs are just the docIDs of the docs having geo_v2 field content right?

Comment thread section_geo_shape_v2_index.go Outdated
continue
}
remap[geoDocID] = uint32(numDocs)
numDocs++

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since numDocs corresponds to the geoDocIDs, can you rename this to numGeoDocs?

crossCells := f.CrossCells()

docID := uint32(len(g.docNums))
g.docNums = append(g.docNums, docNum)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm guessing this is a mapping of geoDocIDs -> localDocNum (of the one having this geoshape field) right? can you rename docID to geoDocID? its a little confusing otherwise
and also going by that assumption, if one of the local docs doesn't have the geo shape field in it, then the mapping and the geoDocID generation would be such that we don't faulty mappings right? and you've verified in your functional testing?

Comment thread section_geo_shape_v2_index.go Outdated
// merged geo docID.
func buildGeoDocRemaps(indexInfos []*geoIndexInfo,
mergedContent *geoIndexContent) (segRemaps [][]uint32, numDocs uint64) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove the empty line

Comment thread section_geo_shape_v2_index.go Outdated
}

func (g *geoShapeV2IndexSectionOpaque) persist(w *FileWriter) error {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think there are some funcs that have these kind of empty new lines. so can you please keep them consistent in all funcs?

CascadingRadium
CascadingRadium previously approved these changes Aug 3, 2026
Comment thread geo_index_cache.go
return nil, nil
}

entry, ok := gc.cache[field]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a race case here?
we release the read lock before calling entry.load(). In that window cleanup() can take the write lock, see refs == 0, and evict + Close() this entry, after which we incRef() an orphaned entry. It's harmless today since Close() only decrements a refcount, but it becomes a use(only it gets FREE) the moment Close() frees real resources (the case the faiss vector cache guards against).

this might help:

if entry, ok := gc.cache[field]; ok {
    defer gc.m.RUnlock()
    return entry.load(except), nil
}

Comment thread geo_index_cache.go Outdated
Comment thread section_geo_shape_v2_index.go Outdated
Comment thread section_geo_shape_v2_index.go Outdated
Comment thread file_callbacks.go Outdated
Comment thread section_geo_shape_v2_index.go Outdated
@Likith101
Likith101 merged commit 6594f3d into master Aug 6, 2026
9 checks passed
@Likith101
Likith101 deleted the geo branch August 6, 2026 07:59
@github-project-automation github-project-automation Bot moved this from Todo to Done in Geo-Shape V2 Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants