Codota Logo
QueryTree
Code IndexAdd Codota to your IDE (free)

How to use
QueryTree
in
com.yahoo.search.query

Best Java code snippets using com.yahoo.search.query.QueryTree (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
SimpleDateFormat s =
  • Codota IconString pattern;new SimpleDateFormat(pattern)
  • Codota IconString template;Locale locale;new SimpleDateFormat(template, locale)
  • Codota Iconnew SimpleDateFormat()
  • Smart code suggestions by Codota
}
origin: vespa-engine/sample-apps

private void addAndItem(QueryTree q, String term) {
  Item root = q.getRoot();
  CompositeItem compositeRoot;
  if (root instanceof AndItem) {
    compositeRoot = (CompositeItem) root;
  } else {
    compositeRoot = new AndItem();
    compositeRoot.addItem(root);
    q.setRoot(compositeRoot);
  }
  compositeRoot.addItem(new WordItem(term));
}
origin: com.yahoo.vespa/container-search

protected final Item simplifyUnnecessaryComposites(Item item) {
  if (item == null) return null;
  QueryTree root = new QueryTree(item);
  QueryCanonicalizer.canonicalize(root);
  return root.getRoot() instanceof NullItem ? null : root.getRoot();
}
origin: com.yahoo.vespa/container-search

@Override
public Object clone() {
  try {
    Model clone = (Model)super.clone();
    if (queryTree != null)
      clone.queryTree = this.queryTree.clone();
    if (sources != null)
      clone.sources = new LinkedHashSet<>(this.sources);
    if (restrict != null)
      clone.restrict = new LinkedHashSet<>(this.restrict);
    return clone;
  }
  catch (CloneNotSupportedException e) {
    throw new RuntimeException("Someone inserted a noncloneable superclass", e);
  }
}
origin: com.yahoo.vespa/container-search

/** Returns the query root. This is null if this is a null query. */
public Item getRoot() {
  if (getItemCount() == 0) return null;
  return getItem(0);
}
origin: com.yahoo.vespa/container-search

/** Returns true if this represents the null query */
public boolean isEmpty() {
  return getRoot() instanceof NullItem || getItemCount() == 0;
}
origin: com.yahoo.vespa/container-search

public void setIndexName(String index) {
  if (getRoot() != null)
    getRoot().setIndexName(index);
}
origin: com.yahoo.vespa/container-search

/** Modifies this query to become the current query AND the given item */
// TODO: Make sure this is complete, unit test and make it public
private void and(Item item) {
  if (isEmpty()) {
    setRoot(item);
  }
  else if (getRoot() instanceof NotItem && item instanceof NotItem) {
    throw new IllegalArgumentException("Can't AND two NOTs"); // TODO: Complete
  }
  else if (getRoot() instanceof NotItem){
    NotItem notItem = (NotItem)getRoot();
    notItem.addPositiveItem(item);
  }
  else if (item instanceof NotItem){
    NotItem notItem = (NotItem)item;
    notItem.addPositiveItem(getRoot());
    setRoot(notItem);
  }
  else {
    AndItem andItem = new AndItem();
    andItem.addItem(getRoot());
    andItem.addItem(item);
    setRoot(andItem);
  }
}
origin: com.yahoo.vespa/container-search

public QueryTree(Item root) {
  setRoot(root);
}
origin: com.yahoo.vespa/container-search

private String queryTreeText() {
  QueryTree root = getModel().getQueryTree();
  if (getTraceLevel() < 2)
    return root.toString();
  if (getTraceLevel() < 6)
    return yqlRepresentation();
  else
    return "\n" + yqlRepresentation() + "\n" + new TextualQueryRepresentation(root.getRoot()) + "\n";
}
origin: com.yahoo.vespa/container-search

public final void setRoot(Item root) {
  if (root == this) throw new IllegalArgumentException("Cannot make a root point at itself");
  if (root == null) throw new IllegalArgumentException("Root must not be null, use NullItem instead.");
  if (root instanceof QueryTree) throw new IllegalArgumentException("Do not use a new QueryTree instance as a root.");
  if (this.getItemCount() == 0) // initializing
    super.addItem(root);
  else
    setItem(0,root); // replacing
}
origin: com.yahoo.vespa/container-search

/**
 * Canonicalize this query
 * 
 * @return null if the query is valid, an error message if it is invalid
 */
public static String canonicalize(QueryTree query) {
  ListIterator<Item> rootItemIterator = query.getItemIterator();
  CanonicalizationResult result = recursivelyCanonicalize(rootItemIterator.next(), rootItemIterator);
  if (query.isEmpty() && ! result.isError()) result = CanonicalizationResult.error("No query");
  return result.error().orElse(null); // preserve old API, unfortunately
}
origin: com.yahoo.vespa/container-search

@Override
public QueryTree parse(Parsable query) {
  Item root = parse(query.getQuery(), null, null, null, null, null);
  if (root == null) {
    root = new NullItem();
  }
  return new QueryTree(root);
}
origin: com.yahoo.vespa/container-search

/** Returns a deep copy of this */
@Override
public QueryTree clone() {
  QueryTree clone = (QueryTree) super.clone();
  fixClonedConnectivityReferences(clone);
  return clone;
}
origin: com.yahoo.vespa/container-search

/**
 * Encodes this query onto the given buffer
 *
 * @param buffer The buffer to encode the query to
 * @return the number of encoded items
 */
public int encode(ByteBuffer buffer) {
  return model.getQueryTree().encode(buffer);
}
origin: com.yahoo.vespa/container-search

@Override
public void addItem(Item item) {
  if (getItemCount()==0)
    super.addItem(item);
  else
    throw new RuntimeException("Programming error: Cannot add multiple roots");
}
origin: com.yahoo.vespa/container-search

public int encode(ByteBuffer buffer) {
  if (getRoot() == null) return 0;
  return getRoot().encode(buffer);
}
origin: com.yahoo.vespa/container-search

static public void andQueryItemWithRoot(QueryTree tree, Item item) {
  if (tree.isEmpty()) {
    tree.setRoot(item);
  } else {
    Item oldRoot = tree.getRoot();
    if (oldRoot.getClass() == AndItem.class) {
      ((AndItem) oldRoot).addItem(item);
    } else {
      AndItem newRoot = new AndItem();
      newRoot.addItem(oldRoot);
      newRoot.addItem(item);
      tree.setRoot(newRoot);
    }
  }
}
origin: com.yahoo.vespa/container-search

private void insertMutableInTree(CompositeItem mutable, CompositeItem original, CompositeItem parent) {
  if (parent == null) {
    query.getModel().getQueryTree().setRoot(mutable);
  } else {
    int parentsIndex = parent.getItemIndex(original);
    parent.setItem(parentsIndex, mutable);
  }
}
origin: com.yahoo.vespa/container-search

@Override
public void addItem(int index, Item item) {
  if (getItemCount()==0 && index==0)
    super.addItem(index,item);
  else
    throw new RuntimeException("Programming error: Cannot add multiple roots, have '" + getRoot() + "'");
}
origin: com.yahoo.vespa/container-search

@NonNull
private QueryTree buildTree(OperatorNode<?> filterPart) {
  Preconditions.checkArgument(filterPart.getArguments().length == 2,
                "Expected 2 arguments to filter, got %s.",
                filterPart.getArguments().length);
  populateYqlSources(filterPart.<OperatorNode<?>> getArgument(0));
  OperatorNode<ExpressionOperator> filterExpression = filterPart.getArgument(1);
  Item root = convertExpression(filterExpression);
  connectItems();
  userQuery = null;
  return new QueryTree(root);
}
com.yahoo.search.queryQueryTree

Javadoc

The root node of a query tree. This is always present above the actual semantic root to ease query manipulation, especially replacing the actual semantic root, but does not have any search semantics on its own.

To ease recursive manipulation of the query tree, this is a composite having one child, which is the actual root.

  • Setting the root item (at position 0, either directly or though the iterator of this, works as expected. Setting at any other position is disallowed.
  • Removing the root is allowed and causes this to be a null query.
  • Adding an item is only allowed if this is currently a null query (having no root)

This is also the home of accessor methods which eases querying into and manipulation of the query tree.

Most used methods

  • setRoot
  • getRoot
    Returns the query root. This is null if this is a null query.
  • <init>
  • clone
    Returns a deep copy of this
  • encode
  • fixClonedConnectivityReferences
  • getItem
  • getItemCount
  • getItemIterator
  • getPositiveTerms
  • isEmpty
    Returns true if this represents the null query
  • setItem
  • isEmpty,
  • setItem,
  • toString

Popular in Java

  • Parsing JSON documents to java classes using gson
  • setRequestProperty (URLConnection)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • setContentView (Activity)
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • Thread (java.lang)
    A thread is a thread of execution in a program. The Java Virtual Machine allows an application to ha
  • URLConnection (java.net)
    The abstract class URLConnection is the superclass of all classes that represent a communications li
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • Timer (java.util)
    A facility for threads to schedule tasks for future execution in a background thread. Tasks may be s
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now