Get the in-RAM zonefile inventory vector.
    offset and length are in *bytes*
3187
def atlas_get_zonefile_inventory( offset=None, length=None ):
    
    global ZONEFILE_INV, ZONEFILE_INV_LOCK

    with ZONEFILE_INV_LOCK:
        try:
            assert ZONEFILE_INV is not None
        except AssertionError:
            log.error("FATAL: zonefile inventory not loaded")
            os.abort()

        if offset is None:
            offset = 0

        if length is None:
            length = len(ZONEFILE_INV) - offset

        if offset >= len(ZONEFILE_INV):
            return ""

        if offset + length > len(ZONEFILE_INV):
            length = len(ZONEFILE_INV) - offset
            
        ret = ZONEFILE_INV[offset:offset+length]
        return ret
214136
def get_item_data(self, session, item, byte_range=None):
        

        # Parse byte range
        if byte_range is not None:
            begin, end = parse_byte_range(byte_range, max_byte=item.file_size)
        else:
            begin, end = 0, item.file_size

        # Open the file
        fp = open(item.file_name, "rb+")

        if not begin:
            return fp, item.file_type, item.file_size
        elif begin and not end:
            fp.seek(begin)
            return fp, item.file_type, item.file_size
        elif begin and end:
            fp.seek(begin)

            data = fp.read(end - begin)
            result = cStringIO.StringIO(data)

            return result, item.file_type, item.file_size
837017
def _findbytes(self, bytes_, start, end, bytealigned):
        
        assert self._datastore.offset == 0
        assert bytealigned is True
        # Extract data bytes from bitstring to be found.
        bytepos = (start + 7) // 8
        found = False
        p = bytepos
        finalpos = end // 8
        increment = max(1024, len(bytes_) * 10)
        buffersize = increment + len(bytes_)
        while p < finalpos:
            # Read in file or from memory in overlapping chunks and search the chunks.
            buf = bytearray(self._datastore.getbyteslice(p, min(p + buffersize, finalpos)))
            pos = buf.find(bytes_)
            if pos != -1:
                found = True
                p += pos
                break
            p += increment
        if not found:
            return ()
        return (p * 8,)
974602
def GetMemMappedMB(self):
        ''''''
        counter = c_uint()
        ret = vmGuestLib.VMGuestLib_GetMemMappedMB(self.handle.value, byref(counter))
        if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
        return counter.value
474977
def read(self, path, filename=None, offset=None, size=-1):
        
        storageScheme, key = self.getkey(path, filename=filename)

        if offset or (size > -1):
            if not offset:
                offset = 0
            if size > -1:
                sizeStr = offset + size - 1  # range header is inclusive
            else:
                sizeStr = ""
            headers = {"Range": "bytes=%d-%s" % (offset, sizeStr)}
            return key.get_contents_as_string(headers=headers)
        else:
            return key.get_contents_as_string()
147223
public static byte getByte(MemorySegment[] segments, int offset) {
		if (inFirstSegment(segments, offset, 1)) {
			return segments[0].get(offset);
		} else {
			return getByteMultiSegments(segments, offset);
		}
	}
1112223
def get_shared_memory_bytes():
    
    # Make sure this is only called on Linux.
    assert sys.platform == "linux" or sys.platform == "linux2"

    shm_fd = os.open("/dev/shm", os.O_RDONLY)
    try:
        shm_fs_stats = os.fstatvfs(shm_fd)
        # The value shm_fs_stats.f_bsize is the block size and the
        # value shm_fs_stats.f_bavail is the number of available
        # blocks.
        shm_avail = shm_fs_stats.f_bsize * shm_fs_stats.f_bavail
    finally:
        os.close(shm_fd)

    return shm_avail
969387
def read_memory_block32(self, addr, size):
        
        data = self.ap.read_memory_block32(addr, size)
        return self.bp_manager.filter_memory_aligned_32(addr, size, data)
45666
private byte[] getDiskBytes(long offset)
      throws IOException {
    mappedFile.seek(dataOffset + offset);

    //Get size of data
    int size = LongPacker.unpackInt(mappedFile);

    //Create output bytes
    byte[] res = new byte[size];

    //Read data
    if (mappedFile.read(res) == -1) {
      throw new EOFException();
    }

    return res;
  }
618468
def _gather_buffer_space():
    '''
    
    '''
    if HAS_PSUTIL and psutil.version_info >= (0, 6, 0):
        # Oh good, we have psutil. This will be quick.
        total_mem = psutil.virtual_memory().total
    else:
        # Avoid loading core grains unless absolutely required
        import platform
        import salt.grains.core
        # We need to load up ``mem_total`` grain. Let's mimic required OS data.
        os_data = {'kernel': platform.system()}
        grains = salt.grains.core._memdata(os_data)
        total_mem = grains['mem_total'] * 1024 * 1024
    # Return the higher number between 5% of the system memory and 10MiB
    return max([total_mem * 0.05, 10 << 20])
1201899
def atlasdb_zonefile_inv_list( bit_offset, bit_length, con=None, path=None ):
    
    with AtlasDBOpen(con=con, path=path) as dbcon:

        sql = "SELECT * FROM zonefiles LIMIT ? OFFSET ?;"
        args = (bit_length, bit_offset)

        cur = dbcon.cursor()
        res = atlasdb_query_execute( cur, sql, args )

        ret = []
        for row in res:
            tmp = {}
            tmp.update(row)
            ret.append(tmp)

    return ret
19397
def _read_vvr_block(self, offset):
        '''
        
        '''
        with self.file.open('rb') as f:
            f.seek(offset, 0)
            block_size = int.from_bytes(f.read(8), 'big')
            block = f.read(block_size-8)

        section_type = int.from_bytes(block[0:4], 'big')
        if section_type == 13:
            # a CVVR
            compressed_size = int.from_bytes(block[12:16], 'big')
            return gzip.decompress(block[16:16+compressed_size])
        elif section_type == 7:
            # a VVR
            return block[4:]
984693
private ByteBuffer getDataBuffer(long index) {
    ByteBuffer buf = dataBuffers[(int) (index / segmentSize)];
    buf.position((int) (index % segmentSize));
    return buf;
  }
878296
private static int get(byte[] block, int offset, byte[] b, int off, int len) {
    System.arraycopy(block, offset, b, off, len);
    return len;
  }
210547
def get_thread_block_dimensions(params, block_size_names=None):
    """"""
    if not block_size_names:
        block_size_names = default_block_size_names

    block_size_x = params.get(block_size_names[0], 256)
    block_size_y = params.get(block_size_names[1], 1)
    block_size_z = params.get(block_size_names[2], 1)
    return (int(block_size_x), int(block_size_y), int(block_size_z))
250873
def GetMemSharedSavedMB(self):
        ''''''
        counter = c_uint()
        ret = vmGuestLib.VMGuestLib_GetMemSharedSavedMB(self.handle.value, byref(counter))
        if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
        return counter.value
154165
def GetMemUsedMB(self):
        ''''''
        counter = c_uint()
        ret = vmGuestLib.VMGuestLib_GetMemUsedMB(self.handle.value, byref(counter))
        if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
        return counter.value