it.unimi.dsi.Util类的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(12.4k)|赞(0)|评价(0)|浏览(172)

本文整理了Java中it.unimi.dsi.Util类的一些代码示例,展示了Util类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util类的具体详情如下:
包路径:it.unimi.dsi.Util
类名称:Util

Util介绍

[英]All-purpose static-method container class.
[中]通用静态方法容器类。

代码示例

代码示例来源:origin: it.unimi.dsi/dsiutils

private String itemsPerTimeInterval(long startCount, final long currentTime, long baseTime) {
  final double secondsPerItem = ((count - startCount) * 1000.0) / (currentTime - baseTime);
  if (speedTimeUnit == TimeUnit.SECONDS || speedTimeUnit == null && secondsPerItem >= 1) return Util.format(secondsPerItem) + " " + itemsName +  "/s";
  if (speedTimeUnit == TimeUnit.MINUTES || speedTimeUnit == null && secondsPerItem * 60 >= 1) return Util.format(secondsPerItem * 60) + " " + itemsName +  "/m";
  if (speedTimeUnit == TimeUnit.HOURS || speedTimeUnit == null && secondsPerItem * 3600 >= 1) return Util.format(secondsPerItem * 3600) + " " + itemsName +  "/h";
  return Util.format(secondsPerItem * 86400) + " " + itemsName +  "/d";
}

代码示例来源:origin: it.unimi.di/mg4j

private static String format( long v, long total ) {
  return v + " (" + Util.formatSize( v / 8 ) + "B, " + Util.format( 100. * v / total ) + "%)\n";
}

代码示例来源:origin: it.unimi.dsi/dsiutils

/** Stores the identity permutation in a new array of given length.
 *
 * @param n the size of the array.
 * @return a new array of length <code>n</code>, filled with the identity permutation.
 */
public static int[] identity(int n) {
  return identity(new int[n]);
}

代码示例来源:origin: it.unimi.dsi/mg4j-big

percAvailableMemory = Util.percAvailableMemory();
if ( ! outOfMemoryError && percAvailableMemory < PERC_AVAILABLE_MEMORY_CHECK ) {
  LOGGER.info( "Starting compaction... (" + percAvailableMemory + "% available)" );
  compacted = true;
  Util.compactMemory();
  percAvailableMemory = Util.percAvailableMemory();
  LOGGER.info( "Compaction completed (" + percAvailableMemory + "% available)" );
LOGGER.info( "Last set of batches indexed at " + Util.format( ( 1000. * occurrences ) / ( System.currentTimeMillis() - batchStartTime ) ) + " occurrences/s" );
batchStartTime = System.currentTimeMillis();
documentsInBatch = 0;

代码示例来源:origin: it.unimi.di/mg4j

new FlaggedOption( "bufferSize", JSAP.INTSIZE_PARSER, Util.formatBinarySize( Combine.DEFAULT_BUFFER_SIZE ), JSAP.NOT_REQUIRED, 'b', "buffer-size", "The size of an I/O buffer." ),
new FlaggedOption( "comp", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'c', "comp", "A compression flag for the index (may be specified several times)." ).setAllowMultipleDeclarations( true ),
new Switch( "noSkips", JSAP.NO_SHORTFLAG, "no-skips", "Disables skips." ),
new FlaggedOption( "quantum", JSAP.INTEGER_PARSER, Integer.toString( BitStreamIndex.DEFAULT_FIXED_QUANTUM ), JSAP.NOT_REQUIRED, 'Q', "quantum", "Enable skips with given quantum, if positive; fix space occupancy of variable-quantum skip towers in percentage if negative." ),
new FlaggedOption( "height", JSAP.INTSIZE_PARSER, Integer.toString( BitStreamIndex.DEFAULT_HEIGHT ), JSAP.NOT_REQUIRED, 'H', "height", "The skip height." ),
new FlaggedOption( "skipBufferSize", JSAP.INTSIZE_PARSER, Util.formatBinarySize( SkipBitStreamIndexWriter.DEFAULT_TEMP_BUFFER_SIZE ), JSAP.NOT_REQUIRED, JSAP.NO_SHORTFLAG, "skip-buffer-size", "The size of the internal temporary buffer used while creating an index with skips." ),
new FlaggedOption( "logInterval", JSAP.LONG_PARSER, Long.toString( ProgressLogger.DEFAULT_LOG_INTERVAL ), JSAP.NOT_REQUIRED, 'l', "log-interval", "The minimum time interval between activity logs in milliseconds." ),
new UnflaggedOption( "outputBasename", JSAP.STRING_PARSER, JSAP.REQUIRED, "The basename of the resulting index." ),

代码示例来源:origin: it.unimi.dsi/webgraph

this.bufferSize = Math.max(1, (bufferSize == 0 ? DEFAULT_BUFFER_SIZE : bufferSize) / ((Long.SIZE / Byte.SIZE) * (counterLongwords + 1)));
info("Relative standard deviation: " + Util.format(100 * HyperLogLogCounterArray.relativeStandardDeviation(log2m)) + "% (" + m  + " registers/counter, " + registerSize + " bits/register, " + Util.format(m * registerSize / 8.) + " bytes/counter)");
if (external) info("Running " + this.numberOfThreads + " threads with a buffer of " + Util.formatSize(this.bufferSize) + " counters");
else info("Running " + this.numberOfThreads + " threads");
for (int i = 0; i < this.discountFunction.length; i++) discountedCentrality[i] = new float[numNodes];
info("HyperBall memory usage: " + Util.formatSize2(usedMemory()) + " [not counting graph(s)]");

代码示例来源:origin: it.unimi.dsi/sux4j

final int[] t = Util.identity(numVars);
  final int[] u = new int[t.length];
  final int[] count = new int[numEquations + 1]; // CountSort
LOGGER.debug("Active variables: " + numActive + " (" + Util.format(numActive * 100 / numVars) + "%)");

代码示例来源:origin: it.unimi.dsi/dsiutils

/** Returns a random seed generated by {@link #randomSeed()} under the form of an array of eight bytes.
 *
 * @return a reasonably good random seed.
 */
public static byte[] randomSeedBytes() {
  final long seed = Util.randomSeed();
  final byte[] s = new byte[8];
  for(int i = Long.SIZE / Byte.SIZE; i-- != 0;) s[i] = (byte)(seed >>> i);
  return s;
}

代码示例来源:origin: it.unimi.dsi/dsiutils

private String freeMemory() {
  return (displayFreeMemory ? "; used/avail/free/total/max mem: "
      + Util.formatSize(RUNTIME.totalMemory() - RUNTIME.freeMemory()) + "/"
      + Util.formatSize(RUNTIME.freeMemory() + (RUNTIME.maxMemory() - RUNTIME.totalMemory())) + "/"
      + Util.formatSize(RUNTIME.freeMemory()) + "/"
      + Util.formatSize(RUNTIME.totalMemory()) + "/"
      + Util.formatSize(RUNTIME.maxMemory()) : "");
}

代码示例来源:origin: blazegraph/database

/** Ensures that Log4J is configured, by invoking, if necessary,
 * {@link org.apache.log4j.BasicConfigurator#configure()}, and
 * setting the root logger level to {@link Level#INFO}.
 */

public static void ensureLog4JIsConfigured() {
  ensureLog4JIsConfigured( null, Level.INFO );
}

代码示例来源:origin: it.unimi.dsi/webgraph

/** Renumbers by decreasing size the components of this set.
 *
 * <p>After a call to this method, both the internal status of this class and the argument
 * array are permuted so that the sizes of strongly connected components are decreasing
 * in the component index.
 *
 *  @param size the components sizes, as returned by {@link #computeSizes()}.
 */
public void sortBySize(final int[] size) {
  final int[] perm = Util.identity(size.length);
  IntArrays.parallelRadixSortIndirect(perm, size, false);
  IntArrays.reverse(perm);
  final int[] copy = size.clone();
  for (int i = size.length; i-- != 0;) size[i] = copy[perm[i]];
  Util.invertPermutationInPlace(perm);
  for(int i = component.length; i-- != 0;) component[i] = perm[component[i]];
}

代码示例来源:origin: it.unimi.dsi/mg4j

long percAvailableMemory = Util.percAvailableMemory();
boolean compacted = false;
if ( ! outOfMemoryError && percAvailableMemory < PERC_AVAILABLE_MEMORY_CHECK ) {
  LOGGER.info( "Starting compaction... (" + percAvailableMemory + "% available)" );
  compacted = true;
  Util.compactMemory();
  percAvailableMemory = Util.percAvailableMemory();
  LOGGER.info( "Compaction completed (" + percAvailableMemory + "% available)" );
  LOGGER.info( "Last set of batches indexed at " + Util.format( ( 1000. * occurrences ) / ( System.currentTimeMillis() - batchStartTime ) ) + " occurrences/s" );
  batchStartTime = System.currentTimeMillis();
  documentsInBatch = 0;

代码示例来源:origin: it.unimi.di/mg4j

new FlaggedOption( "bufferSize", JSAP.INTSIZE_PARSER, Util.formatBinarySize( DEFAULT_BUFFER_SIZE ), JSAP.NOT_REQUIRED, 'b', "buffer-size", "The size of an I/O buffer." ),
new FlaggedOption( "logInterval", JSAP.LONG_PARSER, Long.toString( ProgressLogger.DEFAULT_LOG_INTERVAL ), JSAP.NOT_REQUIRED, 'l', "log-interval", "The minimum time interval between activity logs in milliseconds." ),
new FlaggedOption( "strategy", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 's', "strategy", "A serialised documental partitioning strategy." ),
new Switch( "interleaved", JSAP.NO_SHORTFLAG, "interleaved", "Forces an interleaved index." ),
new Switch( "highPerformance", 'h', "high-performance", "Forces a high-performance index." ),
new FlaggedOption( "cacheSize", JSAP.INTSIZE_PARSER, Util.formatBinarySize( QuasiSuccinctIndexWriter.DEFAULT_CACHE_SIZE ), JSAP.NOT_REQUIRED, JSAP.NO_SHORTFLAG, "cache-size", "The size of the bit cache used while creating a quasi-succinct index." ),
new FlaggedOption( "quantum", JSAP.INTSIZE_PARSER, "32", JSAP.NOT_REQUIRED, 'Q', "quantum", "The skip quantum." ),
new FlaggedOption( "height", JSAP.INTSIZE_PARSER, Integer.toString( BitStreamIndex.DEFAULT_HEIGHT ), JSAP.NOT_REQUIRED, 'H', "height", "The skip height." ),
new FlaggedOption( "skipBufferSize", JSAP.INTSIZE_PARSER, Util.formatBinarySize( SkipBitStreamIndexWriter.DEFAULT_TEMP_BUFFER_SIZE ), JSAP.NOT_REQUIRED, JSAP.NO_SHORTFLAG, "skip-buffer-size", "The size of the internal temporary buffer used while creating an index with skips." ),
new UnflaggedOption( "inputBasename", JSAP.STRING_PARSER, JSAP.REQUIRED, "The basename of the global index." ),
new UnflaggedOption( "outputBasename", JSAP.STRING_PARSER, JSAP.REQUIRED, "The basename of the local indices." )

代码示例来源:origin: it.unimi.dsi/webgraph

/** Creates an Erd&#x151;s&ndash;R&eacute;nyi graph with given parameters and random seed.
 *
 * @param n the number of nodes.
 * @param m the expected number of arcs.
 * @param loops whether loops are allowed or not.
 */
public ErdosRenyiGraph(final int n, final long m, final boolean loops) {
  this(n, m, Util.randomSeed(), loops);
}

代码示例来源:origin: com.blazegraph/dsi-utils

private String freeMemory() {
  return ( displayFreeMemory ? "; used/avail/free/total/max mem: " 
      + Util.formatSize( RUNTIME.totalMemory() - RUNTIME.freeMemory() ) + "/" 
      + Util.formatSize( RUNTIME.freeMemory() + ( RUNTIME.maxMemory() - RUNTIME.totalMemory() ) ) + "/" 
      + Util.formatSize( RUNTIME.freeMemory() ) + "/" 
      + Util.formatSize( RUNTIME.totalMemory() ) + "/" 
      + Util.formatSize( RUNTIME.maxMemory() ) : "" );
}

代码示例来源:origin: blazegraph/database

/** Ensures that Log4J is configured, by invoking, if necessary,
 * {@link org.apache.log4j.BasicConfigurator#configure()}, and
 * setting the root logger level to a specified logging level.
 * 
 * @param level the required logging level.
 */

public static void ensureLog4JIsConfigured( final Level level ) {
  ensureLog4JIsConfigured( null, level );
}

代码示例来源:origin: it.unimi.dsi/webgraph

/**
 * Renumbers by decreasing size the components of this set.
 *
 * <p>After a call to this method, both the internal status of this class and the argument array
 * are permuted so that the sizes of connected components are decreasing in the component index.
 *
 * @param size the components sizes, as returned by {@link #computeSizes()}.
 */
public void sortBySize(final int[] size) {
  final int[] perm = Util.identity(size.length);
  IntArrays.parallelRadixSortIndirect(perm, size, false);
  IntArrays.reverse(perm);
  final int[] copy = size.clone();
  for (int i = size.length; i-- != 0;)
    size[i] = copy[perm[i]];
  Util.invertPermutationInPlace(perm);
  for (int i = component.length; i-- != 0;)
    component[i] = perm[component[i]];
}

代码示例来源:origin: blazegraph/database

/** Formats a size.
 *
 * <P>This method formats a long using suitable unit multipliers (e.g., <samp>K</samp>, <samp>M</samp>, <samp>G</samp>, and <samp>T</samp>)
 * and printing just two fractional digits.
 * @param l a number, representing a size (e.g., memory).
 * @return a string containing a pretty print of the number using unit multipliers.
 */
public static String formatSize( final long l ) {
  if ( l >= 1000000000000L ) return format( l / 1000000000000.0 ) + "T";
  if ( l >= 1000000000L ) return format( l / 1000000000.0 ) + "G";
  if ( l >= 1000000L ) return format( l / 1000000.0 ) + "M";
  if ( l >= 1000L ) return format( l / 1000.0 ) + "K";
  return Long.toString( l );
}

代码示例来源:origin: it.unimi.di/mg4j

if ( ( documentPointer & 0xFF ) == 0 ) {
  percAvailableMemory = Util.percAvailableMemory();
  if ( ! outOfMemoryError && percAvailableMemory < PERC_AVAILABLE_MEMORY_CHECK ) {
    LOGGER.info( "Starting compaction... (" + percAvailableMemory + "% available)" );
    compacted = true;
    Util.compactMemory();
    percAvailableMemory = Util.percAvailableMemory();
    LOGGER.info( "Compaction completed (" + percAvailableMemory + "% available)" );
  LOGGER.info( "Last set of batches indexed at " + Util.format( ( 1000. * occurrences ) / ( System.currentTimeMillis() - batchStartTime ) ) + " occurrences/s" );
  batchStartTime = System.currentTimeMillis();
  documentsInBatch = 0;

代码示例来源:origin: it.unimi.di/mg4j-big

private static String format( long v, long total ) {
  return v + " (" + Util.formatSize( v / 8 ) + "B, " + Util.format( 100. * v / total ) + "%)\n";
}

相关文章