Documentation ¶
Index ¶
- Constants
- func HashHexToSha256(hexAscii string, sha256 *Sha256) error
- func HashSha256ToHexString(hash *Sha256) string
- type BasicHashStore
- type ConcreteHashStoreCreator
- type HashReadWriter
- type HashReader
- type HashStore
- func (hs *HashStore) AppendHash(hash *Sha256) (int64, error)
- func (hs *HashStore) Close() error
- func (hs *HashStore) CountHashes() (int64, error)
- func (hs *HashStore) GetHashAtIndex(index int64, hash *Sha256) error
- func (hs *HashStore) IndexOfHash(hash *Sha256) (int64, error)
- func (hs *HashStore) Sync() error
- type HashStoreCreator
- type ReadWriteSeekCloser
- type Sha256
Constants ¶
View Source
const ZEROBUF = 32 // Arbitrary number. Should be enough (we do check)
Variables ¶
This section is empty.
Functions ¶
func HashHexToSha256 ¶
func HashSha256ToHexString ¶
Types ¶
type BasicHashStore ¶
type BasicHashStore struct {
// contains filtered or unexported fields
}
func NewBasicHashStore ¶
func NewBasicHashStore(file memfile.LookupFileWithSize) *BasicHashStore
func (*BasicHashStore) AppendHash ¶
func (bhs *BasicHashStore) AppendHash(hash *Sha256) (int64, error)
func (*BasicHashStore) Close ¶
func (bhs *BasicHashStore) Close() error
func (*BasicHashStore) CountHashes ¶
func (bhs *BasicHashStore) CountHashes() (int64, error)
func (*BasicHashStore) GetHashAtIndex ¶
func (bhs *BasicHashStore) GetHashAtIndex(index int64, hash *Sha256) error
// IndexOfHash This is a very slow naive implementation, and should only be used for testing
func (bhs *BasicHashStore) IndexOfHash(hash *Sha256) (int64, error) { _, err := bhs.file.Seek(0, io.SeekStart) if err != nil { log.Println(err) log.Println("IndexOfHash(): Could not call file.Seek()") return -1, err } var hashInFile Sha256 index := int64(0) for { bytecount, err := bhs.file.Read(hashInFile[0:32]) if bytecount == 0 || err != nil { log.Println(err) log.Println("IndexOfHash(): file.Read() did not read any bytes") return int64(-1), err } if hashInFile == *hash { return index, nil } index++ } }
func (*BasicHashStore) Sync ¶
func (bhs *BasicHashStore) Sync() error
type ConcreteHashStoreCreator ¶
type ConcreteHashStoreCreator struct {
// contains filtered or unexported fields
}
func (*ConcreteHashStoreCreator) CreateHashStore ¶
func (hsc *ConcreteHashStoreCreator) CreateHashStore() error
func (*ConcreteHashStoreCreator) HashStoreExists ¶
func (hsc *ConcreteHashStoreCreator) HashStoreExists() bool
func (*ConcreteHashStoreCreator) OpenHashStore ¶
func (hsc *ConcreteHashStoreCreator) OpenHashStore() (HashReadWriter, error)
func (*ConcreteHashStoreCreator) OpenHashStoreReadOnly ¶
func (hsc *ConcreteHashStoreCreator) OpenHashStoreReadOnly() (HashReader, error)
type HashReadWriter ¶
type HashReadWriter interface { HashReader AppendHash(hash *Sha256) (int64, error) Sync() error }
type HashReader ¶
type HashStore ¶
type HashStore struct {
// contains filtered or unexported fields
}
func NewHashStore ¶
func NewHashStore(partialHashBitCount int64, entryByteCount int64, collisionsPerChunk int64, hashesFile *BasicHashStore, lookupsFile memfile.SparseLookupFile, collisionsFile *os.File) *HashStore
func (*HashStore) CountHashes ¶
func (*HashStore) GetHashAtIndex ¶
func (*HashStore) IndexOfHash ¶
IndexOfHash -1 indicates "Not Present" but error will be nil if that's all that is wrong
type HashStoreCreator ¶
type HashStoreCreator interface { HashStoreExists() bool CreateHashStore() error OpenHashStore() (HashReadWriter, error) OpenHashStoreReadOnly() (HashReader, error) }
type ReadWriteSeekCloser ¶
type ReadWriteSeekCloser interface { io.ReadWriteSeeker io.Closer }
Click to show internal directories.
Click to hide internal directories.