List of usage examples for com.google.common.primitives UnsignedLong ZERO
UnsignedLong ZERO
To view the source code for com.google.common.primitives UnsignedLong ZERO.
Click Source Link
From source file:org.opendaylight.controller.md.sal.dom.store.impl.DataAndMetadataSnapshot.java
public static DataAndMetadataSnapshot createEmpty(final NodeIdentifier rootNode) { NormalizedNode<?, ?> data = Builders.containerBuilder().withNodeIdentifier(rootNode).build(); StoreMetadataNode metadata = StoreMetadataNode.builder().setNodeVersion(UnsignedLong.ZERO) .setSubtreeVersion(UnsignedLong.ZERO).setData(data).build(); return new DataAndMetadataSnapshot(metadata, Optional.<SchemaContext>absent()); }
From source file:org.opendaylight.controller.md.sal.dom.store.impl.tree.data.StoreMetadataNode.java
public static StoreMetadataNode createEmpty(final NormalizedNode<?, ?> data) { return new StoreMetadataNode(data, UnsignedLong.ZERO, UnsignedLong.ZERO, Collections.<PathArgument, StoreMetadataNode>emptyMap()); }
From source file:org.opendaylight.controller.md.sal.dom.store.impl.DataAndMetadataSnapshot.java
public static DataAndMetadataSnapshot createEmpty(final SchemaContext ctx) { NodeIdentifier rootNodeIdentifier = new NodeIdentifier(ctx.getQName()); NormalizedNode<?, ?> data = Builders.containerBuilder().withNodeIdentifier(rootNodeIdentifier).build(); StoreMetadataNode metadata = StoreMetadataNode.builder().setData(data).setNodeVersion(UnsignedLong.ZERO) .setSubtreeVersion(UnsignedLong.ZERO).build(); return new DataAndMetadataSnapshot(metadata, Optional.of(ctx)); }
From source file:org.opendaylight.controller.cluster.datastore.ShardDataTreeMocking.java
public static ShardDataTreeCohort successfulCommit(final ShardDataTreeCohort mock) { return successfulCommit(mock, UnsignedLong.ZERO); }
From source file:org.jpmml.rexp.RandomForestConverter.java
static <E> List<E> selectValues(List<E> values, Double split, boolean left) { UnsignedLong bits = toUnsignedLong(split.doubleValue()); List<E> result = new ArrayList<>(); for (int i = 0; i < values.size(); i++) { E value = values.get(i);//from w w w . j a va 2s .com boolean append; // Send "true" categories to the left if (left) { // Test if the least significant bit (LSB) is 1 append = (bits.mod(RandomForestConverter.TWO)).equals(UnsignedLong.ONE); } else // Send all other categories to the right { // Test if the LSB is 0 append = (bits.mod(RandomForestConverter.TWO)).equals(UnsignedLong.ZERO); } // End if if (append) { result.add(value); } bits = bits.dividedBy(RandomForestConverter.TWO); } return result; }
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 www . ja 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 (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:org.opendaylight.controller.cluster.datastore.ShardDataTree.java
private void finishCommit(final SimpleShardDataTreeCohort cohort) { final TransactionIdentifier txId = cohort.getIdentifier(); final DataTreeCandidate candidate = cohort.getCandidate(); LOG.debug("{}: Resuming commit of transaction {}", logContext, txId); try {//from ww w.j av a2 s . c o m dataTree.commit(candidate); } catch (Exception e) { LOG.error("{}: Failed to commit transaction {}", logContext, txId, e); failCommit(e); return; } shard.getShardMBean().incrementCommittedTransactionCount(); shard.getShardMBean().setLastCommittedTransactionTime(System.currentTimeMillis()); // FIXME: propagate journal index pendingTransactions.poll().cohort.successfulCommit(UnsignedLong.ZERO); LOG.trace("{}: Transaction {} committed, proceeding to notify", logContext, txId); notifyListeners(candidate); processNextTransaction(); }
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 w ww . ja va2s .co 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)); } }