diff --git a/internal/core/data.go b/internal/core/data.go index a9bcac7f00..4fdfe2b14d 100644 --- a/internal/core/data.go +++ b/internal/core/data.go @@ -17,40 +17,22 @@ import ( ) // Span is a range of keys from [Start, End). -type Span interface { - // Start returns the starting key of the Span. - Start() keys.DataStoreKey - // End returns the ending key of the Span. - End() keys.DataStoreKey - // Compare returns -1 if the provided span is less, 0 if it is equal, and 1 if its greater. - Compare(Span) SpanComparisonResult -} +type Span struct { + // Start represents the starting key of the Span. + Start keys.DataStoreKey -type span struct { - start keys.DataStoreKey - end keys.DataStoreKey + // End represents the ending key of the Span. + End keys.DataStoreKey } -var _ Span = span{} - // NewSpan creates a new Span from the provided start and end keys. func NewSpan(start, end keys.DataStoreKey) Span { - return span{ - start: start, - end: end, + return Span{ + Start: start, + End: end, } } -// Start returns the starting key of the Span. -func (s span) Start() keys.DataStoreKey { - return s.start -} - -// End returns the ending key of the Span. -func (s span) End() keys.DataStoreKey { - return s.end -} - // SpanComparisonResult is the result of comparing two spans. type SpanComparisonResult uint @@ -73,18 +55,18 @@ const ( // Compares two spans returning how the compare to each other. // If the end of one span is adjacent to the other (with no gap possible) // then those ends are considered equal. -func (this span) Compare(other Span) SpanComparisonResult { +func (this Span) Compare(other Span) SpanComparisonResult { if this == other { return Equal } - thisStart := this.start.ToString() - thisEnd := this.end.ToString() - otherStart := other.Start().ToString() - otherEnd := other.End().ToString() + thisStart := this.Start.ToString() + thisEnd := this.End.ToString() + otherStart := other.Start.ToString() + otherEnd := other.End.ToString() if thisStart < otherStart { - if thisEnd == otherStart || isAdjacent(this.end, other.Start()) { + if thisEnd == otherStart || isAdjacent(this.End, other.Start) { return StartBeforeEndEqualToStart } @@ -133,7 +115,7 @@ func (this span) Compare(other Span) SpanComparisonResult { } } - if thisStart == otherEnd || isAdjacent(this.start, other.End()) { + if thisStart == otherEnd || isAdjacent(this.Start, other.End) { return StartEqualToEndEndAfter } @@ -172,7 +154,7 @@ func MergeAscending(spans []Span) []Span { } // Then we insert - newArray[i] = NewSpan(span.Start(), span.End()) + newArray[i] = NewSpan(span.Start, span.End) // Move the values prior to the new one across for j := 0; j < i; j++ { @@ -183,12 +165,12 @@ func MergeAscending(spans []Span) []Span { // Exit the unique-span loop, this span has been handled i = len(uniqueSpans) case StartBeforeEndEqualToStart, StartBeforeEndWithin, StartBeforeEndEqual: - uniqueSpans[i] = NewSpan(span.Start(), uniqueSpan.End()) + uniqueSpans[i] = NewSpan(span.Start, uniqueSpan.End) uniqueSpanFound = true i++ case StartBeforeEndAfter: - uniqueSpans = removeBefore(uniqueSpans, i, span.End().ToString()) - uniqueSpans[i] = NewSpan(span.Start(), span.End()) + uniqueSpans = removeBefore(uniqueSpans, i, span.End.ToString()) + uniqueSpans[i] = NewSpan(span.Start, span.End) uniqueSpanFound = true // Exit the unique-span loop, this span has been handled i = len(uniqueSpans) @@ -197,8 +179,8 @@ func MergeAscending(spans []Span) []Span { // Do nothing, span is contained within an existing unique-span i = len(uniqueSpans) case StartEqualEndAfter, StartWithinEndAfter, StartEqualToEndEndAfter: - uniqueSpans = removeBefore(uniqueSpans, i, span.End().ToString()) - uniqueSpans[i] = NewSpan(uniqueSpan.Start(), span.End()) + uniqueSpans = removeBefore(uniqueSpans, i, span.End.ToString()) + uniqueSpans[i] = NewSpan(uniqueSpan.Start, span.End) uniqueSpanFound = true // Exit the unique-span loop, this span has been handled i = len(uniqueSpans) @@ -220,7 +202,7 @@ func MergeAscending(spans []Span) []Span { func removeBefore(spans []Span, startIndex int, end string) []Span { indexOfLastMatchingItem := -1 for i := startIndex; i < len(spans); i++ { - if spans[i].End().ToString() <= end { + if spans[i].End.ToString() <= end { indexOfLastMatchingItem = i } } diff --git a/internal/core/data_test.go b/internal/core/data_test.go index d55851b795..154441819e 100644 --- a/internal/core/data_test.go +++ b/internal/core/data_test.go @@ -34,8 +34,8 @@ func TestMergeAscending_ReturnsSingle_GivenSingle(t *testing.T) { result := MergeAscending(input) assert.Len(t, result, 1) - assert.Equal(t, start1, result[0].Start()) - assert.Equal(t, end1, result[0].End()) + assert.Equal(t, start1, result[0].Start) + assert.Equal(t, end1, result[0].End) } func TestMergeAscending_ReturnsSecondBeforeFirst_GivenKeysInReverseOrder(t *testing.T) { @@ -52,10 +52,10 @@ func TestMergeAscending_ReturnsSecondBeforeFirst_GivenKeysInReverseOrder(t *test result := MergeAscending(input) assert.Len(t, result, 2) - assert.Equal(t, start2, result[0].Start()) - assert.Equal(t, end2, result[0].End()) - assert.Equal(t, start1, result[1].Start()) - assert.Equal(t, end1, result[1].End()) + assert.Equal(t, start2, result[0].Start) + assert.Equal(t, end2, result[0].End) + assert.Equal(t, start1, result[1].Start) + assert.Equal(t, end1, result[1].End) } func TestMergeAscending_ReturnsItemsInOrder_GivenKeysInMixedOrder(t *testing.T) { @@ -75,13 +75,13 @@ func TestMergeAscending_ReturnsItemsInOrder_GivenKeysInMixedOrder(t *testing.T) result := MergeAscending(input) assert.Len(t, result, 3) - assert.Equal(t, start1, result[0].Start()) - assert.Equal(t, end1, result[0].End()) + assert.Equal(t, start1, result[0].Start) + assert.Equal(t, end1, result[0].End) // Span 3 should be returned between one and two - assert.Equal(t, start3, result[1].Start()) - assert.Equal(t, end3, result[1].End()) - assert.Equal(t, start2, result[2].Start()) - assert.Equal(t, end2, result[2].End()) + assert.Equal(t, start3, result[1].Start) + assert.Equal(t, end3, result[1].End) + assert.Equal(t, start2, result[2].Start) + assert.Equal(t, end2, result[2].End) } func TestMergeAscending_ReturnsSingle_GivenStartBeforeEndEqualToStart(t *testing.T) { @@ -97,8 +97,8 @@ func TestMergeAscending_ReturnsSingle_GivenStartBeforeEndEqualToStart(t *testing result := MergeAscending(input) assert.Len(t, result, 1) - assert.Equal(t, start2, result[0].Start()) - assert.Equal(t, end1, result[0].End()) + assert.Equal(t, start2, result[0].Start) + assert.Equal(t, end1, result[0].End) } func TestMergeAscending_ReturnsSingle_GivenStartBeforeEndAdjacentToStart(t *testing.T) { @@ -114,8 +114,8 @@ func TestMergeAscending_ReturnsSingle_GivenStartBeforeEndAdjacentToStart(t *test result := MergeAscending(input) assert.Len(t, result, 1) - assert.Equal(t, start2, result[0].Start()) - assert.Equal(t, end1, result[0].End()) + assert.Equal(t, start2, result[0].Start) + assert.Equal(t, end1, result[0].End) } func TestMergeAscending_ReturnsSingle_GivenStartBeforeEndWithin(t *testing.T) { @@ -131,8 +131,8 @@ func TestMergeAscending_ReturnsSingle_GivenStartBeforeEndWithin(t *testing.T) { result := MergeAscending(input) assert.Len(t, result, 1) - assert.Equal(t, start2, result[0].Start()) - assert.Equal(t, end1, result[0].End()) + assert.Equal(t, start2, result[0].Start) + assert.Equal(t, end1, result[0].End) } func TestMergeAscending_ReturnsSingle_GivenStartPrefixesEndWithin(t *testing.T) { @@ -148,8 +148,8 @@ func TestMergeAscending_ReturnsSingle_GivenStartPrefixesEndWithin(t *testing.T) result := MergeAscending(input) assert.Len(t, result, 1) - assert.Equal(t, start2, result[0].Start()) - assert.Equal(t, end1, result[0].End()) + assert.Equal(t, start2, result[0].Start) + assert.Equal(t, end1, result[0].End) } func TestMergeAscending_ReturnsSingle_GivenStartBeforeEndWithinEndPrefix(t *testing.T) { @@ -165,8 +165,8 @@ func TestMergeAscending_ReturnsSingle_GivenStartBeforeEndWithinEndPrefix(t *test result := MergeAscending(input) assert.Len(t, result, 1) - assert.Equal(t, start2, result[0].Start()) - assert.Equal(t, end1, result[0].End()) + assert.Equal(t, start2, result[0].Start) + assert.Equal(t, end1, result[0].End) } func TestMergeAscending_ReturnsSingle_GivenStartPrefixesEndWithinEndPrefix(t *testing.T) { @@ -182,8 +182,8 @@ func TestMergeAscending_ReturnsSingle_GivenStartPrefixesEndWithinEndPrefix(t *te result := MergeAscending(input) assert.Len(t, result, 1) - assert.Equal(t, start2, result[0].Start()) - assert.Equal(t, end1, result[0].End()) + assert.Equal(t, start2, result[0].Start) + assert.Equal(t, end1, result[0].End) } func TestMergeAscending_ReturnsSingle_GivenStartBeforeEndEqual(t *testing.T) { @@ -199,8 +199,8 @@ func TestMergeAscending_ReturnsSingle_GivenStartBeforeEndEqual(t *testing.T) { result := MergeAscending(input) assert.Len(t, result, 1) - assert.Equal(t, start2, result[0].Start()) - assert.Equal(t, end1, result[0].End()) + assert.Equal(t, start2, result[0].Start) + assert.Equal(t, end1, result[0].End) } func TestMergeAscending_ReturnsSingle_GivenStartBeforeEndAdjacentAndBefore(t *testing.T) { @@ -216,8 +216,8 @@ func TestMergeAscending_ReturnsSingle_GivenStartBeforeEndAdjacentAndBefore(t *te result := MergeAscending(input) assert.Len(t, result, 1) - assert.Equal(t, start2, result[0].Start()) - assert.Equal(t, end1, result[0].End()) + assert.Equal(t, start2, result[0].Start) + assert.Equal(t, end1, result[0].End) } func TestMergeAscending_ReturnsSingle_GivenStartBeforeEndAdjacentAndGreater(t *testing.T) { @@ -233,8 +233,8 @@ func TestMergeAscending_ReturnsSingle_GivenStartBeforeEndAdjacentAndGreater(t *t result := MergeAscending(input) assert.Len(t, result, 1) - assert.Equal(t, start2, result[0].Start()) - assert.Equal(t, end2, result[0].End()) + assert.Equal(t, start2, result[0].Start) + assert.Equal(t, end2, result[0].End) } func TestMergeAscending_ReturnsSingle_GivenStartPrefixesEndEqual(t *testing.T) { @@ -250,8 +250,8 @@ func TestMergeAscending_ReturnsSingle_GivenStartPrefixesEndEqual(t *testing.T) { result := MergeAscending(input) assert.Len(t, result, 1) - assert.Equal(t, start2, result[0].Start()) - assert.Equal(t, end1, result[0].End()) + assert.Equal(t, start2, result[0].Start) + assert.Equal(t, end1, result[0].End) } func TestMergeAscending_ReturnsSingle_GivenStartPrefixesEndAdjacentAndBefore(t *testing.T) { @@ -267,8 +267,8 @@ func TestMergeAscending_ReturnsSingle_GivenStartPrefixesEndAdjacentAndBefore(t * result := MergeAscending(input) assert.Len(t, result, 1) - assert.Equal(t, start2, result[0].Start()) - assert.Equal(t, end1, result[0].End()) + assert.Equal(t, start2, result[0].Start) + assert.Equal(t, end1, result[0].End) } func TestMergeAscending_ReturnsSingle_GivenStartPrefixesEndAdjacentAndAfter(t *testing.T) { @@ -284,8 +284,8 @@ func TestMergeAscending_ReturnsSingle_GivenStartPrefixesEndAdjacentAndAfter(t *t result := MergeAscending(input) assert.Len(t, result, 1) - assert.Equal(t, start2, result[0].Start()) - assert.Equal(t, end2, result[0].End()) + assert.Equal(t, start2, result[0].Start) + assert.Equal(t, end2, result[0].End) } func TestMergeAscending_ReturnsMiddleSpansMerged_GivenSpanCoveringMiddleSpans(t *testing.T) { @@ -310,13 +310,13 @@ func TestMergeAscending_ReturnsMiddleSpansMerged_GivenSpanCoveringMiddleSpans(t result := MergeAscending(input) assert.Len(t, result, 3) - assert.Equal(t, start1, result[0].Start()) - assert.Equal(t, end1, result[0].End()) + assert.Equal(t, start1, result[0].Start) + assert.Equal(t, end1, result[0].End) // Spans 2 and 3 are within span 5 - assert.Equal(t, start5, result[1].Start()) - assert.Equal(t, end5, result[1].End()) - assert.Equal(t, start4, result[2].Start()) - assert.Equal(t, end4, result[2].End()) + assert.Equal(t, start5, result[1].Start) + assert.Equal(t, end5, result[1].End) + assert.Equal(t, start4, result[2].Start) + assert.Equal(t, end4, result[2].End) } func TestMergeAscending_ReturnsSingle_GivenStartEqualEndWithin(t *testing.T) { @@ -332,8 +332,8 @@ func TestMergeAscending_ReturnsSingle_GivenStartEqualEndWithin(t *testing.T) { result := MergeAscending(input) assert.Len(t, result, 1) - assert.Equal(t, start1, result[0].Start()) - assert.Equal(t, end1, result[0].End()) + assert.Equal(t, start1, result[0].Start) + assert.Equal(t, end1, result[0].End) } func TestMergeAscending_ReturnsSingle_GivenStartEqualEndWithinEndPrefix(t *testing.T) { @@ -349,8 +349,8 @@ func TestMergeAscending_ReturnsSingle_GivenStartEqualEndWithinEndPrefix(t *testi result := MergeAscending(input) assert.Len(t, result, 1) - assert.Equal(t, start1, result[0].Start()) - assert.Equal(t, end1, result[0].End()) + assert.Equal(t, start1, result[0].Start) + assert.Equal(t, end1, result[0].End) } func TestMergeAscending_ReturnsSingle_GivenDuplicates(t *testing.T) { @@ -364,8 +364,8 @@ func TestMergeAscending_ReturnsSingle_GivenDuplicates(t *testing.T) { result := MergeAscending(input) assert.Len(t, result, 1) - assert.Equal(t, start1, result[0].Start()) - assert.Equal(t, end1, result[0].End()) + assert.Equal(t, start1, result[0].Start) + assert.Equal(t, end1, result[0].End) } func TestMergeAscending_ReturnsSingle_GivenStartWithinEndWithin(t *testing.T) { @@ -381,8 +381,8 @@ func TestMergeAscending_ReturnsSingle_GivenStartWithinEndWithin(t *testing.T) { result := MergeAscending(input) assert.Len(t, result, 1) - assert.Equal(t, start1, result[0].Start()) - assert.Equal(t, end1, result[0].End()) + assert.Equal(t, start1, result[0].Start) + assert.Equal(t, end1, result[0].End) } func TestMergeAscending_ReturnsSingle_GivenStartWithinEndWithinEndPrefix(t *testing.T) { @@ -398,8 +398,8 @@ func TestMergeAscending_ReturnsSingle_GivenStartWithinEndWithinEndPrefix(t *test result := MergeAscending(input) assert.Len(t, result, 1) - assert.Equal(t, start1, result[0].Start()) - assert.Equal(t, end1, result[0].End()) + assert.Equal(t, start1, result[0].Start) + assert.Equal(t, end1, result[0].End) } func TestMergeAscending_ReturnsSingle_GivenStartWithinEndEqual(t *testing.T) { @@ -415,8 +415,8 @@ func TestMergeAscending_ReturnsSingle_GivenStartWithinEndEqual(t *testing.T) { result := MergeAscending(input) assert.Len(t, result, 1) - assert.Equal(t, start1, result[0].Start()) - assert.Equal(t, end1, result[0].End()) + assert.Equal(t, start1, result[0].Start) + assert.Equal(t, end1, result[0].End) } func TestMergeAscending_ReturnsSingle_GivenStartWithinEndAdjacentAndBefore(t *testing.T) { @@ -432,8 +432,8 @@ func TestMergeAscending_ReturnsSingle_GivenStartWithinEndAdjacentAndBefore(t *te result := MergeAscending(input) assert.Len(t, result, 1) - assert.Equal(t, start1, result[0].Start()) - assert.Equal(t, end1, result[0].End()) + assert.Equal(t, start1, result[0].Start) + assert.Equal(t, end1, result[0].End) } func TestMergeAscending_ReturnsSingle_GivenStartWithinEndAdjacentAndAfter(t *testing.T) { @@ -449,8 +449,8 @@ func TestMergeAscending_ReturnsSingle_GivenStartWithinEndAdjacentAndAfter(t *tes result := MergeAscending(input) assert.Len(t, result, 1) - assert.Equal(t, start1, result[0].Start()) - assert.Equal(t, end2, result[0].End()) + assert.Equal(t, start1, result[0].Start) + assert.Equal(t, end2, result[0].End) } func TestMergeAscending_ReturnsMiddleSpansMerged_GivenStartEqualEndAfterSpanCoveringMiddleSpans( @@ -477,13 +477,13 @@ func TestMergeAscending_ReturnsMiddleSpansMerged_GivenStartEqualEndAfterSpanCove result := MergeAscending(input) assert.Len(t, result, 3) - assert.Equal(t, start1, result[0].Start()) - assert.Equal(t, end1, result[0].End()) + assert.Equal(t, start1, result[0].Start) + assert.Equal(t, end1, result[0].End) // Spans 2 and 3 are within span 5 - assert.Equal(t, start5, result[1].Start()) - assert.Equal(t, end5, result[1].End()) - assert.Equal(t, start4, result[2].Start()) - assert.Equal(t, end4, result[2].End()) + assert.Equal(t, start5, result[1].Start) + assert.Equal(t, end5, result[1].End) + assert.Equal(t, start4, result[2].Start) + assert.Equal(t, end4, result[2].End) } func TestMergeAscending_ReturnsMiddleSpansMerged_GivenStartWithinEndAfterSpanCoveringMiddleSpans( @@ -510,12 +510,12 @@ func TestMergeAscending_ReturnsMiddleSpansMerged_GivenStartWithinEndAfterSpanCov result := MergeAscending(input) assert.Len(t, result, 3) - assert.Equal(t, start1, result[0].Start()) - assert.Equal(t, end1, result[0].End()) - assert.Equal(t, start2, result[1].Start()) - assert.Equal(t, end5, result[1].End()) - assert.Equal(t, start4, result[2].Start()) - assert.Equal(t, end4, result[2].End()) + assert.Equal(t, start1, result[0].Start) + assert.Equal(t, end1, result[0].End) + assert.Equal(t, start2, result[1].Start) + assert.Equal(t, end5, result[1].End) + assert.Equal(t, start4, result[2].Start) + assert.Equal(t, end4, result[2].End) } func TestMergeAscending_ReturnsMiddleSpansMerged_GivenStartEqualToEndEndAfterSpanCoveringMiddleSpans( @@ -542,12 +542,12 @@ func TestMergeAscending_ReturnsMiddleSpansMerged_GivenStartEqualToEndEndAfterSpa result := MergeAscending(input) assert.Len(t, result, 3) - assert.Equal(t, start1, result[0].Start()) - assert.Equal(t, end1, result[0].End()) - assert.Equal(t, start2, result[1].Start()) - assert.Equal(t, end5, result[1].End()) - assert.Equal(t, start4, result[2].Start()) - assert.Equal(t, end4, result[2].End()) + assert.Equal(t, start1, result[0].Start) + assert.Equal(t, end1, result[0].End) + assert.Equal(t, start2, result[1].Start) + assert.Equal(t, end5, result[1].End) + assert.Equal(t, start4, result[2].Start) + assert.Equal(t, end4, result[2].End) } func TestMergeAscending_ReturnsMiddleSpansMerged_GivenStartAdjacentAndBeforeEndEndAfterSpanCoveringMiddleSpans( @@ -574,12 +574,12 @@ func TestMergeAscending_ReturnsMiddleSpansMerged_GivenStartAdjacentAndBeforeEndE result := MergeAscending(input) assert.Len(t, result, 3) - assert.Equal(t, start1, result[0].Start()) - assert.Equal(t, end1, result[0].End()) - assert.Equal(t, start2, result[1].Start()) - assert.Equal(t, end5, result[1].End()) - assert.Equal(t, start4, result[2].Start()) - assert.Equal(t, end4, result[2].End()) + assert.Equal(t, start1, result[0].Start) + assert.Equal(t, end1, result[0].End) + assert.Equal(t, start2, result[1].Start) + assert.Equal(t, end5, result[1].End) + assert.Equal(t, start4, result[2].Start) + assert.Equal(t, end4, result[2].End) } func TestMergeAscending_ReturnsMiddleSpansMerged_GivenStartAdjacentAndAfterEndEndAfterSpanCoveringMiddleSpans( @@ -606,12 +606,12 @@ func TestMergeAscending_ReturnsMiddleSpansMerged_GivenStartAdjacentAndAfterEndEn result := MergeAscending(input) assert.Len(t, result, 3) - assert.Equal(t, start1, result[0].Start()) - assert.Equal(t, end1, result[0].End()) - assert.Equal(t, start2, result[1].Start()) - assert.Equal(t, end5, result[1].End()) - assert.Equal(t, start4, result[2].Start()) - assert.Equal(t, end4, result[2].End()) + assert.Equal(t, start1, result[0].Start) + assert.Equal(t, end1, result[0].End) + assert.Equal(t, start2, result[1].Start) + assert.Equal(t, end5, result[1].End) + assert.Equal(t, start4, result[2].Start) + assert.Equal(t, end4, result[2].End) } func TestMergeAscending_ReturnsTwoItems_GivenSecondItemAfterFirst(t *testing.T) { @@ -627,10 +627,10 @@ func TestMergeAscending_ReturnsTwoItems_GivenSecondItemAfterFirst(t *testing.T) result := MergeAscending(input) assert.Len(t, result, 2) - assert.Equal(t, start1, result[0].Start()) - assert.Equal(t, end1, result[0].End()) - assert.Equal(t, start2, result[1].Start()) - assert.Equal(t, end2, result[1].End()) + assert.Equal(t, start1, result[0].Start) + assert.Equal(t, end1, result[0].End) + assert.Equal(t, start2, result[1].Start) + assert.Equal(t, end2, result[1].End) } func TestMergeAscending_ReturnsSingle_GivenStartAdjacentAndBeforeEndEndEqual(t *testing.T) { @@ -646,8 +646,8 @@ func TestMergeAscending_ReturnsSingle_GivenStartAdjacentAndBeforeEndEndEqual(t * result := MergeAscending(input) assert.Len(t, result, 1) - assert.Equal(t, start1, result[0].Start()) - assert.Equal(t, end2, result[0].End()) + assert.Equal(t, start1, result[0].Start) + assert.Equal(t, end2, result[0].End) } func TestMergeAscending_ReturnsSingle_GivenStartAdjacentAndBeforeEndEndAdjacentAndAfter( @@ -665,8 +665,8 @@ func TestMergeAscending_ReturnsSingle_GivenStartAdjacentAndBeforeEndEndAdjacentA result := MergeAscending(input) assert.Len(t, result, 1) - assert.Equal(t, start1, result[0].Start()) - assert.Equal(t, end2, result[0].End()) + assert.Equal(t, start1, result[0].Start) + assert.Equal(t, end2, result[0].End) } func TestMergeAscending_ReturnsSingle_GivenStartAdjacentAndBeforeEndEndAfter(t *testing.T) { @@ -682,8 +682,8 @@ func TestMergeAscending_ReturnsSingle_GivenStartAdjacentAndBeforeEndEndAfter(t * result := MergeAscending(input) assert.Len(t, result, 1) - assert.Equal(t, start1, result[0].Start()) - assert.Equal(t, end2, result[0].End()) + assert.Equal(t, start1, result[0].Start) + assert.Equal(t, end2, result[0].End) } func TestMergeAscending_ReturnsSingle_GivenStartAdjacentAndAfterEndEndAfter(t *testing.T) { @@ -699,6 +699,6 @@ func TestMergeAscending_ReturnsSingle_GivenStartAdjacentAndAfterEndEndAfter(t *t result := MergeAscending(input) assert.Len(t, result, 1) - assert.Equal(t, start1, result[0].Start()) - assert.Equal(t, end2, result[0].End()) + assert.Equal(t, start1, result[0].Start) + assert.Equal(t, end2, result[0].End) } diff --git a/internal/db/fetcher/dag.go b/internal/db/fetcher/dag.go index f8206aa648..3fae50c52b 100644 --- a/internal/db/fetcher/dag.go +++ b/internal/db/fetcher/dag.go @@ -54,14 +54,14 @@ func (hf *HeadFetcher) Start( // compare by strings if i < j. // apply the '!= df.reverse' to reverse the sort // if we need to - return (strings.Compare(spans[i].Start().ToString(), spans[j].Start().ToString()) < 0) + return (strings.Compare(spans[i].Start.ToString(), spans[j].Start.ToString()) < 0) }) } hf.spans = spans hf.fieldId = fieldId q := dsq.Query{ - Prefix: hf.spans[0].Start().ToString(), + Prefix: hf.spans[0].Start.ToString(), Orders: []dsq.Order{dsq.OrderByKey{}}, } diff --git a/internal/db/fetcher/fetcher.go b/internal/db/fetcher/fetcher.go index dd13877fce..e273b69318 100644 --- a/internal/db/fetcher/fetcher.go +++ b/internal/db/fetcher/fetcher.go @@ -280,9 +280,9 @@ func (df *DocumentFetcher) start(ctx context.Context, spans []core.Span, withDel for i, span := range spans { // We can only handle value keys, so here we ensure we only read value keys if withDeleted { - valueSpans[i] = core.NewSpan(span.Start().WithDeletedFlag(), span.End().WithDeletedFlag()) + valueSpans[i] = core.NewSpan(span.Start.WithDeletedFlag(), span.End.WithDeletedFlag()) } else { - valueSpans[i] = core.NewSpan(span.Start().WithValueFlag(), span.End().WithValueFlag()) + valueSpans[i] = core.NewSpan(span.Start.WithValueFlag(), span.End.WithValueFlag()) } } @@ -331,7 +331,7 @@ func (df *DocumentFetcher) startNextSpan(ctx context.Context) (bool, error) { } span := df.spans[nextSpanIndex] - df.kvResultsIter, err = df.kvIter.IteratePrefix(ctx, span.Start().ToDS(), span.End().ToDS()) + df.kvResultsIter, err = df.kvIter.IteratePrefix(ctx, span.Start.ToDS(), span.End.ToDS()) if err != nil { return false, err } diff --git a/internal/db/fetcher/versioned.go b/internal/db/fetcher/versioned.go index 29702325bf..c2ea4e2cac 100644 --- a/internal/db/fetcher/versioned.go +++ b/internal/db/fetcher/versioned.go @@ -164,8 +164,8 @@ func (vf *VersionedFetcher) Start(ctx context.Context, spans ...core.Span) error // For the VersionedFetcher, the spans needs to be in the format // Span{Start: DocID, End: CID} - dk := spans[0].Start() - cidRaw := spans[0].End() + dk := spans[0].Start + cidRaw := spans[0].End if dk.DocID == "" { return client.NewErrUninitializeProperty("Spans", "DocID") } else if cidRaw.DocID == "" { // todo: dont abuse DataStoreKey/Span like this! diff --git a/internal/planner/commit.go b/internal/planner/commit.go index f92a7c0101..0df6657295 100644 --- a/internal/planner/commit.go +++ b/internal/planner/commit.go @@ -109,8 +109,8 @@ func (n *dagScanNode) Spans(spans []core.Span) { } for i, span := range headSetSpans { - if span.Start().FieldID != fieldID { - headSetSpans[i] = core.NewSpan(span.Start().WithFieldID(fieldID), keys.DataStoreKey{}) + if span.Start.FieldID != fieldID { + headSetSpans[i] = core.NewSpan(span.Start.WithFieldID(fieldID), keys.DataStoreKey{}) } } @@ -147,8 +147,8 @@ func (n *dagScanNode) simpleExplain() (map[string]any, error) { spansExplainer = append( spansExplainer, map[string]any{ - "start": span.Start().ToString(), - "end": span.End().ToString(), + "start": span.Start.ToString(), + "end": span.End.ToString(), }, ) } diff --git a/internal/planner/scan.go b/internal/planner/scan.go index a36a5eed4a..a010e9de1b 100644 --- a/internal/planner/scan.go +++ b/internal/planner/scan.go @@ -265,8 +265,8 @@ func (n *scanNode) explainSpans() []map[string]any { spanExplainer := map[string]any{ // These must be pretty printed as the explain results need to be returnable // as json via some clients (e.g. http and cli) - "start": span.Start().PrettyPrint(), - "end": span.End().PrettyPrint(), + "start": span.Start.PrettyPrint(), + "end": span.End.PrettyPrint(), } spansExplainer = append(spansExplainer, spanExplainer)