diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 68da8e7..e0c425b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -8,7 +8,7 @@ jobs: test: strategy: matrix: - go-version: [1.21.x, 1.22.x, 1.23.x] + go-version: [1.23.x, 1.24.x, 1.25.x] platform: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.platform }} steps: diff --git a/segment.go b/segment.go index 122a28d..4e2dbad 100644 --- a/segment.go +++ b/segment.go @@ -243,3 +243,24 @@ type Synonym interface { Size() int } + +// NestedSegment is an optional interface that a Segment may implement +// to provide access to nested document relationships within that segment. +type NestedSegment interface { + Segment + // Ancestors returns a slice of ancestor IDs for the given document ID. + // If the document has no ancestors or if the segment does not support nested documents, + // a slice containing only the document ID itself is returned. + Ancestors(docID uint64, prealloc []index.AncestorID) []index.AncestorID + + // CountRoot returns the number of root documents in the segment, excluding any documents + // that are marked as deleted in the provided bitmap. If the segment does not support nested + // documents, it returns the total document count minus the count of deleted documents. + // A root document is defined as a document that is not a child of any other document. + CountRoot(deleted *roaring.Bitmap) uint64 + + // AddNestedDocuments updates the provided bitmap to include all nested documents + // associated with documents marked as deleted in the bitmap. This ensures that when + // a parent document is deleted, all its nested child documents are also considered deleted. + AddNestedDocuments(deleted *roaring.Bitmap) *roaring.Bitmap +}