本文整理匯總了Golang中github.com/uwedeportivo/romba/types.Rom.CrcWithSizeKey方法的典型用法代碼示例。如果您正苦於以下問題:Golang Rom.CrcWithSizeKey方法的具體用法?Golang Rom.CrcWithSizeKey怎麽用?Golang Rom.CrcWithSizeKey使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/uwedeportivo/romba/types.Rom
的用法示例。
在下文中一共展示了Rom.CrcWithSizeKey方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Seen
func (dbd *dbDeduper) Seen(r *types.Rom) (bool, error) {
if len(r.Sha1) > 0 {
val, err := dbd.sha1DB.Get(ro, r.Sha1)
if err != nil {
return false, err
}
return len(val) == 1 && val[0] == 1, nil
}
if len(r.Md5) > 0 {
val, err := dbd.md5DB.Get(ro, r.Md5WithSizeKey())
if err != nil {
return false, err
}
return len(val) == 1 && val[0] == 1, nil
}
if len(r.Crc) > 0 {
val, err := dbd.crcDB.Get(ro, r.CrcWithSizeKey())
if err != nil {
return false, err
}
return len(val) == 1 && val[0] == 1, nil
}
return false, nil
}
示例2: Declare
func (md *memoryDeduper) Declare(r *types.Rom) error {
md.mutex.Lock()
defer md.mutex.Unlock()
if len(r.Crc) > 0 {
md.crcs[string(r.CrcWithSizeKey())] = true
}
if len(r.Md5) > 0 {
md.md5s[string(r.Md5WithSizeKey())] = true
}
if len(r.Sha1) > 0 {
md.sha1s[string(r.Sha1)] = true
}
return nil
}
示例3: Seen
func (md *memoryDeduper) Seen(r *types.Rom) (bool, error) {
md.mutex.Lock()
defer md.mutex.Unlock()
if len(r.Sha1) > 0 && md.sha1s[string(r.Sha1)] {
return true, nil
}
if len(r.Md5) > 0 && md.md5s[string(r.Md5WithSizeKey())] {
return true, nil
}
if len(r.Crc) > 0 && md.crcs[string(r.CrcWithSizeKey())] {
return true, nil
}
return false, nil
}
示例4: CompleteRom
func (kvdb *kvStore) CompleteRom(rom *types.Rom) error {
if rom.Sha1 != nil {
return nil
}
if rom.Md5 != nil {
dBytes, err := kvdb.md5sha1DB.GetKeySuffixesFor(rom.Md5WithSizeKey())
if err != nil {
return err
}
rom.Sha1 = dBytes
return nil
}
if rom.Crc != nil {
dBytes, err := kvdb.crcsha1DB.GetKeySuffixesFor(rom.CrcWithSizeKey())
if err != nil {
return err
}
rom.Sha1 = dBytes
}
return nil
}
示例5: Declare
func (dbd *dbDeduper) Declare(r *types.Rom) error {
if len(r.Crc) > 0 {
err := dbd.crcDB.Put(wo, r.CrcWithSizeKey(), trueVal)
if err != nil {
return err
}
}
if len(r.Md5) > 0 {
err := dbd.md5DB.Put(wo, r.Md5WithSizeKey(), trueVal)
if err != nil {
return err
}
}
if len(r.Sha1) > 0 {
err := dbd.sha1DB.Put(wo, r.Sha1, trueVal)
if err != nil {
return err
}
}
return nil
}
示例6: FilteredDatsForRom
func (kvdb *kvStore) FilteredDatsForRom(rom *types.Rom, filter func(*types.Dat) bool) ([]*types.Dat, []*types.Dat, error) {
var dBytes []byte
if rom.Sha1 != nil {
bs, err := kvdb.sha1DB.GetKeySuffixesFor(rom.Sha1)
if err != nil {
return nil, nil, err
}
if bs != nil {
dBytes = append(dBytes, bs...)
}
}
if rom.Md5 != nil {
bs, err := kvdb.md5DB.GetKeySuffixesFor(rom.Md5WithSizeKey())
if err != nil {
return nil, nil, err
}
if bs != nil {
dBytes = append(dBytes, bs...)
}
}
if rom.Crc != nil {
bs, err := kvdb.crcDB.GetKeySuffixesFor(rom.CrcWithSizeKey())
if err != nil {
return nil, nil, err
}
if bs != nil {
dBytes = append(dBytes, bs...)
}
}
if dBytes == nil {
return nil, nil, nil
}
var dats []*types.Dat
var rejectedDats []*types.Dat
seen := make(map[string]bool)
for i := 0; i < len(dBytes); i += sha1.Size {
sha1Bytes := dBytes[i : i+sha1.Size]
if seen[string(sha1Bytes)] {
continue
}
seen[string(sha1Bytes)] = true
dat, err := kvdb.GetDat(sha1Bytes)
if err != nil {
return nil, nil, err
}
if dat != nil {
if filter(dat) {
dats = append(dats, dat)
} else {
rejectedDats = append(rejectedDats, dat)
}
}
}
return dats, rejectedDats, nil
}