org.jlab.hipo.io
Class HipoByteUtils
- java.lang.Object
-
- org.jlab.hipo.io.HipoByteUtils
-
public class HipoByteUtils extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field and Description static java.util.TreeMap<java.lang.Integer,java.lang.Integer>bitMapstatic intMTU
-
Constructor Summary
Constructors Constructor and Description HipoByteUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static byte[]compressLZ4(byte[] uncompressed)static byte[]compressLZ4max(byte[] uncompressed)static java.util.TreeMap<java.lang.Integer,java.lang.Integer>createBitMap()static byte[]generateByteArray(int count)static bytegetByteFromInt(int data)static bytegetByteFromShort(short data)returns a byte from short number, anything that exceeds the number that fits in the byte they will be thrown away.static java.lang.StringgetByteString(int word)returns byte string representation of the given integer, with 32 bits 0 and 1.static intgetInteger(int data, int bitstart, int bitend)static intgetIntFromByte(byte data)static intgetIntFromShort(short data)static shortgetShortFromByte(byte data)static shortgetShortFromInt(int data)static byte[]gzip(byte[] ungzipped)returns the byte array GZIP compressed.static voidmain(java.lang.String[] args)static voidprintBitMap()static intread(int word, int start, int end)read specific bit from given integer.static intreadLong(long word, int start, int end)read specific bit from given long.static voiduncompressLZ4(byte[] compressed, byte[] uncompressed)static byte[]ungzip(byte[] gzipped)The fastest Ungzip implementation.static intwrite(int word, int number, int start, int end)write a number to a specific bits of existing integer.static longwriteLong(long word, int number, int start, int end)write a number to a specific bits of existing long (64-bits).
-
-
-
Field Detail
-
MTU
public static final int MTU
- See Also:
- Constant Field Values
-
bitMap
public static java.util.TreeMap<java.lang.Integer,java.lang.Integer> bitMap
-
-
Method Detail
-
createBitMap
public static java.util.TreeMap<java.lang.Integer,java.lang.Integer> createBitMap()
-
uncompressLZ4
public static void uncompressLZ4(byte[] compressed, byte[] uncompressed)
-
compressLZ4
public static byte[] compressLZ4(byte[] uncompressed)
-
compressLZ4max
public static byte[] compressLZ4max(byte[] uncompressed)
-
gzip
public static byte[] gzip(byte[] ungzipped)
returns the byte array GZIP compressed.- Parameters:
count-- Returns:
-
ungzip
public static byte[] ungzip(byte[] gzipped)
The fastest Ungzip implementation. See PageInfoTest in ehcache-constructs. A high performance implementation, although not as fast as gunzip3. gunzips 100000 of ungzipped content in 9ms on the reference machine. It does not use a fixed size buffer and is therefore suitable for arbitrary length arrays.- Parameters:
gzipped-- Returns:
- a plain, uncompressed byte[]
-
generateByteArray
public static byte[] generateByteArray(int count)
-
printBitMap
public static void printBitMap()
-
getInteger
public static int getInteger(int data, int bitstart, int bitend)
-
getShortFromByte
public static short getShortFromByte(byte data)
-
getIntFromShort
public static int getIntFromShort(short data)
-
getIntFromByte
public static int getIntFromByte(byte data)
-
getShortFromInt
public static short getShortFromInt(int data)
-
getByteFromInt
public static byte getByteFromInt(int data)
-
getByteFromShort
public static byte getByteFromShort(short data)
returns a byte from short number, anything that exceeds the number that fits in the byte they will be thrown away.- Parameters:
data- short data (2 bytes)- Returns:
- a byte which is lower part of the given short (1 - byte)
-
getByteString
public static java.lang.String getByteString(int word)
returns byte string representation of the given integer, with 32 bits 0 and 1.- Parameters:
word- reference integer word- Returns:
-
write
public static int write(int word, int number, int start, int end)write a number to a specific bits of existing integer. the specified bits are reset to 0 first then the provided number is written into specified bits- Parameters:
word- reference integer word (4 bits) is not changednumber- and integer number written (user should check if the number fits)start- starting bits (first bit is 0)end- ending bit (for one bit start=end)- Returns:
- returns a new integer with bits written
-
writeLong
public static long writeLong(long word, int number, int start, int end)write a number to a specific bits of existing long (64-bits). the specified bits are reset to 0 first then the provided number is written into specified bits- Parameters:
word- reference integer word (4 bits) is not changednumber- and integer number written (user should check if the number fits)start- starting bits (first bit is 0)end- ending bit (for one bit start=end)- Returns:
- returns a new integer with bits written
-
read
public static int read(int word, int start, int end)read specific bit from given integer.- Parameters:
word- integer reference wordstart- starting bit (0 being the first one)end- ending bit (for reading 1 bit start must be = to end)- Returns:
-
readLong
public static int readLong(long word, int start, int end)read specific bit from given long.- Parameters:
word- long reference wordstart- starting bit (0 being the first one)end- ending bit (for reading 1 bit start must be = to end)- Returns:
-
main
public static void main(java.lang.String[] args)
-
-
DMelt 3.0 © DataMelt by jWork.ORG