github.com/attic-labs/noms@v0.0.0-20210827224422-e5fa29d95e8b/go/nbs/benchmarks/file_block_store.go (about) 1 // Copyright 2016 Attic Labs, Inc. All rights reserved. 2 // Licensed under the Apache License, version 2.0: 3 // http://www.apache.org/licenses/LICENSE-2.0 4 5 package main 6 7 import ( 8 "bufio" 9 "bytes" 10 "io" 11 12 "github.com/attic-labs/noms/go/chunks" 13 "github.com/attic-labs/noms/go/hash" 14 "github.com/dustin/go-humanize" 15 ) 16 17 type fileBlockStore struct { 18 bw *bufio.Writer 19 w io.WriteCloser 20 } 21 22 func newFileBlockStore(w io.WriteCloser) chunks.ChunkStore { 23 return fileBlockStore{bufio.NewWriterSize(w, humanize.MiByte), w} 24 } 25 26 func (fb fileBlockStore) Get(h hash.Hash) chunks.Chunk { 27 panic("not impl") 28 } 29 30 func (fb fileBlockStore) GetMany(hashes hash.HashSet, foundChunks chan *chunks.Chunk) { 31 panic("not impl") 32 } 33 34 func (fb fileBlockStore) Has(h hash.Hash) bool { 35 panic("not impl") 36 } 37 38 func (fb fileBlockStore) HasMany(hashes hash.HashSet) (present hash.HashSet) { 39 panic("not impl") 40 } 41 42 func (fb fileBlockStore) Put(c chunks.Chunk) { 43 io.Copy(fb.bw, bytes.NewReader(c.Data())) 44 } 45 46 func (fb fileBlockStore) Version() string { 47 panic("not impl") 48 } 49 50 func (fb fileBlockStore) Close() error { 51 fb.w.Close() 52 return nil 53 } 54 55 func (fb fileBlockStore) Rebase() {} 56 57 func (fb fileBlockStore) Stats() interface{} { 58 return nil 59 } 60 61 func (fb fileBlockStore) StatsSummary() string { 62 return "Unsupported" 63 } 64 65 func (fb fileBlockStore) Root() hash.Hash { 66 return hash.Hash{} 67 } 68 69 func (fb fileBlockStore) Commit(current, last hash.Hash) bool { 70 fb.bw.Flush() 71 return true 72 }