Materialize a {@link WorkUnitStream} into an in-memory list. Note that infinite work unit streams cannot be materialized.
778818
private List<WorkUnit> materializeWorkUnitList(WorkUnitStream workUnitStream) {
    if (!workUnitStream.isFiniteStream()) {
      throw new UnsupportedOperationException("Cannot materialize an infinite work unit stream.");
    }
    return Lists.newArrayList(workUnitStream.getWorkUnits());
  }
234299
private synchronized void materializeWorkUnitAndDatasetStates(String datasetUrn) {
    if (!this.areWorkUnitStatesMaterialized) {
      try {
        CombinedWorkUnitAndDatasetState workUnitAndDatasetState =
            this.workUnitAndDatasetStateFunctional.getCombinedWorkUnitAndDatasetState(datasetUrn);
        this.previousWorkUnitStates = workUnitAndDatasetState.getPreviousWorkUnitStates();
        this.previousDatasetStatesByUrns =
            (Map<String, SourceState>) workUnitAndDatasetState.getPreviousDatasetStatesByUrns();
        this.areWorkUnitStatesMaterialized = true;
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
  }
1218183
public StreamList listStreams(String sessionId) throws OpenTokException {
        String streams = this.client.listStreams(sessionId);
        try {
            return streamListReader.readValue(streams);
        } catch (JsonProcessingException e) {
            throw new RequestException("Exception mapping json: " + e.getMessage());
        } catch (IOException e) {
            throw new RequestException("Exception mapping json: " + e.getMessage());
        }
    }
368621
public ImmutableListMultimap<Symbol, EDLMention> loadEDLMentionsByDocFrom(CharSource source) throws IOException {
    final ImmutableList<EDLMention> edlMentions = loadEDLMentionsFrom(source);
    final ImmutableListMultimap.Builder<Symbol, EDLMention> byDocs =
        ImmutableListMultimap.<Symbol, EDLMention>builder()
            .orderKeysBy(SymbolUtils.byStringOrdering());
    for (final EDLMention edlMention : edlMentions) {
      byDocs.put(edlMention.documentID(), edlMention);
    }
    return byDocs.build();
  }
496707
public <U> BaseSimpleReactStream<U> fromStream(final Stream<CompletableFuture<U>> stream) {

        final Stream s = stream;
        return construct(s);
    }
459444
@Override
  public RecordStreamWithMetadata<D, S> processStream(RecordStreamWithMetadata<D, S> inputStream, WorkUnitState state) {
    Flowable<StreamEntity<D>> filteredStream =
        inputStream.getRecordStream().filter(r -> {
          if (r instanceof ControlMessage) {
            getMessageHandler().handleMessage((ControlMessage) r);
            return true;
          } else if (r instanceof RecordEnvelope) {
            boolean accept = executePolicies(((RecordEnvelope) r).getRecord(), this.results);
            if (!accept) {
              r.ack();
            }
            return accept;
          } else {
            return true;
          }
        });
    filteredStream = filteredStream.doFinally(this::close);
    return inputStream.withRecordStream(filteredStream);
  }
997513
public final Stream<List<T>> chunk(final int chunkSize) {
        synchronized (this.state) {
            checkState();
            return new ChunkStream<T>(this, chunkSize);
        }
    }
163079
private CompletableFuture<Void> copyTxnEpochSegmentsAndCommitTxns(String scope, String stream, List<UUID> transactionsToCommit,
                                                                      List<Long> segmentIds) {
        // 1. create duplicate segments
        // 2. merge transactions in those segments
        // 3. seal txn epoch segments
        String delegationToken = streamMetadataTasks.retrieveDelegationToken();
        CompletableFuture<Void> createSegmentsFuture = Futures.allOf(segmentIds.stream().map(segment -> {
            // Use fixed scaling policy for these segments as they are created, merged into and sealed and are not
            // supposed to auto scale.
            return streamMetadataTasks.notifyNewSegment(scope, stream, segment, ScalingPolicy.fixed(1), delegationToken);
        }).collect(Collectors.toList()));

        return createSegmentsFuture
                .thenCompose(v -> {
                    log.debug("Rolling transaction, successfully created duplicate txn epoch {} for stream {}/{}", segmentIds, scope, stream);
                    // now commit transactions into these newly created segments
                    return commitTransactions(scope, stream, segmentIds, transactionsToCommit);
                })
                .thenCompose(v -> streamMetadataTasks.notifySealedSegments(scope, stream, segmentIds, delegationToken));
    }
33530
public <T> StreamSupplier<T> queryRawStream(List<String> dimensions, List<String> storedMeasures, AggregationPredicate where,
			Class<T> resultClass) throws QueryException {
		return queryRawStream(dimensions, storedMeasures, where, resultClass, classLoader);
	}
984185
public List<WorkUnit> getWorkUnits() {
    ImmutableList.Builder<WorkUnit> allWorkUnits = ImmutableList.builder();
    for (List<WorkUnit> workUnits : this.workUnitsMap.values()) {
      allWorkUnits.addAll(workUnits);
    }
    return allWorkUnits.build();
  }
388838
public final static <T> Stream<T> completableFutureToStream(final CompletableFuture<T> future) {
        return Stream.of(future.join());

    }
1155195
public <U> FutureStream<U> constructFutures(final Stream<CompletableFuture<U>> s) {
        final LazyReact toUse = withStreamOfFutures(true);
        return toUse.construct((Stream<U>) s);
    }
1012627
public OperationBuilder addInputStream(final InputStream in) {
        Assert.checkNotNullParam("in", in);
        if (inputStreams == null) {
            inputStreams = new ArrayList<InputStream>();
        }
        inputStreams.add(in);
        return this;
    }
767541
private <T> Collection<Integer> transformUnion(UnionTransformation<T> union) {
		List<StreamTransformation<T>> inputs = union.getInputs();
		List<Integer> resultIds = new ArrayList<>();

		for (StreamTransformation<T> input: inputs) {
			resultIds.addAll(transform(input));
		}

		return resultIds;
	}
1301177
static ImmutableList<ListAssetsResult> listAssetsAsOfYesterday(
      OrganizationName organizationName, Instant asOf) {
    try (SecurityCenterClient client = SecurityCenterClient.create()) {
      // Start setting up a request for to search for all assets in an organization.
      // OrganizationName organizationName = OrganizationName.of(/*organizationId=*/"123234324");

      // Initialize the builder with the organization and filter
      ListAssetsRequest.Builder request =
          ListAssetsRequest.newBuilder()
              .setParent(organizationName.toString())
              .setFilter(
                  "security_center_properties.resource_type=\"google.cloud.resourcemanager.Project\"");

      // Set read time to either the instant passed in or one day ago.
      asOf = MoreObjects.firstNonNull(asOf, Instant.now().minus(Duration.ofDays(1)));
      request.getReadTimeBuilder().setSeconds(asOf.getEpochSecond()).setNanos(asOf.getNano());

      // Call the API.
      ListAssetsPagedResponse response = client.listAssets(request.build());

      // This creates one list for all assets.  If your organization has a large number of assets
      // this can cause out of memory issues.  You can process them incrementally by returning
      // the Iterable returned response.iterateAll() directly.
      ImmutableList<ListAssetsResult> results = ImmutableList.copyOf(response.iterateAll());
      System.out.println("Projects:");
      System.out.println(results);
      return results;
    } catch (IOException e) {
      throw new RuntimeException("Couldn't create client.", e);
    }
  }
955474
protected void processWorkUnitTemplate(
            final Configuration cfg,
            final DocWorkUnit workUnit,
            final List<Map<String, String>> indexByGroupMaps,
            final List<Map<String, String>> featureMaps)
    {
        try {
            // Merge data-model with template
            Template template = cfg.getTemplate(workUnit.getTemplateName());
            File outputPath = new File(getDestinationDir(), workUnit.getTargetFileName());
            try (final Writer out = new OutputStreamWriter(new FileOutputStream(outputPath))) {
                template.process(workUnit.getRootMap(), out);
            }
        } catch (IOException e) {
            throw new DocException("IOException during documentation creation", e);
        } catch (TemplateException e) {
            throw new DocException("TemplateException during documentation creation", e);
        }

        // Create GSON-friendly container object
        GSONWorkUnit gsonworkunit = createGSONWorkUnit(workUnit, indexByGroupMaps, featureMaps);

        gsonworkunit.populate(
                workUnit.getProperty("summary").toString(),
                workUnit.getProperty("gson-arguments"),
                workUnit.getProperty("description").toString(),
                workUnit.getProperty("name").toString(),
                workUnit.getProperty("group").toString(),
                Boolean.valueOf(workUnit.getProperty("beta").toString()),
                Boolean.valueOf(workUnit.getProperty("experimental").toString())
        );

        // Convert object to JSON and write JSON entry to file
        File outputPathForJSON = new File(getDestinationDir(), workUnit.getJSONFileName());

        try (final BufferedWriter jsonWriter = new BufferedWriter(new FileWriter(outputPathForJSON))) {
            Gson gson = new GsonBuilder()
                .serializeSpecialFloatingPointValues()
                .setPrettyPrinting()
                .create();
            String json = gson.toJson(gsonworkunit);
            jsonWriter.write(json);
        } catch (IOException e) {
            throw new DocException("Failed to create JSON entry", e);
        }
    }
1198210
@Override
    public <X> LazyCollectionX<X> fromStream(final ReactiveSeq<X> stream) {
        return ListX.fromIterable(stream.collect(Collectors.toList()));
    }