List of usage examples for java.lang Integer BYTES
int BYTES
To view the source code for java.lang Integer BYTES.
Click Source Link
From source file:io.pravega.controller.store.stream.tables.HistoryRecord.java
public byte[] toBytePartial() { byte[] b = new byte[PARTIAL_FIELDS_FIXED_LENGTH + segments.size() * Integer.BYTES]; toBytePartial(b);//from w w w. ja v a2s. co m return b; }
From source file:ie.peternagy.jcrypto.algo.AesWrapper.java
protected byte[] extractHeader(byte[] data) { int version = data[0]; int currentPosition = 1; int ivLength = ByteBuffer.wrap(ArrayUtils.subarray(data, currentPosition, currentPosition + Integer.BYTES)) .getInt();//www. ja v a 2 s. c om currentPosition += Integer.BYTES; int saltLength = ByteBuffer .wrap(ArrayUtils.subarray(data, currentPosition, currentPosition + Integer.BYTES)).getInt(); currentPosition += Integer.BYTES; int garbageLength = ByteBuffer .wrap(ArrayUtils.subarray(data, currentPosition, currentPosition + Integer.BYTES)).getInt(); currentPosition += Integer.BYTES; int baseKeyLength = ByteBuffer .wrap(ArrayUtils.subarray(data, currentPosition, currentPosition + Integer.BYTES)).getInt(); currentPosition += Integer.BYTES; iv = ArrayUtils.subarray(data, currentPosition, currentPosition + ivLength); currentPosition += ivLength; salt = ArrayUtils.subarray(data, currentPosition, currentPosition + saltLength); currentPosition += saltLength; currentPosition += garbageLength;//skip garbage byte[] encKeyBase = ArrayUtils.subarray(data, currentPosition, currentPosition + baseKeyLength); currentPosition += baseKeyLength; baseKey = curve.doFinalWithHeader(encKeyBase, false); byte[] content = ArrayUtils.subarray(data, currentPosition, data.length); generateSecretKey(); initCipher(state); return content; }
From source file:de.micromata.genome.logging.spi.ifiles.IndexHeader.java
/** * /* w w w . j av a 2s . c o m*/ * @param start when to start * @param end when to end * @param mem the buffer in the memory * @param filesize the size of the file * @return startoffset, endidx */ public List<Pair<Integer, Integer>> getCandiates(Timestamp start, Timestamp end, MappedByteBuffer mem, int filesize) { List<Pair<Integer, Integer>> ret = new ArrayList<>(); int pos = filesize - ROW_LENGTH; while (pos >= 0) { long logt = mem.getLong(pos); if (start != null && start.getTime() > logt) { continue; } if (end != null && end.getTime() < logt) { break; } int offset = mem.getInt(pos + Long.BYTES); int endOfset = -1; if (pos + ROW_LENGTH + Integer.BYTES < filesize) { endOfset = mem.getInt(pos + Long.BYTES + ROW_LENGTH); } if (offset == endOfset) { // oops System.out.println("Oops"); } ret.add(Pair.make(offset, endOfset)); pos -= ROW_LENGTH; } return ret; }
From source file:io.pravega.controller.store.stream.tables.HistoryRecord.java
private static int getCount(int length) { return (length - FIXED_FIELDS_LENGTH) / Integer.BYTES; }
From source file:io.pravega.controller.store.stream.tables.HistoryRecord.java
private void toBytePartial(byte[] b) { // length//from w w w . j a va2s .c om BitConverter.writeInt(b, lengthOffset(), length); // epoch BitConverter.writeInt(b, epochOffset(), epoch); // segments for (int i = 0; i < segments.size(); i++) { BitConverter.writeInt(b, segmentOffset() + i * Integer.BYTES, segments.get(i)); } // start offset BitConverter.writeInt(b, offsetOffset(segments.size()), length - Long.BYTES - Integer.BYTES); }
From source file:io.pravega.controller.store.stream.tables.HistoryRecord.java
private static int epochOffset() { return lengthOffset() + Integer.BYTES; }
From source file:io.pravega.controller.store.stream.tables.HistoryRecord.java
private static int segmentOffset() { return epochOffset() + Integer.BYTES; }
From source file:io.pravega.controller.store.stream.tables.HistoryRecord.java
private static int offsetOffset(int count) { return segmentOffset() + count * Integer.BYTES; }
From source file:io.pravega.controller.store.stream.tables.HistoryRecord.java
private static int scaleTimeOffset(int segmentCount) { return offsetOffset(segmentCount) + Integer.BYTES; }
From source file:io.pravega.controller.store.stream.tables.HistoryRecord.java
public byte[] toByteArray() { byte[] b = new byte[FIXED_FIELDS_LENGTH + segments.size() * Integer.BYTES]; toBytePartial(b);// w w w . ja v a 2s . c om remainingByteArray(b, PARTIAL_FIELDS_FIXED_LENGTH + segments.size() * Integer.BYTES); return b; }