下面列出了com.google.common.collect.ImmutableList#copyOf ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* 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;
}
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.");
}
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");
}
/**
* 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;
}
/**
* 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;
}
@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);
}
private List<UUID> toChangeIds(Iterator<Map.Entry<DeltaClusteringKey, Change>> iterator) {
return ImmutableList.copyOf(
Iterators.transform(iterator, entry -> entry.getKey().getChangeId()));
}
@Timed
public ImmutableList<Entity> findAll(String name){
return ImmutableList.copyOf(searchByName(name));
}
private AttributeContainerImmutable(String name, List<Attribute> atts) {
this.name = name;
this.atts = ImmutableList.copyOf(atts);
}
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"));
}
@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));
}
}
JavaClassList(List<JavaClass> elements) {
this.elements = ImmutableList.copyOf(elements);
}
public ImmutableList<RelCollation> collations(EnumerableCorrelate join,
RelMetadataQuery mq) {
return ImmutableList.copyOf(
RelMdCollation.enumerableCorrelate(mq, join.getLeft(), join.getRight(),
join.getJoinType()));
}
public List<Filter> getIncludes() {
return ImmutableList.copyOf(includes);
}
@Override
public Object[] elementsToHash() {
return new Object[]{t_1, t_2, t_3, ImmutableList.copyOf(t_4), ImmutableList.copyOf(t_hat)};
}
public ImmutableList<Parameter<Order>> getOrders() {
return ImmutableList.copyOf(orders);
}
/**
* 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);
}
/**
* 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();
}
}
/**
* Get the list of child attributes below this one.
*
* @return The child attributes.
*/
public Iterable<Attribute> getSubAttributes() {
return ImmutableList.copyOf(fSubAttributes.values());
}
/**
* Returns a list of matched relational expressions.
*
* @return matched relational expressions
* @see #rel(int)
*/
public List<RelNode> getRelList() {
return ImmutableList.copyOf(rels);
}