org.elasticsearch.common
Class Bytes
java.lang.Object
org.elasticsearch.common.Bytes
public class Bytes
- extends Object
Constructor Summary |
Bytes()
|
Method Summary |
static int |
atoi(byte[] s)
|
static long |
atol(byte[] s)
|
static byte[] |
itoa(int i)
Blatant copy of Integer.toString, but returning a byte array instead of a String, as
string charset decoding/encoding was killing us on performance. |
static byte[] |
ltoa(long i)
|
static int |
oversize(int minTargetSize,
int bytesPerElement)
Returns an array size >= minTargetSize, generally
over-allocating exponentially to achieve amortized
linear-time cost as the array grows. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
EMPTY_ARRAY
public static final byte[] EMPTY_ARRAY
Bytes
public Bytes()
oversize
public static int oversize(int minTargetSize,
int bytesPerElement)
- Returns an array size >= minTargetSize, generally
over-allocating exponentially to achieve amortized
linear-time cost as the array grows.
NOTE: this was originally borrowed from Python 2.4.2
listobject.c sources (attribution in LICENSE.txt), but
has now been substantially changed based on
discussions from java-dev thread with subject "Dynamic
array reallocation algorithms", started on Jan 12
2010.
- Parameters:
minTargetSize
- Minimum required value to be returned.bytesPerElement
- Bytes used by each element of
the array. See constants in RamUsageEstimator
.
itoa
public static byte[] itoa(int i)
- Blatant copy of Integer.toString, but returning a byte array instead of a String, as
string charset decoding/encoding was killing us on performance.
- Parameters:
i
- integer to convert
- Returns:
- byte[] array containing literal ASCII char representation
atoi
public static int atoi(byte[] s)
throws NumberFormatException
- Throws:
NumberFormatException
ltoa
public static byte[] ltoa(long i)
atol
public static long atol(byte[] s)
throws NumberFormatException
- Throws:
NumberFormatException
Copyright © 2009-2012. All Rights Reserved.