File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -1101,6 +1101,27 @@ type BatchReader interface {
11011101// TODO: move this to be with other consts above
11021102const maxConcurrentPuts = 16
11031103
1104+ // flatfsBatch implements atomic batch operations using a temporary directory.
1105+ //
1106+ // Design principles:
1107+ // - All Put operations write to a temp directory (no sharding)
1108+ // - Writes are done asynchronously in goroutines for performance
1109+ // - Commit atomically renames all files to their sharded destinations
1110+ // - On crash/discard, temp directory is cleaned (no partial writes)
1111+ //
1112+ // Concurrency: Safe for concurrent calls to Put/Delete/Get/Has/GetSize/Query.
1113+ // Not safe to call Commit or Discard concurrently with other operations.
1114+ //
1115+ // Transaction semantics: Read operations (Get/Has/GetSize/Query) see
1116+ // uncommitted writes from the same batch, following standard database
1117+ // transaction isolation.
1118+ //
1119+ // Performance characteristics:
1120+ // - Put: O(1) with async I/O, returns immediately
1121+ // - Get/Has/GetSize: O(n) where n = number of Put operations in batch
1122+ // - Commit: O(n) file renames
1123+ //
1124+ // IMPORTANT: Batch instances should not be reused after Commit or Discard.
11041125type flatfsBatch struct {
11051126 mu sync.Mutex
11061127 puts []datastore.Key
You can’t perform that action at this time.
0 commit comments