List of usage examples for java.util TreeSet addAll
public boolean addAll(Collection<? extends E> c)
From source file:org.apache.hadoop.hbase.zookeeper.lock.ZKInterProcessWriteLock.java
/** * {@inheritDoc}// w ww . ja va2 s .c o m */ @Override protected String getLockPath(String createdZNode, List<String> children) throws IOException { TreeSet<String> sortedChildren = new TreeSet<String>(ZNodeComparator.COMPARATOR); sortedChildren.addAll(children); String pathToWatch = sortedChildren.lower(createdZNode); if (pathToWatch != null) { String nodeHoldingLock = sortedChildren.first(); String znode = ZKUtil.joinZNode(parentLockNode, nodeHoldingLock); handleLockMetadata(znode); } return pathToWatch; }
From source file:com.music.service.PiecePackService.java
@Transactional(readOnly = true) public List<PiecePack> getPiecePacks() { List<PiecePack> packs = dao.listOrdered(PiecePack.class, "priority"); // order pieces in memory, by likes for (PiecePack pack : packs) { TreeSet<Piece> pieces = new TreeSet<>(pieceComparator); pieces.addAll(pack.getPieces()); pack.setPieces(pieces);/*from w w w . j a v a 2s .co m*/ } return packs; }
From source file:com.linkedin.pinot.operator.filter.OrOperatorTest.java
@Test public void testUnionForTwoLists() { int[] docIds1 = new int[] { 2, 3, 10, 15, 16, 28 }; int[] docIds2 = new int[] { 3, 6, 8, 20, 28 }; TreeSet<Integer> treeSet = new TreeSet<>(); treeSet.addAll(Arrays.asList(ArrayUtils.toObject(docIds1))); treeSet.addAll(Arrays.asList(ArrayUtils.toObject(docIds2))); Iterator<Integer> expectedIterator = treeSet.iterator(); List<BaseFilterOperator> operators = new ArrayList<>(); operators.add(FilterOperatorTestUtils.makeFilterOperator(docIds1)); operators.add(FilterOperatorTestUtils.makeFilterOperator(docIds2)); OrOperator orOperator = new OrOperator(operators); BlockDocIdIterator iterator = orOperator.nextBlock().getBlockDocIdSet().iterator(); int docId;/*from www. j a v a2s . co m*/ while ((docId = iterator.next()) != Constants.EOF) { Assert.assertEquals(docId, expectedIterator.next().intValue()); } }
From source file:com.linkedin.pinot.operator.filter.OrOperatorTest.java
@Test public void testUnionForThreeLists() { int[] docIds1 = new int[] { 2, 3, 6, 10, 15, 16, 28 }; int[] docIds2 = new int[] { 3, 6, 8, 20, 28 }; int[] docIds3 = new int[] { 1, 2, 3, 6, 30 }; TreeSet<Integer> treeSet = new TreeSet<>(); treeSet.addAll(Arrays.asList(ArrayUtils.toObject(docIds1))); treeSet.addAll(Arrays.asList(ArrayUtils.toObject(docIds2))); treeSet.addAll(Arrays.asList(ArrayUtils.toObject(docIds3))); Iterator<Integer> expectedIterator = treeSet.iterator(); List<BaseFilterOperator> operators = new ArrayList<>(); operators.add(FilterOperatorTestUtils.makeFilterOperator(docIds1)); operators.add(FilterOperatorTestUtils.makeFilterOperator(docIds2)); operators.add(FilterOperatorTestUtils.makeFilterOperator(docIds3)); OrOperator orOperator = new OrOperator(operators); BlockDocIdIterator iterator = orOperator.nextBlock().getBlockDocIdSet().iterator(); int docId;/*from w w w . ja va 2s . co m*/ while ((docId = iterator.next()) != Constants.EOF) { Assert.assertEquals(docId, expectedIterator.next().intValue()); } }
From source file:com.linkedin.pinot.operator.filter.OrOperatorTest.java
@Test public void testComplex() { int[] docIds1 = new int[] { 2, 3, 6, 10, 15, 16, 28 }; int[] docIds2 = new int[] { 3, 6, 8, 20, 28 }; int[] docIds3 = new int[] { 1, 2, 3, 6, 30 }; TreeSet<Integer> treeSet = new TreeSet<>(); treeSet.addAll(Arrays.asList(ArrayUtils.toObject(docIds1))); treeSet.addAll(Arrays.asList(ArrayUtils.toObject(docIds2))); treeSet.addAll(Arrays.asList(ArrayUtils.toObject(docIds3))); Iterator<Integer> expectedIterator = treeSet.iterator(); List<BaseFilterOperator> childOperators = new ArrayList<>(); childOperators.add(FilterOperatorTestUtils.makeFilterOperator(docIds1)); childOperators.add(FilterOperatorTestUtils.makeFilterOperator(docIds2)); OrOperator childOrOperator = new OrOperator(childOperators); List<BaseFilterOperator> operators = new ArrayList<>(); operators.add(childOrOperator);//w ww . j a v a2 s . co m operators.add(FilterOperatorTestUtils.makeFilterOperator(docIds3)); OrOperator orOperator = new OrOperator(operators); BlockDocIdIterator iterator = orOperator.nextBlock().getBlockDocIdSet().iterator(); int docId; while ((docId = iterator.next()) != Constants.EOF) { Assert.assertEquals(docId, expectedIterator.next().intValue()); } }
From source file:net.sourceforge.fenixedu.domain.residence.ResidenceYear.java
public Set<ResidenceMonth> getSortedMonths() { TreeSet<ResidenceMonth> months = new TreeSet<ResidenceMonth>(new BeanComparator("month")); months.addAll(getMonthsSet()); return months; }
From source file:org.apache.hadoop.hbase.zookeeper.lock.HWriteLockImpl.java
/** * {@inheritDoc}// w w w.ja v a 2s.c om */ @Override protected String getLockPath(String createdZNode, List<String> children) throws IOException, InterruptedException { TreeSet<String> sortedChildren = new TreeSet<String>(new ZNodeComparator(zkWrapper.getIdentifier())); sortedChildren.addAll(children); String pathToWatch = sortedChildren.lower(createdZNode); if (pathToWatch != null) { String nodeHoldingLock = sortedChildren.first(); try { handleLockMetadata(nodeHoldingLock); } catch (IOException e) { LOG.warn("Error processing lock metadata in " + nodeHoldingLock, e); } } return pathToWatch; }
From source file:org.apache.accumulo.shell.commands.AddSplitsCommand.java
@Override public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception { final String tableName = OptUtil.getTableOpt(cl, shellState); final boolean decode = cl.hasOption(base64Opt.getOpt()); final TreeSet<Text> splits = new TreeSet<Text>(); if (cl.hasOption(optSplitsFile.getOpt())) { splits.addAll(ShellUtil.scanFile(cl.getOptionValue(optSplitsFile.getOpt()), decode)); } else {//from ww w . j a v a 2 s .c o m if (cl.getArgList().isEmpty()) { throw new MissingArgumentException("No split points specified"); } for (String s : cl.getArgs()) { splits.add(new Text(s.getBytes(Shell.CHARSET))); } } if (!shellState.getConnector().tableOperations().exists(tableName)) { throw new TableNotFoundException(null, tableName, null); } shellState.getConnector().tableOperations().addSplits(tableName, splits); return 0; }
From source file:base.Engine.java
static Set<TreeSet<PatternInstance>> addPair(Set<TreeSet<PatternInstance>> returnSet, PatternInstance p1, PatternInstance p2) {//from w ww . ja v a 2s . co m TreeSet<PatternInstance> t1 = null; TreeSet<PatternInstance> t2 = null; for (TreeSet<PatternInstance> aTree : returnSet) { if (aTree.contains(p1)) { t1 = aTree; break; } } for (TreeSet<PatternInstance> aTree : returnSet) { if (aTree.contains(p2)) { t2 = aTree; break; } } if (t1 == null && t2 == null) { TreeSet<PatternInstance> newTree = new TreeSet<>(new InstanceComparator()); newTree.add(p1); newTree.add(p2); returnSet.add(newTree); } else if (t1 == null && t2 != null) { t2.add(p1); } else if (t1 != null && t2 == null) { t1.add(p2); } else if (t1 != t2) { t1.addAll(t2); returnSet.remove(t2); } return returnSet; }
From source file:com.linkedin.pinot.operator.OrOperatorTest.java
@Test public void testIntersectionForTwoLists() { int[] list1 = new int[] { 2, 3, 10, 15, 16, 28 }; int[] list2 = new int[] { 3, 6, 8, 20, 28 }; ;/*from ww w . j a v a2s . c om*/ List<Operator> operators = new ArrayList<Operator>(); operators.add(makeFilterOperator(list1)); operators.add(makeFilterOperator(list2)); final OrOperator orOperator = new OrOperator(operators); orOperator.open(); Block block; TreeSet<Integer> set = new TreeSet<Integer>(); set.addAll(Lists.newArrayList(ArrayUtils.toObject(list1))); set.addAll(Lists.newArrayList(ArrayUtils.toObject(list2))); Iterator<Integer> expectedIterator = set.iterator(); while ((block = orOperator.nextBlock()) != null) { final BlockDocIdSet blockDocIdSet = block.getBlockDocIdSet(); final BlockDocIdIterator iterator = blockDocIdSet.iterator(); int docId; while ((docId = iterator.next()) != Constants.EOF) { Assert.assertEquals(expectedIterator.next().intValue(), docId); } } orOperator.close(); }