aboutsummaryrefslogtreecommitdiff
path: root/weed/filer2/filechunks.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2018-05-13 00:11:26 -0700
committerChris Lu <chris.lu@gmail.com>2018-05-13 00:11:26 -0700
commit75a2b05aa31cc321dc724d95ed14414ca4c1b310 (patch)
tree8df69219f75287e7e86663fb1ef08960f80813f7 /weed/filer2/filechunks.go
parentfc7f81f6e7b596ad4f1246a727408f4cbdaa8f88 (diff)
downloadseaweedfs-75a2b05aa31cc321dc724d95ed14414ca4c1b310.tar.xz
seaweedfs-75a2b05aa31cc321dc724d95ed14414ca4c1b310.zip
remove Size from Attr
Diffstat (limited to 'weed/filer2/filechunks.go')
-rw-r--r--weed/filer2/filechunks.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/weed/filer2/filechunks.go b/weed/filer2/filechunks.go
new file mode 100644
index 000000000..b2f05de3a
--- /dev/null
+++ b/weed/filer2/filechunks.go
@@ -0,0 +1,23 @@
+package filer2
+
+type Chunks []FileChunk
+
+func (chunks Chunks) TotalSize() (size uint64) {
+ for _, c := range chunks {
+ t := uint64(c.Offset + int64(c.Size))
+ if size < t {
+ size = t
+ }
+ }
+ return
+}
+
+func (chunks Chunks) Len() int {
+ return len(chunks)
+}
+func (chunks Chunks) Swap(i, j int) {
+ chunks[i], chunks[j] = chunks[j], chunks[i]
+}
+func (chunks Chunks) Less(i, j int) bool {
+ return chunks[i].Offset < chunks[j].Offset
+}