protected BoltRequestMessageReader( BoltConnection connection, BoltResponseHandler externalErrorResponseHandler, List<RequestMessageDecoder> decoders ) { this.connection = connection; this.externalErrorResponseHandler = externalErrorResponseHandler; this.decoders = decoders.stream().collect( toMap( RequestMessageDecoder::signature, identity() ) ); }
@Override public Map<Symbol, Symbol> visitIndexSource(IndexSourceNode node, Set<Symbol> lookupSymbols) { checkState(node.getLookupSymbols().equals(lookupSymbols), "lookupSymbols must be the same as IndexSource lookup symbols"); return lookupSymbols.stream().collect(toImmutableMap(identity(), identity())); } }
public Map<EntityChangeType, List<AtlasEntity>> getChangedDataSetEntities() { final Map<EntityChangeType, List<AtlasEntity>> changedEntities = Stream .of(rootInputPortEntities.values().stream(), rootOutputPortEntities.values().stream(), queues.values().stream()) .flatMap(Function.identity()) .collect(Collectors.groupingBy(entity -> getEntityChangeType(entity.getGuid()))); updateAudit.add("CREATED DataSet entities=" + changedEntities.get(EntityChangeType.CREATED)); updateAudit.add("UPDATED DataSet entities=" + changedEntities.get(EntityChangeType.UPDATED)); updateAudit.add("DELETED DataSet entities=" + changedEntities.get(EntityChangeType.DELETED)); return changedEntities; }
@Override public FinalizingFieldAccessPostAggregator decorate(final Map<String, AggregatorFactory> aggregators) { final Comparator<Object> theComparator; final Function<Object, Object> theFinalizer; if (aggregators != null && aggregators.containsKey(fieldName)) { //noinspection unchecked theComparator = aggregators.get(fieldName).getComparator(); } else { //noinspection unchecked theComparator = (Comparator) Comparators.naturalNullsFirst(); } if (aggregators != null && aggregators.containsKey(fieldName)) { theFinalizer = aggregators.get(fieldName)::finalizeComputation; } else { theFinalizer = Function.identity(); } return new FinalizingFieldAccessPostAggregator( name, fieldName, theComparator, theFinalizer ); }
public ClientStats getClientStats() { Map<String, Long> totalConnectionsPerHost = openChannels.stream().map(Channel::remoteAddress).filter(a -> a.getClass() == InetSocketAddress.class) .map(a -> (InetSocketAddress) a).map(InetSocketAddress::getHostName).collect(Collectors.groupingBy(Function.identity(), Collectors.counting())); Map<String, Long> idleConnectionsPerHost = channelPool.getIdleChannelCountPerHost(); Map<String, HostStats> statsPerHost = totalConnectionsPerHost.entrySet().stream().collect(Collectors.toMap(Entry::getKey, entry -> { final long totalConnectionCount = entry.getValue(); final long idleConnectionCount = idleConnectionsPerHost.getOrDefault(entry.getKey(), 0L); final long activeConnectionCount = totalConnectionCount - idleConnectionCount; return new HostStats(activeConnectionCount, idleConnectionCount); })); return new ClientStats(statsPerHost); }
@Override public Map<String, Long> getIdleChannelCountPerHost() { return partitions .values() .stream() .flatMap(ConcurrentLinkedDeque::stream) .map(idle -> idle.getChannel().remoteAddress()) .filter(a -> a.getClass() == InetSocketAddress.class) .map(a -> (InetSocketAddress) a) .map(InetSocketAddress::getHostName) .collect(Collectors.groupingBy(Function.identity(), Collectors.counting())); }
@Override public Map<SchemaTableName, List<ColumnMetadata>> listTableColumns(ConnectorSession session, SchemaTablePrefix prefix) { return listTables(session, prefix.getSchemaName()).stream().collect(toImmutableMap(identity(), schemaTableName -> getRequiredTableMetadata(schemaTableName).getColumns())); }
private static Function<Page, Page> enforceLayoutProcessor(List<Symbol> expectedLayout, Map<Symbol, Integer> inputLayout) { int[] channels = expectedLayout.stream() .peek(symbol -> checkArgument(inputLayout.containsKey(symbol), "channel not found for symbol: %s", symbol)) .mapToInt(inputLayout::get) .toArray(); if (Arrays.equals(channels, range(0, inputLayout.size()).toArray())) { // this is an identity mapping return Function.identity(); } return new PageChannelSelector(channels); }
AtopTable(String name, String atopLabel, List<AtopColumn> columns) { this.atopLabel = atopLabel; this.name = requireNonNull(name, "name is null"); this.columns = ImmutableList.copyOf(requireNonNull(columns, "columns is null")); columnIndex = this.columns.stream().collect(Collectors.toMap(AtopColumn::getName, Function.identity())); }
throws OrcCorruptionException List<RowGroupStatistics> rowGroups = rowGroupStatistics.get(stripeOffset); if (rowGroups == null) { throw new OrcCorruptionException(orcDataSourceId, "Unexpected stripe at offset %s", stripeOffset); RowGroupStatistics actualRowGroup = new RowGroupStatistics(BOTH, IntStream.range(1, actual.size()).boxed().collect(toImmutableMap(identity(), actual::get))); .collect(toImmutableList()); actual = actual.subList(1, actual.size());
public static Stream<? extends Document> typedChildrenOf(Table table) { return Stream.of( table.columns().map(Document.class::cast), table.primaryKeyColumns().map(Document.class::cast), table.indexes().map(Document.class::cast), table.foreignKeys().map(Document.class::cast) ).flatMap(Function.identity()); }