Get block locations within the specified range.

@see #getBlockLocations(String, long, long)
197370
LocatedBlocks getBlockLocations(String clientMachine, String src,
                                  long offset, long length,
                                  BlockMetaInfoType type) throws IOException {
    INode[] inodes = dir.getExistingPathINodes(src);
    if (isPermissionEnabled && 
        isPermissionCheckingEnabled(inodes)) {
      checkPathAccess(src, inodes, FsAction.READ);
    }

    LocatedBlocks blocks = getBlockLocations(src, inodes[inodes.length-1],
        offset, length, false, type);
    if (blocks != null) {
      //sort the blocks
      DatanodeDescriptor client = host2DataNodeMap.getDatanodeByHost(
        clientMachine);
      for (LocatedBlock b : blocks.getLocatedBlocks()) {
        clusterMap.pseudoSortByDistance(client, b.getLocations());
        // Move decommissioned datanodes to the bottom
        Arrays.sort(b.getLocations(), DFSUtil.DECOM_COMPARATOR);
      }
    }
    return blocks;
  }
17825
public Block getBlock(String sqlquery, Collection queryParams, int startIndex, int count) {
		Debug.logVerbose("[JdonFramework]enter getBlock .. ", module);
		if ((count > this.blockLength) || (count <= 0)) { // every query max
			// length must be
			// little than
			// blockLength
			count = this.blockLength;
		}
		QueryConditonDatakey qcdk = new QueryConditonDatakey(sqlquery, queryParams, startIndex, count, this.blockLength);
		Block block = getBlock(qcdk);
		if (block.getCount() > 0) {
			Debug.logVerbose("[JdonFramework]got a Block" + block.getCount(), module);
			return block;
		} else {
			Debug.logVerbose("[JdonFramework]not found the block!", module);
			return null;
		}
	}
1176875
@Override
  public BlockLocationsResponse getBlockLocations(GetBlockLocationsRequest req) throws IOException {
    Server.setOrignalCaller(req.getOriginalCaller());
    return new BlockLocationsResponse(getBlockLocationsInternal(req.getSrc(), req.getOffset(),
        req.getLength(), BlockMetaInfoType.NONE));
  }
747202
public Collection<BasicBlock> getBlocksContainingInstructionWithOffset(int offset) {
        LinkedList<BasicBlock> result = new LinkedList<>();
        for (Iterator<BasicBlock> i = blockIterator(); i.hasNext();) {
            BasicBlock block = i.next();
            if (block.containsInstructionWithOffset(offset)) {
                result.add(block);
            }
        }
        return result;
    }
30587
function ( range, root ) {
    var container = range.startContainer,
        block;

    // If inline, get the containing block.
    if ( isInline( container ) ) {
      block = getPreviousBlock( container, root );
    } else if ( container !== root && isBlock( container ) ) {
      block = container;
    } else {
      block = getNodeBefore( container, range.startOffset );
      block = getNextBlock( block, root );
    }
    // Check the block actually intersects the range
    return block && isNodeContainedInRange( range, block, true ) ? block : null;
  }
1347773
function getRangeTextNodes(range) {
  var container = range.commonAncestorContainer
    , nodes = getTextNodes(container.parentNode || container)

  return nodes.filter(function (node) {
    return rangeIntersectsNode(range, node) && isNonEmptyTextNode(node)
  })
}
1091928
private long getHashPositionOfElement(Block block, int position)
    {
        checkArgument(!block.isNull(position), "position is null");
        int length = block.getSliceLength(position);
        long hashPosition = getMaskedHash(block.hash(position, 0, length));
        while (true) {
            int blockPosition = blockPositionByHash.get(hashPosition);
            if (blockPosition == EMPTY_SLOT) {
                // Doesn't have this element
                return hashPosition;
            }
            else if (elementBlock.getSliceLength(blockPosition) == length && block.equals(position, 0, elementBlock, blockPosition, 0, length)) {
                // Already has this element
                return hashPosition;
            }

            hashPosition = getMaskedHash(hashPosition + 1);
        }
    }
1321482
public static BlockAndLocation[] locatedBlocks2BlockLocations(
     LocatedBlocks blocks) {
   if (blocks == null) {
     return new BlockAndLocation[0];
   }
   int nrBlocks = blocks.locatedBlockCount();
   BlockAndLocation[] blkLocations = new BlockAndLocation[nrBlocks];
   if (nrBlocks == 0) {
     return blkLocations;
   }
   int idx = 0;
   for (LocatedBlock blk : blocks.getLocatedBlocks()) {
     assert idx < nrBlocks : "Incorrect index";
     DatanodeInfo[] locations = blk.getLocations();
     String[] hosts = new String[locations.length];
     String[] names = new String[locations.length];
     String[] racks = new String[locations.length];
     for (int hCnt = 0; hCnt < locations.length; hCnt++) {
       hosts[hCnt] = locations[hCnt].getHostName();
       names[hCnt] = locations[hCnt].getName();
       NodeBase node = new NodeBase(names[hCnt],
                                    locations[hCnt].getNetworkLocation());
       racks[hCnt] = node.toString();
     }
     Block block = blk.getBlock();
     blkLocations[idx] = new BlockAndLocation(block.getBlockId(),
                                           block.getGenerationStamp(),
                                           names, hosts, racks,
                                           blk.getStartOffset(),
                                           block.getNumBytes(),
                                           blk.isCorrupt());
     idx++;
   }
   return blkLocations;
 }
359171
def _map_block_index_to_location(ir_blocks):
    """"""
    block_index_to_location = {}
    # MarkLocation blocks occur after the blocks related to that location.
    # The core approach here is to buffer blocks until their MarkLocation is encountered
    # after which all buffered blocks can be associated with the encountered MarkLocation.location.
    current_block_ixs = []
    for num, ir_block in enumerate(ir_blocks):
        if isinstance(ir_block, blocks.GlobalOperationsStart):
            if len(current_block_ixs) > 0:
                unassociated_blocks = [ir_blocks[ix] for ix in current_block_ixs]
                raise AssertionError(
                    u'Unexpectedly encountered global operations before mapping blocks '
                    u'{} to their respective locations.'.format(unassociated_blocks))
            break
        current_block_ixs.append(num)
        if isinstance(ir_block, blocks.MarkLocation):
            for ix in current_block_ixs:
                block_index_to_location[ix] = ir_block.location
            current_block_ixs = []
    return block_index_to_location
739875
@Override
	public Iterator<Location> iterator() {
		List<Location> list;
		if(isComplex()) {
			list = getSubLocations();
		}
		else {
			list = new ArrayList<Location>();
			list.add(this);
		}
		return list.iterator();
	}
11461
private static long getBlockSize(LocatedBlocks lbs) throws IOException {
    List<LocatedBlock> locatedBlocks = lbs.getLocatedBlocks();
    long bs = -1;
    for (LocatedBlock lb: locatedBlocks) {
      if (lb.getBlockSize() > bs) {
        bs = lb.getBlockSize();
      }
    }
    return bs;
  }
594895
private Long[] checkLocation(Location location) {
		Long[] positions = new Long[2];
		if (location.isComplement()) {
			positions[0] = location.getEndPosition();
			positions[1] = location.getBeginPosition();
		} else {
			positions[0] = location.getBeginPosition();
			positions[1] = location.getEndPosition();
		}
		return positions;
	}
725336
@Nullable
    public AbsoluteRange getHistogramBoundaries() {
        if (boundaries == null) {
            boundaries = Tools.extractHistogramBoundaries(getBuiltQuery()).orElse(null);
        }

        return boundaries;
    }
240104
protected DataPoint[] getAllInRange(long timestampStartMs, long timestampEndMs) {
        SortedSet<DataPoint> result = new TreeSet<DataPoint>(new Comparator<DataPoint>() {
            @Override
            public int compare(DataPoint block1, DataPoint block2) {
                return Longs.compare(block1.timestamp(), block2.timestamp());
            }
        });
        long keyStart = toTimeSeriesPoint(timestampStartMs);
        long keyEnd = toTimeSeriesPoint(timestampEndMs);
        if (keyEnd == timestampStartMs) {
            keyEnd = toTimeSeriesPoint(timestampEndMs - 1);
        }
        for (long timestamp = keyStart, _end = keyEnd; timestamp <= _end; timestamp += RESOLUTION_MS) {
            DataPoint block = get(timestamp);
            result.add(block);
        }
        return result.toArray(DataPoint.EMPTY_ARR);
    }
920501
private int getBlockInfo(String[] argv, int i) throws IOException {
  	long blockId = Long.valueOf(argv[i++]);
  	LocatedBlockWithFileName locatedBlock = 
  			getDFS().getClient().getBlockInfo(blockId);
  
  	if (null == locatedBlock) {
  		System.err.println("Could not find the block with id : " + blockId);
  		return -1;
  	}
  	
  	StringBuilder sb = new StringBuilder();
  	sb.append("block: ")
  				.append(locatedBlock.getBlock()).append("\n")
  				.append("filename: ")
  				.append(locatedBlock.getFileName()).append("\n")
  				.append("locations: ");
  	
  	DatanodeInfo[] locs = locatedBlock.getLocations();
  	for (int k=0; k<locs.length; k++) {
  		if (k > 0) {
  			sb.append(" , ");
  		}
  		sb.append(locs[k].getHostName());
  	}
  				
  	System.out.println(sb.toString());  	
  	return 0;
  }
545705
function getLocation(func) {
  const location = { ...func.location };

  // if the function has an identifier, start the block after it so the
  // identifier is included in the "scope" of its parent
  const identifierEnd = get(func, "identifier.loc.end");
  if (identifierEnd) {
    location.start = identifierEnd;
  }

  return location;
}
270209
def block_ranges(start_block, last_block, step=5):
    

    if last_block is not None and start_block > last_block:
        raise TypeError(
            "Incompatible start and stop arguments.",
            "Start must be less than or equal to stop.")

    return (
        (from_block, to_block - 1)
        for from_block, to_block
        in segment_count(start_block, last_block + 1, step)
    )