List of usage examples for com.google.common.primitives UnsignedInteger MAX_VALUE
UnsignedInteger MAX_VALUE
To view the source code for com.google.common.primitives UnsignedInteger MAX_VALUE.
Click Source Link
From source file:com.google.reddcoin.core.VarInt.java
/** * Gets the minimum encoded size of the given value. */// w w w. j a v a2 s. com public static int sizeOf(long value) { if (isLessThanUnsigned(value, 253)) return 1; else if (isLessThanUnsigned(value, 65536)) return 3; // 1 marker + 2 data bytes else if (isLessThanUnsigned(value, UnsignedInteger.MAX_VALUE.longValue())) return 5; // 1 marker + 4 data bytes else return 9; // 1 marker + 8 data bytes }
From source file:c1c.v8fs.Chunk.java
@Override public void writeToBuffer(ByteBuffer buffer) { if (header.isNextChunkPresent()) { header.setNextChunkAddress(buffer.position() + 31 + data.length); } else {/*from w w w . ja va 2 s . com*/ header.setNextChunkAddress(UnsignedInteger.MAX_VALUE.longValue()); } this.address = buffer.position(); header.writeToBuffer(buffer); buffer.put(data); }
From source file:c1c.v8fs.ChunkHeader.java
private String toStringBuffer() { return '\u0d0a' + intToHex(chainSize) + ' ' + intToHex(thisChunkSize) + ' ' + (nextChunkPresent ? intToHex(nextChunkAddress) : intToHexSpec(UnsignedInteger.MAX_VALUE.longValue()) + ' ' + '\u0d0a'); }
From source file:org.eclipse.milo.opcua.stack.core.types.builtin.ExpandedNodeId.java
/** * @param namespaceIndex the index for a namespace URI. An index of 0 is used for OPC UA defined NodeIds. * @param identifier the identifier for a node in the address space of an OPC UA Server. *//*from w w w.j a va 2s . co m*/ public ExpandedNodeId(UShort namespaceIndex, UInteger identifier, String namespaceUri, long serverIndex) { checkArgument( identifier.longValue() >= 0 && identifier.longValue() <= UnsignedInteger.MAX_VALUE.longValue()); this.nodeId = new NodeId(namespaceIndex, identifier); this.namespaceUri = namespaceUri; this.serverIndex = serverIndex; }
From source file:com.google.reddcoin.core.VarInt.java
public byte[] encode() { if (isLessThanUnsigned(value, 253)) { return new byte[] { (byte) value }; } else if (isLessThanUnsigned(value, 65536)) { return new byte[] { (byte) 253, (byte) (value), (byte) (value >> 8) }; } else if (isLessThanUnsigned(value, UnsignedInteger.MAX_VALUE.longValue())) { byte[] bytes = new byte[5]; bytes[0] = (byte) 254; Utils.uint32ToByteArrayLE(value, bytes, 1); return bytes; } else {/*from w w w . j a va 2s. c om*/ byte[] bytes = new byte[9]; bytes[0] = (byte) 255; Utils.uint32ToByteArrayLE(value, bytes, 1); Utils.uint32ToByteArrayLE(value >>> 32, bytes, 5); return bytes; } }
From source file:com.google.digitalcoin.core.VarInt.java
public byte[] encodeBE() { if (isLessThanUnsigned(value, 253)) { return new byte[] { (byte) value }; } else if (isLessThanUnsigned(value, 65536)) { return new byte[] { (byte) 253, (byte) (value), (byte) (value >> 8) }; } else if (isLessThanUnsigned(value, UnsignedInteger.MAX_VALUE.longValue())) { byte[] bytes = new byte[5]; bytes[0] = (byte) 254; Utils.uint32ToByteArrayLE(value, bytes, 1); return bytes; } else {//ww w . ja va 2 s .co m byte[] bytes = new byte[9]; bytes[0] = (byte) 255; Utils.uint32ToByteArrayLE(value, bytes, 1); Utils.uint32ToByteArrayLE(value >>> 32, bytes, 5); return bytes; } }
From source file:com.mrd.bitlib.model.Transaction.java
/** * Returns the minimum nSequence number of all inputs * Can be used to detect transactions marked for Full-RBF and thus are very low trust while having 0 conf * Transactions with minSequenceNumber < MAX_INT-1 are eligible for full RBF * https://github.com/bitcoin/bitcoin/pull/6871#event-476297575 * * @return the min nSequence of all inputs of that transaction */// www .j a v a2 s . co m public UnsignedInteger getMinSequenceNumber() { UnsignedInteger minVal = UnsignedInteger.MAX_VALUE; for (TransactionInput input : inputs) { UnsignedInteger nSequence = UnsignedInteger.fromIntBits(input.sequence); if (nSequence.compareTo(minVal) < 0) { minVal = nSequence; } } return minVal; }
From source file:com.mrd.bitlib.model.Transaction.java
/** * Returns true if this transaction is marked for RBF and thus can easily get replaced by a * conflicting transaction while it is still unconfirmed. * * @return true if any of its inputs has a nSequence < MAX_INT-1 *///from w ww .j ava 2 s . c o m public boolean isRbfAble() { if (_rbfAble == null) { _rbfAble = (getMinSequenceNumber().compareTo(UnsignedInteger.MAX_VALUE.minus(UnsignedInteger.ONE)) < 0); } return _rbfAble; }
From source file:se.sics.caracaldb.global.DefaultPolicy.java
private Set<Key> generateVNodes(byte[] schemaId, int num) { Set<Key> keys = new TreeSet<Key>(); // boundary nodes Key start = new Key(schemaId); keys.add(start);/*from w ww. j a va2 s .c o m*/ //virtualHostsPut(end, rset); // this mind end up being override by the next schema, but that's ok since we only need it if there is no next schema if (num == 1) { // single vnode needed return keys; } num--; // account for the initial vnode already created (the end-nodes doesn't count) if (num <= UnsignedBytes.MAX_VALUE) { // another byte for subkeys needed int incr = (int) UnsignedBytes.MAX_VALUE / (int) num; int last = 0; int ceiling = (int) UnsignedBytes.MAX_VALUE - incr; while (last < ceiling) { last = last + incr; Key k = start.append(new byte[] { UnsignedBytes.saturatedCast(last) }).get(); keys.add(k); } } else if (num <= UnsignedInteger.MAX_VALUE.longValue()) { // another 4 bytes for subkeys needed long incr = UnsignedInteger.MAX_VALUE.longValue() / num; long last = 0; long ceiling = UnsignedInteger.MAX_VALUE.longValue() - incr; while (last < ceiling) { last = last + incr; Key k = start.append(new Key(UnsignedInteger.valueOf(last).intValue())).get(); keys.add(k); } } else { // another 8 bytes for subkeys needed (don't support more!) UnsignedLong incr = UnsignedLong.MAX_VALUE.dividedBy(UnsignedLong.valueOf(num)); UnsignedLong last = UnsignedLong.ZERO; UnsignedLong ceiling = UnsignedLong.MAX_VALUE.minus(incr); while (last.compareTo(ceiling) <= 0) { last = last.plus(incr); Key k = start.append(new Key(last.intValue())).get(); keys.add(k); } } return keys; }
From source file:se.sics.caracaldb.global.LookupTable.java
private void generateInitialVirtuals(ByteBuffer schemaId) { ImmutableMap<String, String> meta = schemas.metaData.get(schemaId); //String rfactorS = meta.getOrDefault("rfactor", "3"); String rfactorS = J6.orDefault(meta.get("rfactor"), "3"); Integer rfactor = Integer.parseInt(rfactorS); //String vnodesS = meta.getOrDefault("vnodes", "1"); String vnodesS = J6.orDefault(meta.get("vnodes"), "1"); long vnodes = Long.parseLong(vnodesS); //String forceMasterS = meta.getOrDefault("forceMaster", "false"); String forceMasterS = J6.orDefault(meta.get("forceMaster"), "false"); // it would look so nice in Java8 -.- boolean forceMaster = Boolean.parseBoolean(forceMasterS); // boundary nodes Key start = new Key(schemaId); //Key end = start.inc(); Integer rset = forceMaster ? 0 : findReplicationSetOfSize(rfactor); virtualHostsPut(start, rset);//from www. j a v a 2 s.c o m //virtualHostsPut(end, rset); // this mind end up being override by the next schema, but that's ok since we only need it if there is no next schema if (vnodes == 1) { // single vnode needed return; } vnodes--; // account for the initial vnode already created (the end-nodes doesn't count) Set<Key> subkeys = new TreeSet<Key>(); if (vnodes <= UnsignedBytes.MAX_VALUE) { // another byte for subkeys needed int incr = (int) UnsignedBytes.MAX_VALUE / (int) vnodes; int last = 0; int ceiling = (int) UnsignedBytes.MAX_VALUE - incr; while (last < ceiling) { last = last + incr; Key k = start.append(new byte[] { UnsignedBytes.saturatedCast(last) }).get(); subkeys.add(k); } } else if (vnodes <= UnsignedInteger.MAX_VALUE.longValue()) { // another 4 bytes for subkeys needed long incr = UnsignedInteger.MAX_VALUE.longValue() / vnodes; long last = 0; long ceiling = UnsignedInteger.MAX_VALUE.longValue() - incr; while (last < ceiling) { last = last + incr; Key k = start.append(new Key(UnsignedInteger.valueOf(last).intValue())).get(); subkeys.add(k); } } else { // another 8 bytes for subkeys needed (don't support more!) UnsignedLong incr = UnsignedLong.MAX_VALUE.dividedBy(UnsignedLong.valueOf(vnodes)); UnsignedLong last = UnsignedLong.ZERO; UnsignedLong ceiling = UnsignedLong.MAX_VALUE.minus(incr); while (last.compareTo(ceiling) <= 0) { last = last.plus(incr); Key k = start.append(new Key(last.intValue())).get(); subkeys.add(k); } } for (Key subkey : subkeys) { virtualHostsPut(subkey, forceMaster ? 0 : findReplicationSetOfSize(rfactor)); } }