org.apache.cassandra.utils
Class FBUtilities

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

public class FBUtilities
extends java.lang.Object


Field Summary
static java.math.BigInteger TWO
           
 
Constructor Summary
FBUtilities()
           
 
Method Summary
static int byteArrayToInt(byte[] bytes)
           
static int byteArrayToInt(byte[] bytes, int offset)
           
static java.lang.String bytesToHex(byte... bytes)
           
static int compareByteArrays(byte[] bytes1, byte[] bytes2)
           
static void compressToStream(byte[] input, java.io.ByteArrayOutputStream bos)
           
static byte[] decompress(byte[] compressedData, int off, int len)
           
static void deserialize(org.apache.thrift.TDeserializer deserializer, org.apache.thrift.TBase struct, java.io.DataInput in)
           
static
<T extends java.lang.Comparable<T>>
org.apache.commons.collections.iterators.CollatingIterator
getCollatingIterator()
           
static java.net.InetAddress getLocalAddress()
           
static java.math.BigInteger hash(java.lang.String data)
           
static byte[] hash(java.lang.String type, byte[]... data)
           
static byte[] hexToBytes(java.lang.String str)
           
static java.lang.String mapToString(java.util.Map<?,?> map)
           
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 java.lang.String readNullableString(java.io.DataInput dis)
           
static void renameWithConfirm(java.lang.String tmpFilename, java.lang.String filename)
           
static void serialize(org.apache.thrift.TSerializer serializer, org.apache.thrift.TBase struct, java.io.DataOutput out)
           
static java.lang.String[] strip(java.lang.String string, java.lang.String token)
           
static byte[] toByteArray(int i)
           
static void writeByteArray(byte[] bytes, java.io.DataOutput out)
           
static void writeNullableString(java.lang.String key, java.io.DataOutput dos)
           
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
Constructor Detail

FBUtilities

public FBUtilities()
Method Detail

strip

public static java.lang.String[] strip(java.lang.String string,
                                       java.lang.String token)

getLocalAddress

public static java.net.InetAddress getLocalAddress()

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.

toByteArray

public static byte[] toByteArray(int i)

byteArrayToInt

public static int byteArrayToInt(byte[] bytes)

byteArrayToInt

public static int byteArrayToInt(byte[] bytes,
                                 int offset)

compareByteArrays

public static int compareByteArrays(byte[] bytes1,
                                    byte[] bytes2)

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.

hash

public static java.math.BigInteger hash(java.lang.String data)

hash

public static byte[] hash(java.lang.String type,
                          byte[]... data)

compressToStream

public static void compressToStream(byte[] input,
                                    java.io.ByteArrayOutputStream bos)
                             throws java.io.IOException
Throws:
java.io.IOException

decompress

public static byte[] decompress(byte[] compressedData,
                                int off,
                                int len)
                         throws java.io.IOException,
                                java.util.zip.DataFormatException
Throws:
java.io.IOException
java.util.zip.DataFormatException

writeByteArray

public static void writeByteArray(byte[] bytes,
                                  java.io.DataOutput out)
                           throws java.io.IOException
Throws:
java.io.IOException

hexToBytes

public static byte[] hexToBytes(java.lang.String str)

bytesToHex

public static java.lang.String bytesToHex(byte... bytes)

mapToString

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

writeNullableString

public static void writeNullableString(java.lang.String key,
                                       java.io.DataOutput dos)
                                throws java.io.IOException
Throws:
java.io.IOException

readNullableString

public static java.lang.String readNullableString(java.io.DataInput dis)
                                           throws java.io.IOException
Throws:
java.io.IOException

renameWithConfirm

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

getCollatingIterator

public static <T extends java.lang.Comparable<T>> org.apache.commons.collections.iterators.CollatingIterator getCollatingIterator()

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


Copyright © 2010 The Apache Software Foundation