Adds or removes a block from the to-be-removed blocks set of the worker.

@param add true if to add, to remove otherwise
@param blockId the id of the block to be added or removed
337277
public void updateToRemovedBlock(boolean add, long blockId) {
    if (add) {
      if (mBlocks.contains(blockId)) {
        mToRemoveBlocks.add(blockId);
      }
    } else {
      mToRemoveBlocks.remove(blockId);
    }
  }
1099207
@Override
  public void commitBlock(long workerId, long usedBytesOnTier, String tierAlias, long blockId,
      long length) throws NotFoundException, UnavailableException {
    LOG.debug("Commit block from workerId: {}, usedBytesOnTier: {}, blockId: {}, length: {}",
        workerId, usedBytesOnTier, blockId, length);

    MasterWorkerInfo worker = mWorkers.getFirstByField(ID_INDEX, workerId);
    // TODO(peis): Check lost workers as well.
    if (worker == null) {
      throw new NotFoundException(ExceptionMessage.NO_WORKER_FOUND.getMessage(workerId));
    }

    // Lock the worker metadata first.
    try (JournalContext journalContext = createJournalContext()) {
      synchronized (worker) {
        try (LockResource lr = lockBlock(blockId)) {
          Optional<BlockMeta> block = mBlockStore.getBlock(blockId);
          if (!block.isPresent() || block.get().getLength() != length) {
            if (block.isPresent() && block.get().getLength() != Constants.UNKNOWN_SIZE) {
              LOG.warn("Rejecting attempt to change block length from {} to {}",
                  block.get().getLength(), length);
            } else {
              mBlockStore.putBlock(blockId, BlockMeta.newBuilder().setLength(length).build());
              BlockInfoEntry blockInfo =
                  BlockInfoEntry.newBuilder().setBlockId(blockId).setLength(length).build();
              journalContext.append(JournalEntry.newBuilder().setBlockInfo(blockInfo).build());
            }
          }

          // Update the block metadata with the new worker location.
          mBlockStore.addLocation(blockId, BlockLocation.newBuilder()
              .setWorkerId(workerId)
              .setTier(tierAlias)
              .build());
          // This worker has this block, so it is no longer lost.
          mLostBlocks.remove(blockId);

          // Update the worker information for this new block.
          // TODO(binfan): when retry commitBlock on master is expected, make sure metrics are not
          // double counted.
          worker.addBlock(blockId);
          worker.updateUsedBytes(tierAlias, usedBytesOnTier);
          worker.updateLastUpdatedTimeMs();
        }
      }
    }
  }
516991
def add(self, *blocks, indentation=0) -> "CodeBlock":
        
        for block in blocks:
            if block is not None:
                self._blocks.append((indentation, block))

        return self
419129
DatanodeBlockInfo add(int namespaceId, Block block,
      DatanodeBlockInfo replicaInfo) {
    checkBlock(block);
    NamespaceMap nm = getNamespaceMap(namespaceId);
    if (nm == null) {
      return null;
    }
    replicaInfo.setBlock(block);
    if (datasetDelta != null) {
      datasetDelta.addBlock(namespaceId, block);
    }
    return nm.addBlockInfo(block, replicaInfo);
  }
1052896
function (blockname) {
            this._stack.push(this._curblock);
            this._curblock = this._blocks[blockname];
            if (this.indentUnit && this._curblock) {
                this._updateIndent();
            }
        }
547026
final void freeBlock(long blockId) throws IOException {
        if (blockId == 0) {
            // Can't free block 0.
        }
        else {
            try {
                mFreeBlocksBitlist.lock().acquireWriteLock();
                mFreeBlocksBitlist.set(blockId);
                if (mFirstFreeBlock == 0 || blockId < mFirstFreeBlock) {
                    setFirstFreeBlock(blockId);
                }
            }
            catch (InterruptedException e) {
                throw new InterruptedIOException();
            }
            finally {
                mFreeBlocksBitlist.lock().releaseLock();
            }
        }
    }
828373
public boolean hasComponent(int blockId) {
        for (int i = 0; i < length; i++) {
            if (blockIdList[i] == blockId) {
                return true;
            }
        }
        return false;
    }
769541
void loadBlock(BlockId blockId, ByteBuffer block) throws IOException {
        synchronized (m_accessLock) {
            if (! m_blockPathMap.containsKey(blockId)) {
                throw new IllegalArgumentException("Request to load block that is not stored: " + blockId);
            }

            int origPosition = block.position();
            block.position(0);
            Path blockPath = m_blockPathMap.get(blockId);
            try (SeekableByteChannel channel = Files.newByteChannel(blockPath)) {
                channel.read(block);
            }
            finally {
                block.position(origPosition);
            }
        }
    }
579673
void removeFromInvalidates(String storageID) {
    LightWeightHashSet<Block> blocks = recentInvalidateSets.remove(storageID);
    if (blocks != null) {
      pendingDeletionBlocksCount -= blocks.size();
    }
  }
1363995
def add_comes_from(self, basic_block):
        
        if basic_block is None:
            return

        if self.lock:
            return

        # Return if already added
        if basic_block in self.comes_from:
            return

        self.lock = True
        self.comes_from.add(basic_block)
        basic_block.add_goes_to(self)
        self.lock = False
247852
public void add(StorageDirView dir, long blockId, long blockSizeBytes) {
    Pair<List<Long>, Long> candidate;
    if (mDirCandidates.containsKey(dir)) {
      candidate = mDirCandidates.get(dir);
    } else {
      candidate = new Pair<List<Long>, Long>(new ArrayList<Long>(), 0L);
      mDirCandidates.put(dir, candidate);
    }

    candidate.getFirst().add(blockId);
    long blockBytes = candidate.getSecond() + blockSizeBytes;
    candidate.setSecond(blockBytes);

    long sum = blockBytes + dir.getAvailableBytes();
    if (mMaxBytes < sum) {
      mMaxBytes = sum;
      mDirWithMaxBytes = dir;
    }
  }
1277135
@Override
	public boolean add(E e) {
		if (capacity <= linkedBlockingQueue.size())
			linkedBlockingQueue.remove();
		return linkedBlockingQueue.add(e);
	}
506305
void addToInvalidates(Block b, DatanodeInfo n, boolean ackRequired) {
    addToInvalidatesNoLog(b, n, ackRequired);
    if (isInitialized && !isInSafeModeInternal()) {
      // do not log in startup phase
      NameNode.stateChangeLog.info("BLOCK* NameSystem.addToInvalidates: "
        + b.getBlockName() + " is added to invalidSet of " + n.getName());
    }
  }
417582
public void addBlocksToDelete(List<Long> blocks) {
    for (long id : blocks) {
      if (mRemovingBlocks.contains(id)) {
        LOG.debug("{} is being removed. Current queue size is {}.", id, mBlocksToRemove.size());
        continue;
      }
      try {
        mBlocksToRemove.put(id);
        mRemovingBlocks.add(id);
      } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        LOG.warn("AsyncBlockRemover got interrupted while it was putting block {}.", id);
      }
    }
  }
893030
public void setId(String id) {
        logger.entering(id);
        this.id = id;
        logger.exiting();
    }
1371665
public function addBlock($blockId, ModelInterface $block)
    {
        $this->blockPool->add($blockId, $block);
        return $this;
    }
382459
private static void multBlockAdd( double []blockA, double []blockB, double []blockC,
                                     final int m, final int n, final int o,
                                     final int blockLength ) {
//        for( int i = 0; i < m; i++ ) {
//            for( int j = 0; j < o; j++ ) {
//                double val = 0;
//                for( int k = 0; k < n; k++ ) {
//                    val += blockA[ i*blockLength + k]*blockB[ k*blockLength + j];
//                }
//
//                blockC[ i*blockLength + j] += val;
//            }
//        }

//        int rowA = 0;
//        for( int i = 0; i < m; i++ , rowA += blockLength) {
//            for( int j = 0; j < o; j++ ) {
//                double val = 0;
//                int indexB = j;
//                int indexA = rowA;
//                int end = indexA + n;
//                for( ; indexA != end; indexA++ , indexB += blockLength ) {
//                    val += blockA[ indexA ]*blockB[ indexB ];
//                }
//
//                blockC[ rowA + j] += val;
//            }
//        }

//        for( int k = 0; k < n; k++ ) {
//            for( int i = 0; i < m; i++ ) {
//                for( int j = 0; j < o; j++ ) {
//                    blockC[ i*blockLength + j] += blockA[ i*blockLength + k]*blockB[ k*blockLength + j];
//                }
//            }
//        }

        for( int k = 0; k < n; k++ ) {
            int rowB = k*blockLength;
            int endB = rowB+o;
            for( int i = 0; i < m; i++ ) {
                int indexC = i*blockLength;
                double valA = blockA[ indexC + k];
                int indexB = rowB;
                
                while( indexB != endB ) {
                    blockC[ indexC++ ] += valA*blockB[ indexB++];
                }
            }
        }
    }