public String getPaths() { return pathDeque.stream().collect(Collectors.joining("")); }
static String formatIndexes(Deque<Integer> indexes) { if (indexes == null || indexes.isEmpty()) { return ""; } String indexesString = indexes.stream().map(Object::toString).collect(joining("][", "[", "]")); return " at index " + indexesString; }
private List<String> mkPath(Deque<T> copy) { return copy.stream() .filter(node1 -> node1 instanceof NamedNode) .map(node1 -> ((NamedNode) node1).getName()) .collect(Collectors.toList()); }
SchemaGeneratorDirectiveHelper.Parameters mkBehaviourParams() { List<NamedNode> list = nodeStack.stream() .filter(NamedNode.class::isInstance) .map(NamedNode.class::cast) .collect(Collectors.toList()); Deque<NamedNode> deque = new ArrayDeque<>(list); return new SchemaGeneratorDirectiveHelper.Parameters(typeRegistry, wiring, new NodeParentTree<>(deque), directiveBehaviourContext, codeRegistry); }
/** * Stops the scheduler and all tasks. */ public void stop() { cancelAllTasks(); worlds.stop(); executor.shutdownNow(); asyncTaskExecutor.shutdown(); synchronized (inTickTaskCondition) { inTickTasks.stream().filter(task -> task instanceof Future) .forEach(task -> ((Future) task).cancel(false)); inTickTasks.clear(); } }
/** * Checks whether there is any invalid family name in HFiles to be bulk loaded. */ private void validateFamiliesInHFiles(Table table, Deque<LoadQueueItem> queue, boolean silence) throws IOException { Set<String> familyNames = Arrays.asList(table.getDescriptor().getColumnFamilies()).stream() .map(f -> f.getNameAsString()).collect(Collectors.toSet()); List<String> unmatchedFamilies = queue.stream().map(item -> Bytes.toString(item.getFamily())) .filter(fn -> !familyNames.contains(fn)).distinct().collect(Collectors.toList()); if (unmatchedFamilies.size() > 0) { String msg = "Unmatched family names found: unmatched family names in HFiles to be bulkloaded: " + unmatchedFamilies + "; valid family names of table " + table.getName() + " are: " + familyNames; LOG.error(msg); if (!silence) { throw new IOException(msg); } } }
private Stream<InternalReader<?>> readersWithDefaults() { return Stream.concat(readers.stream(), Stream.of( reader(String.class, stringContentReader()), reader(byte[].class, ContentReaders.byteArrayReader()), reader(InputStream.class, ContentReaders.inputStreamReader()))); }
/** * Returns the cards of the library in a list ordered from top to buttom * * @param game * @return */ public List<Card> getCards(Game game) { return library.stream().map(game::getCard).collect(Collectors.toList()); }
public String dump(TimeUnit units) { long now = System.nanoTime(); synchronized(this) { String samples = _samples.stream() .mapToLong(t -> units.convert(now - t, TimeUnit.NANOSECONDS)) .mapToObj(Long::toString) .collect(Collectors.joining(System.lineSeparator())); return String.format("%s%n%s", toString(now), samples); } }
public int count(FilterCard filter, Game game) { return (int) library.stream().filter(cardId -> filter.match(game.getCard(cardId), game)).count(); }
public final static <T> boolean endsWith(final Stream<T> stream, final Iterable<T> iterable) { Tuple2<Integer,Iterator<T>> sizeAndIterator = findSize(iterable); final Deque<T> list = new ArrayDeque<T>(sizeAndIterator._1()); stream.forEach(v -> { list.add(v); if (list.size() > sizeAndIterator._1()) list.remove(); }); return startsWith(list.stream(), sizeAndIterator._2()); }
@Test public void testMutableDequeConcat() { Deque<Integer> one = new LinkedList<>(); one.add(1); one.add(2); one.add(3); Deque<Integer> two = new LinkedList<>(); two.add(4); two.add(5); two.add(6); Deque<Integer> result = BiFunctions.<Integer>mutableDequeConcat().apply(one, two); assertThat(result.stream().collect(Collectors.toList()),equalTo(asList(1,2,3,4,5,6))); }
private boolean handleControlFlowInFinally(Tree.Kind jumpKind) { if (jumpKind == Tree.Kind.BREAK_STATEMENT || jumpKind == Tree.Kind.CONTINUE_STATEMENT) { return false; } else { Tree.Kind parentOfControlFlowStatement = treeKindStack.stream() .filter(t -> t == Tree.Kind.BLOCK || t == Tree.Kind.METHOD) .findFirst() .orElse(Tree.Kind.METHOD); return parentOfControlFlowStatement == Tree.Kind.BLOCK; } }
@Override public Iterable<TransactionAware> getTransactionAwares() { return (txContext == null) ? NO_TX_AWARES : Stream.concat(activeTxAwares.values().stream(), extraTxAwares.stream())::iterator; }
/** * Convert a deque to a list. * * @param deque Deque to convert * @return Deque as a list */ private static List<String> dequeToList(final Deque<String> deque) { ArrayList<String> result = new ArrayList<>(); deque.stream().forEachOrdered(result::add); result.sort(String.CASE_INSENSITIVE_ORDER); return Collections.unmodifiableList(result); }
private void calcCumSum() { int[] inlierCounts = inlierPaneCounts.stream().mapToInt(i->i).toArray(); int[] outlierCounts = outlierPaneCounts.stream().mapToInt(i->i).toArray(); inlierCountCumSum = new ArrayList<>(inlierPaneCounts.size() + 1); outlierCountCumSum = new ArrayList<>(inlierPaneCounts.size() + 1); inlierCountCumSum.add(0); outlierCountCumSum.add(0); for (int i = 0; i < inlierPaneCounts.size(); i ++) { inlierCountCumSum.add(inlierCountCumSum.get(i) + (int)inlierCounts[i]); outlierCountCumSum.add(outlierCountCumSum.get(i) + (int)outlierCounts[i]); } }
private TreeModel getTreeModel(){ Deque<PMMLObject> parents = getParents(); return (TreeModel)parents.stream() .filter(TreeModel.class::isInstance) .findFirst().get(); } }
@Override public Spliterator<T> trySplit() { final List<Spliterator<T>> split = _spliterators.stream() .map(Spliterator::trySplit) .collect(Collectors.toList()); return split.stream().noneMatch(Objects::isNull) ? new ConcatSpliterator<>(split) : null; }
@Override public int characteristics() { return _spliterators.stream() .mapToInt(Spliterator::characteristics) .reduce(0xFFFFFFFF, (i1, i2) -> i1 & i2) & ~Spliterator.SORTED; }
public BsonDocument getProjectionDocument() throws JsonParseException { final BsonDocument projection = new BsonDocument(); if (keys == null || keys.isEmpty()) { return null; } else { keys.stream().forEach((String f) -> { projection.putAll(BsonDocument.parse(f)); // this can throw JsonParseException for invalid keys parameters }); } return projection; }