Calculates a BitSet filter that includes all the nodes
that have content in properties according to the field name
passed in the constructor of this MatchAllScorer.

@throws IOException if an error occurs while reading from
the search index.
322173
private void calculateDocFilter() throws IOException
   {
      PerQueryCache cache = PerQueryCache.getInstance();
      @SuppressWarnings("unchecked")
      Map<String, BitSet> readerCache = 
               (Map<String, BitSet>)cache.get(MatchAllScorer.class, reader);
      if (readerCache == null)
      {
         readerCache = new HashMap<String, BitSet>();
         cache.put(MatchAllScorer.class, reader, readerCache);
      }
      // get BitSet for field
      docFilter = (BitSet)readerCache.get(field);

      if (docFilter != null)
      {
         // use cached BitSet;
         return;
      }

      // otherwise calculate new
      docFilter = new BitSet(reader.maxDoc());
      // we match all terms
      String namedValue = FieldNames.createNamedValue(field, "");
      TermEnum terms = reader.terms(new Term(FieldNames.PROPERTIES, namedValue));
      try
      {
         TermDocs docs = reader.termDocs();
         try
         {
            while (terms.term() != null && terms.term().field() == FieldNames.PROPERTIES
               && terms.term().text().startsWith(namedValue))
            {
               docs.seek(terms);
               while (docs.next())
               {
                  docFilter.set(docs.doc());
               }
               terms.next();
            }
         }
         finally
         {
            docs.close();
         }
      }
      finally
      {
         terms.close();
      }

      // put BitSet into cache
      readerCache.put(field, docFilter);
   }
1260025
public Set<String> keySet() throws IOException {
    Set<String> ret = new HashSet<>();
    JsonParser p = this.getParser();
    JsonToken t;

    t = p.nextToken();

    while (t != null) {
      if (t == JsonToken.FIELD_NAME) {
        ret.add(p.getCurrentName());
      }
      t = p.nextToken();
    }
    p.close();
    return ret;
  }
1350758
private ImmutableList<ContentResult> filterPotentialMatches(List<ContentResult> candidates) {
    // Sort candidates such that those with the longest formatted strings come first.
    Collections.sort(candidates, new Comparator<ContentResult>() {
      @Override
      public int compare(ContentResult o1, ContentResult o2) {
        String o1Formatted = o1.getL10nFormatted();
        String o2Formatted = o2.getL10nFormatted();
        int o1Length = o1Formatted.length();
        int o2Length = o2Formatted.length();
        // Sort longest to shortest, then lexicographically.
        if (o1Length > o2Length) {
          return -1;
        } else if (o1Length == o2Length) {
          return o1Formatted.compareTo(o2Formatted);
        } else {
          return 1;
        }
      }
    });
    // Build the final result by filtering out ContentResult instances that with formatted strings that are contained by
    // the already selected instances' formatted strings.
    List<ContentResult> res = new ArrayList<>();
    for (ContentResult candidate : candidates) {
      boolean contained = false;
      for (ContentResult member : res) {
        if (member.getL10nFormatted().contains(candidate.getL10nFormatted())) {
          contained = true;
          break;
        }
      }
      if (!contained) {
        res.add(candidate);
      }
    }
    return ImmutableList.copyOf(res);
  }
466112
public <E extends Exception> boolean allMatch(Try.ShortPredicate<E> filter) throws E {
        return allMatch(0, size(), filter);
    }
227383
public <E extends Exception> boolean allMatch(Try.BytePredicate<E> filter) throws E {
        return allMatch(0, size(), filter);
    }
269617
public static NodeSet fromFilter(String filter) {
        Map<String, Map<String, String>> stringMapMap = parseFilter(filter);
        NodeSet nodeSet = new NodeSet();
        nodeSet.createInclude(stringMapMap.get("include"));
        nodeSet.createExclude(stringMapMap.get("exclude"));
        return nodeSet;
    }
912841
Set<String> searchInstancesContainingKey(String searchKey)
            throws KnowledgeSourceReadException {
        return getFromProtege(searchKey,
                new ProtegeCommand<Set<String>, String>(
                        "search instance in a given  slot") {
                    @Override
                    Set<String> get(String matchString) {
                        Set<String> searchResults = new HashSet<>();
                        try {
                            Collection<Frame> displayNameMatches = protegeKnowledgeBase
                                    .getMatchingFrames(protegeKnowledgeBase
                                            .getSlot("displayName"), null, false,
                                            "*" + matchString.trim() + "*", -1);
                            Collection<Frame> nameMatches = protegeKnowledgeBase
                                    .getMatchingFrames(protegeKnowledgeBase
                                            .getSlot(":NAME"), null, false, "*"
                                            + matchString.trim() + "*", -1);
                            Slot nameSlot = protegeKnowledgeBase.getSlot(":NAME");
                            Cls propositionCls = protegeKnowledgeBase.getCls("Proposition");
                            if (displayNameMatches != null) {
                                for (Frame match : displayNameMatches)
                                    if (match instanceof Instance) {
                                        Instance temp = (Instance) match;
                                        if (temp.hasType(propositionCls)) {
                                            searchResults.add((String) getOwnSlotValue(match, nameSlot));
                                        }
                                    }
                            }
                            if (nameMatches != null) {
                                for (Frame match : nameMatches) {
                                    if (match instanceof Instance) {
                                        Instance temp = (Instance) match;
                                        if (temp.hasType(propositionCls)) {
                                            String result = (String) getOwnSlotValue(match, nameSlot);
                                            if (!searchResults.contains(result))
                                                searchResults.add(result);
                                        }
                                    }
                                }
                            }
                        } catch (KnowledgeSourceReadException e) {
                            e.printStackTrace();
                        }
                        return searchResults;
                    }
                });
    }
913520
public <V> boolean contains(IndexDefinition<T, V> indexDefinition, V value) {
    FieldIndex<T, V> index = (FieldIndex<T, V>) mIndices.get(indexDefinition);
    if (index == null) {
      throw new IllegalStateException("the given index isn't defined for this IndexedSet");
    }
    return index.containsField(value);
  }
713482
def _filter_nodes(superclass, all_nodes=_all_nodes):
    """"""
    node_names = (node.__name__ for node in all_nodes
                  if issubclass(node, superclass))
    return frozenset(node_names)
617467
public void matchValue(String ElementName, int value, int oper)
    {
        // Delete the old search filter
        m_filter = null;
        // If not NOT_IN, assume IN
        // (Since ints are passed by value, it is OK to change it)
        if (oper != NOT_IN)
        {
            oper = IN;
            // Create a leaf node for this list and store it as the filter
        }
        m_filter = new SearchBaseLeafInt(ElementName, oper, new int[]
        {
            value
        });
    }
1062390
private Filter createValueMatchFilter(
      FilterAdapterContext context, SingleColumnValueFilter filter) throws IOException {
    ValueFilter valueFilter = new ValueFilter(filter.getOperator(), filter.getComparator());
    return delegateAdapter.toFilter(context, valueFilter);
  }
821297
public static synchronized void registerFieldsToFilter(Class<?> containingClass,
                                              String ... fieldNames) {
        fieldFilterMap =
            registerFilter(fieldFilterMap, containingClass, fieldNames);
    }
390846
public static void match(DatabaseClient client) throws IOException {
    // create a manager for document search criteria
    QueryManager queryMgr = client.newQueryManager();

    // specify the search criteria for the documents
    String criteria = "neighborhoods";
    StringQueryDefinition querydef = queryMgr.newStringDefinition();
    querydef.setCriteria(criteria);

    // create a manager for matching rules
    RuleManager ruleMgr = client.newRuleManager();

    // match the rules against the documents qualified by the criteria
    RuleDefinitionList matchedRules = ruleMgr.match(querydef, new RuleDefinitionList());

    // iterate over the matched rules
    Iterator<RuleDefinition> ruleItr = matchedRules.iterator();
    while (ruleItr.hasNext()) {
      RuleDefinition rule = ruleItr.next();
      System.out.println(
        "document criteria "+criteria+" matched rule "+
          rule.getName()+" with metadata "+rule.getMetadata()
      );
    }
  }
1173505
List<IntArrayList> findSubnetworks(PrepEdgeFilter filter) {
        final BooleanEncodedValue accessEnc = filter.getAccessEnc();
        final EdgeExplorer explorer = ghStorage.createEdgeExplorer(filter);
        int locs = ghStorage.getNodes();
        List<IntArrayList> list = new ArrayList<>(100);
        final GHBitSet bs = new GHBitSetImpl(locs);
        for (int start = 0; start < locs; start++) {
            if (bs.contains(start))
                continue;

            final IntArrayList intList = new IntArrayList(20);
            list.add(intList);
            new BreadthFirstSearch() {
                int tmpCounter = 0;

                @Override
                protected GHBitSet createBitSet() {
                    return bs;
                }

                @Override
                protected final boolean goFurther(int nodeId) {
                    if (tmpCounter > maxEdgesPerNode.get())
                        maxEdgesPerNode.set(tmpCounter);

                    tmpCounter = 0;
                    intList.add(nodeId);
                    return true;
                }

                @Override
                protected final boolean checkAdjacent(EdgeIteratorState edge) {
                    if (edge.get(accessEnc) || edge.getReverse(accessEnc)) {
                        tmpCounter++;
                        return true;
                    }
                    return false;
                }

            }.start(explorer, start);
            intList.trimToSize();
        }
        return list;
    }
467762
private void parseFieldRemove(String fieldName, UNode addNode) {
        Set<String> removeValueSet = new LinkedHashSet<>();
        for (UNode valueNode : addNode.getMemberList()) {
            Utils.require(valueNode.isValue() && valueNode.getName().equals("value"),
                          "Value expected for 'remove' element: " + valueNode);
            removeValueSet.add(valueNode.getValue());
        }
        removeFieldValues(fieldName, removeValueSet);
    }
1245579
private boolean findMatches() throws IOException {
    // check for something in queue of matches
    if (!queueMatches.isEmpty()) {
      return true;
    } else {
      ignoreItem.advanceToDoc(spans.docID());
      while (true) {
        // try to get something in queue of spans
        if (queueSpans.isEmpty() && !collectSpan()) {
          return false;
        }
        // try to get matches with first span in queue
        Match firstMatch = queueSpans.remove(0);
        // create a list of matches with same startPosition as firstMatch
        List<Match> matches = new ArrayList<>();
        matches.add(firstMatch);
        // matches.addAll(expandWithIgnoreItem(spans.docID(), firstMatch));
        // try to collect spans until lastStartPosition not equal to
        // startPosition of firstMatch
        while (!lastSpan && (lastStartPosition == firstMatch.startPosition())) {
          collectSpan();
        }
        while (!queueSpans.isEmpty() && (queueSpans.get(0)
            .startPosition() == firstMatch.startPosition())) {
          Match additionalMatch = queueSpans.remove(0);
          matches.add(additionalMatch);
          matches.addAll(expandWithIgnoreItem(spans.docID(), additionalMatch));
        }
        // construct all matches for this startPosition
        for (Match match : matches) {
          for (int n = (minimumRecurrence - 1); n <= (maximumRecurrence
              - 1); n++) {
            findMatches(match, n);
          }
        }
        // check for something in queue of matches
        if (!queueMatches.isEmpty()) {
          ignoreItem.removeBefore(spans.docID(),
              queueMatches.get(0).startPosition());
          return true;
        }
      }
    }
  }
387430
public FieldType calcFieldType( String content ) {
        final SnippetBuilder.SnippetType snippetType = SnippetBuilder.getType( content );
        if ( snippetType.equals( SnippetBuilder.SnippetType.FORALL ) ) {
            return FieldType.FORALL_FIELD;
        } else if ( !snippetType.equals(
                SnippetBuilder.SnippetType.SINGLE ) ) {
            return FieldType.NORMAL_FIELD;
        }
        for ( String op : operators ) {
            if ( content.endsWith( op ) ) {
                return FieldType.OPERATOR_FIELD;
            }
        }
        return FieldType.SINGLE_FIELD;
    }