Java Code Examples for com.google.common.primitives.Longs.toByteArray()

The following are Jave code examples for showing how to use toByteArray() of the com.google.common.primitives.Longs class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: minebox   File: BitPatternGenerator.java   View Source Code Vote up 5 votes
private byte[] seedForThisBlock(long blockNumber) {
    final byte[] bnarr = Longs.toByteArray(blockNumber);
    final int longArrLen = 8;
    final byte[] seedSecRandom = new byte[EncConstants.SHA256_LEN + longArrLen];

    System.arraycopy(bnarr, 0, seedSecRandom, 0, longArrLen);
    System.arraycopy(secretKey, 0, seedSecRandom, longArrLen, EncConstants.SHA256_LEN);
    return bnarr;
}
 
Example 2
Project: twister2   File: LMDBTest.java   View Source Code Vote up 5 votes
public static void main(String[] args) {
  //Memory Manager
  Path dataPath = new Path("/home/pulasthi/work/twister2/lmdbdatabase");
  MemoryManager memoryManager = new LMDBMemoryManager(dataPath);
  byte[] val = Longs.toByteArray(1231212121213L);
  memoryManager.put(1234L, val);

  ByteBuffer results = memoryManager.get(1234L);
  long res = results.getLong();
  if(res == 1231212121213L){
    System.out.println("Correct");
  }
}
 
Example 3
Project: tools   File: BitPatternGenerator.java   View Source Code Vote up 5 votes
private byte[] seedForThisBlock(long blockNumber) {
    final byte[] bnarr = Longs.toByteArray(blockNumber);
    final int longArrLen = 8;
    final byte[] seedSecRandom = new byte[EncConstants.SHA256_LEN + longArrLen];

    System.arraycopy(bnarr, 0, seedSecRandom, 0, longArrLen);
    System.arraycopy(secretKey, 0, seedSecRandom, longArrLen, EncConstants.SHA256_LEN);
    return bnarr;
}
 
Example 4
Project: hadoop-oss   File: TestCryptoCodec.java   View Source Code Vote up 4 votes
private static BigInteger calculateRef(byte[] initIV, long counter) {
  byte[] cb = Longs.toByteArray(counter);
  BigInteger bi = new BigInteger(1, initIV);
  return bi.add(new BigInteger(1, cb));
}
 
Example 5
Project: hadoop   File: TestCryptoCodec.java   View Source Code Vote up 4 votes
private static BigInteger calculateRef(byte[] initIV, long counter) {
  byte[] cb = Longs.toByteArray(counter);
  BigInteger bi = new BigInteger(1, initIV);
  return bi.add(new BigInteger(1, cb));
}
 
Example 6
Project: dremio-oss   File: AbstractTestOCCKVStore.java   View Source Code Vote up 4 votes
@Override
public byte[] convert(Value v) {
  return v.version == null? Longs.toByteArray(-1) : Longs.toByteArray(v.version);
}
 
Example 7
Project: util   File: NumberUtil.java   View Source Code Vote up 4 votes
public static byte[] toBytes(long value) {
	return Longs.toByteArray(value);
}
 
Example 8
Project: guava-mock   File: LittleEndianDataOutputStream.java   View Source Code Vote up 2 votes
/**
 * Writes a {@code long} as specified by {@link DataOutputStream#writeLong(long)}, except using
 * little-endian byte order.
 *
 * @throws IOException if an I/O error occurs
 */
@Override
public void writeLong(long v) throws IOException {
  byte[] bytes = Longs.toByteArray(Long.reverseBytes(v));
  write(bytes, 0, bytes.length);
}
 
Example 9
Project: googles-monorepo-demo   File: LittleEndianDataOutputStream.java   View Source Code Vote up 2 votes
/**
 * Writes a {@code long} as specified by {@link DataOutputStream#writeLong(long)}, except using
 * little-endian byte order.
 *
 * @throws IOException if an I/O error occurs
 */
@Override
public void writeLong(long v) throws IOException {
  byte[] bytes = Longs.toByteArray(Long.reverseBytes(v));
  write(bytes, 0, bytes.length);
}