marshal converts to json and compresses the bucketindex
()
| 29 | |
| 30 | // marshal converts to json and compresses the bucketindex |
| 31 | func (b *TenantIndex) marshal() ([]byte, error) { |
| 32 | buffer := &bytes.Buffer{} |
| 33 | |
| 34 | gzip := gzip.NewWriter(buffer) |
| 35 | gzip.Name = internalFilename |
| 36 | |
| 37 | jsonBytes, err := json.Marshal(b) |
| 38 | if err != nil { |
| 39 | return nil, err |
| 40 | } |
| 41 | |
| 42 | if _, err = gzip.Write(jsonBytes); err != nil { |
| 43 | return nil, err |
| 44 | } |
| 45 | if err = gzip.Flush(); err != nil { |
| 46 | return nil, err |
| 47 | } |
| 48 | if err = gzip.Close(); err != nil { |
| 49 | return nil, err |
| 50 | } |
| 51 | |
| 52 | return buffer.Bytes(), nil |
| 53 | } |
| 54 | |
| 55 | // unmarshal decompresses and unmarshals the results from json |
| 56 | func (b *TenantIndex) unmarshal(buffer []byte) error { |