/** * Atomically increments by one the element at index {@code i}. * * @param i the index * @return the updated value */ public final int incrementAndGet(int i) { return addAndGet(i, 1); }
/** * Atomically decrements by one the element at index {@code i}. * * @param i the index * @return the updated value */ public final int decrementAndGet(int i) { return addAndGet(i, -1); }
@Override public Value atomic(Value value) { assert _key.home(); MapReduce trainer = MapReduce._instances.get(_key); if( trainer != null ) { for( int y = 1; y < trainer._ls.length; y++ ) { for( int i = 0; i < _w[y].length; i++ ) trainer._ls[y]._w[i] += _w[y][i]; for( int i = 0; i < _b[y].length; i++ ) trainer._ls[y]._b[i] += _b[y][i]; } for( int y = 1; y < trainer._ls.length; y++ ) { _w[y] = trainer._ls[y]._w; _b[y] = trainer._ls[y]._b; } for( int i = 0; i < _counts.length; i += 2 ) trainer._counts.addAndGet(_counts[i], _counts[i + 1]); _counts = null; _processed = trainer.processed(); } return null; } }
private void incData(FederationComponent newComp, FederationComponent oldComp) { Map<String, Object> newState = (newComp != null ? newComp.getObjectState() : null); Map<String, Object> oldState; if (oldComp != null && oldComp.getOldState().size() > 0) { oldState = oldComp.getOldState(); } else { oldState = (oldComp != null ? oldComp.getObjectState() : null); } if (newState != null) { for (int index = 0; index < keys.size(); index++) { prevCounters.set(index, currCounters.get(index)); Integer newVal = (Integer) newState.get(keys.get(index)); if (newVal == null) { continue; } Integer oldVal = 0; if (oldState != null) { Object val = oldState.get(keys.get(index)); if (val != null) { oldVal = (Integer) val; } } currCounters.addAndGet(index, newVal - oldVal); } } }
private int doIntRead(final int idx) { // early out for sampler; it called prepareForSample if (samplerThread.get() != null) { return this.intStorage.get(idx); } synchronized (this.intReadPrepLock[idx]) { if (!isIntDirty(idx)) { // no need to prepare if not dirty return this.intStorage.get(idx); } } // this can take a while so release sync prepareThreadStoreList(); synchronized (this.intReadPrepLock[idx]) { if (!clearIntDirty(idx)) { // no need to prepare if not dirty return this.intStorage.get(idx); } int delta = 0; for (ThreadStorage ts : this.threadStoreList) { delta += ts.intStore.getAndSet(idx, 0); } if (delta != 0) { return this.intStorage.addAndGet(idx, delta); } else { return this.intStorage.get(idx); } } }
@Override public void run() { for (int i = start; i < end; i++) { int chunkIndex = sourceChunkStartingIndex[i]; int degree = sourceDegreeData[i]; for (int j = 0; j < degree; j++) { int source = i; int target = relationshipTarget[chunkIndex + j]; int weight = relationshipWeight==null ? 1 : relationshipWeight[chunkIndex + j]; pageRanksAtomic.addAndGet(target, weight * previousPageRanks[source]); } } } });
@Override public void compute(int iterations, RelationshipType... relationshipTypes) { stats.iterations = iterations; long start = System.currentTimeMillis(); final int[] src = new int[nodeCount]; dst = new AtomicIntegerArray(nodeCount); final int[] degrees = computeDegrees(); stats.readNodeMillis = System.currentTimeMillis() - start; stats.nodes = nodeCount; start = System.currentTimeMillis(); int[] relationshipTypesIds = fetchRelationshipTypeIds(relationshipTypes); stats.readRelationshipMillis = System.currentTimeMillis() - start; stats.relationships = relCount; start = System.currentTimeMillis(); for (int iteration = 0; iteration < iterations; iteration++) { startIteration(src, dst, degrees); MultiThreadedGlobalGraphOperations.forAllRelationships(db, pool, BATCH_SIZE, (ktx, relationshipScanCursor) -> { if (relationshipTypes.length == 0 || contains(relationshipTypesIds, relationshipScanCursor.type())) { int endNode = (int) relationshipScanCursor.targetNodeReference(); int startNode = (int) relationshipScanCursor.sourceNodeReference(); dst.addAndGet(endNode, src[startNode]); } }); } stats.computeMillis = System.currentTimeMillis() - start; }
/** * Atomically increments by one the element at index {@code i}. * * @param i the index * @return the updated value */ public final int incrementAndGet(int i) { return addAndGet(i, 1); }
/** * Atomically decrements by one the element at index {@code i}. * * @param i the index * @return the updated value */ public final int decrementAndGet(int i) { return addAndGet(i, -1); }
/** * Atomically increments by one the element at index {@code i}. * * @param i the index * @return the updated value */ public final int incrementAndGet(int i) { return addAndGet(i, 1); }
/** * Atomically increments by one the element at index {@code i}. * * @param i the index * @return the updated value */ public final int incrementAndGet(int i) { return addAndGet(i, 1); }
/** * Atomically increments by one the element at index {@code i}. * * @param i the index * @return the updated value */ public final int incrementAndGet(int i) { return addAndGet(i, 1); }
/** * Atomically decrements by one the element at index {@code i}. * * @param i the index * @return the updated value */ public final int decrementAndGet(int i) { return addAndGet(i, -1); }
/** * Atomically increments by one the element at index {@code i}. * * @param i the index * @return the updated value */ public final int incrementAndGet(int i) { return addAndGet(i, 1); }
/** * Atomically decrements by one the element at index {@code i}. * * @param i the index * @return the updated value */ public final int decrementAndGet(int i) { return addAndGet(i, -1); }
/** * Atomically decrements by one the element at index {@code i}. * * @param i the index * @return the updated value */ public final int decrementAndGet(int i) { return addAndGet(i, -1); }
/** * Atomically decrements by one the element at index {@code i}. * * @param i the index * @return the updated value */ public final int decrementAndGet(int i) { return addAndGet(i, -1); }
/** * Atomically increments by one the element at index {@code i}. * * @param i the index * @return the updated value */ public final int incrementAndGet(int i) { return addAndGet(i, 1); }
private final AtomicIntegerArray ints = new AtomicIntegerArray(KNOWN_SIZE); [...] int len = ints.length(); for (int i=0; i<len; ++i) { ints.addAndGet(i, value); } }
public void add(long index, int delta) { assert index < capacity(); final int pageIndex = pageIndex(index); final int indexInPage = indexInPage(index); pages[pageIndex].addAndGet(indexInPage, delta); }