Fix to avro reader

This commit is contained in:
Aditya Ujeniya
2025-10-27 20:44:40 +01:00
parent 856ccbb969
commit 44e98e8f2f
5 changed files with 73 additions and 7 deletions

View File

@@ -492,6 +492,32 @@ func (l *Level) loadAvroFile(m *MemoryStore, f *os.File, from int64) error {
return nil
}
interval, err := time.ParseDuration(Keys.Checkpoints.Interval)
if err != nil {
fmt.Printf("error while parsing interval: %#v", err)
}
now := time.Now().Unix()
cutOff := time.Unix(fromTimestamp, 0).Add(interval).Unix()
newCount := (min(now, cutOff) - fromTimestamp) / resolution
if recordCounter < newCount {
// fmt.Printf("Record Count: %d, Required Count: %d\n", recordCounter, newCount)
insertCount := newCount - recordCounter
for range insertCount {
for key := range metricsData {
metricsData[key] = append(metricsData[key], schema.ConvertToFloat(0.0))
}
}
err := UpdateAvroFile(f, insertCount)
if err != nil {
fmt.Printf("error while inserting blanks into avro: %s\n", err)
}
}
for key, floatArray := range metricsData {
metricName := ReplaceKey(key)