@Override public Iterator<T> iterator() { return Iterators.transform(fromCollection.iterator(), function); }
@Override public Iterator<T> iterator() { return Iterators.transform(fromIterable.iterator(), function); }
/** * Iterating persistentStore as a iterator of {@link org.apache.drill.exec.store.sys.ProfileJsonIterator.ProfileJson}. */ private Iterator<ProfileJson> transformJson(Iterator<Entry<String, UserBitShared.QueryProfile>> all) { return Iterators.transform(all, new Function<Entry<String, UserBitShared.QueryProfile>, ProfileJson>() { @Nullable @Override public ProfileJson apply(@Nullable Entry<String, UserBitShared.QueryProfile> input) { if (input == null || input.getValue() == null) { return ProfileJson.getDefault(); } //Constructing ProfileInfo final String queryID = input.getKey(); String profileJson; try { profileJson = new String(profileSerializer.serialize(input.getValue())); } catch (IOException e) { logger.debug("Failed to serialize profile for: " + queryID, e); profileJson = "{ 'message' : 'error (unable to serialize profile: "+ queryID +")' }"; } return new ProfileJson( queryID, profileJson ); } }); }
return Iterators.transform(all, new Function<Entry<String, UserBitShared.QueryProfile>, ProfileInfo>() { @Nullable @Override
@Override Iterator<Entry<K, V2>> entryIterator() { return Iterators.transform( fromMap.entrySet().iterator(), Maps.<K, V1, V2>asEntryToEntryFunction(transformer)); }
@Override public Iterator<String> keys() { return Iterators.transform(entries(), new Function<Map.Entry<String, V>, String>() { @Nullable @Override public String apply(@Nullable Map.Entry<String, V> input) { return input.getKey(); } }); }
@SuppressWarnings("unchecked") @Override Iterator<Cell<C, R, V>> cellIterator() { return Iterators.transform(original.cellSet().iterator(), (Function) TRANSPOSE_CELL); }
@Override public Iterator<V> values() { return Iterators.transform(entries(), new Function<Map.Entry<String, V>, V>() { @Nullable @Override public V apply(final Map.Entry<String, V> entry) { return entry.getValue(); } }); }
private static <K, V> Iterator<Entry<K, V>> transformEntries(Iterator<Entry<K, V>> entries) { return Iterators.transform( entries, new Function<Entry<K, V>, Entry<K, V>>() { @Override public Entry<K, V> apply(Entry<K, V> entry) { return new UnmodifiableEntry<K, V>(entry); } }); }
static <K, V> Iterator<K> keyIterator(Iterator<Entry<K, V>> entryIterator) { return Iterators.transform(entryIterator, Maps.<K>keyFunction()); }
static <K, V> Iterator<V> valueIterator(Iterator<Entry<K, V>> entryIterator) { return Iterators.transform(entryIterator, Maps.<V>valueFunction()); }
@Override public Iterator<T> iterator() { return Iterators.concat(Iterators.transform(inputs.iterator(), Iterables.<T>toIterator())); } };
@Override Iterator<Cell<R, C, V2>> cellIterator() { return Iterators.transform(fromTable.cellSet().iterator(), cellFunction()); }
public static Set<String> asSet(final List<String> list) { if (list == null) { return Sets.newHashSet(); } return Sets.newHashSet(Iterators.transform(list.iterator(), new Function<String, String>() { @Nullable @Override public String apply(@Nullable String input) { return input == null ? null : input.toUpperCase(); } })); }
@Override Iterator<Entry<K, V2>> entryIterator() { return Iterators.transform( fromMultimap.entries().iterator(), Maps.<K, V1, V2>asEntryToEntryFunction(transformer)); }
@Override public Iterator<Map.Entry<String, V>> entries() { return Iterators.transform(getClient().entries(), new Function<Map.Entry<String, byte[]>, Map.Entry<String, V>>() { @Nullable @Override public Map.Entry<String, V> apply(@Nullable Map.Entry<String, byte[]> input) { try { final V value = config.getSerializer().deserialize(input.getValue()); return new ImmutableEntry<>(input.getKey(), value); } catch (final IOException e) { throw new DrillRuntimeException(String.format("unable to deserialize value at key %s", input.getKey()), e); } } }); }
@Override public Iterator<Map.Entry<String, V>> getRange(final int skip, final int take) { final Iterator<Map.Entry<String, byte[]>> entries = client.entries(); Iterators.advance(entries, skip); return Iterators.transform(Iterators.limit(entries, take), new Function<Map.Entry<String, byte[]>, Map.Entry<String, V>>() { @Nullable @Override public Map.Entry<String, V> apply(@Nullable Map.Entry<String, byte[]> input) { try { final V value = config.getSerializer().deserialize(input.getValue()); return new ImmutableEntry<>(input.getKey(), value); } catch (final IOException e) { throw new DrillRuntimeException(String.format("unable to deserialize value at key %s", input.getKey()), e); } } }); }