FreeBSD/contrib/subversion/subversion/libsvn_fs_fs/cached_data.c
/* Walk through all windows in the representation addressed by RS in FS
 * (excluding the delta bases) and put those not already cached into the
 * window caches.  If MAX_OFFSET is not -1, don't read windows that start
 * at or beyond that offset.  Use POOL for temporary allocations.
 *
 * This function requires RS->RAW_WINDOW_CACHE and RS->WINDOW_CACHE to
 * be non-NULL.
 */
Walk through all windows in the representation addressed by RS in FS
(excluding the delta bases) and put those not already cached into the
window caches.  If MAX_OFFSET is not -1, don't read windows that start
at or beyond that offset.  Use POOL for temporary allocations.

This function requires RS->RAW_WINDOW_CACHE and RS->WINDOW_CACHE to
be non-NULL.
Walk through all windows in the representation addressed by RS in FS ( excluding the delta bases ) and put those not already cached into the window caches . If MAX_OFFSET is not - 1 don ' t read windows that start at or beyond that offset . Use POOL for temporary allocations . This function requires RS - > RAW_WINDOW_CACHE and RS - > WINDOW_CACHE to be non - NULL .
static svn_error_t *
cache_windows(svn_fs_t *fs,
              rep_state_t *rs,
              apr_off_t max_offset,
              apr_pool_t *pool)
{
  apr_pool_t *iterpool = svn_pool_create(pool);
  while (rs->current < rs->size)
    {
      apr_off_t end_offset;
      svn_boolean_t found = FALSE;
      window_cache_key_t key = { 0 };
      svn_pool_clear(iterpool);
      if (max_offset != -1 && rs->start + rs->current >= max_offset)
        {
          svn_pool_destroy(iterpool);
          return SVN_NO_ERROR;
        }
      SVN_ERR(svn_cache__get_partial((void **) &end_offset, &found,
                                     rs->raw_window_cache,
                                     get_window_key(&key, rs),
                                     get_raw_window_end, NULL,
                                     iterpool));
      if (! found)
        SVN_ERR(svn_cache__get_partial((void **) &end_offset, &found,
                                       rs->window_cache, &key,
                                       get_txdelta_window_end, NULL,
                                       iterpool));
      if (found)
        {
          rs->current = end_offset;
        }
      else
        {
          svn_fs_fs__raw_cached_window_t window;
          apr_off_t start_offset = rs->start + rs->current;
          apr_size_t window_len;
          char *buf;
          SVN_ERR(rs_aligned_seek(rs, NULL, start_offset, iterpool));
          SVN_ERR(svn_txdelta__read_raw_window_len(&window_len,
                                                   rs->sfile->rfile->stream,
                                                   iterpool));
          buf = apr_palloc(iterpool, window_len + 1);
          SVN_ERR(rs_aligned_seek(rs, NULL, start_offset, iterpool));
          SVN_ERR(svn_io_file_read_full2(rs->sfile->rfile->file, buf,
                                         window_len, NULL, NULL, iterpool));
          buf[window_len] = 0;
          rs->current += window_len;
          window.end_offset = rs->current;
          window.window.len = window_len;
          window.window.data = buf;
          SVN_ERR(svn_cache__set(rs->raw_window_cache, &key, &window,
                                 iterpool));
        }
      if (rs->current > rs->size)
        return svn_error_create(SVN_ERR_FS_CORRUPT, NULL,
                                _("Reading one svndiff window read beyond "
                                            "the end of the representation"));
      rs->chunk_index++;
    }
  svn_pool_destroy(iterpool);
  return SVN_NO_ERROR;
}
static svn_error_t * cache_windows ( svn_fs_t * fs , rep_state_t * rs , apr_off_t max_offset , apr_pool_t * pool ) { apr_pool_t * iterpool = svn_pool_create ( pool ) ; while ( rs -> current < rs -> size ) { apr_off_t end_offset ; svn_boolean_t found = FALSE ; window_cache_key_t key = { 0 } ; svn_pool_clear ( iterpool ) ; if ( max_offset != -1 && rs -> start + rs -> current >= max_offset ) { svn_pool_destroy ( iterpool ) ; return SVN_NO_ERROR ; } SVN_ERR ( svn_cache__get_partial ( ( void * * ) & end_offset , & found , rs -> raw_window_cache , get_window_key ( & key , rs ) , get_raw_window_end , NULL , iterpool ) ) ; if ( ! found ) SVN_ERR ( svn_cache__get_partial ( ( void * * ) & end_offset , & found , rs -> window_cache , & key , get_txdelta_window_end , NULL , iterpool ) ) ; if ( found ) { rs -> current = end_offset ; } else { svn_fs_fs__raw_cached_window_t window ; apr_off_t start_offset = rs -> start + rs -> current ; apr_size_t window_len ; char * buf ; SVN_ERR ( rs_aligned_seek ( rs , NULL , start_offset , iterpool ) ) ; SVN_ERR ( svn_txdelta__read_raw_window_len ( & window_len , rs -> sfile -> rfile -> stream , iterpool ) ) ; buf = apr_palloc ( iterpool , window_len + 1 ) ; SVN_ERR ( rs_aligned_seek ( rs , NULL , start_offset , iterpool ) ) ; SVN_ERR ( svn_io_file_read_full2 ( rs -> sfile -> rfile -> file , buf , window_len , NULL , NULL , iterpool ) ) ; buf [ window_len ] = 0 ; rs -> current += window_len ; window . end_offset = rs -> current ; window . window . len = window_len ; window . window . data = buf ; SVN_ERR ( svn_cache__set ( rs -> raw_window_cache , & key , & window , iterpool ) ) ; } if ( rs -> current > rs -> size ) return svn_error_create ( SVN_ERR_FS_CORRUPT , NULL , _ ( " " " " ) ) ; rs -> chunk_index ++ ; } svn_pool_destroy ( iterpool ) ; return SVN_NO_ERROR ; }
Walk through all windows in the representation addressed by RS in FS
 (excluding the delta bases) and put those not already cached into the
 window caches.
Walk through all windows in the representation addressed by RS in FS ( excluding the delta bases ) and put those not already cached into the window caches .
/* We don't need to read the data again if it is already in cache.
       * It might be cached as either raw or parsed window.
       */ /* Read, decode and cache the window. */ /* navigate to the current window */ /* Read the raw window. */ /* update relative offset in representation */ /* Construct the cachable raw window object. */ /* cache the window now */