]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/subversion/subversion/libsvn_fs_x/temp_serializer.h
Update svn-1.9.7 to 1.10.0.
[FreeBSD/FreeBSD.git] / contrib / subversion / subversion / libsvn_fs_x / temp_serializer.h
1 /* temp_serializer.h : serialization functions for caching of FSX structures
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_TEMP_SERIALIZER_H
24 #define SVN_LIBSVN_FS_X_TEMP_SERIALIZER_H
25
26 #include "private/svn_temp_serializer.h"
27 #include "fs.h"
28
29 /**
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.
33  */
34 const char*
35 svn_fs_x__combine_number_and_string(apr_int64_t number,
36                                     const char *string,
37                                     apr_pool_t *result_pool);
38
39 /**
40  * Serialize APR array @a *a within the serialization @a context.
41  * The elements within the array must not contain pointers.
42  */
43 void
44 svn_fs_x__serialize_apr_array(struct svn_temp_serializer__context_t *context,
45                               apr_array_header_t **a);
46
47 /**
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.
50  */
51 void
52 svn_fs_x__deserialize_apr_array(void *buffer,
53                                 apr_array_header_t **array,
54                                 apr_pool_t *result_pool);
55
56
57 /**
58  * #svn_txdelta_window_t is not sufficient for caching the data it
59  * represents because data read process needs auxiliary information.
60  */
61 typedef struct
62 {
63   /* the txdelta window information cached / to be cached */
64   svn_txdelta_window_t *window;
65
66   /* the revision file read pointer position before reading the window */
67   apr_off_t start_offset;
68
69   /* the revision file read pointer position right after reading the window */
70   apr_off_t end_offset;
71 } svn_fs_x__txdelta_cached_window_t;
72
73 /**
74  * Implements #svn_cache__serialize_func_t for
75  * #svn_fs_x__txdelta_cached_window_t.
76  */
77 svn_error_t *
78 svn_fs_x__serialize_txdelta_window(void **buffer,
79                                    apr_size_t *buffer_size,
80                                    void *item,
81                                    apr_pool_t *pool);
82
83 /**
84  * Implements #svn_cache__deserialize_func_t for
85  * #svn_fs_x__txdelta_cached_window_t.
86  */
87 svn_error_t *
88 svn_fs_x__deserialize_txdelta_window(void **item,
89                                      void *buffer,
90                                      apr_size_t buffer_size,
91                                      apr_pool_t *result_pool);
92
93 /**
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*).
96  */
97 svn_error_t *
98 svn_fs_x__serialize_properties(void **data,
99                                apr_size_t *data_len,
100                                void *in,
101                                apr_pool_t *pool);
102
103 /**
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*).
106  */
107 svn_error_t *
108 svn_fs_x__deserialize_properties(void **out,
109                                  void *data,
110                                  apr_size_t data_len,
111                                  apr_pool_t *result_pool);
112
113 /**
114  * Implements #svn_cache__serialize_func_t for #svn_fs_x__noderev_t
115  */
116 svn_error_t *
117 svn_fs_x__serialize_node_revision(void **buffer,
118                                   apr_size_t *buffer_size,
119                                   void *item,
120                                   apr_pool_t *pool);
121
122 /**
123  * Implements #svn_cache__deserialize_func_t for #svn_fs_x__noderev_t
124  */
125 svn_error_t *
126 svn_fs_x__deserialize_node_revision(void **item,
127                                     void *buffer,
128                                     apr_size_t buffer_size,
129                                     apr_pool_t *result_pool);
130
131 /**
132  * Implements #svn_cache__serialize_func_t for a #svn_fs_x__dir_data_t
133  */
134 svn_error_t *
135 svn_fs_x__serialize_dir_entries(void **data,
136                                 apr_size_t *data_len,
137                                 void *in,
138                                 apr_pool_t *pool);
139
140 /**
141  * Implements #svn_cache__deserialize_func_t for a #svn_fs_x__dir_data_t
142  */
143 svn_error_t *
144 svn_fs_x__deserialize_dir_entries(void **out,
145                                   void *data,
146                                   apr_size_t data_len,
147                                   apr_pool_t *result_pool);
148
149 /**
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. */
153 svn_error_t *
154 svn_fs_x__get_sharded_offset(void **out,
155                              const void *data,
156                              apr_size_t data_len,
157                              void *baton,
158                              apr_pool_t *pool);
159
160 /**
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.
164  */
165 svn_error_t *
166 svn_fs_x__extract_dir_filesize(void **out,
167                                const void *data,
168                                apr_size_t data_len,
169                                void *baton,
170                                apr_pool_t *pool);
171
172 /**
173  * Baton type to be used with svn_fs_x__extract_dir_entry. */
174 typedef struct svn_fs_x__ede_baton_t
175 {
176   /* Name of the directory entry to find. */
177   const char *name;
178
179   /* Lookup hint [in / out] */
180   apr_size_t hint;
181
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;
185
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;
192
193 /**
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.
199  */
200 svn_error_t *
201 svn_fs_x__extract_dir_entry(void **out,
202                             const void *data,
203                             apr_size_t data_len,
204                             void *baton,
205                             apr_pool_t *pool);
206
207 /**
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.
215  */
216 typedef struct replace_baton_t
217 {
218   /** name of the directory entry to modify */
219   const char *name;
220
221   /** directory entry to insert instead */
222   svn_fs_x__dirent_t *new_entry;
223
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;
227 } replace_baton_t;
228
229 /**
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.
233  */
234 svn_error_t *
235 svn_fs_x__replace_dir_entry(void **data,
236                             apr_size_t *data_len,
237                             void *baton,
238                             apr_pool_t *pool);
239
240 /**
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.
244  */
245 svn_error_t *
246 svn_fs_x__reset_txn_filesize(void **data,
247                              apr_size_t *data_len,
248                              void *baton,
249                              apr_pool_t *pool);
250
251 /**
252  * Implements #svn_cache__serialize_func_t for a #svn_fs_x__rep_header_t.
253  */
254 svn_error_t *
255 svn_fs_x__serialize_rep_header(void **data,
256                                apr_size_t *data_len,
257                                void *in,
258                                apr_pool_t *pool);
259
260 /**
261  * Implements #svn_cache__deserialize_func_t for a #svn_fs_x__rep_header_t.
262  */
263 svn_error_t *
264 svn_fs_x__deserialize_rep_header(void **out,
265                                  void *data,
266                                  apr_size_t data_len,
267                                  apr_pool_t *result_pool);
268
269 /*** Block of changes in a changed paths list. */
270 typedef struct svn_fs_x__changes_list_t
271 {
272   /* Offset of the first element in CHANGES within the changed paths list
273      on disk. */
274   apr_off_t start_offset;
275
276   /* Offset of the first element behind CHANGES within the changed paths
277      list on disk. */
278   apr_off_t end_offset;
279
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. */
282   svn_boolean_t eol;
283
284   /* Array of #svn_fs_x__change_t * representing a consecutive sub-range of
285      elements in a changed paths list. */
286
287   /* number of entries in the array */
288   int count;
289
290   /* reference to the changes */
291   svn_fs_x__change_t **changes;
292
293 } svn_fs_x__changes_list_t;
294
295 /**
296  * Implements #svn_cache__serialize_func_t for a #svn_fs_x__changes_list_t.
297  */
298 svn_error_t *
299 svn_fs_x__serialize_changes(void **data,
300                             apr_size_t *data_len,
301                             void *in,
302                             apr_pool_t *pool);
303
304 /**
305  * Implements #svn_cache__deserialize_func_t for a #svn_fs_x__changes_list_t.
306  */
307 svn_error_t *
308 svn_fs_x__deserialize_changes(void **out,
309                               void *data,
310                               apr_size_t data_len,
311                               apr_pool_t *result_pool);
312
313 #endif