/*
Read header of archive, cache Ranges.
497044
private void readHeader() throws IOException {
		final RandomAccessFile baseFile = mFiles.get(0);

		// Get file sizes
		for (final RandomAccessFile file : mFiles) {
			mFileSizes.add(file.length());
		}

		// Version
		final int version = baseFile.readInt();
		if (version != VERSION) {
			throw new IOException("Bad file version: " + version);
		}

		// Tile Size
		final int tile_size = baseFile.readInt();
		if (tile_size != TILE_SIZE) {
			throw new IOException("Bad tile size: " + tile_size);
		}

		// Read Source List
		final int sourceCount = baseFile.readInt();

		for (int i=0;i<sourceCount;i++) {
			final int sourceIndex = baseFile.readInt();
			final int sourceNameLength = baseFile.readInt();
			final byte[] nameData = new byte[sourceNameLength];
			baseFile.read(nameData, 0, sourceNameLength);

			final String sourceName = new String(nameData);
			mSources.put(new Integer(sourceIndex), sourceName);
		}

		// Read Ranges
		final int num_ranges = baseFile.readInt();
		for (int i=0;i<num_ranges;i++) {
			final GEMFRange rs = new GEMFRange();
			rs.zoom = baseFile.readInt();
			rs.xMin = baseFile.readInt();
			rs.xMax = baseFile.readInt();
			rs.yMin = baseFile.readInt();
			rs.yMax = baseFile.readInt();
			rs.sourceIndex = baseFile.readInt();
			rs.offset = baseFile.readLong();
			mRangeData.add(rs);
		}
	}
1227612
def readpartial(self, start, end):
        ''
        #return self.jfs.raw('%s?mode=bin' % self.path,
        return self.jfs.raw(url=self.path, params={'mode':'bin'},
                            # note that we deduct 1 from end because
                            # in http Range requests, the end value is included in the slice,
                            # whereas in python, it is not
                            extra_headers={'Range':'bytes=%s-%s' % (start, end-1)})
933333
def read_mm_header(fd, byte_order, dtype, count):
    """"""
    return numpy.rec.fromfile(fd, MM_HEADER, 1, byteorder=byte_order)[0]
367583
def parse_range_header(range):
    '''
    
    '''
    match = re.match('^items=([0-9]+)-([0-9]+)$', range)
    if match:
        start = int(match.group(1))
        finish = int(match.group(2))
        if finish < start:
            finish = start
        return {
            'start': start,
            'finish': finish,
            'number': finish - start + 1
        }
    else:
        return False
44161
def _read_header(self):
        '''
        
        '''
        self._fh.seek(0)
        buf = self._fh.read(4*2)
        fc, dc = struct.unpack("<II", buf)
        return fc, dc
1018443
def _GetChunkForReading(self, chunk):
    """"""
    offset = chunk * self._HASH_SIZE
    self.index.seek(offset)

    chunk_name = self.index.read(self._HASH_SIZE)

    try:
      return self.chunk_cache.Get(chunk_name)
    except KeyError:
      pass

    # We don't have this chunk already cached. The most common read
    # access pattern is contiguous reading so since we have to go to
    # the data store already, we read ahead to reduce round trips.
    self.index.seek(offset)
    readahead = []

    for _ in range(self._READAHEAD):
      name = self.index.read(self._HASH_SIZE)
      if name and name not in self.chunk_cache:
        readahead.append(rdf_objects.BlobID.FromBytes(name))

    self._ReadChunks(readahead)
    try:
      return self.chunk_cache.Get(chunk_name)
    except KeyError:
      raise aff4.ChunkNotFoundError("Cannot open chunk %s" % chunk)
84982
def read_mm_header(fh, byteorder, dtype, count, offsetsize):
    """"""
    mmh = fh.read_record(TIFF.MM_HEADER, byteorder=byteorder)
    mmh = recarray2dict(mmh)
    mmh['Dimensions'] = [
        (bytes2str(d[0]).strip(), d[1], d[2], d[3], bytes2str(d[4]).strip())
        for d in mmh['Dimensions']]
    d = mmh['GrayChannel']
    mmh['GrayChannel'] = (
        bytes2str(d[0]).strip(), d[1], d[2], d[3], bytes2str(d[4]).strip())
    return mmh
331600
def cached_read(self, kind):
        """"""
        if not kind in self.cache:
            self.pull_stats(kind)
        if self.epochnow() - self.cache[kind]['lastcall'] > self.cache_timeout:
            self.pull_stats(kind)
        return self.cache[kind]['lastvalue']
789106
def read_archive(self,header,prepend=None):
        
        # Start by looking for the any backup WCS keywords to
        # determine whether archived values are present and to set
        # the prefix used.
        _prefix = None
        _archive = False
        if header is not None:
            for kw in header.items():
                if kw[0][1:] in self.wcstrans.keys():
                    _prefix = kw[0][0]
                    _archive = True
                    break

        if not _archive:
            self.archive(prepend=prepend)
            return

        # We have archive keywords and a defined prefix
        # Go through and append them to self.backup
        if _prefix is not None:
            self.prepend = _prefix
        else:
            self.prepend = DEFAULT_PREFIX

        for key in self.wcstrans.keys():
            _archive_key = self._buildNewKeyname(key,_prefix)
            if key!= 'pixel scale':
                if _archive_key in header:
                    self.orig_wcs[_archive_key] = header[_archive_key]
                else:
                    self.orig_wcs[_archive_key] = header[key]
                self.backup[key] = _archive_key
                self.revert[_archive_key] = key

        # Establish plate scale value
        _cd11str = self.prepend+'CD1_1'
        _cd21str = self.prepend+'CD2_1'
        pscale = self.compute_pscale(self.orig_wcs[_cd11str],self.orig_wcs[_cd21str])
        _archive_key = self.prepend.lower()+'pscale'
        self.orig_wcs[_archive_key] = pscale
        self.backup['pixel scale'] = _archive_key
        self.revert[_archive_key] = 'pixel scale'

        # Setup keyword to record when these keywords were backed up.
        if 'WCSCDATE' in header:
            self.orig_wcs['WCSCDATE'] = header['WCSCDATE']
        else:
            self.orig_wcs['WCSCDATE'] = fileutil.getLTime()
        self.backup['WCSCDATE'] = 'WCSCDATE'
        self.revert['WCSCDATE'] = 'WCSCDATE'
800369
public static long[][] getRange(Map<String, String> headers) {
		String rangeValue = getHeaderValue(headers, HTTP_RANGE_HEADER_UP);
		if (rangeValue == null) return null;
		rangeValue = rangeValue.trim();
		return parseRanges(rangeValue);
	}
1004594
def read(self):
        """"""

        def warn(msg, elapsed_time, current_time):
            desc = self._cache_id_desc()
            self._warnings(
                "{0} {1}: {2}s < {3}s", msg, desc, elapsed_time, current_time)

        file_time = get_time()
        out = self._out
        if out is None:
            if self.verbose:
                self._warnings("reading {0} from disk", self._cache_id_desc())
            with open(self._cache_file, 'rb') as f_in:
                out = None
                while True:
                    t_out = f_in.read(CHUNK_SIZE)
                    if not len(t_out):
                        break
                    if out is not None:
                        out += t_out
                    else:
                        out = t_out
                self._out = out
        (cache_id_obj, elapsed_time, res) = self._read(out)
        self.ensure_cache_id(cache_id_obj)
        real_time = get_time() - file_time
        if elapsed_time is not None and real_time > elapsed_time:
            warn("reading cache from disk takes longer than computing!",
                 elapsed_time, real_time)
        elif self._start_time is not None and elapsed_time is not None:
            current_time = get_time() - self._start_time
            if elapsed_time < current_time:
                warn("reading cache takes longer than computing!",
                     elapsed_time, current_time)
        self._last_access = get_time()
        return res
1329316
def read_chunked(self):
        """"""
        self._load_metadata()
        for i in range(self.npartitions):
            yield self._get_partition(i)
425245
private List<ByteRange> parseRangeHeader(final String rangeHeader, final int resourceLength) {
        final List<ByteRange> byteRanges;
        if (rangeHeader.contains("=")) {
            final String[] parts = rangeHeader.split("=", -1);
            if (parts.length > 1) {
                byteRanges = Arrays.stream(parts[1].split(",", -1))
                        .map(String::trim)
                        .map(s -> ByteRange.parse(s, resourceLength))
                        .collect(Collectors.toList());
            } else {
                byteRanges = Collections.emptyList();
            }
        } else {
            byteRanges = Collections.emptyList();
        }
        return byteRanges;
    }
73053
public boolean readHeaders() throws IOException {
		boolean result = readRecord();

		// copy the header data from the column array
		// to the header string array

		headersHolder.Length = columnsCount;

		headersHolder.Headers = new String[columnsCount];

		for (int i = 0; i < headersHolder.Length; i++) {
			String columnValue = get(i);

			headersHolder.Headers[i] = columnValue;

			// if there are duplicate header names, we will save the last one
			headersHolder.IndexByName.put(columnValue, new Integer(i));
		}

		if (result) {
			currentRecord--;
		}

		columnsCount = 0;

		return result;
	}
858152
def _read_page_header(file_obj):
    """"""
    tin = TFileTransport(file_obj)
    pin = TCompactProtocolFactory().get_protocol(tin)
    page_header = parquet_thrift.PageHeader()
    page_header.read(pin)
    return page_header
1057210
function readEntries (directoryReader, oldEntries, callback) {
  directoryReader.readEntries(
    (entries) => {
      const newEntries = [...oldEntries, ...entries]
      // According to the FileSystem API spec, readEntries() must be called until it calls the callback with an empty array.
      if (entries.length) {
        setTimeout(() => {
          readEntries(directoryReader, newEntries, callback)
        }, 0)
      // Done iterating this particular directory
      } else {
        callback(newEntries)
      }
    },
    // Make sure we resolve on error anyway
    () =>
      callback(oldEntries)
  )
}
877138
def _read_top_header(self):
    """"""
    magic = self._fh.read(4)
    l_text = struct.unpack('<i',self._fh.read(4))[0]
    header_text = self._fh.read(l_text).rstrip('\0')
    n_ref = struct.unpack('<i',self._fh.read(4))[0]
    return header_text, n_ref