本文整理汇总了Java中com.google.common.collect.Iterables.size方法的典型用法代码示例。如果您正苦于以下问题:Java Iterables.size方法的具体用法?Java Iterables.size怎么用?Java Iterables.size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.collect.Iterables
的用法示例。
在下文中一共展示了Iterables.size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processFiles
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
private void processFiles(ZipOutputStream outputStream, Iterable<? extends File> files, byte[] buffer, HashSet<String> seenPaths, Map<String, List<String>> services,
ProgressLogger progressLogger) throws Exception {
PercentageProgressFormatter progressFormatter = new PercentageProgressFormatter("Generating", Iterables.size(files) + ADDITIONAL_PROGRESS_STEPS);
for (File file : files) {
progressLogger.progress(progressFormatter.getProgress());
if (file.getName().endsWith(".jar")) {
processJarFile(outputStream, file, buffer, seenPaths, services);
} else {
processDirectory(outputStream, file, buffer, seenPaths, services);
}
progressFormatter.increment();
}
writeServiceFiles(outputStream, services);
progressLogger.progress(progressFormatter.incrementAndGetProgress());
writeIdentifyingMarkerFile(outputStream);
progressLogger.progress(progressFormatter.incrementAndGetProgress());
}
示例2: processElement
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@ProcessElement
public void processElement(ProcessContext c) {
KV<String, Iterable<InputContent>> kv = c.element();
String documentHash = kv.getKey();
Iterable<InputContent> dupes = kv.getValue();
boolean isFirst = true;
int groupSize = Iterables.size(dupes);
for (InputContent ic : dupes) {
// Check if this doc was already processed and stored in BQ
Map<String,Long> sideInputMap = c.sideInput(alreadyProcessedDocsSideInput);
Long proTime = sideInputMap.get(ic.expectedDocumentHash);
if (proTime!=null) {
c.output(PipelineTags.contentNotToIndexExactDupesTag,ic);
continue;
}
if (isFirst) {
isFirst = false;
c.output(ic);
} else {
c.output(PipelineTags.contentNotToIndexExactDupesTag,ic);
}
}
}
示例3: getMapFolders
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
public Set<Path> getMapFolders(final Logger logger) throws IOException {
final Set<Path> mapFolders = new HashSet<>();
for(Path root : getRootPaths()) {
int depth = "".equals(root.toString()) ? 0 : Iterables.size(root);
Files.walkFileTree(getPath().resolve(root), ImmutableSet.of(FileVisitOption.FOLLOW_LINKS), maxDepth - depth, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
if(!isExcluded(dir)) {
if(MapFolder.isMapFolder(dir)) {
mapFolders.add(dir);
}
return FileVisitResult.CONTINUE;
} else {
logger.fine("Skipping excluded path " + dir);
return FileVisitResult.SKIP_SUBTREE;
}
}
});
}
return mapFolders;
}
示例4: sameElements
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@SuppressWarnings("ObjectEquality")
private static <T> boolean sameElements(Iterable<? extends T> a, Iterable<? extends T> b)
{
if (Iterables.size(a) != Iterables.size(b)) {
return false;
}
Iterator<? extends T> first = a.iterator();
Iterator<? extends T> second = b.iterator();
while (first.hasNext() && second.hasNext()) {
if (first.next() != second.next()) {
return false;
}
}
return true;
}
示例5: buildIntervals
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
public static List<Interval<PartitionPosition, SSTableReader>> buildIntervals(Iterable<SSTableReader> sstables)
{
List<Interval<PartitionPosition, SSTableReader>> intervals = new ArrayList<>(Iterables.size(sstables));
for (SSTableReader sstable : sstables)
intervals.add(Interval.<PartitionPosition, SSTableReader>create(sstable.first, sstable.last, sstable));
return intervals;
}
示例6: charSplitter
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@Benchmark void charSplitter(int reps) {
int total = 0;
for (int i = 0; i < reps; i++) {
total += Iterables.size(CHAR_SPLITTER.split(input));
}
}
示例7: bulkGenerate
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
ArrayList<VisualBlockData> bulkGenerate(Player player, Iterable<Location> locations) {
ArrayList<VisualBlockData> data = new ArrayList<>(Iterables.size(locations));
for (Location location : locations) {
data.add(this.generate(player, location));
}
return data;
}
示例8: testParameterization
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@Test
public void testParameterization() throws IOException {
Resource resource = new ClassPathResource("/subsystem/parameters.feature");
Iterable<Recipe> recipes = factory.get(resource);
int recipeCount = Iterables.size(recipes);
assertEquals(2, recipeCount, "wrong number of Recipe objects returned");
}
示例9: getPluginLoader
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
ClassLoader getPluginLoader() {
if (pluginLoader != null) return pluginLoader;
final ClassLoader defaultLoader = getClass().getClassLoader();
Object purls = super.getProperty(PLUGIN_URLS_KEY);
if (purls == null) return defaultLoader;
Iterable<String> jars = SPLITTER.split((String) purls);
int len = Iterables.size(jars);
if ( len > 0) {
final URL[] urls = new URL[len];
try {
int i = 0;
for (String jar : jars) {
LOG.debug(jar);
urls[i++] = new URL(jar);
}
} catch (Exception e) {
throw new MetricsConfigException(e);
}
if (LOG.isDebugEnabled()) {
LOG.debug("using plugin jars: "+ Iterables.toString(jars));
}
pluginLoader = doPrivileged(new PrivilegedAction<ClassLoader>() {
@Override public ClassLoader run() {
return new URLClassLoader(urls, defaultLoader);
}
});
return pluginLoader;
}
if (parent instanceof MetricsConfig) {
return ((MetricsConfig) parent).getPluginLoader();
}
return defaultLoader;
}
示例10: countSubDirs
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
private long countSubDirs(Path path) throws IOException {
try (DirectoryStream<Path> ds = Files.newDirectoryStream(path, Files::isDirectory)) {
return Iterables.size(ds);
} catch (DirectoryIteratorException e) {
throw new IOException(e);
}
}
示例11: stringSplitter
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@Benchmark void stringSplitter(int reps) {
int total = 0;
for (int i = 0; i < reps; i++) {
total += Iterables.size(STRING_SPLITTER.split(input));
}
}
示例12: countRows
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
private int countRows(final Table table) throws IOException {
int count = 0;
final Scan scan = new Scan();
scan.addFamily(EventStoreColumnFamily.COUNTS.asByteArray());
scan.addFamily(EventStoreColumnFamily.VALUES.asByteArray());
try (final ResultScanner results = table.getScanner(scan)) {
count = Iterables.size(results);
}
return count;
}
示例13: applyDiff
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
protected void applyDiff ( final IProgressMonitor parentMonitor ) throws InterruptedException, ExecutionException
{
final SubMonitor monitor = SubMonitor.convert ( parentMonitor, 100 );
monitor.setTaskName ( Messages.ImportWizard_TaskName );
final Collection<DiffEntry> result = this.mergeController.merge ( wrap ( monitor.newChild ( 10 ) ) );
if ( result.isEmpty () )
{
monitor.done ();
return;
}
final Iterable<List<DiffEntry>> splitted = Iterables.partition ( result, Activator.getDefault ().getPreferenceStore ().getInt ( PreferenceConstants.P_DEFAULT_CHUNK_SIZE ) );
final SubMonitor sub = monitor.newChild ( 90 );
try
{
final int size = Iterables.size ( splitted );
sub.beginTask ( Messages.ImportWizard_TaskName, size );
int pos = 0;
for ( final Iterable<DiffEntry> i : splitted )
{
sub.subTask ( String.format ( Messages.ImportWizard_SubTaskName, pos, size ) );
final List<DiffEntry> entries = new LinkedList<DiffEntry> ();
Iterables.addAll ( entries, i );
final NotifyFuture<Void> future = this.connection.getConnection ().applyDiff ( entries, null, new DisplayCallbackHandler ( getShell (), "Apply diff", "Confirmation for applying diff is required" ) );
future.get ();
pos++;
sub.worked ( 1 );
}
}
finally
{
sub.done ();
}
}
示例14: sortedCopy
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
/**
* Creates a copy of an {@link Iterable} of columns, where the copy is sorted such that the
* columns appear in the same order as they do in the supplied {@link ResultSet}.
*
* @param columns Columns expected.
* @param resultSet The result set containing the values.
* @return The sorted columns.
*/
public static Collection<Column> sortedCopy(Iterable<Column> columns, ResultSet resultSet) {
Column[] result = new Column[Iterables.size(columns)];
for (Column column : columns) {
try {
result[resultSet.findColumn(column.getName()) - 1] = column;
} catch(SQLException ex) {
throw new IllegalStateException("Could not retrieve column [" + column.getName() + "]", ex);
}
}
return Collections.unmodifiableCollection(Arrays.asList(result));
}
示例15: apply
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@Override
@SuppressFBWarnings(value = "DE_MIGHT_IGNORE", justification = "Any exceptions are to be ignored")
public Integer apply(final Iterable input) {
if (null == input) {
throw new IllegalArgumentException("Input cannot be null");
}
try {
return Iterables.size(input);
} finally {
CloseableUtil.close(input);
}
}