1 /* cached_data.h --- cached (read) access to FSX data 2 * 3 * ==================================================================== 4 * Licensed to the Apache Software Foundation (ASF) under one 5 * or more contributor license agreements. See the NOTICE file 6 * distributed with this work for additional information 7 * regarding copyright ownership. The ASF licenses this file 8 * to you under the Apache License, Version 2.0 (the 9 * "License"); you may not use this file except in compliance 10 * with the License. You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, 15 * software distributed under the License is distributed on an 16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 * KIND, either express or implied. See the License for the 18 * specific language governing permissions and limitations 19 * under the License. 20 * ==================================================================== 21 */ 22 23 #ifndef SVN_LIBSVN_FS_X_CACHED_DATA_H 24 #define SVN_LIBSVN_FS_X_CACHED_DATA_H 25 26 #include "svn_pools.h" 27 #include "svn_fs.h" 28 29 #include "fs.h" 30 #include "index.h" 31 32 33 34 /* Set *NODEREV_P to the node-revision for the node ID in FS. Do any 35 allocations in POOL. */ 36 svn_error_t * 37 svn_fs_x__get_node_revision(svn_fs_x__noderev_t **noderev_p, 38 svn_fs_t *fs, 39 const svn_fs_x__id_t *id, 40 apr_pool_t *result_pool, 41 apr_pool_t *scratch_pool); 42 43 /* Set *COUNT to the value of the mergeinfo_count member of the node- 44 revision for the node ID in FS. Do temporary allocations in SCRATCH_POOL. 45 */ 46 svn_error_t * 47 svn_fs_x__get_mergeinfo_count(apr_int64_t *count, 48 svn_fs_t *fs, 49 const svn_fs_x__id_t *id, 50 apr_pool_t *scratch_pool); 51 52 /* Verify that representation REP in FS can be accessed. 53 Do any allocations in SCRATCH_POOL. */ 54 svn_error_t * 55 svn_fs_x__check_rep(svn_fs_x__representation_t *rep, 56 svn_fs_t *fs, 57 apr_pool_t *scratch_pool); 58 59 /* Follow the representation delta chain in FS starting with REP. The 60 number of reps (including REP) in the chain will be returned in 61 *CHAIN_LENGTH. *SHARD_COUNT will be set to the number of shards 62 accessed. Do any allocations in SCRATCH_POOL. */ 63 svn_error_t * 64 svn_fs_x__rep_chain_length(int *chain_length, 65 int *shard_count, 66 svn_fs_x__representation_t *rep, 67 svn_fs_t *fs, 68 apr_pool_t *scratch_pool); 69 70 /* Set *CONTENTS_P to be a readable svn_stream_t that receives the text 71 representation REP as seen in filesystem FS. If CACHE_FULLTEXT is 72 not set, bypass fulltext cache lookup for this rep and don't put the 73 reconstructed fulltext into cache. 74 Allocate *CONTENT_P in RESULT_POOL. */ 75 svn_error_t * 76 svn_fs_x__get_contents(svn_stream_t **contents_p, 77 svn_fs_t *fs, 78 svn_fs_x__representation_t *rep, 79 svn_boolean_t cache_fulltext, 80 apr_pool_t *result_pool); 81 82 /* Set *CONTENTS_P to be a readable svn_stream_t that receives the text 83 representation REP as seen in filesystem FS. Read the latest element 84 of the delta chain from FILE at offset OFFSET. 85 Use POOL for allocations. */ 86 svn_error_t * 87 svn_fs_x__get_contents_from_file(svn_stream_t **contents_p, 88 svn_fs_t *fs, 89 svn_fs_x__representation_t *rep, 90 apr_file_t *file, 91 apr_off_t offset, 92 apr_pool_t *pool); 93 94 /* Determine on-disk and expanded sizes of the representation identified 95 * by ENTRY in FS and return the result in PACKED_LEN and EXPANDED_LEN, 96 * respectively. FILE must point to the start of the representation and 97 * STREAM must be a stream defined on top of FILE. 98 * Use SCRATCH_POOL for temporary allocations. 99 */ 100 svn_error_t * 101 svn_fs_x__get_representation_length(svn_filesize_t *packed_len, 102 svn_filesize_t *expanded_len, 103 svn_fs_t *fs, 104 svn_fs_x__revision_file_t *rev_file, 105 svn_fs_x__p2l_entry_t* entry, 106 apr_pool_t *scratch_pool); 107 108 /* Attempt to fetch the text representation of node-revision NODEREV as 109 seen in filesystem FS and pass it along with the BATON to the PROCESSOR. 110 Set *SUCCESS only of the data could be provided and the processing 111 had been called. 112 Use SCRATCH_POOL for temporary allocations. 113 */ 114 svn_error_t * 115 svn_fs_x__try_process_file_contents(svn_boolean_t *success, 116 svn_fs_t *fs, 117 svn_fs_x__noderev_t *noderev, 118 svn_fs_process_contents_func_t processor, 119 void* baton, 120 apr_pool_t *scratch_pool); 121 122 /* Set *STREAM_P to a delta stream turning the contents of the file SOURCE 123 into the contents of the file TARGET, allocated in RESULT_POOL. 124 If SOURCE is NULL, an empty string will be used in its stead. 125 Use SCRATCH_POOL for temporary allocations. 126 */ 127 svn_error_t * 128 svn_fs_x__get_file_delta_stream(svn_txdelta_stream_t **stream_p, 129 svn_fs_t *fs, 130 svn_fs_x__noderev_t *source, 131 svn_fs_x__noderev_t *target, 132 apr_pool_t *result_pool, 133 apr_pool_t *scratch_pool); 134 135 /* Set *ENTRIES to an apr_array_header_t of dirent structs that contain 136 the directory entries of node-revision NODEREV in filesystem FS. The 137 returned table is allocated in RESULT_POOL and entries are sorted 138 lexicographically. SCRATCH_POOL is used for temporary allocations. */ 139 svn_error_t * 140 svn_fs_x__rep_contents_dir(apr_array_header_t **entries_p, 141 svn_fs_t *fs, 142 svn_fs_x__noderev_t *noderev, 143 apr_pool_t *result_pool, 144 apr_pool_t *scratch_pool); 145 146 /* Return the directory entry from ENTRIES that matches NAME. If no such 147 entry exists, return NULL. If HINT is not NULL, set *HINT to the array 148 index of the entry returned. Successive calls in a linear scan scenario 149 will be faster called with the same HINT variable. */ 150 svn_fs_x__dirent_t * 151 svn_fs_x__find_dir_entry(apr_array_header_t *entries, 152 const char *name, 153 int *hint); 154 155 /* Set *DIRENT to the entry identified by NAME in the directory given 156 by NODEREV in filesystem FS. If no such entry exits, *DIRENT will 157 be NULL. The value referenced by HINT can be used to speed up 158 consecutive calls when travering the directory in name order. 159 Any value is allowed, however APR_SIZE_MAX gives best performance 160 when there has been no previous lookup for the same directory. 161 162 The returned object is allocated in RESULT_POOL; SCRATCH_POOL 163 used for temporary allocations. */ 164 svn_error_t * 165 svn_fs_x__rep_contents_dir_entry(svn_fs_x__dirent_t **dirent, 166 svn_fs_t *fs, 167 svn_fs_x__noderev_t *noderev, 168 const char *name, 169 apr_size_t *hint, 170 apr_pool_t *result_pool, 171 apr_pool_t *scratch_pool); 172 173 /* Set *PROPLIST to be an apr_hash_t containing the property list of 174 node-revision NODEREV as seen in filesystem FS. Allocate the result 175 in RESULT_POOL and use SCRATCH_POOL for temporary allocations. */ 176 svn_error_t * 177 svn_fs_x__get_proplist(apr_hash_t **proplist, 178 svn_fs_t *fs, 179 svn_fs_x__noderev_t *noderev, 180 apr_pool_t *result_pool, 181 apr_pool_t *scratch_pool); 182 183 /* Create a changes retrieval context object in *RESULT_POOL and return it 184 * in *CONTEXT. It will allow svn_fs_x__get_changes to fetch consecutive 185 * blocks (one per invocation) from REV's changed paths list in FS. 186 * Use SCRATCH_POOL for temporary allocations. */ 187 svn_error_t * 188 svn_fs_x__create_changes_context(svn_fs_x__changes_context_t **context, 189 svn_fs_t *fs, 190 svn_revnum_t rev, 191 apr_pool_t *result_pool, 192 apr_pool_t *scratch_pool); 193 194 /* Fetch the block of changes from the CONTEXT and return it in *CHANGES. 195 * Allocate the result in RESULT_POOL and use SCRATCH_POOL for temporaries. 196 */ 197 svn_error_t * 198 svn_fs_x__get_changes(apr_array_header_t **changes, 199 svn_fs_x__changes_context_t *context, 200 apr_pool_t *result_pool, 201 apr_pool_t *scratch_pool); 202 203 #endif 204