Attempts to retrieve all trees from the UID table, including their rules.
If no trees were found, the result will be an empty list
@param tsdb The TSDB to use for storage
@return A list of tree objects. May be empty if none were found
169456
public static Deferred<List<Tree>> fetchAllTrees(final TSDB tsdb) {
    
    final Deferred<List<Tree>> result = new Deferred<List<Tree>>();
    
    /**
     * Scanner callback that recursively calls itself to load the next set of
     * rows from storage. When the scanner returns a null, the callback will
     * return with the list of trees discovered.
     */
    final class AllTreeScanner implements Callback<Object, 
      ArrayList<ArrayList<KeyValue>>> {
  
      private final List<Tree> trees = new ArrayList<Tree>();
      private final Scanner scanner;
      
      public AllTreeScanner() {
        scanner = setupAllTreeScanner(tsdb);
      }
      
      /**
       * Fetches the next set of results from the scanner and adds this class
       * as a callback.
       * @return A list of trees if the scanner has reached the end
       */
      public Object fetchTrees() {
        return scanner.nextRows().addCallback(this);
      }
      
      @Override
      public Object call(ArrayList<ArrayList<KeyValue>> rows)
          throws Exception {
        if (rows == null) {
          result.callback(trees);
          return null;
        }
        
        for (ArrayList<KeyValue> row : rows) {
          final Tree tree = new Tree();
          for (KeyValue column : row) {
            if (column.qualifier().length >= TREE_QUALIFIER.length && 
                Bytes.memcmp(TREE_QUALIFIER, column.qualifier()) == 0) {
              // it's *this* tree. We deserialize to a new object and copy
              // since the columns could be in any order and we may get a rule 
              // before the tree object
              final Tree local_tree = JSON.parseToObject(column.value(), 
                  Tree.class);
              tree.created = local_tree.created;
              tree.description = local_tree.description;
              tree.name = local_tree.name;
              tree.notes = local_tree.notes;
              tree.strict_match = local_tree.strict_match;
              tree.enabled = local_tree.enabled;
              tree.store_failures = local_tree.store_failures;
              
              // WARNING: Since the JSON data in storage doesn't contain the tree
              // ID, we need to parse it from the row key
              tree.setTreeId(bytesToId(row.get(0).key()));
              
            // tree rule
            } else if (column.qualifier().length > TreeRule.RULE_PREFIX().length &&
                Bytes.memcmp(TreeRule.RULE_PREFIX(), column.qualifier(), 
                0, TreeRule.RULE_PREFIX().length) == 0) {
              final TreeRule rule = TreeRule.parseFromStorage(column);
              tree.addRule(rule);
            }
          }
          
          // only add the tree if we parsed a valid ID
          if (tree.tree_id > 0) {
            trees.add(tree);
          }
        }
        
        // recurse to get the next set of rows from the scanner
        return fetchTrees();
      }
      
    }
    
    // start the scanning process
    new AllTreeScanner().fetchTrees();
    return result;
  }
961268
public List<Action> getRootActions() {
		final List<Action> rootActions = srcUpdTrees.stream().map(t -> originalActionsSrc.get(t))
				.collect(Collectors.toList());

		rootActions.addAll(srcDelTrees.stream() //
				.filter(t -> !srcDelTrees.contains(t.getParent()) && !srcUpdTrees.contains(t.getParent())) //
				.map(t -> originalActionsSrc.get(t)) //
				.collect(Collectors.toList()));

		rootActions.addAll(dstAddTrees.stream() //
				.filter(t -> !dstAddTrees.contains(t.getParent()) && !dstUpdTrees.contains(t.getParent())) //
				.map(t -> originalActionsDst.get(t)) //
				.collect(Collectors.toList()));

		rootActions.addAll(dstMvTrees.stream() //
				.filter(t -> !dstMvTrees.contains(t.getParent())) //
				.map(t -> originalActionsDst.get(t)) //
				.collect(Collectors.toList()));

		rootActions.removeAll(Collections.singleton(null));
		return rootActions;
	}
437896
@Override
	public Iterable<T> findAllById(final Iterable<ID> ids) {
		return arangoOperations.find(ids, domainClass);
	}
790120
public Optional<DataType> get( Object tree, List<String> keys ) {

        if ( keys.size() != traversalLength ) {
            throw new TraversrException( "Traversal Path and number of keys mismatch, traversalLength:" + traversalLength + " numKeys:" + keys.size() );
        }

        return root.traverse( tree, TraversalStep.Operation.GET, keys.iterator(), null );
    }
122507
private void handleRule(TSDB tsdb, HttpQuery query) {
    final TreeRule rule;
    if (query.hasContent()) {
      rule = query.serializer().parseTreeRuleV1();
    } else {
      rule = parseRule(query);
    }
    
    try {
      
      // no matter what, we'll need a tree to work with, so make sure it exists
      Tree tree = null;
        tree = Tree.fetchTree(tsdb, rule.getTreeId())
          .joinUninterruptibly();
  
      if (tree == null) {
        throw new BadRequestException(HttpResponseStatus.NOT_FOUND, 
            "Unable to locate tree: " + rule.getTreeId());
      }
      
      // if get, then we're just returning a rule from a tree
      if (query.getAPIMethod() == HttpMethod.GET) {
        
        final TreeRule tree_rule = tree.getRule(rule.getLevel(), 
            rule.getOrder());
        if (tree_rule == null) {
          throw new BadRequestException(HttpResponseStatus.NOT_FOUND, 
              "Unable to locate rule: " + rule);
        }
        query.sendReply(query.serializer().formatTreeRuleV1(tree_rule));
        
      } else if (query.getAPIMethod() == HttpMethod.POST || query.getAPIMethod() == HttpMethod.PUT) {
  
        if (rule.syncToStorage(tsdb, (query.getAPIMethod() == HttpMethod.PUT))
            .joinUninterruptibly()) {
          final TreeRule stored_rule = TreeRule.fetchRule(tsdb, 
              rule.getTreeId(), rule.getLevel(), rule.getOrder())
              .joinUninterruptibly();
          query.sendReply(query.serializer().formatTreeRuleV1(stored_rule));
        } else {
          throw new RuntimeException("Unable to save rule " + rule + 
              " to storage");
        }
  
      } else if (query.getAPIMethod() == HttpMethod.DELETE) {
  
        if (tree.getRule(rule.getLevel(), rule.getOrder()) == null) {
          throw new BadRequestException(HttpResponseStatus.NOT_FOUND, 
              "Unable to locate rule: " + rule);
        }
        TreeRule.deleteRule(tsdb, tree.getTreeId(), rule.getLevel(), 
            rule.getOrder()).joinUninterruptibly(); 
        query.sendStatusOnly(HttpResponseStatus.NO_CONTENT);
  
      } else {
        throw new BadRequestException(HttpResponseStatus.BAD_REQUEST, 
          "Unsupported HTTP request method");
      }
    
    } catch (BadRequestException e) {
      throw e;
    } catch (IllegalStateException e) {
      query.sendStatusOnly(HttpResponseStatus.NOT_MODIFIED);
    } catch (IllegalArgumentException e) {
      throw new BadRequestException(e);
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
610880
private List<Row> getTable(String name)
   {
      List<Row> result = m_tables.get(name);
      if (result == null)
      {
         result = Collections.emptyList();
      }
      return result;
   }
986054
public static ImmutableSet<Symbol> findReferencedIdentifiers(Tree tree) {
    ImmutableSet.Builder<Symbol> builder = ImmutableSet.builder();
    createFindIdentifiersScanner(builder, null).scan(tree, null);
    return builder.build();
  }
35701
@SuppressWarnings("unchecked")
	@Pure
	public Tree<RoadPolyline, ?> getInternalTree() {
		if (this.roadSegments instanceof GISTreeSet<?, ?>) {
			return ((GISTreeSet<RoadPolyline, ?>) this.roadSegments).getTree();
		}
		return null;
	}
922395
@Override
    public List<String[]> getTableDataInArray() throws WidgetException {
        try {
            List<String[]> list = new ArrayList<String[]>();
            NodeList nodes = getNodeListUsingJavaXPath(getTableXPath(generateXPathLocator()) + "/tbody[1]");
            NodeList tbodyChildNodes = nodes.item(0).getChildNodes();
            for (int i = 0; i < tbodyChildNodes.getLength(); i++) {
                Node n = tbodyChildNodes.item(i);
                if (n != null && n.getNodeName() != null && n.getNodeName() != null
                        && n.getNodeName().equalsIgnoreCase("tr")) {
                    NamedNodeMap trNodeAttributes = n.getAttributes();
                    Node trStyleAttr = trNodeAttributes.getNamedItem("style");
                    boolean proceed = true;
                    if (trStyleAttr != null) {
                        String style = trStyleAttr.getTextContent();
                        style = style.toLowerCase();
                        if (style.contains("display: none") || style.contains("display:none")
                                || style.contains("visibility: hidden")) {
                            proceed = false;
                        }
                    }

                    if (proceed) {
                        List<String> rowData = new ArrayList<String>();
                        NodeList cnl = n.getChildNodes();
                        for (int j = 0; j < cnl.getLength(); j++) {
                            Node cn = cnl.item(j);

                            if (cn != null && cn.getNodeName() != null && cn.getNodeName() != null
                                    && cn.getNodeName().equalsIgnoreCase("td")) {
                                NamedNodeMap tdNodeAttributes = cn.getAttributes();
                                Node tdStyleAttr = tdNodeAttributes.getNamedItem("style");
                                if (tdStyleAttr != null) {
                                    String style = tdStyleAttr.getTextContent();
                                    style = style.toLowerCase();
                                    if (!(style.contains("display: none")
                                            || style.contains("display:none") || style
                                                .contains("visibility: hidden"))) {
                                        rowData.add(getRecursiveTextContext(cn).trim());
                                    }
                                } else {
                                    rowData.add(getRecursiveTextContext(cn).trim());
                                }
                            }
                        }

                        // If rowData size == 0 that means there were no TDs
                        // inside of TR.
                        // It triggers that the row was used as headers
                        if (rowData.size() > 0) {
                            list.add(rowData.toArray(new String[rowData.size()]));
                        }
                    }
                }
            }

            return list;
        } catch (Exception e) {
            throw new WidgetException("Error while getting table data in array", generateXPathLocator(), e);
        }
    }
596126
public <T extends JCTree> List<T> translate(List<T> trees, Type pt) {
        Type prevPt = this.pt;
        List<T> res;
        try {
            this.pt = pt;
            res = translate(trees);
        } finally {
            this.pt = prevPt;
        }
        return res;
    }
305769
@Override
    public List<T> getAll(final Collection<String> ids) {
        if (ids == null || ids.size() == 0) {
            return Collections.<T> emptyList();
        }

        // we need a List of ids to partition
        final List<String> idList;
        if (ids instanceof List) {
            idList = (List<String>) ids;
        } else {
            idList = Lists.newArrayList(ids);
        }

        // fetch records in groups of X
        List<T> result = null;
        for (final List<String> partition : Lists.partition(idList, config.getPartitionSize())) {
            result = doGetAll(result, partition);
        }

        // make sure we always return non-null list
        if (result == null) {
            return Collections.<T> emptyList();
        }
        return result;
    }
155470
public List<T> findAll() {
        if (cache && cachedObjects != null) {
            return cachedObjects;
        }

        List<String> ids = getObjectList();

        List<T> listT = new ArrayList<>();

        for (String id : ids) {
            listT.add(find(id));
        }

        if (cache) {
            cachedObjects = listT;
        }

        return listT;
    }
916815
@Override
    public Iterable<T> findAll(Iterable<I> ids) {
        List<T> results = new ArrayList<>();
        for (I id : ids) {
            T t = findOne(id);
            if (t != null) {
                results.add(t);
            }
        }
        return results;
    }
107963
public DecisionTree[] getTrees() {
        DecisionTree[] forest = new DecisionTree[trees.size()];
        for (int i = 0; i < forest.length; i++)
            forest[i] = trees.get(i).tree;

        return forest;
    }
387925
def facetrecordtrees(table, key, start='start', stop='stop'):
    

    import intervaltree
    getstart = attrgetter(start)
    getstop = attrgetter(stop)
    getkey = attrgetter(key)
    trees = dict()
    for rec in records(table):
        k = getkey(rec)
        if k not in trees:
            trees[k] = intervaltree.IntervalTree()
        trees[k].addi(getstart(rec), getstop(rec), rec)
    return trees
357493
public static Collection<Comparable<?>> getDatabaseShardingValues(final String logicTable) {
        return null == HINT_MANAGER_HOLDER.get() ? Collections.<Comparable<?>>emptyList() : HINT_MANAGER_HOLDER.get().databaseShardingValues.get(logicTable);
    }
1238438
private static List<Tree<Node>> getNewTree(Tree<Node> inst){	
		delDefault(inst);
		List<Tree<Node>> newTreeList = new ArrayList<Tree<Node>>();
		List<Tree<Node>> children = new ArrayList<Tree<Node>>();
		if(!inst.isLeaf()&&!inst.getFirstChild().isLeaf()){
			boolean hasPu = false;
			Tree<Node> newInst=null;
			for(int i=0;i<inst.getFirstChild().children.size();i++){
				children.add(inst.getFirstChild().getChild(i));				
				String tag = inst.getFirstChild().getLabel().getTag();
				String flag0 = inst.getFirstChild().getChild(i).getLabel().getTag();
				String data0 = inst.getFirstChild().getChild(i).getLabel().getData();			
				if(flag0.equals("PU")&&
						(data0.equals("，")
						||data0.equals("；")
						||data0.equals("、")
						||data0.equals("。")
						||data0.equals("！")
						||data0.equals("？"))){
					hasPu = true;
					if(children.size()!=0)
						newInst = new Tree<Node>(new Node(tag,"",0),children);
					else
						newInst = new Tree<Node>(new Node(tag,"",0));
					
					newTreeList.add(newInst);
					children = new ArrayList<Tree<Node>>();
				}				
			}
			if(!hasPu)
				newTreeList.add(inst);
		}
		return newTreeList;
	}