talariadb / talaria

TalariaDB is a distributed, highly available, and low latency time-series database for Presto
MIT License
215 stars 31 forks source link

When writter is nil, we should not ingest events #104

Open atlas-comstock opened 2 years ago

atlas-comstock commented 2 years ago
// WriteBlock writes a one or multiple blocks to the underlying writer.
func (s *Flusher) WriteBlock(blocks []block.Block, schema typeof.Schema) error {
    if s.writer == nil || len(blocks) == 0 {
        return nil
    }

    // Merge the blocks based on the specified merging function
    // buffer, err := s.merge(blocks, schema)
    // if err != nil {
    //     return err
    // }

    // Generate the file name and write the data to the underlying writer
    return s.writer.Write(s.generateFileName(blocks[0]), blocks)
}

In Flusher, we should return an error when the writer is nil, otherwise, the badgerDB data will be deleted without writing to any writter. It would be better to keep them in badgerDB

tardunge commented 2 years ago

How about having a Writer scoped Flusher?