|
|
@ -58,8 +58,9 @@ const freezerTableSize = 2 * 1000 * 1000 * 1000 |
|
|
|
// - The append-only nature ensures that disk writes are minimized.
|
|
|
|
// - The append-only nature ensures that disk writes are minimized.
|
|
|
|
// - The in-order data ensures that disk reads are always optimized.
|
|
|
|
// - The in-order data ensures that disk reads are always optimized.
|
|
|
|
type Freezer struct { |
|
|
|
type Freezer struct { |
|
|
|
frozen atomic.Uint64 // Number of items already frozen
|
|
|
|
datadir string |
|
|
|
tail atomic.Uint64 // Number of the first stored item in the freezer
|
|
|
|
frozen atomic.Uint64 // Number of items already frozen
|
|
|
|
|
|
|
|
tail atomic.Uint64 // Number of the first stored item in the freezer
|
|
|
|
|
|
|
|
|
|
|
|
// This lock synchronizes writers and the truncate operation, as well as
|
|
|
|
// This lock synchronizes writers and the truncate operation, as well as
|
|
|
|
// the "atomic" (batched) read operations.
|
|
|
|
// the "atomic" (batched) read operations.
|
|
|
@ -109,6 +110,7 @@ func NewFreezer(datadir string, namespace string, readonly bool, maxTableSize ui |
|
|
|
} |
|
|
|
} |
|
|
|
// Open all the supported data tables
|
|
|
|
// Open all the supported data tables
|
|
|
|
freezer := &Freezer{ |
|
|
|
freezer := &Freezer{ |
|
|
|
|
|
|
|
datadir: datadir, |
|
|
|
readonly: readonly, |
|
|
|
readonly: readonly, |
|
|
|
tables: make(map[string]*freezerTable), |
|
|
|
tables: make(map[string]*freezerTable), |
|
|
|
instanceLock: lock, |
|
|
|
instanceLock: lock, |
|
|
@ -172,6 +174,11 @@ func (f *Freezer) Close() error { |
|
|
|
return nil |
|
|
|
return nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// AncientDatadir returns the path of the ancient store.
|
|
|
|
|
|
|
|
func (f *Freezer) AncientDatadir() (string, error) { |
|
|
|
|
|
|
|
return f.datadir, nil |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// HasAncient returns an indicator whether the specified ancient data exists
|
|
|
|
// HasAncient returns an indicator whether the specified ancient data exists
|
|
|
|
// in the freezer.
|
|
|
|
// in the freezer.
|
|
|
|
func (f *Freezer) HasAncient(kind string, number uint64) (bool, error) { |
|
|
|
func (f *Freezer) HasAncient(kind string, number uint64) (bool, error) { |
|
|
|