Java Code Examples for com.google.common.collect.ImmutableList#copyOf()

The following examples show how to use com.google.common.collect.ImmutableList#copyOf() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BenchmarkNodeScheduler.java    From presto with Apache License 2.0 5 votes vote down vote up
@Override
public NetworkLocation locate(HostAddress address)
{
    List<String> parts = new ArrayList<>(ImmutableList.copyOf(Splitter.on(".").split(address.getHostText())));
    Collections.reverse(parts);
    return new NetworkLocation(parts);
}
 
Example 2
Source File: BlackboxGradingEngine.java    From judgels with GNU General Public License v2.0 5 votes vote down vote up
private void doAggregate() {
    MDC.put("gradingPhase", "AGGREGATE");
    LOGGER.info("Aggregation started.");
    ImmutableList.Builder<SubtaskVerdict> subtaskVerdictBuilder = ImmutableList.builder();
    for (Subtask subtask : config.getSubtasks()) {
        List<TestCaseVerdict> testCaseVerdicts =
                ImmutableList.copyOf(testCaseVerdictsBySubtaskIds.get(subtask.getId() + 1));
        AggregationResult aggregationResult =
                getAggregator().aggregate(testCaseVerdicts, subtask.getPoints());

        SubtaskVerdict subtaskVerdict = aggregationResult.getSubtaskVerdict();
        List<String> testCasePoints = aggregationResult.getTestCasePoints();

        subtaskVerdictBuilder.add(subtaskVerdict);

        for (int i = 0; i < testCaseVerdicts.size(); i++) {
            Integer[] testCaseIndices = testCaseIndicesBySubtaskIds.get(subtask.getId() + 1).get(i);
            int testGroupIndex = testCaseIndices[0];
            int testCaseIndex = testCaseIndices[1];
            String points = testCasePoints.get(i);
            testGroupPoints.get(testGroupIndex).set(testCaseIndex, points);
        }
    }

    subtaskVerdicts = subtaskVerdictBuilder.build();
    gradingVerdict = subtaskAggregator.aggregate(subtaskVerdictBuilder.build());
    LOGGER.info("Aggregation finished.");
}
 
Example 3
Source File: LegacyIncludeScanner.java    From bazel with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a new IncludeScanner
 *
 * @param cache externally scoped cache of file-path to inclusion-set mappings
 * @param pathCache include path existence cache
 * @param quoteIncludePaths the list of quote search path dirs (-iquote)
 * @param includePaths the list of all other non-framework search path dirs (-I and -isystem)
 * @param frameworkIncludePaths the list of framework other search path dirs (-F)
 */
LegacyIncludeScanner(
    IncludeParser parser,
    ExecutorService includePool,
    ConcurrentMap<Artifact, ListenableFuture<Collection<Inclusion>>> cache,
    PathExistenceCache pathCache,
    List<PathFragment> quoteIncludePaths,
    List<PathFragment> includePaths,
    List<PathFragment> frameworkIncludePaths,
    Path outputPath,
    Path execRoot,
    ArtifactFactory artifactFactory,
    Supplier<SpawnIncludeScanner> spawnIncludeScannerSupplier,
    boolean useAsyncIncludeScanner) {
  this.parser = parser;
  this.includePool = includePool;
  this.fileParseCache = cache;
  this.pathCache = pathCache;
  this.artifactFactory = Preconditions.checkNotNull(artifactFactory);
  this.spawnIncludeScannerSupplier = spawnIncludeScannerSupplier;
  this.quoteIncludePaths = ImmutableList.<PathFragment>builder()
      .addAll(quoteIncludePaths)
      .addAll(includePaths)
      .build();
  this.quoteIncludePathsFrameworkIndex = quoteIncludePaths.size();
  this.includePaths = ImmutableList.copyOf(includePaths);
  this.frameworkIncludePaths = ImmutableList.copyOf(frameworkIncludePaths);
  this.inclusionCache =
      useAsyncIncludeScanner ? new AsyncInclusionCache() : new LegacyInclusionCache();
  this.execRoot = execRoot;
  this.outputPathFragment = outputPath.relativeTo(execRoot);
  this.includeRootFragment =
      outputPathFragment.getRelative(BlazeDirectories.RELATIVE_INCLUDE_DIR);
  this.absoluteRoot = Root.absoluteRoot(execRoot.getFileSystem());
  this.useAsyncIncludeScanner = useAsyncIncludeScanner;
}
 
Example 4
Source File: TableScanNode.java    From presto with Apache License 2.0 5 votes vote down vote up
public TableScanNode(
        PlanNodeId id,
        TableHandle table,
        List<Symbol> outputs,
        Map<Symbol, ColumnHandle> assignments,
        TupleDomain<ColumnHandle> enforcedConstraint)
{
    super(id);
    this.table = requireNonNull(table, "table is null");
    this.outputSymbols = ImmutableList.copyOf(requireNonNull(outputs, "outputs is null"));
    this.assignments = ImmutableMap.copyOf(requireNonNull(assignments, "assignments is null"));
    checkArgument(assignments.keySet().containsAll(outputs), "assignments does not cover all of outputs");
    this.enforcedConstraint = requireNonNull(enforcedConstraint, "enforcedConstraint is null");
}
 
Example 5
Source File: GlobalClientInterceptorRegistry.java    From grpc-spring-boot-starter with MIT License 5 votes vote down vote up
/**
 * Gets the immutable and sorted list of global server interceptors.
 *
 * @return The list of globally registered server interceptors.
 */
public ImmutableList<ClientInterceptor> getClientInterceptors() {
    if (this.sortedClientInterceptors == null) {
        List<ClientInterceptor> temp = Lists.newArrayList(this.clientInterceptors);
        sortInterceptors(temp);
        this.sortedClientInterceptors = ImmutableList.copyOf(temp);
    }
    return this.sortedClientInterceptors;
}
 
Example 6
Source File: JobArchiveServiceImpl.java    From genie with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor.
 *
 * @param jobArchivers             The ordered list of {@link JobArchiver} implementations to use. Not empty.
 * @param directoryManifestFactory The job directory manifest factory
 */
public JobArchiveServiceImpl(
    final List<JobArchiver> jobArchivers,
    final DirectoryManifest.Factory directoryManifestFactory
) {
    this.jobArchivers = ImmutableList.copyOf(jobArchivers);
    this.directoryManifestFactory = directoryManifestFactory;
}
 
Example 7
Source File: JavaClassList.java    From ArchUnit with Apache License 2.0 4 votes vote down vote up
JavaClassList(List<JavaClass> elements) {
    this.elements = ImmutableList.copyOf(elements);
}
 
Example 8
Source File: ExceptionInfo.java    From armeria with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a new instance.
 */
public ExceptionInfo(String name, Iterable<FieldInfo> fields, @Nullable String docString) {
    this.name = requireNonNull(name, "name");
    this.fields = ImmutableList.copyOf(requireNonNull(fields, "fields"));
    this.docString = Strings.emptyToNull(docString);
}
 
Example 9
Source File: IndexQueryBuilder.java    From grakn with GNU Affero General Public License v3.0 4 votes vote down vote up
public ImmutableList<Parameter<Order>> getOrders() {
    return ImmutableList.copyOf(orders);
}
 
Example 10
Source File: ShuffleProof.java    From chvote-protocol-poc with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public Object[] elementsToHash() {
    return new Object[]{t_1, t_2, t_3, ImmutableList.copyOf(t_4), ImmutableList.copyOf(t_hat)};
}
 
Example 11
Source File: Options.java    From japicmp with Apache License 2.0 4 votes vote down vote up
public List<Filter> getIncludes() {
	return ImmutableList.copyOf(includes);
}
 
Example 12
Source File: RelMdCollation.java    From calcite with Apache License 2.0 4 votes vote down vote up
public ImmutableList<RelCollation> collations(EnumerableCorrelate join,
    RelMetadataQuery mq) {
  return ImmutableList.copyOf(
      RelMdCollation.enumerableCorrelate(mq, join.getLeft(), join.getRight(),
          join.getJoinType()));
}
 
Example 13
Source File: IncludeScanning.java    From bazel with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public ListenableFuture<List<Artifact>> determineAdditionalInputs(
    @Nullable IncludeScannerSupplier includeScannerSupplier,
    CppCompileAction action,
    ActionExecutionContext actionExecutionContext,
    IncludeScanningHeaderData includeScanningHeaderData)
    throws ExecException, InterruptedException {
  // Return null when no include scanning occurs, as opposed to an empty set, to distinguish from
  // the case where includes are scanned but none are found.
  if (!action.shouldScanIncludes()) {
    return null;
  }

  Preconditions.checkNotNull(includeScannerSupplier, action);

  Set<Artifact> includes = Sets.newConcurrentHashSet();

  final List<PathFragment> absoluteBuiltInIncludeDirs = new ArrayList<>();
  includes.addAll(action.getBuiltInIncludeFiles());

  // Deduplicate include directories. This can occur especially with "built-in" and "system"
  // include directories because of the way we retrieve them. Duplicate include directories
  // really mess up #include_next directives.
  Set<PathFragment> includeDirs = new LinkedHashSet<>(action.getIncludeDirs());
  List<PathFragment> quoteIncludeDirs = action.getQuoteIncludeDirs();
  List<PathFragment> frameworkIncludeDirs = action.getFrameworkIncludeDirs();
  List<String> cmdlineIncludes = includeScanningHeaderData.getCmdlineIncludes();

  includeDirs.addAll(includeScanningHeaderData.getSystemIncludeDirs());

  // Add the system include paths to the list of include paths.
  for (PathFragment pathFragment : action.getBuiltInIncludeDirectories()) {
    if (pathFragment.isAbsolute()) {
      absoluteBuiltInIncludeDirs.add(pathFragment);
    }
    includeDirs.add(pathFragment);
  }

  List<PathFragment> includeDirList = ImmutableList.copyOf(includeDirs);
  IncludeScanner scanner =
      includeScannerSupplier.scannerFor(quoteIncludeDirs, includeDirList, frameworkIncludeDirs);

  Artifact mainSource = action.getMainIncludeScannerSource();
  Collection<Artifact> sources = action.getIncludeScannerSources();

  try (SilentCloseable c =
      Profiler.instance()
          .profile(ProfilerTask.SCANNER, action.getSourceFile().getExecPathString())) {
    ListenableFuture<?> future =
        scanner.processAsync(
            mainSource,
            sources,
            includeScanningHeaderData,
            cmdlineIncludes,
            includes,
            action,
            actionExecutionContext,
            action.getGrepIncludes());
    return Futures.transformAsync(
        future,
        new AsyncFunction<Object, List<Artifact>>() {
          @Override
          public ListenableFuture<List<Artifact>> apply(Object input) throws Exception {
            return Futures.immediateFuture(
                collect(actionExecutionContext, includes, absoluteBuiltInIncludeDirs));
          }
        },
        MoreExecutors.directExecutor());
  } catch (IOException e) {
    throw new EnvironmentalExecException(
        e, createFailureDetail("Include scanning IOException", Code.SCANNING_IO_EXCEPTION));
  }
}
 
Example 14
Source File: MergedEntryDto.java    From centraldogma with Apache License 2.0 4 votes vote down vote up
public MergedEntryDto(Revision revision, EntryType type, T content, Iterable<String> paths) {
    this.revision = requireNonNull(revision, "revision");
    this.type = requireNonNull(type, "type");
    this.content = requireNonNull(content, "content");
    this.paths = ImmutableList.copyOf(requireNonNull(paths, "paths"));
}
 
Example 15
Source File: AttributeContainerHelper.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private AttributeContainerImmutable(String name, List<Attribute> atts) {
  this.name = name;
  this.atts = ImmutableList.copyOf(atts);
}
 
Example 16
Source File: DataService.java    From micro-server with Apache License 2.0 4 votes vote down vote up
@Timed
public ImmutableList<Entity> findAll(String name){
	return ImmutableList.copyOf(searchByName(name));
	
}
 
Example 17
Source File: RedundantDeltaTest.java    From emodb with Apache License 2.0 4 votes vote down vote up
private List<UUID> toChangeIds(Iterator<Map.Entry<DeltaClusteringKey, Change>> iterator) {
    return ImmutableList.copyOf(
            Iterators.transform(iterator, entry -> entry.getKey().getChangeId()));
}
 
Example 18
Source File: StructDefinition.java    From tracecompass with Eclipse Public License 2.0 3 votes vote down vote up
/**
 * Constructor This one takes the scope and thus speeds up definition
 * creation
 *
 * @param declaration
 *            the parent declaration
 * @param definitionScope
 *            the parent scope
 * @param scope
 *            the scope of this variable
 * @param structFieldName
 *            the field name
 * @param fieldNames
 *            the list of fields
 * @param definitions
 *            the definitions
 * @since 1.0
 */
public StructDefinition(@NonNull StructDeclaration declaration,
        IDefinitionScope definitionScope,
        @NonNull ILexicalScope scope,
        @NonNull String structFieldName,
        @NonNull Iterable<@NonNull String> fieldNames,
        Definition[] definitions) {
    super(declaration, definitionScope, structFieldName, scope);
    fFieldNames = ImmutableList.copyOf(fieldNames);
    fDefinitions = definitions;
    if (fFieldNames.isEmpty()) {
        fDefinitionsMap = Collections.emptyMap();
    }
}
 
Example 19
Source File: RelOptRuleCall.java    From calcite with Apache License 2.0 2 votes vote down vote up
/**
 * Returns a list of matched relational expressions.
 *
 * @return matched relational expressions
 * @see #rel(int)
 */
public List<RelNode> getRelList() {
  return ImmutableList.copyOf(rels);
}
 
Example 20
Source File: Attribute.java    From tracecompass with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Get the list of child attributes below this one.
 *
 * @return The child attributes.
 */
public Iterable<Attribute> getSubAttributes() {
    return ImmutableList.copyOf(fSubAttributes.values());
}