Skip to content
This repository has been archived by the owner on May 15, 2019. It is now read-only.

Optimized Selector Variant #53

Merged

Conversation

josharnold52
Copy link
Contributor

As of #51, custom selectors can no longer leverage the bloom filter. I'd like to try and restore that ability in a more (hopefully) palatable way:

trait OptimizingSelector[+A] extends Selector[A] {
  /***
   * Provides a hint as to whether the selector can any children or their
   * descendants in the specified group.  Note that this is merely a hint,
   * `isDefinedAt` is the authoritative determinant of whether a selector matches.
   */
  def canMatchIn(group: Group[Node]): Boolean
} 

Basically, canMatchIn takes the role of the old matches method, but with (hopefully) cleaner semantics. Of course, implementations can call Group.matches(String) to reproduce the old functionality.

For some concrete examples, here are some searches that I'd like to be able to do while leveraging the bloom filter optimization:

  1. Find all elements, e that have a given name and a given attribute value
  2. Find all elements, e with a given name and return f(e) for some transform f.
  3. Find all elements, e that contain a child element with a given name.

@djspiewak
Copy link
Owner

Ok, yeah, that is a lot more general than just matching on ElemSelector…and you provided tests! Merged!

@djspiewak djspiewak merged commit 669fd62 into djspiewak:zipper-replacement Sep 23, 2011
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants