/** Get an int from a byte array (network order) * @param b Byte Array */ public static final int getInt(byte[]b) { return getInt(b, 0) ; }
@Override public final int hashCode(byte[] key) { return Bytes.getInt(key) ; } } ;
/** Get an int from a byte array (network order) * @param b Byte Array */ public static final int getInt(byte[]b) { return getInt(b, 0) ; }
/** Get an int from a byte array (network order) * @param b Byte Array */ public static final int getInt(byte[]b) { return getInt(b, 0) ; }
public static int recordToInt(Record key) { return Bytes.getInt(key.getKey()) ; }
public static int recordToInt(Record key) { return Bytes.getInt(key.getKey()) ; }
static public String format(JournalEntry entry) { StringBuilder sbuff = new StringBuilder() ; sbuff.append("Entry: ") ; sbuff.append(" "+entry.type) ; if ( entry.componentId != null ) { String label = entry.componentId.label() ; if ( label != null ) sbuff.append(label) ; sbuff.append(" [..") ; int z = Bytes.getInt(entry.componentId.getBytes(), entry.componentId.getBytes().length-4) ; sbuff.append(Integer.toHexString(z)) ; sbuff.append("]") ; } if ( entry.data != null ) sbuff.append(" "+ByteBufferLib.details(entry.data)) ; return sbuff.toString() ; } }
static public String format(JournalEntry entry) { StringBuilder sbuff = new StringBuilder() ; sbuff.append("Entry: ") ; sbuff.append(" "+entry.type) ; if ( entry.componentId != null ) { String label = entry.componentId.label() ; if ( label != null ) sbuff.append(label) ; sbuff.append(" [..") ; int z = Bytes.getInt(entry.componentId.getBytes(), entry.componentId.getBytes().length-4) ; sbuff.append(Integer.toHexString(z)) ; sbuff.append("]") ; } if ( entry.data != null ) sbuff.append(" "+ByteBufferLib.details(entry.data)) ; return sbuff.toString() ; } }
public static int recordToInt(Record key) { return Bytes.getInt(key.getKey()) ; }
public static int recordToInt(Record key) { return Bytes.getInt(key.getKey()) ; }
if ( lenRead != SizeofCRC ) throw new TDBTransactionException("Failed to read block checksum (got "+lenRead+" bytes, not "+SizeofCRC+").") ; int checksum = Bytes.getInt(crcTrailer.array()) ; if ( checksum != (int)adler.getValue() ) throw new TDBTransactionException("Checksum error reading from the Journal.") ;
@Test public void packInt3() { byte[] b = new byte[4] ; Bytes.setInt(0xF1F2F3F4,b) ; int i = Bytes.getInt(b) ; assertEquals(0xF1F2F3F4, i) ; }
private static String readOne(Transactional transactional, TransBinaryDataFile transBinaryFile, long posn) { return Txn.calculateRead(transactional, ()->{ byte[] lenBytes = new byte[4] ; long x = posn ; int got = transBinaryFile.read(x, lenBytes) ; x += got ; int len = Bytes.getInt(lenBytes) ; byte[] bytes = new byte[len] ; got = transBinaryFile.read(x, bytes) ; x += got ; return StrUtils.fromUTF8bytes(bytes) ; }) ; }
private static String readOne(Transactional transactional, TransBinaryDataFile transBinaryFile, long posn) { return Txn.calculateRead(transactional, ()->{ byte[] lenBytes = new byte[4] ; long x = posn ; int got = transBinaryFile.read(x, lenBytes) ; x += got ; int len = Bytes.getInt(lenBytes) ; byte[] bytes = new byte[len] ; got = transBinaryFile.read(x, bytes) ; x += got ; return StrUtils.fromUTF8bytes(bytes) ; }) ; }
private static String readOne(Transactional transactional, TransBinaryDataFile transBinaryFile, long posn) { return Txn.calculateRead(transactional, ()->{ byte[] lenBytes = new byte[4] ; long x = posn ; int got = transBinaryFile.read(x, lenBytes) ; x += got ; int len = Bytes.getInt(lenBytes) ; byte[] bytes = new byte[len] ; got = transBinaryFile.read(x, bytes) ; x += got ; return StrUtils.fromUTF8bytes(bytes) ; }) ; }