diff options
| author | Chris Lu <chris.lu@gmail.com> | 2020-09-03 11:00:20 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2020-09-03 11:00:20 -0700 |
| commit | b8f32bcab94a23cc5cb92f32fdd655a5b55ebb6d (patch) | |
| tree | bde567ba06f243041e97aef31c35ccdce001d132 /weed/filer/abstract_sql | |
| parent | f76a2b2c8a22c97a5811e0ccf1776043ecc4a0f1 (diff) | |
| download | seaweedfs-b8f32bcab94a23cc5cb92f32fdd655a5b55ebb6d.tar.xz seaweedfs-b8f32bcab94a23cc5cb92f32fdd655a5b55ebb6d.zip | |
filer: compress stored metadata
Diffstat (limited to 'weed/filer/abstract_sql')
| -rw-r--r-- | weed/filer/abstract_sql/abstract_sql_store.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/weed/filer/abstract_sql/abstract_sql_store.go b/weed/filer/abstract_sql/abstract_sql_store.go index 368bec973..48b5795c2 100644 --- a/weed/filer/abstract_sql/abstract_sql_store.go +++ b/weed/filer/abstract_sql/abstract_sql_store.go @@ -67,6 +67,10 @@ func (store *AbstractSqlStore) InsertEntry(ctx context.Context, entry *filer.Ent return fmt.Errorf("encode %s: %s", entry.FullPath, err) } + if len(entry.Chunks) > 50 { + meta = util.MaybeGzipData(meta) + } + res, err := store.getTxOrDB(ctx).ExecContext(ctx, store.SqlInsert, util.HashStringToLong(dir), name, dir, meta) if err != nil { if !strings.Contains(strings.ToLower(err.Error()), "duplicate") { @@ -126,7 +130,7 @@ func (store *AbstractSqlStore) FindEntry(ctx context.Context, fullpath util.Full entry := &filer.Entry{ FullPath: fullpath, } - if err := entry.DecodeAttributesAndChunks(data); err != nil { + if err := entry.DecodeAttributesAndChunks(util.MaybeDecompressData(data)); err != nil { return entry, fmt.Errorf("decode %s : %v", entry.FullPath, err) } @@ -188,7 +192,7 @@ func (store *AbstractSqlStore) ListDirectoryPrefixedEntries(ctx context.Context, entry := &filer.Entry{ FullPath: util.NewFullPath(string(fullpath), name), } - if err = entry.DecodeAttributesAndChunks(data); err != nil { + if err = entry.DecodeAttributesAndChunks(util.MaybeDecompressData(data)); err != nil { glog.V(0).Infof("scan decode %s : %v", entry.FullPath, err) return nil, fmt.Errorf("scan decode %s : %v", entry.FullPath, err) } |
