Get the minimum and maximum block offset for the specified
        namespace
175935
def block_offset_bounds(self, namespace):
        """"""
        cursor = self.cursor
        cursor.execute('SELECT MIN("offset"), MAX("offset") '
                       'FROM gauged_statistics WHERE namespace = %s',
                       (namespace,))
        return cursor.fetchone()
1246408
def get_overlay_data_start_offset(self):
        """"""

        highest_PointerToRawData = 0
        highest_SizeOfRawData = 0
        for section in self.sections:
            
            # If a section seems to fall outside the boundaries of the file we assume it's either
            # because of intentionally misleading values or because the file is truncated
            # In either case we skip it
            if section.PointerToRawData + section.SizeOfRawData > len(self.__data__):
                continue
                
            if section.PointerToRawData + section.SizeOfRawData > highest_PointerToRawData + highest_SizeOfRawData:
                highest_PointerToRawData = section.PointerToRawData
                highest_SizeOfRawData = section.SizeOfRawData
                
        if len(self.__data__) > highest_PointerToRawData + highest_SizeOfRawData:
            return highest_PointerToRawData + highest_SizeOfRawData
            
        return None
59310
public LocatedBlocks getBlockLocations(String src, INode inode, long offset, long length,
                                         boolean doAccessTime, BlockMetaInfoType type)
    throws IOException {
    if (offset < 0) {
      throw new IOException("Negative offset is not supported. File: " + src);
    }
    if (length < 0) {
      throw new IOException("Negative length is not supported. File: " + src);
    }
    final LocatedBlocks ret = getBlockLocationsInternal(src, inode,
      offset, length, Integer.MAX_VALUE, doAccessTime, type);
    if (auditLog.isInfoEnabled()) {
      logAuditEvent(getCurrentUGI(),
        Server.getRemoteIp(),
        "open", src, null, null);
    }
    return ret;
  }
132206
public static long getPosFromBlockOffset(long offsetInBlock, int bytesPerChecksum,
      int checksumSize) {
    // We only support to read full chunks, so offsetInBlock must be the boundary
    // of the chunks.
    assert offsetInBlock % bytesPerChecksum == 0;
    // The position in the file will be the same as the file size for the block
    // size.
    return getFileLengthFromBlockSize(offsetInBlock, bytesPerChecksum, checksumSize);
  }
1000148
public long getFinalizedBlockLength(int namespaceId, Block b) throws IOException {
    DatanodeBlockInfo info = volumeMap.get(namespaceId, b);
    if (info == null) {
      throw new IOException("Can't find block " + b + " in volumeMap");
    }
    return info.getFinalizedSize();
  }
1256823
def _get_offset(cmd):
    """"""
    dict_offset = cmd.dictionary_page_offset
    data_offset = cmd.data_page_offset
    if dict_offset is None or data_offset < dict_offset:
        return data_offset
    return dict_offset
558894
def get_data_range(self, name):
        """"""
        mini, maxi = np.inf, -np.inf
        for i in range(self.n_blocks):
            data = self[i]
            if data is None:
                continue
            # get the scalar if availble
            arr = get_scalar(data, name)
            if arr is None:
                continue
            tmi, tma = np.nanmin(arr), np.nanmax(arr)
            if tmi < mini:
                mini = tmi
            if tma > maxi:
                maxi = tma
        return mini, maxi
102960
function findTokenIndex(tokens, offset) {
  var min = 0;
  var max = tokens.length - 1;

  while (min <= max) {
    var ptr = ((min + max) / 2) | 0;
    var token = tokens[ptr];
    if (endOf(token) <= offset) {
      min = ptr + 1;
    } else if (startOf(token) > offset) {
      max = ptr - 1;
    } else {
      return ptr;
    }
  }

  return ptr;
}
107925
public static int estimateCompressedSize(int[] inputBlock, int bits,
                int blockSize)  {
                int maxNoExp = (1 << bits) - 1;
                // Size of the header and the bits-bit slots
                int outputOffset = HEADER_SIZE + bits * blockSize;
                int expNum = 0;

                for (int i = 0; i < blockSize; ++i) {
                        if (inputBlock[i] > maxNoExp) {
                                expNum++;
                        }
                }
                outputOffset += (expNum << 5);

                return outputOffset;
        }
1335050
def next_offsets(self):
        # type: (Descriptor) -> Offsets
        
        resume_bytes = self._resume()
        with self._meta_lock:
            if self._chunk_num >= self._total_chunks:
                return None, resume_bytes
            if self._chunk_size == -1 and self._src_block_list is not None:
                num_bytes = self._src_block_list[self._chunk_num].size
            else:
                if self._offset + self._chunk_size > self._src_ase.size:
                    num_bytes = self._src_ase.size - self._offset
                else:
                    num_bytes = self._chunk_size
            chunk_num = self._chunk_num
            range_start = self._offset
            range_end = self._offset + num_bytes - 1
            self._offset += num_bytes
            self._chunk_num += 1
            return Offsets(
                chunk_num=chunk_num,
                num_bytes=num_bytes,
                range_start=range_start,
                range_end=range_end,
            ), resume_bytes
620515
def _get_offset(self):
        
        sx, sxy, syx, sy, ox, oy = self.transformation
        return (ox, oy)
459855
def _offset_from_spaces(dom, ran):
    """"""
    affected = np.not_equal(dom.shape, ran.shape)
    diff_l = np.abs(ran.grid.min() - dom.grid.min())
    offset_float = diff_l / dom.cell_sides
    offset = np.around(offset_float).astype(int)
    for i in range(dom.ndim):
        if affected[i] and not np.isclose(offset[i], offset_float[i]):
            raise ValueError('in axis {}: range is shifted relative to domain '
                             'by a non-multiple {} of cell_sides'
                             ''.format(i, offset_float[i] - offset[i]))
    offset[~affected] = 0
    return tuple(offset)
491659
public void readRiceSignedBlock(int[] vals, int pos, int nvals, int parameter) throws IOException {
        int j, valI = 0;
        int cbits = 0, uval = 0, msbs = 0, lsbsLeft = 0;
        byte blurb, saveBlurb;
        int state = 0; // 0 = getting unary MSBs, 1 = getting binary LSBs
        if (nvals == 0) return;
        int i = getByte;
        
        long startBits = getByte * 8 + getBit;
        
        // We unroll the main loop to take care of partially consumed blurbs here.
        if (getBit > 0) {
            saveBlurb = blurb = buffer[i];
            cbits = getBit;
            blurb <<= cbits;
            while (true) {
                if (state == 0) {
                    if (blurb != 0) {
                        for (j = 0; (blurb & BLURB_TOP_BIT_ONE) == 0; j++)
                            blurb <<= 1;
                        msbs += j;
                        
                        // dispose of the unary end bit
                        blurb <<= 1;
                        j++;
                        cbits += j;
                        uval = 0;
                        lsbsLeft = parameter;
                        state++;
                        //totalBitsRead += msbs;
                        if (cbits == BITS_PER_BLURB) {
                            cbits = 0;
                            readCRC16 = CRC16.update(saveBlurb, readCRC16);
                            break;
                        }
                    } else {
                        msbs += BITS_PER_BLURB - cbits;
                        cbits = 0;
                        readCRC16 = CRC16.update(saveBlurb, readCRC16);
                        //totalBitsRead += msbs;
                        break;
                    }
                } else {
                    int availableBits = BITS_PER_BLURB - cbits;
                    if (lsbsLeft >= availableBits) {
                        uval <<= availableBits;
                        uval |= ((blurb & 0xff) >> cbits);
                        cbits = 0;
                        readCRC16 = CRC16.update(saveBlurb, readCRC16);
                        //totalBitsRead += availableBits;
                        if (lsbsLeft == availableBits) {
                            // compose the value
                            uval |= (msbs << parameter);
                            if ((uval & 1) != 0)
                                vals[pos + valI++] = -((int) (uval >> 1)) - 1;
                            else
                                vals[pos + valI++] = (int) (uval >> 1);
                            if (valI == nvals)
                                break;
                            msbs = 0;
                            state = 0;
                        }
                        lsbsLeft -= availableBits;
                        break;
                    } else {
                        uval <<= lsbsLeft;
                        uval |= ((blurb & 0xff) >> (BITS_PER_BLURB - lsbsLeft));
                        blurb <<= lsbsLeft;
                        cbits += lsbsLeft;
                        //totalBitsRead += lsbsLeft;
                        // compose the value
                        uval |= (msbs << parameter);
                        if ((uval & 1) != 0)
                            vals[pos + valI++] = -((int) (uval >> 1)) - 1;
                        else
                            vals[pos + valI++] = (int) (uval >> 1);
                        if (valI == nvals) {
                            // back up one if we exited the for loop because we
                            // read all nvals but the end came in the middle of
                            // a blurb
                            i--;
                            break;
                        }
                        msbs = 0;
                        state = 0;
                    }
                }
            }
            i++;
            getByte = i;
            getBit = cbits;
            //totalConsumedBits = (i << BITS_PER_BLURB_LOG2) | cbits;
            //totalBitsRead += (BITS_PER_BLURB) | cbits;
        }
        
        // Now that we are blurb-aligned the logic is slightly simpler
        while (valI < nvals) {
            for (; i < putByte && valI < nvals; i++) {
                saveBlurb = blurb = buffer[i];
                cbits = 0;
                while (true) {
                    if (state == 0) {
                        if (blurb != 0) {
                            for (j = 0; (blurb & BLURB_TOP_BIT_ONE) == 0; j++) blurb <<= 1;
                            msbs += j;
                            // dispose of the unary end bit
                            blurb <<= 1;
                            j++;
                            cbits += j;
                            uval = 0;
                            lsbsLeft = parameter;
                            state++;
                            //totalBitsRead += msbs;
                            if (cbits == BITS_PER_BLURB) {
                                cbits = 0;
                                readCRC16 = CRC16.update(saveBlurb, readCRC16);
                                break;
                            }
                        } else {
                            msbs += BITS_PER_BLURB - cbits;
                            cbits = 0;
                            readCRC16 = CRC16.update(saveBlurb, readCRC16);
                            //totalBitsRead += msbs;
                            break;
                        }
                    } else {
                        int availableBits = BITS_PER_BLURB - cbits;
                        if (lsbsLeft >= availableBits) {
                            uval <<= availableBits;
                            uval |= ((blurb & 0xff) >> cbits);
                            cbits = 0;
                            readCRC16 = CRC16.update(saveBlurb, readCRC16);
                            //totalBitsRead += availableBits;
                            if (lsbsLeft == availableBits) {
                                // compose the value
                                uval |= (msbs << parameter);
                                if ((uval & 1) != 0)
                                    vals[pos + valI++] = -((int) (uval >> 1)) - 1;
                                else
                                    vals[pos + valI++] = (int) (uval >> 1);
                                if (valI == nvals)
                                    break;
                                msbs = 0;
                                state = 0;
                            }
                            lsbsLeft -= availableBits;
                            break;
                        } else {
                            uval <<= lsbsLeft;
                            uval |= ((blurb & 0xff) >> (BITS_PER_BLURB - lsbsLeft));
                            blurb <<= lsbsLeft;
                            cbits += lsbsLeft;
                            //totalBitsRead += lsbsLeft;
                            // compose the value
                            uval |= (msbs << parameter);
                            if ((uval & 1) != 0)
                                vals[pos + valI++] = -((int) (uval >> 1)) - 1;
                            else
                                vals[pos + valI++] = (int) (uval >> 1);
                            if (valI == nvals) {
                                // back up one if we exited the for loop because
                                // we read all nvals but the end came in the
                                // middle of a blurb
                                i--;
                                break;
                            }
                            msbs = 0;
                            state = 0;
                        }
                    }
                }
            }
            getByte = i;
            getBit = cbits;
            //totalConsumedBits = (i << BITS_PER_BLURB_LOG2) | cbits;
            //totalBitsRead += (BITS_PER_BLURB) | cbits;
            if (valI < nvals) {
                long endBits = getByte * 8 + getBit;
                //System.out.println("SE0 "+startBits+" "+endBits);
                totalBitsRead += endBits - startBits;
                availBits -=  endBits - startBits;
                readFromStream();
                // these must be zero because we can only get here if we got to
                // the end of the buffer
                i = 0;
                startBits = getByte * 8 + getBit;
            }
        }
        
        long endBits = getByte * 8 + getBit;
        //System.out.println("SE1 "+startBits+" "+endBits);
        totalBitsRead += endBits - startBits;
        availBits -= endBits - startBits;
    }
540046
def value_offset(prop)
      src_range = prop.name_source_range
      src_range.start_pos.offset +
        (src_range.end_pos.offset - src_range.start_pos.offset) +
        whitespace_after_colon(prop).take_while { |w| w == ' ' }.size
    end
248941
def rpc_get_names_in_namespace( self, namespace_id, offset, count, **con_info ):
        
        if not check_namespace(namespace_id):
            return {'error': 'Invalid name or namespace', 'http_status': 400}

        if not check_offset(offset):
            return {'error': 'invalid offset', 'http_status': 400}

        if not check_count(count, 100):
            return {'error': 'invalid count', 'http_status': 400}

        if not is_namespace_valid( namespace_id ):
            return {'error': 'invalid namespace ID', 'http_status': 400}

        db = get_db_state(self.working_dir)
        res = db.get_names_in_namespace( namespace_id, offset=offset, count=count )
        db.close()

        return self.success_response( {'names': res} )
935867
function findTokenIndex(tokens, offset) {
  var min = 0;
  var max = tokens.length - 1;

  while (min <= max) {
    var ptr = (min + max) / 2 | 0;
    var token = tokens[ptr];
    if (token.end <= offset) {
      min = ptr + 1;
    } else if (token.start > offset) {
      max = ptr - 1;
    } else {
      return ptr;
    }
  }

  return ptr;
}
1153127
def bb_get_instr_max_width(basic_block):
    
    asm_mnemonic_max_width = 0

    for instr in basic_block:
        if len(instr.mnemonic) > asm_mnemonic_max_width:
            asm_mnemonic_max_width = len(instr.mnemonic)

    return asm_mnemonic_max_width