blob: 5bec484efc5a88a1fc9457225f07867171dfd34a [file] [log] [blame]
kushb0c1ac82017-10-06 00:57:29 +02001// Copyright 2017 The Bazel Authors. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14package com.google.devtools.build.lib.skyframe;
15
16import com.google.auto.value.AutoValue;
17import com.google.common.collect.ImmutableList;
18import com.google.common.collect.Interner;
19import com.google.devtools.build.lib.actions.FilesetTraversalParams;
20import com.google.devtools.build.lib.concurrent.BlazeInterners;
21import com.google.devtools.build.skyframe.SkyFunctionName;
22import com.google.devtools.build.skyframe.SkyKey;
23import java.util.stream.StreamSupport;
24
25/** A {@link SkyKey} for the {@link FilesetEntryFunction} */
26@AutoValue
27public abstract class FilesetEntryKey implements SkyKey {
28 private static final Interner<FilesetEntryKey> INTERNER = BlazeInterners.newWeakInterner();
29
30 abstract FilesetTraversalParams params();
31
32 @Override
mschaller163e61f2019-02-11 10:01:33 -080033 public FilesetTraversalParams argument() {
kushb0c1ac82017-10-06 00:57:29 +020034 return params();
35 }
36
37 @Override
38 public SkyFunctionName functionName() {
39 return SkyFunctions.FILESET_ENTRY;
40 }
41
42 public static FilesetEntryKey key(FilesetTraversalParams param) {
43 return INTERNER.intern(new AutoValue_FilesetEntryKey(param));
44 }
45
mschaller163e61f2019-02-11 10:01:33 -080046 public static ImmutableList<FilesetEntryKey> keys(Iterable<FilesetTraversalParams> params) {
kushb0c1ac82017-10-06 00:57:29 +020047 return StreamSupport.stream(params.spliterator(), /*parallel=*/ false)
48 .map(FilesetEntryKey::key)
49 .collect(ImmutableList.toImmutableList());
50 }
51}