org.apache.hadoop.examples.pi
Class Util

java.lang.Object
  extended by org.apache.hadoop.examples.pi.Util

public class Util
extends Object

Utility methods


Nested Class Summary
static class Util.Timer
          Timer
 
Field Summary
static PrintStream err
          Error stream
static PrintStream out
          Output stream
 
Constructor Summary
Util()
           
 
Method Summary
static int accuracy(long terms, boolean print)
          Estimate accuracy.
static void checkDirectory(File dir)
          Check local directory.
static
<T extends Combinable<T>>
List<T>
combine(Collection<T> items)
          Combine a list of items.
static PrintWriter createWriter(File dir, String prefix)
          Create a writer of a local file.
static
<T,E extends Callable<T>>
void
execute(int nThreads, List<E> callables)
          Execute the callables by a number of threads
static String long2string(long n)
          Covert a long to a String in comma separated number format.
static String millis2String(long n)
          Covert milliseconds to a String.
static long parseLongVariable(String name, String s)
          Parse a variable.
static String parseStringVariable(String name, String s)
          Parse a variable.
static String pi2string(double pi, long terms)
          Convert a pi value to a String.
static void printBitSkipped(long b)
          Print a "bits skipped" message.
static int printUsage(String[] args, String usage)
          Print usage messages
static long string2long(String s)
          Covert a String to a long.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

out

public static final PrintStream out
Output stream


err

public static final PrintStream err
Error stream

Constructor Detail

Util

public Util()
Method Detail

millis2String

public static String millis2String(long n)
Covert milliseconds to a String.


string2long

public static long string2long(String s)
Covert a String to a long. This support comma separated number format.


long2string

public static String long2string(long n)
Covert a long to a String in comma separated number format.


parseLongVariable

public static long parseLongVariable(String name,
                                     String s)
Parse a variable.


parseStringVariable

public static String parseStringVariable(String name,
                                         String s)
Parse a variable.


execute

public static <T,E extends Callable<T>> void execute(int nThreads,
                                                     List<E> callables)
                    throws InterruptedException,
                           ExecutionException
Execute the callables by a number of threads

Throws:
InterruptedException
ExecutionException

printUsage

public static int printUsage(String[] args,
                             String usage)
Print usage messages


combine

public static <T extends Combinable<T>> List<T> combine(Collection<T> items)
Combine a list of items.


checkDirectory

public static void checkDirectory(File dir)
Check local directory.


createWriter

public static PrintWriter createWriter(File dir,
                                       String prefix)
                                throws IOException
Create a writer of a local file.

Throws:
IOException

printBitSkipped

public static void printBitSkipped(long b)
Print a "bits skipped" message.


pi2string

public static String pi2string(double pi,
                               long terms)
Convert a pi value to a String.


accuracy

public static int accuracy(long terms,
                           boolean print)
Estimate accuracy.



Copyright © 2009 The Apache Software Foundation