hll

package
v0.0.26 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 29, 2024 License: Apache-2.0 Imports: 2 Imported by: 1

Documentation

Overview

*

  • Licensed to the Apache Software Foundation (ASF) under one or more
  • contributor license agreements. See the NOTICE file distributed with this
  • work for additional information regarding copyright ownership. The ASF
  • licenses this file to you under the Apache License, Version 2.0 (the
  • "License"); you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  • WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  • License for the specific language governing permissions and limitations under
  • the License. *

*

  • This is a very fast, non-cryptographic hash suitable for general hash-based
  • lookup. See http://murmurhash.googlepages.com/ for more details.
  • <p/>
  • <p>
  • The C version of MurmurHash 2.0 found at that site was ported to Java by
  • Andrzej Bialecki (ab at getopt org).
  • </p>

Index

Constants

View Source
const (
	LOG2_BITS_PER_WORD = 6
	REGISTER_SIZE      = 5
)

Variables

This section is empty.

Functions

func MurmurHash

func MurmurHash(o uint32) uint32
func MurmurHash(Object o) int {
       if (o == null) {
           return 0;
       }
       if (o instanceof Long) {
           return hashLong((Long) o);
       }
       if (o instanceof Integer) {
           return hashLong((Integer) o);
       }
       if (o instanceof Double) {
           return hashLong(Double.doubleToRawLongBits((Double) o));
       }
       if (o instanceof Float) {
           return hashLong(Float.floatToRawIntBits((Float) o));
       }
       if (o instanceof String) {
           return hash(((String) o).getBytes());
       }
       if (o instanceof byte[]) {
           return hash((byte[]) o);
       }

       return hash(o.toString());
   }

func MurmurHashByte

func MurmurHashByte(data []byte) uint32

func MurmurHashByteSeed

func MurmurHashByteSeed(data []byte, seed uint32) uint32

func MurmurHashLong

func MurmurHashLong(data uint64) uint32

func MurmurHashLongByte

func MurmurHashLongByte(data []byte, length int32) uint64
func MurmurHash64(Object o) int64 {
       if (o == null) {
           return 0l;
       } else if (o instanceof String) {
           final byte[] bytes = ((String) o).getBytes();
           return hash64(bytes, bytes.length);
       } else if (o instanceof byte[]) {
           final byte[] bytes = (byte[]) o;
           return hash64(bytes, bytes.length);
       }
       return hash64(o.toString());
   }

64 bit implementation copied from here: https://github.com/tnm/murmurhash-java *

  • Generates 64 bit hash from byte array with default seed value. *
  • @param data byte array to hash
  • @param length length of the array to hash
  • @return 64 bit hash of the given string

func Round

func Round(val float64) int64

Types

type HyperLogLog

type HyperLogLog struct {
	// contains filtered or unexported fields
}

func BuildHyperLogLog

func BuildHyperLogLog(bytes []byte) *HyperLogLog

* Initial code from HyperLogLog.Builder.build() * by Scouter-Project

func NewHyperLogLog

func NewHyperLogLog(log2m uint32, registerSet *RegisterSet) *HyperLogLog

*

  • Creates a new HyperLogLog instance using the given registers. Used for

  • unmarshalling a serialized instance and for merging multiple counters

  • together. *

  • @param registerSet

  • - the initial values for the register set

    @Deprecated

func NewHyperLogLogDefault

func NewHyperLogLogDefault() *HyperLogLog

func NewHyperLogLogFloat

func NewHyperLogLogFloat(Rsd float64) *HyperLogLog

*

  • Create a new HyperLogLog instance using the specified standard deviation. *
  • @param rsd
  • - the relative standard deviation for the counter. smaller
  • values create counters that require more space.

func NewHyperLogLogInt

func NewHyperLogLogInt(log2m uint32) *HyperLogLog

*

  • Create a new HyperLogLog instance. The log2m parameter defines the
  • accuracy of the counter. The larger the log2m the better the accuracy.
  • <p/>
  • accuracy = 1.04/sqrt(2^log2m) *
  • @param log2m
  • - the number of bits to use as the basis for the HLL instance

func (*HyperLogLog) AddAll

func (this *HyperLogLog) AddAll(other *HyperLogLog)

*

  • Add all the elements of the other set to this set.
  • <p/>
  • This operation does not imply a loss of precision. *
  • @param other
  • A compatible Hyperloglog instance (same log2m)
  • @throws CardinalityMergeException
  • if other is not compatible

func (*HyperLogLog) Cardinality

func (this *HyperLogLog) Cardinality() uint64

func (*HyperLogLog) GetBytes

func (this *HyperLogLog) GetBytes() []byte

* This method is modified by Souter-pcode *

func (*HyperLogLog) Merge

func (this *HyperLogLog) Merge(estimators ...*HyperLogLog) *HyperLogLog

func (*HyperLogLog) Offer

func (this *HyperLogLog) Offer(o uint32) bool
public boolean offer(Object o) {
		final int x = MurmurHash.hash(o);
		return offerHashed(x);
	}

func (*HyperLogLog) OfferLong

func (this *HyperLogLog) OfferLong(o uint64) bool

func (*HyperLogLog) Sizeof

func (this *HyperLogLog) Sizeof() int

type RegisterSet

type RegisterSet struct {
	Count int
	Size  int
	M     []uint32
}

func NewRegisterSet

func NewRegisterSet(count int) *RegisterSet

func NewRegisterSetInit

func NewRegisterSetInit(count int, initialValues []uint32) *RegisterSet

func (*RegisterSet) Bits

func (this *RegisterSet) Bits() []uint32

func (*RegisterSet) Get

func (this *RegisterSet) Get(position int) uint32

func (*RegisterSet) Merge

func (this *RegisterSet) Merge(that *RegisterSet)

func (*RegisterSet) ReadOnlyBits

func (this *RegisterSet) ReadOnlyBits() []uint32

func (*RegisterSet) Set

func (this *RegisterSet) Set(position, value uint32)

func (*RegisterSet) UpdateIfGreater

func (this *RegisterSet) UpdateIfGreater(position, value uint32) bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL