kush | b0c1ac8 | 2017-10-06 00:57:29 +0200 | [diff] [blame] | 1 | // 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. |
| 14 | package com.google.devtools.build.lib.skyframe; |
| 15 | |
| 16 | import com.google.auto.value.AutoValue; |
| 17 | import com.google.common.collect.ImmutableList; |
| 18 | import com.google.common.collect.Interner; |
| 19 | import com.google.devtools.build.lib.actions.FilesetTraversalParams; |
| 20 | import com.google.devtools.build.lib.concurrent.BlazeInterners; |
| 21 | import com.google.devtools.build.skyframe.SkyFunctionName; |
| 22 | import com.google.devtools.build.skyframe.SkyKey; |
| 23 | import java.util.stream.StreamSupport; |
| 24 | |
| 25 | /** A {@link SkyKey} for the {@link FilesetEntryFunction} */ |
| 26 | @AutoValue |
| 27 | public abstract class FilesetEntryKey implements SkyKey { |
| 28 | private static final Interner<FilesetEntryKey> INTERNER = BlazeInterners.newWeakInterner(); |
| 29 | |
| 30 | abstract FilesetTraversalParams params(); |
| 31 | |
| 32 | @Override |
mschaller | 163e61f | 2019-02-11 10:01:33 -0800 | [diff] [blame] | 33 | public FilesetTraversalParams argument() { |
kush | b0c1ac8 | 2017-10-06 00:57:29 +0200 | [diff] [blame] | 34 | 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 | |
mschaller | 163e61f | 2019-02-11 10:01:33 -0800 | [diff] [blame] | 46 | public static ImmutableList<FilesetEntryKey> keys(Iterable<FilesetTraversalParams> params) { |
kush | b0c1ac8 | 2017-10-06 00:57:29 +0200 | [diff] [blame] | 47 | return StreamSupport.stream(params.spliterator(), /*parallel=*/ false) |
| 48 | .map(FilesetEntryKey::key) |
| 49 | .collect(ImmutableList.toImmutableList()); |
| 50 | } |
| 51 | } |