本文整理汇总了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();
}