To facilitate the management of what could be many nodes found by a single query,
 we forward off any unknown methods to each node in the results query.
 We assume that if one node accepts the method, then all of them will.
10795
def method_missing(name, *args)
      if self[0].respond_to?(name)
        self.inject(QueryResult.new) do |memo, node|
          ret = node.send(name, *args)
          memo << ret if ret
          memo
        end
      else
        super
      end
    end
266220
private void processForwardDeclare(Node n, Node parent) {
    CodingConvention convention = compiler.getCodingConvention();

    String typeDeclaration = null;
    try {
      typeDeclaration = Iterables.getOnlyElement(
          convention.identifyTypeDeclarationCall(n));
    } catch (NullPointerException | NoSuchElementException | IllegalArgumentException e) {
      compiler.report(
          JSError.make(
              n,
              INVALID_FORWARD_DECLARE,
              "A single type could not identified for the goog.forwardDeclare statement"));
    }

    if (typeDeclaration != null) {
      compiler.forwardDeclareType(typeDeclaration);
      // Forward declaration was recorded and we can remove the call.
      Node toRemove = parent.isExprResult() ? parent : parent.getParent();
      NodeUtil.deleteNode(toRemove, compiler);
    }
  }
982165
def find_all(self, **names):
        
        values = names.items()
        if len(values) != 1:
            raise ValueError('Only one query is allowed at a time')
        name, value = values[0]
        for item in self:
            if item.get(name) == value:
                yield item
18075
protected boolean processQueryParameters(Trace trace, Node node) {
        boolean ret = false;

        // Translate query string into a map
        Set<Property> queryString = node.getProperties(Constants.PROP_HTTP_QUERY);
        if (!queryString.isEmpty()) {
            StringTokenizer st = new StringTokenizer(queryString.iterator().next().getValue(), "&");
            while (st.hasMoreTokens()) {
                String token = st.nextToken();
                String[] namevalue = token.split("=");
                if (namevalue.length == 2) {
                    if (queryParameters.contains(namevalue[0])) {
                        try {
                            node.getProperties().add(new Property(namevalue[0],
                                    URLDecoder.decode(namevalue[1], "UTF-8")));
                            ret = true;
                        } catch (UnsupportedEncodingException e) {
                            if (log.isLoggable(Level.FINEST)) {
                                log.finest("Failed to decode value '" + namevalue[1] + "': " + e);
                            }
                        }
                    } else if (log.isLoggable(Level.FINEST)) {
                        log.finest("Ignoring query parameter '" + namevalue[0] + "'");
                    }
                } else if (log.isLoggable(Level.FINEST)) {
                    log.finest("Query string part does not include name/value pair: " + token);
                }
            }
        }

        return ret;
    }
973262
def def_forward(mappings, *names)
      if mappings.instance_of? Hash
        mappings.each do |method_name, target|
          define_singleton_method method_name do |*args, &block|
            self.config = config.public_send(target, *args, &block)
          end
        end
      else
        def_forward([mappings, *names].map{|name| {name => name}}.inject(:merge))
      end
    end
1293503
def recurse(query, index):
    
    for node in app.store.find(query):
        if node.is_leaf:
            index.add(node.path)
        else:
            recurse('{0}.*'.format(node.path), index)
612725
public static NextNodeAndQuery getNextNodeAndQuery(IntermediateQuery query,
                                                       NodeCentricOptimizationResults<? extends QueryNode> results) {

        /**
         * If there is still a node at center: gets the next one of it
         */
        Optional<? extends QueryNode> optionalNewNode = results.getOptionalNewNode();
        if (optionalNewNode.isPresent()) {
            Optional<QueryNode> optionalNextNode = getDepthFirstNextNode(query, optionalNewNode.get());

            return new NextNodeAndQuery(optionalNextNode, query);
        }

        /**
         * Otherwise, if there is a replacing child: returns it
         */
        Optional<QueryNode> optionalReplacingChild = results.getOptionalReplacingChild();
        if (optionalReplacingChild.isPresent()) {
            return new NextNodeAndQuery(optionalReplacingChild, query);
        }

        /**
         * Otherwise, if there is a next sibling: returns it
         */
        Optional<QueryNode> optionalNextSibling = results.getOptionalNextSibling();
        if (optionalNextSibling.isPresent()) {
            return new NextNodeAndQuery(optionalNextSibling, query);
        }

        /**
         * Otherwise, looks for the next node of the closest ancestor (already visited)
         */
        Optional<QueryNode> optionalClosestAncestor = results.getOptionalClosestAncestor();
        if (optionalClosestAncestor.isPresent()) {
            Optional<QueryNode> optionalNextNode = getDepthFirstNextNode(query, optionalClosestAncestor.get(), true);
            return new NextNodeAndQuery(optionalNextNode, query);
        }
        /**
         * Nothing else to explore
         */
        else {
            return new NextNodeAndQuery(Optional.<QueryNode>empty(), query);
        }
    }
1158157
function() {
    var query = new nodes.Query
      , expr
      , pred
      , id;

    // hash values support
    if ('ident' == this.peek().type
      && ('.' == this.lookahead(2).type
      || '[' == this.lookahead(2).type)) {
      this.cond = true;
      expr = this.expression();
      this.cond = false;
      query.push(new nodes.Feature(expr.nodes));
      return query;
    }

    if (pred = this.accept('ident') || this.accept('not')) {
      pred = new nodes.Literal(pred.val.string || pred.val);

      this.skipSpacesAndComments();
      if (id = this.accept('ident')) {
        query.type = id.val;
        query.predicate = pred;
      } else {
        query.type = pred;
      }
      this.skipSpacesAndComments();

      if (!this.accept('&&')) return query;
    }

    do {
      query.push(this.feature());
    } while (this.accept('&&'));

    return query;
  }
749036
def __get_known_node(self, ip, host):
        '''
        
        '''
        # already known by IP ?
        for ex in self.nodes:
            for exip in ex.ip:
                if (exip == '0.0.0.0'):
                    continue
                if (exip == ip):
                    return (ex, 0)

        # already known by HOST ?
        node = self.__get_known_node_by_host(host)
        if (node != None):
            # node already known
            if (ip not in node.ip):
                node.ip.append(ip)
                return (node, 1)
            return (node, 0)

        return (None, 0)
184521
def _process_queries(self, queries):
        
        # First, let's mush everything into a single Q. Then we can
        # parse that into bits.
        new_q = Q()

        for query in queries:
            new_q += query

        # Now we have a single Q that needs to be processed.
        should_q = [self._process_query(query) for query in new_q.should_q]
        must_q = [self._process_query(query) for query in new_q.must_q]
        must_not_q = [self._process_query(query) for query in new_q.must_not_q]

        if len(must_q) > 1 or (len(should_q) + len(must_not_q) > 0):
            # If there's more than one must_q or there are must_not_q
            # or should_q, then we need to wrap the whole thing in a
            # boolean query.
            bool_query = {}
            if must_q:
                bool_query['must'] = must_q
            if should_q:
                bool_query['should'] = should_q
            if must_not_q:
                bool_query['must_not'] = must_not_q
            return {'bool': bool_query}

        if must_q:
            # There's only one must_q query and that's it, so we hoist
            # that.
            return must_q[0]

        return {}
874567
private void moveNextResults(boolean clearPreviousResults) {
        if (clearPreviousResults) {
            allResults.clear();
        }
        allResults.addAll(nextResults);
        nextResults.clear();
    }
1039157
function( query, elements ){
        if( query != null ){
          var matches = false;
          elements = elements(); // make elements functional so we save cycles if query == null

          // query must match for at least one element (may be recursive)
          for(var i = 0; i < elements.size(); i++){
            if( queryMatches( query, elements.eq(i) ) ){
              matches = true;
              break;
            }
          }

          return matches;
        } else {
          return true;
        }
      }
947221
def already_resolved(self, pattern: QueryTriple) -> bool:
        
        if self.sparql_locked or pattern == (None, None, None):
            return True
        for resolved_node in self.resolved_nodes:
            if resolved_node != (None, None, None) and \
                    (pattern[0] == resolved_node[0] or resolved_node[0] is None) and \
                    (pattern[1] == resolved_node[1] or resolved_node[1] is None) and\
                    (pattern[2] == resolved_node[2] or resolved_node[2] is None):
                return True
        return False
1232471
def map_query_to_results

			#Initalize map
			result_map = initialize_map

			# Apply the normalization to the result map
			normalized = get_query_map("normalized")
			if normalized
				result_map = get_normalizations_for(result_map, normalized)
			end

			# Apply the redirects to the result map
			redirects = get_query_map("redirects")
			if redirects
				result_map = get_redirects_for(result_map, redirects)
			end

			result_map

		end
1081018
public void prepareForEnumeration() {
        if (isPreparer()) {
            for (NodeT node : nodeTable.values()) {
                // Prepare each node for traversal
                node.initialize();
                if (!this.isRootNode(node)) {
                    // Mark other sub-DAGs as non-preparer
                    node.setPreparer(false);
                }
            }
            initializeDependentKeys();
            initializeQueue();
        }
    }
503869
private NextNodeAndQuery optimizeJoinOrFilter(IntermediateQuery currentQuery, JoinOrFilterNode currentNode) {

        /**
         * Tries to build a PushDownBooleanExpressionProposal for the current node
         */
        Optional<PushDownBooleanExpressionProposal> optionalProposal = makeProposal(
                currentQuery, currentNode);

        /**
         * Applies it and extracts from the results the necessary information
         * for continuing the navigation
         */
        if (optionalProposal.isPresent()) {
            PushDownBooleanExpressionProposal proposal = optionalProposal.get();

            // Applies the proposal and casts the results
            NodeCentricOptimizationResults<JoinOrFilterNode> results;
            try {
                results = currentQuery.applyProposal(proposal);
            } catch (EmptyQueryException e) {
                throw new IllegalStateException("Unexpected empty query exception while pushing down boolean expressions");
            }

            return getNextNodeAndQuery(currentQuery, results);
        } else {
            return new NextNodeAndQuery(getDepthFirstNextNode(currentQuery, currentNode), currentQuery);
        }
    }
1179523
def perfom_query(iterator, &block)
      if example
        connection.by_example(example, options).each(&iterator)
      else
        connection.all(options).each(&iterator)
      end
    end