Skip to content

Commit

Permalink
fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
kolesnikovae committed Apr 10, 2024
1 parent e3036ea commit 38b9edc
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion pkg/phlaredb/delta.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func newSampleDict(samples schemav1.Samples) map[uint32]uint64 {
return dict
}

func (d *deltaProfiles) computeDelta(ps schemav1.InMemoryProfile) schemav1.Samples {
func (d *deltaProfiles) computeDelta(ps *schemav1.InMemoryProfile) schemav1.Samples {
d.mtx.Lock()
defer d.mtx.Unlock()

Expand Down
2 changes: 1 addition & 1 deletion pkg/phlaredb/downsample/downsample_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func TestDownsampler_Aggregation(t *testing.T) {
}

func TestDownsampler_VaryingFingerprints(t *testing.T) {
profiles := make([]schemav1.InMemoryProfile, 0)
profiles := make([]*schemav1.InMemoryProfile, 0)
for i := 0; i < 5; i++ {
builder := testhelper.NewProfileBuilder(1703853310000000000).CPUProfile() // 2023-12-29T12:35:10Z
builder.ForStacktraceString("a", "b", "c").AddSamples(30)
Expand Down
2 changes: 1 addition & 1 deletion pkg/phlaredb/head.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func (h *Head) Ingest(ctx context.Context, p *profilev1.Profile, id uuid.UUID, e
continue
}

if err := h.profiles.ingest(ctx, []schemav1.InMemoryProfile{profile}, lbls[idxType], metricName); err != nil {
if err := h.profiles.ingest(ctx, []*schemav1.InMemoryProfile{profile}, lbls[idxType], metricName); err != nil {
return err
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/phlaredb/profile_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ func (s *profileStore) writeRowGroups(path string, rowGroups []parquet.RowGroup)
return n, numRowGroups, nil
}

func (s *profileStore) ingest(_ context.Context, profiles []schemav1.InMemoryProfile, lbs phlaremodel.Labels, profileName string) error {
func (s *profileStore) ingest(_ context.Context, profiles []*schemav1.InMemoryProfile, lbs phlaremodel.Labels, profileName string) error {
s.profilesLock.Lock()
defer s.profilesLock.Unlock()

Expand All @@ -400,15 +400,15 @@ func (s *profileStore) ingest(_ context.Context, profiles []schemav1.InMemoryPro
}

// add profile to the index
s.index.Add(&p, lbs, profileName)
s.index.Add(p, lbs, profileName)

// increase size of stored data
addedBytes := profiles[pos].Size()
s.metrics.sizeBytes.WithLabelValues(s.Name()).Set(float64(s.size.Add(addedBytes)))
s.totalSize.Add(addedBytes)

// add to slice
s.slice = append(s.slice, &p)
s.slice = append(s.slice, p)
s.metrics.samples.Add(float64(len(p.Samples.StacktraceIDs)))

}
Expand Down
8 changes: 4 additions & 4 deletions pkg/phlaredb/profile_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func TestProfileStore_RowGroupSplitting(t *testing.T) {

for i := 0; i < 100; i++ {
p := tc.values(i)
require.NoError(t, store.ingest(ctx, []schemav1.InMemoryProfile{p.p}, p.lbls, p.profileName))
require.NoError(t, store.ingest(ctx, []*schemav1.InMemoryProfile{&p.p}, p.lbls, p.profileName))
for store.flushing.Load() {
time.Sleep(time.Millisecond)
}
Expand Down Expand Up @@ -302,7 +302,7 @@ func TestProfileStore_Ingestion_SeriesIndexes(t *testing.T) {

for i := 0; i < 9; i++ {
p := threeProfileStreams(i)
require.NoError(t, store.ingest(ctx, []schemav1.InMemoryProfile{p.p}, p.lbls, p.profileName))
require.NoError(t, store.ingest(ctx, []*schemav1.InMemoryProfile{&p.p}, p.lbls, p.profileName))
}

// flush profiles and ensure the correct number of files are created
Expand Down Expand Up @@ -345,7 +345,7 @@ func BenchmarkFlush(b *testing.B) {
for i := 0; i < 10^6; i++ {
p := threeProfileStreams(i)
p.p.Samples = samples
require.NoError(b, store.ingest(ctx, []schemav1.InMemoryProfile{p.p}, p.lbls, p.profileName))
require.NoError(b, store.ingest(ctx, []*schemav1.InMemoryProfile{&p.p}, p.lbls, p.profileName))
}
require.NoError(b, store.cutRowGroup(len(store.slice)))
}
Expand Down Expand Up @@ -602,7 +602,7 @@ func TestRemoveFailedSegment(t *testing.T) {
require.NoError(t, store.Init(dir, defaultParquetConfig, contextHeadMetrics(context.Background())))
// fake a failed segment
_, err := os.Create(dir + "/profiles.0.parquet")
require.NoError(t, store.ingest(context.Background(), []schemav1.InMemoryProfile{{}}, phlaremodel.LabelsFromStrings(), "memory"))
require.NoError(t, store.ingest(context.Background(), []*schemav1.InMemoryProfile{{}}, phlaremodel.LabelsFromStrings(), "memory"))
require.NoError(t, err)
err = store.cutRowGroup(1)
require.NoError(t, err)
Expand Down
6 changes: 3 additions & 3 deletions pkg/phlaredb/symdb/dedup_slice.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var (
// - PartitionWriter should only rewrite profile symbol indices;
// - InMemoryProfile should be created somewhere else on the call side.

func (p *PartitionWriter) WriteProfileSymbols(profile *profilev1.Profile) []schemav1.InMemoryProfile {
func (p *PartitionWriter) WriteProfileSymbols(profile *profilev1.Profile) []*schemav1.InMemoryProfile {
// create a rewriter state
rewrites := &rewriter{}

Expand Down Expand Up @@ -87,9 +87,9 @@ func (p *PartitionWriter) WriteProfileSymbols(profile *profilev1.Profile) []sche
p.locations.ingest(locs, rewrites)
samplesPerType := p.convertSamples(rewrites, profile.Sample, spans)

profiles := make([]schemav1.InMemoryProfile, len(samplesPerType))
profiles := make([]*schemav1.InMemoryProfile, len(samplesPerType))
for idxType := range samplesPerType {
profiles[idxType] = schemav1.InMemoryProfile{
profiles[idxType] = &schemav1.InMemoryProfile{
StacktracePartition: p.header.Partition,
Samples: samplesPerType[idxType],
DropFrames: profile.DropFrames,
Expand Down
2 changes: 1 addition & 1 deletion pkg/phlaredb/symdb/symdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func (s *SymDB) newPartition(partition uint64) *PartitionWriter {
return &p
}

func (s *SymDB) WriteProfileSymbols(partition uint64, profile *profilev1.Profile) []schemav1.InMemoryProfile {
func (s *SymDB) WriteProfileSymbols(partition uint64, profile *profilev1.Profile) []*schemav1.InMemoryProfile {
return s.PartitionWriter(partition).WriteProfileSymbols(profile)
}

Expand Down

0 comments on commit 38b9edc

Please sign in to comment.