Class

scala.meta.internal.metals

StringBloomFilter

Related Doc: package metals

Permalink

class StringBloomFilter extends AnyRef

A wrapper around a bloom filter that is optimized for fast insertions of strings with shared prefixes.

To index a classpath, Metals walks through all possible prefixes of a given classfile path. For example, given the string "InputStream.class" Metals builds a bloom filter containing the set of the following strings: I, In, Inp, Inpu, Input, S, St, Str, Stre, Strea and Stream.

The naive approach to construct a bloom filter of all those prefix strings is to create a BloomFilter[CharSequence] and insert all those prefixes. This approach has sub-optimal performance because it requires a quadratic number of iterations on the characters of the classfile path.

This class implements an optimized approach to build that bloom filter in a way that requires only a linear pass on the characters of the classfile path. The trick is to construct a BloomFilter[Long] instead of BloomFilter[CharSequence] and incrementally build the hashcode of each prefix string as we iterate over each character in the string.

Additionally, this class exposes a mightContain(Long) method that speeds up search queries by allowing the client to pre-compute the hash of the query string and re-use mightContain calls to multiple bloom filters. For every single fuzzy symbol search (which happens on every single scope completion request) we usually perform several thousand bloom filter mightContain calls so should also help avoid a non-trivial amount of unnecessary hashing.

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. StringBloomFilter
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new StringBloomFilter(estimatedSize: Int)

    Permalink

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. def approximateElementCount(): Long

    Permalink
  5. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  6. val bloom: BloomFilter[java.lang.Long]

    Permalink
  7. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. def computeHashCode(chars: CharSequence): Long

    Permalink

    Computes the hascode of a single string that can be later passed to mightContain(Long).

  9. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  10. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  11. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  12. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  13. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  14. def isFull: Boolean

    Permalink
  15. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  16. val maxFalsePositiveRatio: Double

    Permalink
  17. def mightContain(hashCode: Long): Boolean

    Permalink

    Returns true if the bloom filter contains the string with the given hashcode.

    Returns true if the bloom filter contains the string with the given hashcode.

    This method is can help improve performance when calling mightContain with the same query string to multiple different bloom filters.

  18. def mightContain(chars: CharSequence): Boolean

    Permalink

    Returns true if the bloom filter contains the given string.

  19. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  20. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  21. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  22. def putCharIncrementally(char: Char): Boolean

    Permalink

    Inserts a new string to the bloom filter that is the concatenation of the current hash value and the given character.

    Inserts a new string to the bloom filter that is the concatenation of the current hash value and the given character.

    Use this method when inserting multiple strings that share the same prefix, for example to insert all prefixes of "Simple" you can do

    putCharIncrementally('S') // insert S
    putCharIncrementally('i') // insert Si
    putCharIncrementally('m') // insert Sim
    putCharIncrementally('p') // insert Simp
    putCharIncrementally('l') // insert Simpl
    putCharIncrementally('e') // insert Simple
  23. def putCharSequence(chars: CharSequence): Boolean

    Permalink

    Insert a single string into the bloom filter.

  24. def reset(): Unit

    Permalink

    Resets the hash value.

  25. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  26. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  27. def value(): Long

    Permalink

    Returns the current hash value.

  28. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  29. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  30. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped