1 /* temp_serializer.h : serialization functions for caching of FSX structures
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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
20 * ====================================================================
23 #ifndef SVN_LIBSVN_FS_X_TEMP_SERIALIZER_H
24 #define SVN_LIBSVN_FS_X_TEMP_SERIALIZER_H
26 #include "private/svn_temp_serializer.h"
30 * Prepend the @a number to the @a string in a space efficient way such that
31 * no other (number,string) combination can produce the same result.
32 * Allocate the result from @a result_pool.
35 svn_fs_x__combine_number_and_string(apr_int64_t number,
37 apr_pool_t *result_pool);
40 * Serialize APR array @a *a within the serialization @a context.
41 * The elements within the array must not contain pointers.
44 svn_fs_x__serialize_apr_array(struct svn_temp_serializer__context_t *context,
45 apr_array_header_t **a);
48 * Deserialize APR @a *array within the @a buffer. Set its pool member to
49 * @a result_pool. The elements within the array must not contain pointers.
52 svn_fs_x__deserialize_apr_array(void *buffer,
53 apr_array_header_t **array,
54 apr_pool_t *result_pool);
58 * #svn_txdelta_window_t is not sufficient for caching the data it
59 * represents because data read process needs auxiliary information.
63 /* the txdelta window information cached / to be cached */
64 svn_txdelta_window_t *window;
66 /* the revision file read pointer position before reading the window */
67 apr_off_t start_offset;
69 /* the revision file read pointer position right after reading the window */
71 } svn_fs_x__txdelta_cached_window_t;
74 * Implements #svn_cache__serialize_func_t for
75 * #svn_fs_x__txdelta_cached_window_t.
78 svn_fs_x__serialize_txdelta_window(void **buffer,
79 apr_size_t *buffer_size,
84 * Implements #svn_cache__deserialize_func_t for
85 * #svn_fs_x__txdelta_cached_window_t.
88 svn_fs_x__deserialize_txdelta_window(void **item,
90 apr_size_t buffer_size,
91 apr_pool_t *result_pool);
94 * Implements #svn_cache__serialize_func_t for a properties hash
95 * (@a in is an #apr_hash_t of svn_string_t elements, keyed by const char*).
98 svn_fs_x__serialize_properties(void **data,
104 * Implements #svn_cache__deserialize_func_t for a properties hash
105 * (@a *out is an #apr_hash_t of svn_string_t elements, keyed by const char*).
108 svn_fs_x__deserialize_properties(void **out,
111 apr_pool_t *result_pool);
114 * Implements #svn_cache__serialize_func_t for #svn_fs_x__noderev_t
117 svn_fs_x__serialize_node_revision(void **buffer,
118 apr_size_t *buffer_size,
123 * Implements #svn_cache__deserialize_func_t for #svn_fs_x__noderev_t
126 svn_fs_x__deserialize_node_revision(void **item,
128 apr_size_t buffer_size,
129 apr_pool_t *result_pool);
132 * Implements #svn_cache__serialize_func_t for a #svn_fs_x__dir_data_t
135 svn_fs_x__serialize_dir_entries(void **data,
136 apr_size_t *data_len,
141 * Implements #svn_cache__deserialize_func_t for a #svn_fs_x__dir_data_t
144 svn_fs_x__deserialize_dir_entries(void **out,
147 apr_pool_t *result_pool);
150 * Implements #svn_cache__partial_getter_func_t. Set (apr_off_t) @a *out
151 * to the element indexed by (apr_int64_t) @a *baton within the
152 * serialized manifest array @a data and @a data_len. */
154 svn_fs_x__get_sharded_offset(void **out,
161 * Implements #svn_cache__partial_getter_func_t.
162 * Set (svn_filesize_t) @a *out to the filesize info stored with the
163 * serialized directory in @a data of @a data_len. @a baton is unused.
166 svn_fs_x__extract_dir_filesize(void **out,
173 * Baton type to be used with svn_fs_x__extract_dir_entry. */
174 typedef struct svn_fs_x__ede_baton_t
176 /* Name of the directory entry to find. */
179 /* Lookup hint [in / out] */
182 /** Current length of the in-txn in-disk representation of the directory.
183 * SVN_INVALID_FILESIZE if unknown. */
184 svn_filesize_t txn_filesize;
186 /** Will be set by the callback. If FALSE, the cached data is out of date.
187 * We need this indicator because the svn_cache__t interface will always
188 * report the lookup as a success (FOUND==TRUE) if the generic lookup was
189 * successful -- regardless of what the entry extraction callback does. */
190 svn_boolean_t out_of_date;
191 } svn_fs_x__ede_baton_t;
194 * Implements #svn_cache__partial_getter_func_t for a single
195 * #svn_fs_x__dirent_t within a serialized directory contents hash,
196 * identified by its name (in (svn_fs_x__ede_baton_t *) @a *baton).
197 * If the filesize specified in the baton does not match the cached
198 * value for this directory, @a *out will be NULL as well.
201 svn_fs_x__extract_dir_entry(void **out,
208 * Describes the change to be done to a directory: Set the entry
209 * identify by @a name to the value @a new_entry. If the latter is
210 * @c NULL, the entry shall be removed if it exists. Otherwise it
211 * will be replaced or automatically added, respectively. The
212 * @a filesize allows readers to identify stale cache data (e.g.
213 * due to concurrent access to txns); writers use it to update the
214 * cached file size info.
216 typedef struct replace_baton_t
218 /** name of the directory entry to modify */
221 /** directory entry to insert instead */
222 svn_fs_x__dirent_t *new_entry;
224 /** Current length of the in-txn in-disk representation of the directory.
225 * SVN_INVALID_FILESIZE if unknown. */
226 svn_filesize_t txn_filesize;
230 * Implements #svn_cache__partial_setter_func_t for a single
231 * #svn_fs_x__dirent_t within a serialized directory contents hash,
232 * identified by its name in the #replace_baton_t in @a baton.
235 svn_fs_x__replace_dir_entry(void **data,
236 apr_size_t *data_len,
241 * Implements #svn_cache__partial_setter_func_t for a #svn_fs_x__dir_data_t
242 * at @a *data, resetting its txn_filesize field to SVN_INVALID_FILESIZE.
243 * &a baton should be NULL.
246 svn_fs_x__reset_txn_filesize(void **data,
247 apr_size_t *data_len,
252 * Implements #svn_cache__serialize_func_t for a #svn_fs_x__rep_header_t.
255 svn_fs_x__serialize_rep_header(void **data,
256 apr_size_t *data_len,
261 * Implements #svn_cache__deserialize_func_t for a #svn_fs_x__rep_header_t.
264 svn_fs_x__deserialize_rep_header(void **out,
267 apr_pool_t *result_pool);
269 /*** Block of changes in a changed paths list. */
270 typedef struct svn_fs_x__changes_list_t
272 /* Offset of the first element in CHANGES within the changed paths list
274 apr_off_t start_offset;
276 /* Offset of the first element behind CHANGES within the changed paths
278 apr_off_t end_offset;
280 /* End of list reached? This may have false negatives in case the number
281 of elements in the list is a multiple of our block / range size. */
284 /* Array of #svn_fs_x__change_t * representing a consecutive sub-range of
285 elements in a changed paths list. */
287 /* number of entries in the array */
290 /* reference to the changes */
291 svn_fs_x__change_t **changes;
293 } svn_fs_x__changes_list_t;
296 * Implements #svn_cache__serialize_func_t for a #svn_fs_x__changes_list_t.
299 svn_fs_x__serialize_changes(void **data,
300 apr_size_t *data_len,
305 * Implements #svn_cache__deserialize_func_t for a #svn_fs_x__changes_list_t.
308 svn_fs_x__deserialize_changes(void **out,
311 apr_pool_t *result_pool);