Write the chunk bytes to the file.
(chunkIdx uint64, b []byte)
| 190 | |
| 191 | // Write the chunk bytes to the file. |
| 192 | func (df *DataFile) Write(chunkIdx uint64, b []byte) error { |
| 193 | if !df.Contains(chunkIdx) { |
| 194 | return fmt.Errorf("chunk not found") |
| 195 | } |
| 196 | |
| 197 | if len(b) > int(df.chunkSize) { |
| 198 | return fmt.Errorf("write data too large") |
| 199 | } |
| 200 | |
| 201 | _, err := df.file.WriteAt(b, HEADER_SIZE+int64(chunkIdx-df.chunkIdxStart)*int64(df.chunkSize)) |
| 202 | return err |
| 203 | } |
| 204 | |
| 205 | // Read the metadata of the kv |
| 206 | func (df *DataFile) ReadMeta(kvIdx uint64) ([]byte, error) { |
no test coverage detected