## org.apache.cassandra.utils
Class FBUtilities

    java.lang.Object
      org.apache.cassandra.utils.FBUtilities

    public class FBUtilities

extends java.lang.Object

Field Summary
`static int` `MAX_UNSIGNED_SHORT`
`static java.math.BigInteger` `TWO`

Constructor Summary
`FBUtilities()`

Method Summary
`static long` `absoluteFromFraction(double fractOrAbs, long total)`
`static void` `atomicSetMax(java.util.concurrent.atomic.AtomicInteger atomic, int i)`
`static void` `atomicSetMax(java.util.concurrent.atomic.AtomicLong atomic, long i)`
`static int` `byteArrayToInt(byte[] b)` Convert the byte array to an int starting from the given offset.

`static

`<T> java.lang.Class<T>`

`

`classForName(java.lang.String classname, java.lang.String readable)`

`static

`<T> CloseableIterator<T>`

`

`closeableIterator(java.util.Iterator<T> iterator)`

`static int` `compareUnsigned(byte[] bytes1, byte[] bytes2, int offset1, int offset2, int len1, int len2)`

`static

`<T> T`

`

`construct(java.lang.String classname, java.lang.String readable)`
Constructs an instance of the given class, which must have a no-arg constructor.

`static void` `copyIntoBytes(byte[] bytes, int offset, int i)` Copy bytes from int into bytes starting from offset.
`static void` `copyIntoBytes(byte[] bytes, int offset, long l)` Copy bytes from long into bytes starting from offset.
`static void` `deserialize(org.apache.thrift.TDeserializer deserializer, org.apache.thrift.TBase struct, java.io.DataInput in)`
`static int` `encodedUTF8Length(java.lang.String st)`
`static java.net.InetAddress` `getBroadcastAddress()`
`static java.net.InetAddress` `getLocalAddress()` Please use getBroadcastAddress instead.
`static java.lang.reflect.Field` `getProtectedField(java.lang.Class klass, java.lang.String fieldName)` Used to get access to protected/private field of the specified class
`static java.lang.String` `getReleaseVersionString()`
`static byte[]` `hash(java.nio.ByteBuffer... data)`
`static java.math.BigInteger` `hashToBigInteger(java.nio.ByteBuffer data)`
`static Pair<java.math.BigInteger,java.lang.Boolean>` `midpoint(java.math.BigInteger left, java.math.BigInteger right, int sigbits)` Given two bit arrays represented as BigIntegers, containing the given number of significant bits, calculate a midpoint.
`static IRowCacheProvider` `newCacheProvider(java.lang.String cache_provider)`
`static java.security.MessageDigest` `newMessageDigest(java.lang.String algorithm)`
`static IPartitioner` `newPartitioner(java.lang.String partitionerClassName)`
`static double` `parseDoubleOrPercent(java.lang.String value)` Parses a string representing either a fraction, absolute value or percentage.
`static void` `renameWithConfirm(java.lang.String tmpFilename, java.lang.String filename)`
`static java.lang.String` `resourceToFile(java.lang.String filename)`

`static

`<T> byte[]`

`

`serialize(T object, IVersionedSerializer<T> serializer, int version)`

`static void` `serialize(org.apache.thrift.TSerializer serializer, org.apache.thrift.TBase struct, java.io.DataOutput out)`

`static

`<T extends java.lang.Comparable> java.util.SortedSet<T>`

`

`singleton(T column)`

`static void` `sortSampledKeys(java.util.List<DecoratedKey> keys, Range range)`
`static java.security.MessageDigest` `threadLocalMD5Digest()`
`static java.util.Random` `threadLocalRandom()`
`static long` `timestampMicros()`
`static byte[]` `toByteArray(int i)`
`static byte[]` `toByteArray(long l)`
`static java.lang.String` `toString(java.util.Map<?,?> map)`
`static java.lang.RuntimeException` `unchecked(java.lang.Exception e)`
`static void` `waitOnFutures(java.lang.Iterable<java.util.concurrent.Future<?>> futures)`
`static void` `waitOnFutures(java.util.List<CreationTimeAwareFuture<?>> hintFutures, long timeout, java.util.concurrent.TimeUnit timeUnit)` Waits for the futures to complete.
`static void` `waitOnFutures(java.util.List<IAsyncResult> results, long ms)`
`static byte[]` `xor(byte[] left, byte[] right)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### TWO

    public static final java.math.BigInteger TWO

### MAX_UNSIGNED_SHORT

    public static final int MAX_UNSIGNED_SHORT

See Also:
  Constant Field Values

Constructor Detail

### FBUtilities

    public FBUtilities()

Method Detail

### threadLocalMD5Digest

    public static java.security.MessageDigest threadLocalMD5Digest()

### newMessageDigest

    public static java.security.MessageDigest newMessageDigest(java.lang.String algorithm)

### threadLocalRandom

    public static java.util.Random threadLocalRandom()

### parseDoubleOrPercent

    public static double parseDoubleOrPercent(java.lang.String value)

  Parses a string representing either a fraction, absolute value or percentage.

### getLocalAddress

    public static java.net.InetAddress getLocalAddress()

  Please use getBroadcastAddress instead. You need this only when you have to listen/connect.

### getBroadcastAddress

    public static java.net.InetAddress getBroadcastAddress()

### absoluteFromFraction

    public static long absoluteFromFraction(double fractOrAbs,
                                            long total)

  Parameters:
    `fractOrAbs` - A double that may represent a fraction or absolute value.
    `total` - If fractionOrAbs is a fraction, the total to take the fraction from
  Returns:
    An absolute value which may be larger than the total.

### midpoint

    public static Pair<java.math.BigInteger,java.lang.Boolean> midpoint(java.math.BigInteger left,
                                                                        java.math.BigInteger right,
                                                                        int sigbits)

  Given two bit arrays represented as BigIntegers, containing the given number of significant bits, calculate a midpoint.

  Parameters:
    `left` - The left point.
    `right` - The right point.
    `sigbits` - The number of bits in the points that are significant.
  Returns:
    A midpoint that will compare bitwise halfway between the params, and a boolean representing whether a non-zero lsbit remainder was generated.

### copyIntoBytes

    public static void copyIntoBytes(byte[] bytes,
                                     int offset,
                                     int i)

  Copy bytes from int into bytes starting from offset.

  Parameters:
    `bytes` - Target array
    `offset` - Offset into the array
    `i` - Value to write

### toByteArray

    public static byte[] toByteArray(int i)

  Parameters:
    `i` - Write this int to an array
  Returns:
    4-byte array containing the int

### copyIntoBytes

    public static void copyIntoBytes(byte[] bytes,
                                     int offset,
                                     long l)

  Copy bytes from long into bytes starting from offset.

  Parameters:
    `bytes` - Target array
    `offset` - Offset into the array
    `l` - Value to write

### toByteArray

    public static byte[] toByteArray(long l)

  Parameters:
    `l` - Write this long to an array
  Returns:
    8-byte array containing the long

### byteArrayToInt

    public static int byteArrayToInt(byte[] b)

  Convert the byte array to an int starting from the given offset.

  Parameters:
    `b` - The byte array
  Returns:
    The integer

### compareUnsigned

    public static int compareUnsigned(byte[] bytes1,
                                      byte[] bytes2,
                                      int offset1,
                                      int offset2,
                                      int len1,
                                      int len2)

### xor

    public static byte[] xor(byte[] left,
                             byte[] right)

  Returns:
    The bitwise XOR of the inputs. The output will be the same length as the longer input, but if either input is null, the output will be null.

### hashToBigInteger

    public static java.math.BigInteger hashToBigInteger(java.nio.ByteBuffer data)

### hash

    public static byte[] hash(java.nio.ByteBuffer... data)

### renameWithConfirm

    public static void renameWithConfirm(java.lang.String tmpFilename,
                                         java.lang.String filename)
                                  throws java.io.IOException

  Throws:
    `java.io.IOException`

### atomicSetMax

    public static void atomicSetMax(java.util.concurrent.atomic.AtomicInteger atomic,
                                    int i)

### atomicSetMax

    public static void atomicSetMax(java.util.concurrent.atomic.AtomicLong atomic,
                                    long i)

### serialize

    public static void serialize(org.apache.thrift.TSerializer serializer,
                                 org.apache.thrift.TBase struct,
                                 java.io.DataOutput out)
                          throws java.io.IOException

  Throws:
    `java.io.IOException`

### deserialize

    public static void deserialize(org.apache.thrift.TDeserializer deserializer,
                                   org.apache.thrift.TBase struct,
                                   java.io.DataInput in)
                            throws java.io.IOException

  Throws:
    `java.io.IOException`

### sortSampledKeys

    public static void sortSampledKeys(java.util.List<DecoratedKey> keys,
                                       Range range)

### encodedUTF8Length

    public static int encodedUTF8Length(java.lang.String st)

### resourceToFile

    public static java.lang.String resourceToFile(java.lang.String filename)
                                           throws ConfigurationException

  Throws:
    `ConfigurationException`

### getReleaseVersionString

    public static java.lang.String getReleaseVersionString()

### timestampMicros

    public static long timestampMicros()

### waitOnFutures

    public static void waitOnFutures(java.lang.Iterable<java.util.concurrent.Future<?>> futures)

### waitOnFutures

    public static void waitOnFutures(java.util.List<IAsyncResult> results,
                                     long ms)
                              throws java.util.concurrent.TimeoutException

  Throws:
    `java.util.concurrent.TimeoutException`

### waitOnFutures

    public static void waitOnFutures(java.util.List<CreationTimeAwareFuture<?>> hintFutures,
                                     long timeout,
                                     java.util.concurrent.TimeUnit timeUnit)
                              throws java.util.concurrent.TimeoutException

  Waits for the futures to complete.

  Parameters:
    `timeout` - the timeout expressed in `TimeUnit` units
    `timeUnit` - TimeUnit
  Throws:
    `java.util.concurrent.TimeoutException` - if the waiting time exceeds `timeout`

### newPartitioner

    public static IPartitioner newPartitioner(java.lang.String partitionerClassName)
                                       throws ConfigurationException

  Throws:
    `ConfigurationException`

### classForName

    public static <T> java.lang.Class<T> classForName(java.lang.String classname,
                                                      java.lang.String readable)
                                           throws ConfigurationException

  Parameters:
    `classname` - Fully qualified classname.
    `readable` - Descriptive noun for the role the class plays.
  Returns:
    The Class for the given name.
  Throws:
    `ConfigurationException` - If the class cannot be found.

### construct

    public static <T> T construct(java.lang.String classname,
                                  java.lang.String readable)
                       throws ConfigurationException

  Constructs an instance of the given class, which must have a no-arg constructor.

  Parameters:
    `classname` - Fully qualified classname.
    `readable` - Descriptive noun for the role the class plays.
  Throws:
    `ConfigurationException` - If the class cannot be found.

### singleton

    public static <T extends java.lang.Comparable> java.util.SortedSet<T> singleton(T column)

### toString

    public static java.lang.String toString(java.util.Map<?,?> map)

### getProtectedField

    public static java.lang.reflect.Field getProtectedField(java.lang.Class klass,
                                                            java.lang.String fieldName)

  Used to get access to protected/private field of the specified class

  Parameters:
    `klass` - - name of the class
    `fieldName` - - name of the field
  Returns:
    Field or null on error

### newCacheProvider

    public static IRowCacheProvider newCacheProvider(java.lang.String cache_provider)
                                              throws ConfigurationException

  Throws:
    `ConfigurationException`

### closeableIterator

    public static <T> CloseableIterator<T> closeableIterator(java.util.Iterator<T> iterator)

### serialize

    public static <T> byte[] serialize(T object,
                                       IVersionedSerializer<T> serializer,
                                       int version)
                            throws java.io.IOException

  Throws:
    `java.io.IOException`

### unchecked

    public static java.lang.RuntimeException unchecked(java.lang.Exception e)

Copyright © 2012 The Apache Software Foundation