当前位置: 首页>>代码示例>>Java>>正文


Java Iterables.size方法代码示例

本文整理汇总了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());
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:23,代码来源:RuntimeShadedJarCreator.java

示例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);
		}
	}
}
 
开发者ID:GoogleCloudPlatform,项目名称:dataflow-opinion-analysis,代码行数:26,代码来源:IndexerPipeline.java

示例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;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:22,代码来源:MapSource.java

示例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;
}
 
开发者ID:dbiir,项目名称:rainbow,代码行数:19,代码来源:ExpressionTreeRewriter.java

示例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;
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:8,代码来源:SSTableIntervalTree.java

示例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));
  }
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:8,代码来源:SplitterBenchmark.java

示例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;
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:9,代码来源:BlockFiller.java

示例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");
}
 
开发者ID:qas-guru,项目名称:martini-core,代码行数:9,代码来源:DefaultMixologyTest.java

示例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;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:34,代码来源:MetricsConfig.java

示例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);
	}
}
 
开发者ID:cryptomator,项目名称:fuse-nio-adapter,代码行数:8,代码来源:ReadOnlyDirectoryHandler.java

示例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));
  }
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:8,代码来源:SplitterBenchmark.java

示例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;
}
 
开发者ID:gchq,项目名称:stroom-stats,代码行数:11,代码来源:StatisticsTestService.java

示例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 ();
    }

}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:41,代码来源:ImportWizard.java

示例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));
}
 
开发者ID:alfasoftware,项目名称:morf,代码行数:20,代码来源:ResultSetMetadataSorter.java

示例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);
    }
}
 
开发者ID:gchq,项目名称:koryphe,代码行数:13,代码来源:Size.java


注:本文中的com.google.common.collect.Iterables.size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。