Skip to content

Commit 4e05972

Browse files
authored
Remove naive compactor. (#609)
1 parent 2e45fb2 commit 4e05972

File tree

6 files changed

+0
-346
lines changed

6 files changed

+0
-346
lines changed

pkg/synccompactor/benchmark_test.go

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"github.com/conductorone/baton-sdk/pkg/connectorstore"
1212
"github.com/conductorone/baton-sdk/pkg/dotc1z"
1313
"github.com/conductorone/baton-sdk/pkg/synccompactor/attached"
14-
"github.com/conductorone/baton-sdk/pkg/synccompactor/naive"
1514
"github.com/stretchr/testify/require"
1615
)
1716

@@ -209,66 +208,6 @@ func generateTestData(ctx context.Context, t *testing.B, tmpDir string, dataset
209208
return baseFile, baseSyncID, appliedFile, appliedSyncID
210209
}
211210

212-
// benchmarkNaiveCompactor runs a benchmark using the naive compactor.
213-
func benchmarkNaiveCompactor(b *testing.B, dataset BenchmarkData) {
214-
ctx := context.Background()
215-
216-
for b.Loop() {
217-
b.StopTimer()
218-
219-
// Create temporary directories
220-
tmpDir, err := os.MkdirTemp("", "benchmark-naive")
221-
require.NoError(b, err)
222-
defer os.RemoveAll(tmpDir)
223-
224-
outputDir, err := os.MkdirTemp("", "benchmark-output")
225-
require.NoError(b, err)
226-
defer os.RemoveAll(outputDir)
227-
228-
// Generate test data
229-
baseFile, _, appliedFile, _ := generateTestData(ctx, b, tmpDir, dataset)
230-
231-
opts := []dotc1z.C1ZOption{
232-
dotc1z.WithPragma("journal_mode", "WAL"),
233-
}
234-
235-
// Use naive compactor
236-
baseC1Z, err := dotc1z.NewC1ZFile(ctx, baseFile, opts...)
237-
require.NoError(b, err)
238-
defer baseC1Z.Close()
239-
240-
appliedC1Z, err := dotc1z.NewC1ZFile(ctx, appliedFile, opts...)
241-
require.NoError(b, err)
242-
defer appliedC1Z.Close()
243-
244-
destFile := filepath.Join(tmpDir, "naive-dest.c1z")
245-
destOpts := []dotc1z.C1ZOption{
246-
dotc1z.WithTmpDir(tmpDir),
247-
}
248-
destOpts = append(destOpts, opts...)
249-
destC1Z, err := dotc1z.NewC1ZFile(ctx, destFile, destOpts...)
250-
require.NoError(b, err)
251-
defer destC1Z.Close()
252-
253-
// Start a sync in the destination file
254-
_, err = destC1Z.StartNewSync(ctx, connectorstore.SyncTypeFull, "")
255-
require.NoError(b, err)
256-
257-
b.StartTimer()
258-
259-
// Benchmark the naive compaction
260-
naiveCompactor := naive.NewNaiveCompactor(baseC1Z, appliedC1Z, destC1Z)
261-
err = naiveCompactor.Compact(ctx)
262-
require.NoError(b, err)
263-
264-
b.StopTimer()
265-
266-
// End the sync
267-
err = destC1Z.EndSync(ctx)
268-
require.NoError(b, err)
269-
}
270-
}
271-
272211
// benchmarkAttachedCompactor runs a benchmark using the attached compactor.
273212
func benchmarkAttachedCompactor(b *testing.B, dataset BenchmarkData) {
274213
ctx := context.Background()
@@ -328,26 +267,14 @@ func benchmarkAttachedCompactor(b *testing.B, dataset BenchmarkData) {
328267

329268
// Benchmark functions for different data sizes and approaches
330269

331-
func BenchmarkNaiveCompactor_Small(b *testing.B) {
332-
benchmarkNaiveCompactor(b, SmallDataset)
333-
}
334-
335270
func BenchmarkAttachedCompactor_Small(b *testing.B) {
336271
benchmarkAttachedCompactor(b, SmallDataset)
337272
}
338273

339-
func BenchmarkNaiveCompactor_Medium(b *testing.B) {
340-
benchmarkNaiveCompactor(b, MediumDataset)
341-
}
342-
343274
func BenchmarkAttachedCompactor_Medium(b *testing.B) {
344275
benchmarkAttachedCompactor(b, MediumDataset)
345276
}
346277

347-
func BenchmarkNaiveCompactor_Large(b *testing.B) {
348-
benchmarkNaiveCompactor(b, LargeDataset)
349-
}
350-
351278
func BenchmarkAttachedCompactor_Large(b *testing.B) {
352279
benchmarkAttachedCompactor(b, LargeDataset)
353280
}

pkg/synccompactor/compactor.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
"github.com/conductorone/baton-sdk/pkg/sdk"
1717
"github.com/conductorone/baton-sdk/pkg/sync"
1818
"github.com/conductorone/baton-sdk/pkg/synccompactor/attached"
19-
"github.com/conductorone/baton-sdk/pkg/synccompactor/naive"
2019
"github.com/grpc-ecosystem/go-grpc-middleware/logging/zap/ctxzap"
2120
"go.opentelemetry.io/otel"
2221
"go.uber.org/zap"
@@ -330,13 +329,6 @@ func (c *Compactor) doOneCompaction(ctx context.Context, base *CompactableSync,
330329
}
331330

332331
switch c.compactorType {
333-
case CompactorTypeNaive:
334-
// TODO: Add support for syncID or remove naive compactor.
335-
runner := naive.NewNaiveCompactor(baseFile, appliedFile, newFile)
336-
if err := runner.Compact(ctx); err != nil {
337-
l.Error("error running compaction", zap.Error(err))
338-
return nil, err
339-
}
340332
case CompactorTypeAttached:
341333
runner := attached.NewAttachedCompactor(baseFile, appliedFile, newFile)
342334
if err := runner.CompactWithSyncID(ctx, newSyncId); err != nil {

pkg/synccompactor/compactor_test.go

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -36,27 +36,6 @@ func TestAttachedCompactorWithTmpDir(t *testing.T) {
3636
})
3737
}
3838

39-
func TestNaiveCompactorWithTmpDir(t *testing.T) {
40-
ctx := context.Background()
41-
42-
inputSyncsDir, err := os.MkdirTemp("", "compactor-test")
43-
require.NoError(t, err)
44-
defer os.RemoveAll(inputSyncsDir)
45-
46-
outputDir, err := os.MkdirTemp("", "compactor-output")
47-
require.NoError(t, err)
48-
defer os.RemoveAll(outputDir)
49-
50-
// Create temporary directory for intermediate files
51-
tmpDir, err := os.MkdirTemp("", "compactor-tmp")
52-
require.NoError(t, err)
53-
defer os.RemoveAll(tmpDir)
54-
55-
runCompactorTest(t, ctx, inputSyncsDir, func(compactableSyncs []*CompactableSync) (*Compactor, func() error, error) {
56-
return NewCompactor(ctx, outputDir, compactableSyncs, WithTmpDir(tmpDir), WithCompactorType(CompactorTypeNaive))
57-
})
58-
}
59-
6039
func runCompactorTest(t *testing.T, ctx context.Context, inputSyncsDir string, createCompactor func([]*CompactableSync) (*Compactor, func() error, error)) {
6140
opts := []dotc1z.C1ZOption{
6241
dotc1z.WithPragma("journal_mode", "WAL"),
@@ -732,10 +711,6 @@ func TestSyncTypeUnion_AttachedCompactor(t *testing.T) {
732711
runSyncTypeUnionTests(t, CompactorTypeAttached, getAllSyncTypeTestCases())
733712
}
734713

735-
func TestSyncTypeUnion_NaiveCompactor(t *testing.T) {
736-
runSyncTypeUnionTests(t, CompactorTypeNaive, getBasicSyncTypeTestCases())
737-
}
738-
739714
// getAllSyncTypeTestCases returns comprehensive test cases for sync type union logic.
740715
func getAllSyncTypeTestCases() []syncTypeTestCase {
741716
return []syncTypeTestCase{
@@ -817,32 +792,6 @@ func getAllSyncTypeTestCases() []syncTypeTestCase {
817792
}
818793
}
819794

820-
// getBasicSyncTypeTestCases returns a subset of test cases for basic validation.
821-
func getBasicSyncTypeTestCases() []syncTypeTestCase {
822-
return []syncTypeTestCase{
823-
{
824-
name: "Full + Partial = Full",
825-
input: []connectorstore.SyncType{connectorstore.SyncTypeFull, connectorstore.SyncTypePartial},
826-
expected: connectorstore.SyncTypeFull,
827-
},
828-
{
829-
name: "ResourcesOnly + Partial = ResourcesOnly",
830-
input: []connectorstore.SyncType{connectorstore.SyncTypeResourcesOnly, connectorstore.SyncTypePartial},
831-
expected: connectorstore.SyncTypeResourcesOnly,
832-
},
833-
{
834-
name: "Partial + Partial = Partial",
835-
input: []connectorstore.SyncType{connectorstore.SyncTypePartial, connectorstore.SyncTypePartial},
836-
expected: connectorstore.SyncTypePartial,
837-
},
838-
{
839-
name: "Full + ResourcesOnly + Partial = Full",
840-
input: []connectorstore.SyncType{connectorstore.SyncTypeFull, connectorstore.SyncTypeResourcesOnly, connectorstore.SyncTypePartial},
841-
expected: connectorstore.SyncTypeFull,
842-
},
843-
}
844-
}
845-
846795
type syncTypeTestCase struct {
847796
name string
848797
input []connectorstore.SyncType

pkg/synccompactor/naive/naive.go

Lines changed: 0 additions & 88 deletions
This file was deleted.

pkg/synccompactor/naive/naive_unroll.go

Lines changed: 0 additions & 98 deletions
This file was deleted.

0 commit comments

Comments
 (0)