FreeBSD/contrib/subversion/subversion/libsvn_fs_fs/cached_data.c
/* Read all txdelta / plain windows following REP_HEADER in FS as described
 * by ENTRY.  Read the data from the already open FILE and the wrapping
 * STREAM object.  If MAX_OFFSET is not -1, don't read windows that start
 * at or beyond that offset.  Use SCRATCH_POOL for temporary allocations.
 * If caching is not enabled, this is a no-op.
 */
Read all txdelta / plain windows following REP_HEADER in FS as described
by ENTRY.  Read the data from the already open FILE and the wrapping
STREAM object.  If MAX_OFFSET is not -1, don't read windows that start
at or beyond that offset.  Use SCRATCH_POOL for temporary allocations.
If caching is not enabled, this is a no-op.
Read all txdelta / plain windows following REP_HEADER in FS as described by ENTRY . Read the data from the already open FILE and the wrapping STREAM object . If MAX_OFFSET is not - 1 don ' t read windows that start at or beyond that offset . Use SCRATCH_POOL for temporary allocations . If caching is not enabled this is a no - op .
static svn_error_t *
block_read_windows(svn_fs_fs__rep_header_t *rep_header,
                   svn_fs_t *fs,
                   svn_fs_fs__revision_file_t *rev_file,
                   svn_fs_fs__p2l_entry_t* entry,
                   apr_off_t max_offset,
                   apr_pool_t *result_pool,
                   apr_pool_t *scratch_pool)
{
  fs_fs_data_t *ffd = fs->fsap_data;
  rep_state_t rs = { 0 };
  apr_off_t offset;
  window_cache_key_t key = { 0 };
  if (   (rep_header->type != svn_fs_fs__rep_plain
          && (!ffd->txdelta_window_cache || !ffd->raw_window_cache))
      || (rep_header->type == svn_fs_fs__rep_plain
          && !ffd->combined_window_cache))
    return SVN_NO_ERROR;
  SVN_ERR(init_rep_state(&rs, rep_header, fs, rev_file, entry,
                         result_pool));
  offset = rs.start + rs.current;
  if (rep_header->type == svn_fs_fs__rep_plain)
    {
      svn_stringbuf_t *plaintext;
      svn_boolean_t is_cached;
      SVN_ERR(svn_cache__has_key(&is_cached, rs.combined_cache,
                                 get_window_key(&key, &rs),
                                 scratch_pool));
      if (is_cached)
        return SVN_NO_ERROR;
      SVN_ERR(aligned_seek(fs, rev_file->file, NULL, offset, scratch_pool));
      plaintext = svn_stringbuf_create_ensure(rs.size, result_pool);
      SVN_ERR(svn_io_file_read_full2(rev_file->file, plaintext->data,
                                     rs.size, &plaintext->len, NULL,
                                     result_pool));
      plaintext->data[plaintext->len] = 0;
      rs.current += rs.size;
      SVN_ERR(set_cached_combined_window(plaintext, &rs, scratch_pool));
    }
  else
    {
      SVN_ERR(cache_windows(fs, &rs, max_offset, scratch_pool));
    }
  return SVN_NO_ERROR;
}
static svn_error_t * block_read_windows ( svn_fs_fs__rep_header_t * rep_header , svn_fs_t * fs , svn_fs_fs__revision_file_t * rev_file , svn_fs_fs__p2l_entry_t * entry , apr_off_t max_offset , apr_pool_t * result_pool , apr_pool_t * scratch_pool ) { fs_fs_data_t * ffd = fs -> fsap_data ; rep_state_t rs = { 0 } ; apr_off_t offset ; window_cache_key_t key = { 0 } ; if ( ( rep_header -> type != svn_fs_fs__rep_plain && ( ! ffd -> txdelta_window_cache || ! ffd -> raw_window_cache ) ) || ( rep_header -> type == svn_fs_fs__rep_plain && ! ffd -> combined_window_cache ) ) return SVN_NO_ERROR ; SVN_ERR ( init_rep_state ( & rs , rep_header , fs , rev_file , entry , result_pool ) ) ; offset = rs . start + rs . current ; if ( rep_header -> type == svn_fs_fs__rep_plain ) { svn_stringbuf_t * plaintext ; svn_boolean_t is_cached ; SVN_ERR ( svn_cache__has_key ( & is_cached , rs . combined_cache , get_window_key ( & key , & rs ) , scratch_pool ) ) ; if ( is_cached ) return SVN_NO_ERROR ; SVN_ERR ( aligned_seek ( fs , rev_file -> file , NULL , offset , scratch_pool ) ) ; plaintext = svn_stringbuf_create_ensure ( rs . size , result_pool ) ; SVN_ERR ( svn_io_file_read_full2 ( rev_file -> file , plaintext -> data , rs . size , & plaintext -> len , NULL , result_pool ) ) ; plaintext -> data [ plaintext -> len ] = 0 ; rs . current += rs . size ; SVN_ERR ( set_cached_combined_window ( plaintext , & rs , scratch_pool ) ) ; } else { SVN_ERR ( cache_windows ( fs , & rs , max_offset , scratch_pool ) ) ; } return SVN_NO_ERROR ; }
Read all txdelta / plain windows following REP_HEADER in FS as described
 by ENTRY.
Read all txdelta / plain windows following REP_HEADER in FS as described by ENTRY .
/* RS->FILE may be shared between RS instances -> make sure we point
   * to the right data. */ /* already in cache? */ /* for larger reps, the header may have crossed a block boundary.
       * make sure we still read blocks properly aligned, i.e. don't use
       * plain seek here. */