/** * A sensible definition of {@link #lastEntry} in terms of the {@code iterator()} of the {@link * #entrySet} of {@link #descendingMap}. If you override {@code descendingMap}, you may wish to * override {@code lastEntry} to forward to this implementation. */ protected Entry<K, V> standardLastEntry() { return Iterables.getFirst(descendingMap().entrySet(), null); }
@Override public T getFirst(V value) { Set<T> all = mIndexMap.get(value); return all == null ? null : Iterables.getFirst(all, null); }
/** * A sensible definition of {@link #firstEntry} in terms of the {@code iterator()} of {@link * #entrySet}. If you override {@code entrySet}, you may wish to override {@code firstEntry} to * forward to this implementation. */ protected Entry<K, V> standardFirstEntry() { return Iterables.getFirst(entrySet(), null); }
/** * A sensible definition of {@link #lastEntry} in terms of the {@code iterator()} of the {@link * #entrySet} of {@link #descendingMap}. If you override {@code descendingMap}, you may wish to * override {@code lastEntry} to forward to this implementation. */ protected Entry<K, V> standardLastEntry() { return Iterables.getFirst(descendingMap().entrySet(), null); }
/** * A sensible definition of {@link #firstEntry} in terms of the {@code iterator()} of {@link * #entrySet}. If you override {@code entrySet}, you may wish to override {@code firstEntry} to * forward to this implementation. */ protected Entry<K, V> standardFirstEntry() { return Iterables.getFirst(entrySet(), null); }
private static Path buildRootPath() { Path root = Iterables.getFirst(FileSystems.getDefault().getRootDirectories(), null); if (root == null) { throw new RuntimeException("Can't find a root filesystem!"); } return root; }
/** @since 12.0 */ @GwtIncompatible // NavigableSet @Override public E higher(E e) { return Iterables.getFirst(tailSet(e, false), null); }
/** @since 12.0 */ @GwtIncompatible // NavigableSet @Override public E ceiling(E e) { return Iterables.getFirst(tailSet(e, true), null); }
@Override public Optional<String> getBrokerServiceName(TieredBrokerConfig tierConfig, Query query) { // Somewhat janky way of always selecting highest priority broker for this type of query if (query instanceof TimeBoundaryQuery) { return Optional.of( Iterables.getFirst( tierConfig.getTierToBrokerMap().values(), tierConfig.getDefaultBrokerServiceName() ) ); } return Optional.absent(); } }
public CounterStat getInputDataSize() { OperatorContext inputOperator = getFirst(operatorContexts, null); if (inputOperator != null) { return inputOperator.getInputDataSize(); } else { return new CounterStat(); } }
public CounterStat getInputPositions() { OperatorContext inputOperator = getFirst(operatorContexts, null); if (inputOperator != null) { return inputOperator.getInputPositions(); } else { return new CounterStat(); } }
public void testGetFirst_withDefault_singleton() { Iterable<String> iterable = Collections.singletonList("foo"); assertEquals("foo", Iterables.getFirst(iterable, "bar")); }
public void testGetFirst_withDefault_empty() { Iterable<String> iterable = Collections.emptyList(); assertEquals("bar", Iterables.getFirst(iterable, "bar")); }
public void testGetFirst_withDefault_empty_null() { Iterable<String> iterable = Collections.emptyList(); assertNull(Iterables.getFirst(iterable, null)); }
public void testGetFirst_withDefault_multiple() { Iterable<String> iterable = asList("foo", "bar"); assertEquals("foo", Iterables.getFirst(iterable, "qux")); }
/** Returns the name of the first check, or {@code ""}. */ @Override public String toString() { return getFirst(getAllChecks().keySet(), ""); } }
/** * Returns the first valid offset in the entire journal. * * @return first offset */ public long getLogStartOffset() { final Iterable<LogSegment> logSegments = JavaConversions.asJavaIterable(kafkaLog.logSegments()); final LogSegment segment = Iterables.getFirst(logSegments, null); if (segment == null) { return 0; } return segment.baseOffset(); }
private void testMapRoundTrip(Type type, Iterable<?> writeValues, Set<Format> skipFormats) throws Exception { // json does not support null keys, so we just write the first value Object nullKeyWrite = Iterables.getFirst(writeValues, null); // values in simple map and mix in some null values testRoundTripType( createMapType(type), transform(insertNullEvery(5, writeValues), value -> toHiveMap(nullKeyWrite, value)), skipFormats); }
@Override public boolean matches(ExpressionTree tree, VisitorState state) { Types types = state.getTypes(); Type classType = state.getSymtab().classType; Type runtimeExceptionType = state.getSymtab().runtimeExceptionType; Type argType = getType(tree); // Make sure that the argument is a Class<Something> (and not null/bottom). if (!isSubtype(argType, classType, state) || argType.getTag() == BOT) { return false; } List<Type> typeArguments = ((ClassType) argType).getTypeArguments(); Type exceptionType = Iterables.getFirst(typeArguments, null); return types.isSubtype(exceptionType, runtimeExceptionType); } };
@Test public void testMissingMetadata() throws IOException, SegmentLoadingException { expectedException.expect(RuntimeException.class); expectedException.expectMessage(CoreMatchers.startsWith("Index metadata doesn't exist for segment")); final TestIndexIO indexIO = (TestIndexIO) toolbox.getIndexIO(); indexIO.removeMetadata(Iterables.getFirst(indexIO.getQueryableIndexMap().keySet(), null)); final List<DataSegment> segments = new ArrayList<>(SEGMENTS); CompactionTask.createIngestionSchema( toolbox, new SegmentProvider(segments), new PartitionConfigurationManager(null, TUNING_CONFIG), null, null, keepSegmentGranularity, null, objectMapper ); }