• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang murmur3.New64函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/spaolacci/murmur3.New64函数的典型用法代码示例。如果您正苦于以下问题:Golang New64函数的具体用法?Golang New64怎么用?Golang New64使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了New64函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: hash

func hash(ids ...string) uint64 {
	id := murmur3.New64()
	for _, i := range ids {
		id.Write([]byte(i))
	}
	return id.Sum64()
}
开发者ID:CNDonny,项目名称:scope,代码行数:7,代码来源:merger.go


示例2: smartHash

func smartHash(file string) (uint64, error) {
	h := murmur3.New64()

	f, err := os.Open(file)
	defer f.Close()

	fi, err := f.Stat()
	if err != nil {
		return 0, err
	}

	if fi.Size() <= FULL_HASH_LIMIT {
		buffer := make([]byte, fi.Size())
		f.Read(buffer)
		h.Write(buffer)
	} else {
		buffer := make([]byte, SAMPLE_SIZE)
		f.Read(buffer)
		h.Write(buffer)
		f.Seek(fi.Size()/2, 0)
		f.Read(buffer)
		h.Write(buffer)
		f.Seek(-SAMPLE_SIZE, 2)
		f.Read(buffer)
		h.Write(buffer)
	}

	return h.Sum64(), nil
}
开发者ID:kalafut,项目名称:dsync,代码行数:29,代码来源:fash.go


示例3: AuthorID

// AuthorID generates a unique ID based on the murmur hash of the public key.
func (key *PrivateKey) AuthorID() (string, error) {
	hasher := murmur3.New64()
	buf, err := x509.MarshalPKIXPublicKey(&(*ecdsa.PrivateKey)(key).PublicKey)
	if err != nil {
		return "", err
	}
	hasher.Write(buf)
	return "degdb:author_" + strconv.Itoa(int(hasher.Sum64())), nil
}
开发者ID:nonempty,项目名称:degdb,代码行数:10,代码来源:crypto.go


示例4: Merge

func (dumbMerger) Merge(reports []report.Report) report.Report {
	rpt := report.MakeReport()
	id := murmur3.New64()
	for _, r := range reports {
		rpt = rpt.Merge(r)
		id.Write([]byte(r.ID))
	}
	rpt.ID = fmt.Sprintf("%x", id.Sum64())
	return rpt
}
开发者ID:CNDonny,项目名称:scope,代码行数:10,代码来源:merger.go


示例5: hashFiles

func hashFiles(files <-chan *File, catalog *Catalog) {
	buffer := make([]byte, SAMPLE_SIZE)
	h := murmur3.New64()
	for file := range files {
		h.Reset()
		f, _ := os.Open(file.Path)
		f.Read(buffer)
		h.Write(buffer)
		f.Close()

		file.Hash = h.Sum64()
		catalog.AddFile(file)
	}
}
开发者ID:kalafut,项目名称:dsync,代码行数:14,代码来源:fash.go


示例6: TestBloomFilter

func TestBloomFilter(t *testing.T) {
	l := []uint{uint(len(web2)), 200000, 100000, 50000}
	h := []hash.Hash{fnv.New64(), crc64.New(crc64.MakeTable(crc64.ECMA)), murmur3.New64(), cityhash.New64(), md5.New(), sha1.New()}
	n := []string{"fnv.New64()", "crc64.New()", "murmur3.New64()", "cityhash.New64()", "md5.New()", "sha1.New()"}

	for i := range l {
		for j := range h {
			fmt.Printf("\n\nTesting %s with size %d\n", n[j], l[i])
			bf := New(l[i])
			bf.SetHasher(h[j])
			testBloomFilter(t, bf)
		}
	}
}
开发者ID:jasonmoo,项目名称:bloom,代码行数:14,代码来源:standard_test.go


示例7: TestBloomFilter

func TestBloomFilter(t *testing.T) {
	l := []uint{uint(len(web2)), 200000, 100000, 50000}
	h := []hash.Hash{fnv.New64(), crc64.New(crc64.MakeTable(crc64.ECMA)), murmur3.New64(), cityhash.New64(), md5.New(), sha1.New()}
	n := []string{"fnv.New64()", "crc64.New()", "murmur3.New64()", "cityhash.New64()", "md5.New()", "sha1.New()"}
	b := []func(uint) bloom.Bloom{standard.New, partitioned.New}
	bn := []string{"standard", "partitioned"}

	for i := range l {
		for j := range h {
			for k := range b {
				fmt.Printf("\n\nTesting %s with size %d using %s\n", n[j], l[i], bn[k])
				bf := New(l[i])
				bf.SetHasher(h[j])
				bf.(*ScalableBloom).SetBloomFilter(b[k])
				bf.Reset()
				testBloomFilter(t, bf)
			}
		}
	}
}
开发者ID:postfix,项目名称:bloom-1,代码行数:20,代码来源:scalable_test.go


示例8: BenchmarkBloomMurmur3

func BenchmarkBloomMurmur3(b *testing.B) {
	var lines []string
	lines = append(lines, web2...)
	for len(lines) < b.N {
		lines = append(lines, web2...)
	}

	bf := New(uint(b.N))
	bf.SetHasher(murmur3.New64())
	fn := 0

	b.ResetTimer()

	for l := 0; l < b.N; l++ {
		if !(bf.Add([]byte(lines[l])).Check([]byte(lines[l]))) {
			fn++
		}
	}

	b.StopTimer()
}
开发者ID:jasonmoo,项目名称:bloom,代码行数:21,代码来源:standard_test.go


示例9: Report

// Report returns a merged report over all added reports. It implements
// Reporter.
func (c *collector) Report() report.Report {
	c.mtx.Lock()
	defer c.mtx.Unlock()

	// If the oldest report is still within range,
	// and there is a cached report, return that.
	if c.cached != nil && len(c.reports) > 0 {
		oldest := now().Add(-c.window)
		if c.reports[0].timestamp.Before(oldest) {
			return *c.cached
		}
	}
	c.reports = clean(c.reports, c.window)

	rpt := report.MakeReport()
	id := murmur3.New64()
	for _, tr := range c.reports {
		rpt = rpt.Merge(tr.report)
		id.Write([]byte(tr.report.ID))
	}
	rpt.ID = fmt.Sprintf("%x", id.Sum64())
	c.cached = &rpt
	return rpt
}
开发者ID:pauloheck,项目名称:scope,代码行数:26,代码来源:collector.go


示例10: newHasher

// newHasher allocates and return a new Hasher.
func newHasher() *hasher {
	return &hasher{mmh3: murmur3.New64()}
}
开发者ID:strangemonad,项目名称:cockroach,代码行数:4,代码来源:hasher.go


示例11: RandomUint64

// RandomUint64 creates a random uint64 number
func RandomUint64(data string) uint64 {
	hasher := murmur3.New64()
	hasher.Write([]byte(uuid.NewUUID()))
	return hasher.Sum64()
}
开发者ID:kmchen,项目名称:golang-utils,代码行数:6,代码来源:golang-utils.go


示例12: BenchmarkUseMurmur

func BenchmarkUseMurmur(b *testing.B) {
	h := murmur3.New64()
	benchmarkHash(b, h)
}
开发者ID:dgraph-io,项目名称:experiments,代码行数:4,代码来源:hash_test.go


示例13: TestUseMurmur_Collissions

func TestUseMurmur_Collissions(t *testing.T) {
	h := murmur3.New64()
	testCollissions(t, h)
}
开发者ID:dgraph-io,项目名称:experiments,代码行数:4,代码来源:hash_test.go


示例14: versionFromBytes

func versionFromBytes(b []byte) string {
	hasher := murmur3.New64()
	hasher.Write(b)
	return fmt.Sprintf("%d", hasher.Sum64())
}
开发者ID:hsinhoyeh,项目名称:goimjson,代码行数:5,代码来源:imjson.go



注:本文中的github.com/spaolacci/murmur3.New64函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang murmur3.Sum128函数代码示例发布时间:2022-05-28
下一篇:
Golang glog.V函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap