Returns length of the byte array, returning 0 if the array is null. Useful for calculating sizes.
b
- byte array, which can be null
Get the data from the Bytes.
Use passed bytes as backing array for this instance.
Use passed bytes as backing array for this instance.
Returns the number of valid bytes in the buffer
Return the offset into the buffer.
Define the sort order of the Bytes.
compareTo
in interface Comparable<Bytes>
that
- The other bytes writable
Compares the bytes in this object to the specified byte array
Convert a list of byte[] to an array
array
- List of byte [].
Returns a copy of the bytes referred to by this writable
Read byte-array written with a WritableableUtils.vint prefix.
in
- Input to read from.
in
IOException
- e
Read byte-array written with a WritableableUtils.vint prefix. IOException is converted to a RuntimeException.
in
- Input to read from.
in
Write byte-array with a WritableableUtils.vint prefix.
out
- output stream to be written to
b
- array to write
IOException
- e
Write byte-array to out with a vint length prefix.
out
- output stream
b
- array
offset
- offset into array
length
- length past offset
IOException
- e
Write byte-array from src to tgt with a vint length prefix.
tgt
- target array
tgtOffset
- offset into target array
src
- source array
srcOffset
- source offset
srcLength
- source length
Put bytes at the specified byte array position.
tgtBytes
- the byte array
tgtOffset
- position in the array
srcBytes
- array to write out
srcOffset
- source offset
srcLength
- source length
Write a single byte out to the specified byte array position.
bytes
- the byte array
offset
- position in the array
b
- byte to write out
Add the whole content of the ByteBuffer to the bytes arrays. The ByteBuffer is modified.
bytes
- the byte array
offset
- position in the array
buf
- ByteBuffer to write out
Returns a new byte array, copied from the given buf
, from the index 0 (inclusive) to the limit (exclusive), regardless of the current position. The position and the other index parameters are not changed.
buf
- a byte buffer
Convert a byte[] into a string. Charset is assumed to be UTF-8.
b
- Presumed UTF-8 encoded byte array.
b
Joins two byte arrays together using a separator.
b1
- The first byte array.
sep
- The separator to use.
b2
- The second byte array.
This method will convert utf8 encoded bytes into a string. If the given byte array is null, this method will return null.
b
- Presumed UTF-8 encoded byte array.
off
- offset into array
b
or null
This method will convert utf8 encoded bytes into a string. If the given byte array is null, this method will return null.
b
- Presumed UTF-8 encoded byte array.
off
- offset into array
len
- length of utf-8 sequence
b
or null
Write a printable representation of a byte array.
b
- byte array
Converts the given byte buffer to a printable representation, from the index 0 (inclusive) to the limit (exclusive), regardless of the current position. The position and the other index parameters are not changed.
buf
- a byte buffer
Write a printable representation of a byte array. Non-printable characters are hex escaped in the format \\x%02X, eg: \x00 \x05 etc
b
- array to write out
off
- offset to start at
len
- length to write
Takes a ASCII digit in the range A-F0-9 and returns the corresponding integer/ordinal value.
ch
- The hex digit.
Converts a string to a UTF-8 byte array.
s
- string
Convert a boolean to a byte array. True becomes -1 and false becomes 0.
b
- value
b
encoded in a byte array.
b
- array
Convert a long value to a byte array using big-endian.
val
- value to convert
bytes
- array
Converts a byte array to a long value. Assumes there will be
SIZEOF_LONG
bytes available.
bytes
- bytes
offset
- offset
Converts a byte array to a long value.
bytes
- array of bytes
offset
- offset into array
length
- length of data (must be SIZEOF_LONG
)
IllegalArgumentException
- if length is not SIZEOF_LONG
or if there's not enough room in the array at the offset indicated.
Put a long value out to the specified byte array position.
bytes
- the byte array
offset
- position in the array
val
- long to write out
IllegalArgumentException
- if the byte array given doesn't have enough room at the offset specified.
Put a float value out to the specified byte array position. Presumes float encoded as IEEE 754 floating-point "single format"
bytes
- byte array
Put a float value out to the specified byte array position. Presumes float encoded as IEEE 754 floating-point "single format"
bytes
- array to convert
offset
- offset into array
Put a float value out to the specified byte array position.
bytes
- byte array
offset
- offset to write to
f
- float value
bytes
Return the float represented as byte[]
Return double made from passed bytes.
Return double made from passed bytes.
Put a double value out to the specified byte array position as the IEEE 754 double format.
bytes
- byte array
offset
- offset to write to
d
- value
bytes
Serialize a double as the IEEE 754 double format output. The resultant array will be 8 bytes long.
d
- value
Convert an int value to a byte array. Big-endian. Same as what DataOutputStream.writeInt does.
val
- value
Converts a byte array to an int value
bytes
- byte array
Converts a byte array to an int value
bytes
- byte array
offset
- offset into array
Converts a byte array to an int value
bytes
- byte array
offset
- offset into array
length
- length of int (has to be SIZEOF_INT
)
IllegalArgumentException
- if length is not SIZEOF_INT
or if there's not enough room in the array at the offset indicated.
Converts a byte array to an int value
bytes
- byte array
offset
- offset into array
length
- how many bytes should be considered for creating int
IllegalArgumentException
- if there's not enough room in the array at the offset indicated.
Put an int value out to the specified byte array position.
bytes
- the byte array
offset
- position in the array
val
- int to write out
IllegalArgumentException
- if the byte array given doesn't have enough room at the offset specified.
Convert a short value to a byte array of
SIZEOF_SHORT
bytes long.
val
- value
Converts a byte array to a short value
bytes
- byte array
Converts a byte array to a short value
bytes
- byte array
offset
- offset into array
Converts a byte array to a short value
bytes
- byte array
offset
- offset into array
length
- length, has to be SIZEOF_SHORT
IllegalArgumentException
- if length is not SIZEOF_SHORT
or if there's not enough room in the array at the offset indicated.
Returns a new byte array, copied from the given buf
, from the position (inclusive) to the limit (exclusive). The position and the other index parameters are not changed.
buf
- a byte buffer
Put a short value out to the specified byte array position.
bytes
- the byte array
offset
- position in the array
val
- short to write out
IllegalArgumentException
- if the byte array given doesn't have enough room at the offset specified.
Put an int value as short out to the specified byte array position. Only the lower 2 bytes of the short will be put into the array. The caller of the API need to make sure they will not loose the value by doing so. This is useful to store an unsigned short which is represented as int in other parts.
bytes
- the byte array
offset
- position in the array
val
- value to write out
IllegalArgumentException
- if the byte array given doesn't have enough room at the offset specified.
Convert a BigDecimal value to a byte array
Converts a byte array to a BigDecimal
Converts a byte array to a BigDecimal value
Put a BigDecimal value out to the specified byte array position.
bytes
- the byte array
offset
- position in the array
val
- BigDecimal to write out
Encode a long value as a variable length integer.
vint
- Integer to make a vint of.
Reads a zero-compressed encoded long from input buffer and returns it.
buffer
- buffer to convert
Reads a zero-compressed encoded long from input buffer and returns it.
buffer
- Binary array
offset
- Offset into array at which vint begins.
Lexicographically compare two arrays.
left
- left operand
right
- right operand
Lexicographically compare two arrays.
buffer1
- left operand
buffer2
- right operand
offset1
- Where to start comparing in the left buffer
offset2
- Where to start comparing in the right buffer
length1
- How much to compare from the left buffer
length2
- How much to compare from the right buffer
Lexicographically determine the equality of two arrays.
left
- left operand
right
- right operand
Lexicographically determine the equality of two arrays.
left
- left operand
leftOffset
- offset into left operand
leftLen
- length of left operand
right
- right operand
rightOffset
- offset into right operand
rightLen
- length of right operand
Lexicographically determine the equality of two byte[], one as ByteBuffer.
a
- left operand
buf
- right operand
Return true if the byte array on the right is a prefix of the byte array on the left.
Calculate a hash code from a given byte array.
b
- bytes to hash
WritableComparator.hashBytes(byte[], int)
on the passed in array. This method is what Text
use calculating hash code.
Calculate a hash code from a given byte array.
b
- value
length
- length of the value
WritableComparator.hashBytes(byte[], int)
on the passed in array. This method is what Text
use calculating hash code.
Calculate a hash code from a given byte array suitable for use as a key in maps.
b
- bytes to hash
b
as an Integer that can be used as key in Maps.
Calculate a hash code from a given byte array suitable for use as a key in maps.
b
- bytes to hash
length
- length to hash
b
as an Integer that can be used as key in Maps.
Concatenate byte arrays.
a
- lower half
b
- upper half
Concatenate byte arrays.
a
- first third
b
- second third
c
- third third
Concatenate byte arrays.
arrays
- all the arrays to concatenate together.
Make a new byte array from a subset of bytes at the head of another.
a
- array
length
- amount of bytes to grab
length
bytes from a
Make a new byte array from a subset of bytes at the tail of another.
a
- array
length
- amount of bytes to snarf
length
bytes from a
Make a new byte array from a subset of bytes at the head of another, zero padded as desired.
a
- array
length
- new array size
a
plus length
prepended 0 bytes
Make a new byte array from a subset of bytes at the tail of another, zero padded as desired.
a
- array
length
- new array size
a
plus length
appended 0 bytes
Split passed range. Expensive operation relatively. Uses BigInteger math. Useful splitting ranges for MapReduce jobs.
a
- Beginning of range
b
- End of range
num
- Number of times to split range. Pass 1 if you want to split the range in two; i.e. one split.
Split passed range. Expensive operation relatively. Uses BigInteger math. Useful splitting ranges for MapReduce jobs.
a
- Beginning of range
b
- End of range
inclusive
- Whether the end of range is prefix-inclusive or is considered an exclusive boundary. Automatic splits are generally exclusive and manual splits with an explicit range utilize an inclusive end of range.
num
- Number of times to split range. Pass 1 if you want to split the range in two; i.e. one split.
Iterate over keys within the passed range, splitting at an [a,b) boundary.
Iterate over keys within the passed range.
Calculate the hash code for a given range of bytes.
bytes
- array to hash
offset
- offset to start from
length
- length to hash
Create an array of byte[] given an array of String.
t
- operands
Create an array of byte[] given an array of String.
t
- operands
Create a byte[][] where first and only entry is column
column
- operand
column
Create a byte[][] where first and only entry is column
column
- operand
column
Binary search for keys in indexes using Bytes.BYTES_RAWCOMPARATOR.
arr
- array of byte arrays to search for
key
- the key you want to find
offset
- the offset in the key you want to find
length
- the length of the key
Binary search for keys in indexes.
arr
- array of byte arrays to search for
key
- the key you want to find
comparator
- a comparator to compare.
Bytewise binary increment/deincrement of long contained in byte array on given amount.
value
- - array of bytes containing long (length <= SIZEOF_LONG)
amount
- value will be incremented on (deincremented if negative)
Writes a string as a fixed-size field, padded with zeros.
IOException
Reads a fixed-size field and interprets it as a string padded with zeros.
IOException
Copy the byte array given in parameter and return an instance of a new byte array with the same length and the same content.
bytes
- the byte array to duplicate
Copy the byte array given in parameter and return an instance of a new byte array with the same length and the same content.
bytes
- the byte array to copy from
Search sorted array "a" for byte "key". I can't remember if I wrote this or copied it from somewhere. (mcorgan)
a
- Array to search. Entries must be sorted and unique.
fromIndex
- First index inclusive of "a" to include in the search.
toIndex
- Last index exclusive of "a" to include in the search.
key
- The byte to search for.
Treat the byte[] as an unsigned series of bytes, most significant bits first. Start by adding 1 to the rightmost bit/byte and carry over all overflows to the more significant bits/bytes.
input
- The byte[] to increment.
Returns the index of the first appearance of the value target
in array
.
array
- an array of byte
values, possibly empty
target
- a primitive byte
value
i
for which array[i] == target
, or -1
if no such index exists.
Returns the start position of the first occurrence of the specified
target
within
array
, or
-1
if there is no such occurrence.
More formally, returns the lowest index i
such that java.util.Arrays.copyOfRange(array, i, i + target.length)
contains exactly the same elements as target
.
array
- the array to search for the sequence target
target
- the array to search for as a sub-sequence of array
Return true if target is present as an element anywhere in the given array.
array
- an array of byte
values, possibly empty
target
- a primitive byte
value
true
if target
is present as an element anywhere in array
.
Return true if target is present as an element anywhere in the given array.
array
- an array of byte
values, possibly empty
target
- an array of byte
true
if target
is present anywhere in array
Fill given array with zeros.
b
- array which needs to be filled with zeros
Fill given array with zeros at the specified position.
Fill given array with random bytes.
b
- array which needs to be filled with random bytes
If you want random bytes generated by a strong source of randomness use secureRandom(byte[])
.
b
- array which needs to be filled with random bytes
If you want random bytes generated by a strong source of randomness use secureRandom(byte[], int, int)
.
b
- array which needs to be filled with random bytes
offset
- staring offset in array
length
- number of bytes to fill
Fill given array with random bytes using a strong random number generator.
b
- array which needs to be filled with random bytes
Fill given array with random bytes at the specified position using a strong random number generator.
b
- array which needs to be filled with random bytes
offset
- staring offset in array
length
- number of bytes to fill
Create a max byte array with the specified max byte count
maxByteCount
- the length of returned byte array
Create a byte array which is multiple given bytes
Convert a byte range into a hex string
Convert a byte array into a hex string
Create a byte array from a string of hash digits. The length of the string must be a multiple of 2
Find index of passed delimiter.
b
moving rightward.
Find index of passed delimiter walking from end of buffer backwards.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4