下面列出了com.google.common.collect.Multimaps#filterKeys ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Finds all the content functions and returns a map indexed by function name to the function.
*/
public static Multimap<String,Function> getContentFunctions(JexlNode query) {
FunctionReferenceVisitor visitor = new FunctionReferenceVisitor();
query.jjtAccept(visitor, null);
Multimap<String,Function> functionsInNamespace = Multimaps.index(visitor.functions().get(ContentFunctions.CONTENT_FUNCTION_NAMESPACE), Function::name);
return Multimaps.filterKeys(functionsInNamespace, TermOffsetPopulator::isContentFunctionTerm);
}
void awaitHealthy(long timeout, TimeUnit unit) throws TimeoutException {
monitor.enter();
try {
if (!monitor.waitForUninterruptibly(awaitHealthGuard, timeout, unit)) {
throw new TimeoutException(
"Timeout waiting for the services to become healthy. The "
+ "following services have not started: " + Multimaps.filterKeys(servicesByState, in(ImmutableSet.of(NEW, STARTING))));
}
checkHealthy();
} finally {
monitor.leave();
}
}
void awaitStopped(long timeout, TimeUnit unit) throws TimeoutException {
monitor.enter();
try {
if (!monitor.waitForUninterruptibly(stoppedGuard, timeout, unit)) {
throw new TimeoutException(
"Timeout waiting for the services to stop. The following "
+ "services have not stopped: " + Multimaps.filterKeys(servicesByState, not(in(EnumSet.of(TERMINATED, FAILED)))));
}
} finally {
monitor.leave();
}
}
@GuardedBy("monitor")
void checkHealthy() {
if (states.count(RUNNING) != numberOfServices) {
IllegalStateException exception = new IllegalStateException("Expected to be healthy after starting. The following services are not running: " + Multimaps.filterKeys(servicesByState, not(equalTo(RUNNING))));
throw exception;
}
}
void awaitHealthy(long timeout, TimeUnit unit) throws TimeoutException {
monitor.enter();
try {
if (!monitor.waitForUninterruptibly(awaitHealthGuard, timeout, unit)) {
throw new TimeoutException(
"Timeout waiting for the services to become healthy. The "
+ "following services have not started: " + Multimaps.filterKeys(servicesByState, in(ImmutableSet.of(NEW, STARTING))));
}
checkHealthy();
} finally {
monitor.leave();
}
}
void awaitStopped(long timeout, TimeUnit unit) throws TimeoutException {
monitor.enter();
try {
if (!monitor.waitForUninterruptibly(stoppedGuard, timeout, unit)) {
throw new TimeoutException(
"Timeout waiting for the services to stop. The following "
+ "services have not stopped: " + Multimaps.filterKeys(servicesByState, not(in(EnumSet.of(TERMINATED, FAILED)))));
}
} finally {
monitor.leave();
}
}
@GuardedBy("monitor")
void checkHealthy() {
if (states.count(RUNNING) != numberOfServices) {
IllegalStateException exception = new IllegalStateException("Expected to be healthy after starting. The following services are not running: " + Multimaps.filterKeys(servicesByState, not(equalTo(RUNNING))));
throw exception;
}
}
void awaitHealthy(long timeout, TimeUnit unit) throws TimeoutException {
monitor.enter();
try {
if (!monitor.waitForUninterruptibly(awaitHealthGuard, timeout, unit)) {
throw new TimeoutException("Timeout waiting for the services to become healthy. The "
+ "following services have not started: " + Multimaps.filterKeys(servicesByState, in(ImmutableSet.of(NEW, STARTING))));
}
checkHealthy();
} finally {
monitor.leave();
}
}
void awaitStopped(long timeout, TimeUnit unit) throws TimeoutException {
monitor.enter();
try {
if (!monitor.waitForUninterruptibly(stoppedGuard, timeout, unit)) {
throw new TimeoutException("Timeout waiting for the services to stop. The following "
+ "services have not stopped: " + Multimaps.filterKeys(servicesByState, not(in(EnumSet.of(TERMINATED, FAILED)))));
}
} finally {
monitor.leave();
}
}
@GuardedBy("monitor")
void checkHealthy() {
if (states.count(RUNNING) != numberOfServices) {
IllegalStateException exception = new IllegalStateException("Expected to be healthy after starting. The following services are not running: " + Multimaps.filterKeys(servicesByState, not(equalTo(RUNNING))));
throw exception;
}
}
void awaitHealthy(long timeout, TimeUnit unit) throws TimeoutException {
monitor.enter();
try {
if (!monitor.waitForUninterruptibly(awaitHealthGuard, timeout, unit)) {
throw new TimeoutException(
"Timeout waiting for the services to become healthy. The "
+ "following services have not started: " + Multimaps.filterKeys(servicesByState, in(ImmutableSet.of(NEW, STARTING))));
}
checkHealthy();
} finally {
monitor.leave();
}
}
void awaitStopped(long timeout, TimeUnit unit) throws TimeoutException {
monitor.enter();
try {
if (!monitor.waitForUninterruptibly(stoppedGuard, timeout, unit)) {
throw new TimeoutException(
"Timeout waiting for the services to stop. The following "
+ "services have not stopped: " + Multimaps.filterKeys(servicesByState, not(in(EnumSet.of(TERMINATED, FAILED)))));
}
} finally {
monitor.leave();
}
}
@GuardedBy("monitor")
void checkHealthy() {
if (states.count(RUNNING) != numberOfServices) {
IllegalStateException exception = new IllegalStateException("Expected to be healthy after starting. The following services are not running: " + Multimaps.filterKeys(servicesByState, not(equalTo(RUNNING))));
throw exception;
}
}
void awaitHealthy(long timeout, TimeUnit unit) throws TimeoutException {
monitor.enter();
try {
if (!monitor.waitForUninterruptibly(awaitHealthGuard, timeout, unit)) {
throw new TimeoutException(
"Timeout waiting for the services to become healthy. The "
+ "following services have not started: "
+ Multimaps.filterKeys(servicesByState, in(ImmutableSet.of(NEW, STARTING))));
}
checkHealthy();
} finally {
monitor.leave();
}
}
void awaitStopped(long timeout, TimeUnit unit) throws TimeoutException {
monitor.enter();
try {
if (!monitor.waitForUninterruptibly(stoppedGuard, timeout, unit)) {
throw new TimeoutException(
"Timeout waiting for the services to stop. The following "
+ "services have not stopped: "
+ Multimaps.filterKeys(servicesByState, not(in(EnumSet.of(TERMINATED, FAILED)))));
}
} finally {
monitor.leave();
}
}
@GuardedBy("monitor")
void checkHealthy() {
if (states.count(RUNNING) != numberOfServices) {
IllegalStateException exception =
new IllegalStateException(
"Expected to be healthy after starting. The following services are not running: "
+ Multimaps.filterKeys(servicesByState, not(equalTo(RUNNING))));
throw exception;
}
}
public EventArgScoringAlignment<EquivClassType> copyFiltered(
final Predicate<EquivClassType> filter) {
return new EventArgScoringAlignment<EquivClassType>(docID(), argumentOutput, answerKey,
Iterables.filter(truePositiveECs, filter),
Iterables.filter(falsePositiveECs, filter),
Iterables.filter(falseNegativeECs, filter),
Iterables.filter(unassessed, filter),
Multimaps.filterKeys(ecsToAnswerKey, filter),
Multimaps.filterKeys(ecsToSystem, filter));
}
public Multimap<String, Duration> executionTimesForPrefixName(String prefixName) {
synchronized (executionTimes) {
return Multimaps.filterKeys(executionTimes, key -> key.startsWith(prefixName));
}
}
/**
* Return only offsets for a limited set of fields
*
* @param fields
* @return
*/
public TreeMultimap<Zone,TermWeightPosition> fetchOffsets(Set<Zone> fields) {
checkNotNull(fields);
return (TreeMultimap<Zone,TermWeightPosition>) Multimaps.filterKeys(this.offsetsPerField, new FieldFilterPredicate(fields));
}