本文整理匯總了Java中com.google.common.collect.Iterators.cycle方法的典型用法代碼示例。如果您正苦於以下問題:Java Iterators.cycle方法的具體用法?Java Iterators.cycle怎麽用?Java Iterators.cycle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.common.collect.Iterators
的用法示例。
在下文中一共展示了Iterators.cycle方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: ExternalSortBatch
import com.google.common.collect.Iterators; //導入方法依賴的package包/類
public ExternalSortBatch(ExternalSort popConfig, FragmentContext context, RecordBatch incoming) throws OutOfMemoryException {
super(popConfig, context, true);
this.incoming = incoming;
DrillConfig config = context.getConfig();
Configuration conf = new Configuration();
conf.set("fs.default.name", config.getString(ExecConstants.EXTERNAL_SORT_SPILL_FILESYSTEM));
try {
this.fs = FileSystem.get(conf);
} catch (IOException e) {
throw new RuntimeException(e);
}
SPILL_BATCH_GROUP_SIZE = config.getInt(ExecConstants.EXTERNAL_SORT_SPILL_GROUP_SIZE);
SPILL_THRESHOLD = config.getInt(ExecConstants.EXTERNAL_SORT_SPILL_THRESHOLD);
dirs = Iterators.cycle(config.getStringList(ExecConstants.EXTERNAL_SORT_SPILL_DIRS));
copierAllocator = oContext.getAllocator().getChildAllocator(
context, PriorityQueueCopier.INITIAL_ALLOCATION, PriorityQueueCopier.MAX_ALLOCATION, true);
FragmentHandle handle = context.getHandle();
fileName = String.format("%s/major_fragment_%s/minor_fragment_%s/operator_%s", QueryIdHelper.getQueryId(handle.getQueryId()),
handle.getMajorFragmentId(), handle.getMinorFragmentId(), popConfig.getOperatorId());
}
示例2: manyFiles
import com.google.common.collect.Iterators; //導入方法依賴的package包/類
@Test
public void manyFiles() throws Exception {
List<CompleteFileWork> chunks = generateChunks(1000);
Iterator<DrillbitEndpoint> incomingEndpointsIterator = Iterators.cycle(endpoints);
List<DrillbitEndpoint> incomingEndpoints = Lists.newArrayList();
final int width = 28 * 30;
for (int i = 0; i < width; i++) {
incomingEndpoints.add(incomingEndpointsIterator.next());
}
ListMultimap<Integer, CompleteFileWork> mappings = AssignmentCreator.getMappings(incomingEndpoints, chunks, null);
System.out.println(mappings.keySet().size());
for (int i = 0; i < width; i++) {
Assert.assertTrue("no mapping for entry " + i, mappings.get(i) != null && mappings.get(i).size() > 0);
}
}
示例3: recalculateOrdering
import com.google.common.collect.Iterators; //導入方法依賴的package包/類
private void recalculateOrdering() {
// clear ordering
order.clear();
// Create new ordering, probably a better way to do this...
for (Map.Entry<VirtualSpoutIdentifier, Boolean> entry: allIds.entrySet()) {
// If throttled
if (entry.getValue()) {
order.add(entry.getKey());
} else {
// Add entries at ratio
for (int x = 0; x < ratio; x++) {
order.add(entry.getKey());
}
}
}
// create new iterator that cycles endlessly
consumerIdIterator = Iterators.cycle(order);
}
示例4: manyFiles
import com.google.common.collect.Iterators; //導入方法依賴的package包/類
@Test
public void manyFiles() throws Exception {
List<CompleteWork> chunks = generateChunks(1000);
Iterator<NodeEndpoint> incomingEndpointsIterator = Iterators.cycle(endpoints);
List<NodeEndpoint> incomingEndpoints = Lists.newArrayList();
final int width = 28 * 30;
for (int i = 0; i < width; i++) {
incomingEndpoints.add(incomingEndpointsIterator.next());
}
ListMultimap<Integer, CompleteWork> mappings = AssignmentCreator.getMappings(incomingEndpoints, chunks);
System.out.println(mappings.keySet().size());
for (int i = 0; i < width; i++) {
Assert.assertTrue("no mapping for entry " + i, mappings.get(i) != null && mappings.get(i).size() > 0);
}
}
示例5: getIterator
import com.google.common.collect.Iterators; //導入方法依賴的package包/類
private Iterator<Martini> getIterator(Mixologist mixologist) {
String spelFilter = super.getPropertyAsString(ARGUMENT_SPEL_FILTER).trim();
Collection<Martini> martiniCollection =
spelFilter.isEmpty() ? mixologist.getMartinis() : mixologist.getMartinis(spelFilter);
List<Martini> martinis = new ArrayList<>(martiniCollection);
boolean shuffled = super.getPropertyAsBoolean(ARGUMENT_SHUFFLED_ITERATION);
if (shuffled) {
SecureRandom random = new SecureRandom();
Collections.shuffle(martinis, random);
}
boolean cyclic = super.getPropertyAsBoolean(ARGUMENT_CYCLIC_ITERATOR);
return cyclic ? Iterators.cycle(martinis) : Iterators.consumingIterator(martinis.iterator());
}
示例6: TrackerClientProvider
import com.google.common.collect.Iterators; //導入方法依賴的package包/類
public TrackerClientProvider(final TorrentWithStats torrent, final ConnectionHandler connectionHandler, final BitTorrentClient bitTorrentClient) {
this.torrent = torrent;
this.connectionHandler = connectionHandler;
this.bitTorrentClient = bitTorrentClient;
final Set<URI> addresses = torrent.getTorrent().getAnnounceList().stream()
.unordered()
.flatMap(Collection::stream)
.collect(Collectors.toSet());
this.addressIterator = Iterators.cycle(addresses);
this.addressesCount = addresses.size();
}
示例7: reset
import com.google.common.collect.Iterators; //導入方法依賴的package包/類
private void reset() {
allFilesCyclic = Iterators.cycle(files.values());
restart();
}