From cde12f34d6e1c17082a4c8fd2062a471ee635836 Mon Sep 17 00:00:00 2001 From: CascadingRadium Date: Thu, 12 Jun 2025 01:38:46 +0530 Subject: [PATCH 01/12] first draft --- segment.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/segment.go b/segment.go index 122a28d..87e14fe 100644 --- a/segment.go +++ b/segment.go @@ -243,3 +243,9 @@ type Synonym interface { Size() int } + +type NestedSegment interface { + Segment + + NestedDictionary(field string, path string, arrayPosition int) (TermDictionary, error) +} From 6e5ec9ae441959e20a3a00b787f0b210a0aa774a Mon Sep 17 00:00:00 2001 From: CascadingRadium Date: Tue, 8 Jul 2025 00:56:32 +0530 Subject: [PATCH 02/12] interface change --- segment.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/segment.go b/segment.go index 87e14fe..9891d13 100644 --- a/segment.go +++ b/segment.go @@ -247,5 +247,5 @@ type Synonym interface { type NestedSegment interface { Segment - NestedDictionary(field string, path string, arrayPosition int) (TermDictionary, error) + NestedDictionary(nestedState index.NestedState, field string) (TermDictionary, error) } From 7d484f974408745f389246314a3a86fb951c603a Mon Sep 17 00:00:00 2001 From: CascadingRadium Date: Fri, 22 Aug 2025 17:11:14 +0530 Subject: [PATCH 03/12] new Ancestors() API --- segment.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/segment.go b/segment.go index 9891d13..6ffa184 100644 --- a/segment.go +++ b/segment.go @@ -247,5 +247,5 @@ type Synonym interface { type NestedSegment interface { Segment - NestedDictionary(nestedState index.NestedState, field string) (TermDictionary, error) + Ancestors(docID uint64) []uint64 } From 69d4841fac53b21fa3e65aa372d0c45e94ff1b03 Mon Sep 17 00:00:00 2001 From: Rahul Rampure Date: Sat, 13 Sep 2025 19:25:41 +0530 Subject: [PATCH 04/12] comments --- segment.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/segment.go b/segment.go index 6ffa184..729ac39 100644 --- a/segment.go +++ b/segment.go @@ -244,8 +244,17 @@ 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 document IDs for the given document ID. + // If the document has no ancestors or if the segment does not support nested documents, + // an empty slice is returned. Ancestors(docID uint64) []uint64 + + // Descendants returns a slice of descendant document IDs for the given document ID. + // If the document has no descendants or if the segment does not support nested documents, + // an empty slice is returned. + Descendants(docID uint64) []uint64 } From f18e31a34ceb4c3ad954120683a178bae724c963 Mon Sep 17 00:00:00 2001 From: Rahul Rampure Date: Tue, 14 Oct 2025 18:37:32 +0530 Subject: [PATCH 05/12] CountRoot API --- segment.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/segment.go b/segment.go index 729ac39..fcc6353 100644 --- a/segment.go +++ b/segment.go @@ -257,4 +257,10 @@ type NestedSegment interface { // If the document has no descendants or if the segment does not support nested documents, // an empty slice is returned. Descendants(docID uint64) []uint64 + + // 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 } From f652df9984bb8f1d6e7e95afd2da134ade463a72 Mon Sep 17 00:00:00 2001 From: Rahul Rampure Date: Tue, 14 Oct 2025 20:46:41 +0530 Subject: [PATCH 06/12] new API --- segment.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/segment.go b/segment.go index fcc6353..e64f6dd 100644 --- a/segment.go +++ b/segment.go @@ -263,4 +263,9 @@ type NestedSegment interface { // 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 } From 84ad4a02992220b5087fcc024bd9e36059750889 Mon Sep 17 00:00:00 2001 From: Rahul Rampure Date: Thu, 23 Oct 2025 19:58:37 +0530 Subject: [PATCH 07/12] remove descendants --- segment.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/segment.go b/segment.go index e64f6dd..79243cf 100644 --- a/segment.go +++ b/segment.go @@ -253,11 +253,6 @@ type NestedSegment interface { // an empty slice is returned. Ancestors(docID uint64) []uint64 - // Descendants returns a slice of descendant document IDs for the given document ID. - // If the document has no descendants or if the segment does not support nested documents, - // an empty slice is returned. - Descendants(docID uint64) []uint64 - // 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. From 0a12445b8ede620130e5ef9bba74725fdfeedf3a Mon Sep 17 00:00:00 2001 From: Rahul Rampure Date: Tue, 11 Nov 2025 11:38:42 +0530 Subject: [PATCH 08/12] HasNestedDocs API --- segment.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/segment.go b/segment.go index 79243cf..534e9f0 100644 --- a/segment.go +++ b/segment.go @@ -248,6 +248,8 @@ type Synonym interface { // to provide access to nested document relationships within that segment. type NestedSegment interface { Segment + // HasNestedDocs checks if the segment has any documents with ancestry (i.e., nested documents). + HasNestedDocs() bool // Ancestors returns a slice of ancestor document IDs for the given document ID. // If the document has no ancestors or if the segment does not support nested documents, // an empty slice is returned. From 63c885dd31a443f0752ce936b6cb8db7a04d4148 Mon Sep 17 00:00:00 2001 From: Rahul Rampure Date: Tue, 11 Nov 2025 13:29:16 +0530 Subject: [PATCH 09/12] remove API --- segment.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/segment.go b/segment.go index 534e9f0..79243cf 100644 --- a/segment.go +++ b/segment.go @@ -248,8 +248,6 @@ type Synonym interface { // to provide access to nested document relationships within that segment. type NestedSegment interface { Segment - // HasNestedDocs checks if the segment has any documents with ancestry (i.e., nested documents). - HasNestedDocs() bool // Ancestors returns a slice of ancestor document IDs for the given document ID. // If the document has no ancestors or if the segment does not support nested documents, // an empty slice is returned. From 846c521200d8105277fde9e3badbcc0e52867850 Mon Sep 17 00:00:00 2001 From: Rahul Rampure Date: Wed, 26 Nov 2025 20:19:13 +0530 Subject: [PATCH 10/12] interface change --- segment.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/segment.go b/segment.go index 79243cf..1b6414f 100644 --- a/segment.go +++ b/segment.go @@ -248,10 +248,10 @@ type Synonym interface { // to provide access to nested document relationships within that segment. type NestedSegment interface { Segment - // Ancestors returns a slice of ancestor document IDs for the given document ID. + // 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, - // an empty slice is returned. - Ancestors(docID uint64) []uint64 + // a slice containing only the document ID itself is returned. + Ancestors(docID uint64) []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 From eb5ca51b4f190c1481f6989d4e59299e391c5b49 Mon Sep 17 00:00:00 2001 From: Rahul Rampure Date: Thu, 27 Nov 2025 12:17:34 +0530 Subject: [PATCH 11/12] allow prealloc --- segment.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/segment.go b/segment.go index 1b6414f..4e2dbad 100644 --- a/segment.go +++ b/segment.go @@ -251,7 +251,7 @@ type NestedSegment interface { // 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) []index.AncestorID + 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 From dcaa538608be831f410bb1a9a67f3ce72f3254e6 Mon Sep 17 00:00:00 2001 From: Rahul Rampure Date: Tue, 2 Dec 2025 15:12:49 +0530 Subject: [PATCH 12/12] update workflows --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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: