SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
add writer pattern object for later use
chrislub21a67bbe67b
diff --git a/weed/filesys/page_writer/writer_pattern.go b/weed/filesys/page_writer/writer_pattern.gonew file mode 100644index 0000000000..c7641c37fa--- /dev/null+++ b/weed/filesys/page_writer/writer_pattern.go@@ -0,0 +1,31 @@+package page_writer++type WriterPattern struct {+ isStreaming bool+ lastWriteOffset int64+}++// For streaming write: only cache the first chunk+// For random write: fall back to temp file approach++func NewWriterPattern() *WriterPattern {+ return &WriterPattern{+ isStreaming: true,+ lastWriteOffset: 0,+ }+}++func (rp *WriterPattern) MonitorWriteAt(offset int64, size int) {+ if rp.lastWriteOffset > offset {+ rp.isStreaming = false+ }+ rp.lastWriteOffset = offset+}++func (rp *WriterPattern) IsStreamingMode() bool {+ return rp.isStreaming+}++func (rp *WriterPattern) IsRandomMode() bool {+ return !rp.isStreaming+}