]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/subversion/subversion/libsvn_fs_fs/temp_serializer.h
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / subversion / subversion / libsvn_fs_fs / temp_serializer.h
1 /* temp_serializer.h : serialization functions for caching of FSFS 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__TEMP_SERIALIZER_H
24 #define SVN_LIBSVN_FS__TEMP_SERIALIZER_H
25
26 #include "fs.h"
27
28 /**
29  * Prepend the @a number to the @a string in a space efficient way such that
30  * no other (number,string) combination can produce the same result.
31  * Allocate temporaries as well as the result from @a pool.
32  */
33 const char*
34 svn_fs_fs__combine_number_and_string(apr_int64_t number,
35                                      const char *string,
36                                      apr_pool_t *pool);
37
38 /**
39  * Serialize a @a noderev_p within the serialization @a context.
40  */
41 void
42 svn_fs_fs__noderev_serialize(struct svn_temp_serializer__context_t *context,
43                              node_revision_t * const *noderev_p);
44
45 /**
46  * Deserialize a @a noderev_p within the @a buffer.
47  */
48 void
49 svn_fs_fs__noderev_deserialize(void *buffer,
50                                node_revision_t **noderev_p);
51
52
53 /**
54  * Adds position information to the raw window data in WINDOW.
55  */
56 typedef struct
57 {
58   /* the (unprocessed) txdelta window byte sequence cached / to be cached */
59   svn_string_t window;
60
61   /* the offset within the representation right after reading the window */
62   apr_off_t end_offset;
63
64   /* svndiff version */
65   int ver;
66 } svn_fs_fs__raw_cached_window_t;
67
68 /**
69  * Implements #svn_cache__serialize_func_t for
70  * #svn_fs_fs__raw_cached_window_t.
71  */
72 svn_error_t *
73 svn_fs_fs__serialize_raw_window(void **buffer,
74                                 apr_size_t *buffer_size,
75                                 void *item,
76                                 apr_pool_t *pool);
77
78 /**
79  * Implements #svn_cache__deserialize_func_t for
80  * #svn_fs_fs__raw_cached_window_t.
81  */
82 svn_error_t *
83 svn_fs_fs__deserialize_raw_window(void **item,
84                                   void *buffer,
85                                   apr_size_t buffer_size,
86                                   apr_pool_t *pool);
87
88 /**
89  * #svn_txdelta_window_t is not sufficient for caching the data it
90  * represents because data read process needs auxiliary information.
91  */
92 typedef struct
93 {
94   /* the txdelta window information cached / to be cached */
95   svn_txdelta_window_t *window;
96
97   /* the revision file read pointer position right after reading the window */
98   apr_off_t end_offset;
99 } svn_fs_fs__txdelta_cached_window_t;
100
101 /**
102  * Implements #svn_cache__serialize_func_t for
103  * #svn_fs_fs__txdelta_cached_window_t.
104  */
105 svn_error_t *
106 svn_fs_fs__serialize_txdelta_window(void **buffer,
107                                     apr_size_t *buffer_size,
108                                     void *item,
109                                     apr_pool_t *pool);
110
111 /**
112  * Implements #svn_cache__deserialize_func_t for
113  * #svn_fs_fs__txdelta_cached_window_t.
114  */
115 svn_error_t *
116 svn_fs_fs__deserialize_txdelta_window(void **item,
117                                       void *buffer,
118                                       apr_size_t buffer_size,
119                                       apr_pool_t *pool);
120
121 /**
122  * Implements #svn_cache__serialize_func_t for a manifest
123  * (@a in is an #apr_array_header_t of apr_off_t elements).
124  */
125 svn_error_t *
126 svn_fs_fs__serialize_manifest(void **data,
127                               apr_size_t *data_len,
128                               void *in,
129                               apr_pool_t *pool);
130
131 /**
132  * Implements #svn_cache__deserialize_func_t for a manifest
133  * (@a *out is an #apr_array_header_t of apr_off_t elements).
134  */
135 svn_error_t *
136 svn_fs_fs__deserialize_manifest(void **out,
137                                 void *data,
138                                 apr_size_t data_len,
139                                 apr_pool_t *pool);
140
141 /**
142  * Implements #svn_cache__serialize_func_t for a properties hash
143  * (@a in is an #apr_hash_t of svn_string_t elements, keyed by const char*).
144  */
145 svn_error_t *
146 svn_fs_fs__serialize_properties(void **data,
147                                 apr_size_t *data_len,
148                                 void *in,
149                                 apr_pool_t *pool);
150
151 /**
152  * Implements #svn_cache__deserialize_func_t for a properties hash
153  * (@a *out is an #apr_hash_t of svn_string_t elements, keyed by const char*).
154  */
155 svn_error_t *
156 svn_fs_fs__deserialize_properties(void **out,
157                                   void *data,
158                                   apr_size_t data_len,
159                                   apr_pool_t *pool);
160
161 /**
162  * Implements #svn_cache__serialize_func_t for a properties hash
163  * (@a in is an #apr_hash_t of svn_string_t elements, keyed by const char*).
164  */
165 svn_error_t *
166 svn_fs_fs__serialize_revprops(void **data,
167                               apr_size_t *data_len,
168                               void *in,
169                               apr_pool_t *pool);
170
171 /**
172  * Implements #svn_cache__deserialize_func_t for a properties hash
173  * (@a *out is an #apr_hash_t of svn_string_t elements, keyed by const char*).
174  */
175 svn_error_t *
176 svn_fs_fs__deserialize_revprops(void **out,
177                                 void *data,
178                                 apr_size_t data_len,
179                                 apr_pool_t *pool);
180
181 /**
182  * Implements #svn_cache__serialize_func_t for #svn_fs_id_t
183  */
184 svn_error_t *
185 svn_fs_fs__serialize_id(void **data,
186                         apr_size_t *data_len,
187                         void *in,
188                         apr_pool_t *pool);
189
190 /**
191  * Implements #svn_cache__deserialize_func_t for #svn_fs_id_t
192  */
193 svn_error_t *
194 svn_fs_fs__deserialize_id(void **out,
195                           void *data,
196                           apr_size_t data_len,
197                           apr_pool_t *pool);
198
199 /**
200  * Implements #svn_cache__serialize_func_t for #node_revision_t
201  */
202 svn_error_t *
203 svn_fs_fs__serialize_node_revision(void **buffer,
204                                    apr_size_t *buffer_size,
205                                    void *item,
206                                    apr_pool_t *pool);
207
208 /**
209  * Implements #svn_cache__deserialize_func_t for #node_revision_t
210  */
211 svn_error_t *
212 svn_fs_fs__deserialize_node_revision(void **item,
213                                      void *buffer,
214                                      apr_size_t buffer_size,
215                                      apr_pool_t *pool);
216
217 /**
218  * Implements #svn_cache__serialize_func_t for a #svn_fs_fs__dir_data_t
219  */
220 svn_error_t *
221 svn_fs_fs__serialize_dir_entries(void **data,
222                                  apr_size_t *data_len,
223                                  void *in,
224                                  apr_pool_t *pool);
225
226 /**
227  * Same as svn_fs_fs__serialize_dir_entries but allocates extra room for
228  * in-place modification.
229  */
230 svn_error_t *
231 svn_fs_fs__serialize_txndir_entries(void **data,
232                                     apr_size_t *data_len,
233                                     void *in,
234                                     apr_pool_t *pool);
235
236 /**
237  * Implements #svn_cache__deserialize_func_t for a #svn_fs_fs__dir_data_t
238  */
239 svn_error_t *
240 svn_fs_fs__deserialize_dir_entries(void **out,
241                                    void *data,
242                                    apr_size_t data_len,
243                                    apr_pool_t *pool);
244
245 /**
246  * Implements #svn_cache__partial_getter_func_t.  Set (apr_off_t) @a *out
247  * to the element indexed by (apr_int64_t) @a *baton within the
248  * serialized manifest array @a data and @a data_len. */
249 svn_error_t *
250 svn_fs_fs__get_sharded_offset(void **out,
251                               const void *data,
252                               apr_size_t data_len,
253                               void *baton,
254                               apr_pool_t *pool);
255
256 /**
257  * Implements #svn_cache__partial_getter_func_t.
258  * Set (svn_filesize_t) @a *out to the filesize info stored with the
259  * serialized directory in @a data of @a data_len.  @a baton is unused.
260  */
261 svn_error_t *
262 svn_fs_fs__extract_dir_filesize(void **out,
263                                 const void *data,
264                                 apr_size_t data_len,
265                                 void *baton,
266                                 apr_pool_t *pool);
267
268 /**
269  * Describes the entry to be found in a directory: Identifies the entry
270  * by @a name and requires the directory file size to be @a filesize.
271  */
272 typedef struct extract_dir_entry_baton_t
273 {
274   /** name of the directory entry to return */
275   const char *name;
276
277   /** Current length of the in-txn in-disk representation of the directory.
278    * SVN_INVALID_FILESIZE if unknown. */
279   svn_filesize_t txn_filesize;
280
281   /** Will be set by the callback.  If FALSE, the cached data is out of date.
282    * We need this indicator because the svn_cache__t interface will always
283    * report the lookup as a success (FOUND==TRUE) if the generic lookup was
284    * successful -- regardless of what the entry extraction callback does. */
285   svn_boolean_t out_of_date;
286 } extract_dir_entry_baton_t;
287
288
289 /**
290  * Implements #svn_cache__partial_getter_func_t for a single
291  * #svn_fs_dirent_t within a serialized directory contents hash,
292  * identified by its name (in (extract_dir_entry_baton_t *) @a *baton).
293  * If the filesize specified in the baton does not match the cached
294  * value for this directory, @a *out will be NULL as well.
295  */
296 svn_error_t *
297 svn_fs_fs__extract_dir_entry(void **out,
298                              const void *data,
299                              apr_size_t data_len,
300                              void *baton,
301                              apr_pool_t *pool);
302
303 /**
304  * Describes the change to be done to a directory: Set the entry
305  * identify by @a name to the value @a new_entry. If the latter is
306  * @c NULL, the entry shall be removed if it exists. Otherwise it
307  * will be replaced or automatically added, respectively.  The
308  * @a filesize allows readers to identify stale cache data (e.g.
309  * due to concurrent access to txns); writers use it to update the
310  * cached file size info.
311  */
312 typedef struct replace_baton_t
313 {
314   /** name of the directory entry to modify */
315   const char *name;
316
317   /** directory entry to insert instead */
318   svn_fs_dirent_t *new_entry;
319
320   /** Current length of the in-txn in-disk representation of the directory.
321    * SVN_INVALID_FILESIZE if unknown. */
322   svn_filesize_t txn_filesize;
323 } replace_baton_t;
324
325 /**
326  * Implements #svn_cache__partial_setter_func_t for a single
327  * #svn_fs_dirent_t within a serialized directory contents hash,
328  * identified by its name in the #replace_baton_t in @a baton.
329  */
330 svn_error_t *
331 svn_fs_fs__replace_dir_entry(void **data,
332                              apr_size_t *data_len,
333                              void *baton,
334                              apr_pool_t *pool);
335
336 /**
337  * Implements #svn_cache__partial_setter_func_t for a #svn_fs_fs__dir_data_t
338  * at @a *data, resetting its txn_filesize field to SVN_INVALID_FILESIZE.
339  * &a baton should be NULL.
340  */
341 svn_error_t *
342 svn_fs_fs__reset_txn_filesize(void **data,
343                               apr_size_t *data_len,
344                               void *baton,
345                               apr_pool_t *pool);
346
347 /**
348  * Implements #svn_cache__serialize_func_t for a #svn_fs_fs__rep_header_t.
349  */
350 svn_error_t *
351 svn_fs_fs__serialize_rep_header(void **data,
352                                 apr_size_t *data_len,
353                                 void *in,
354                                 apr_pool_t *pool);
355
356 /**
357  * Implements #svn_cache__deserialize_func_t for a #svn_fs_fs__rep_header_t.
358  */
359 svn_error_t *
360 svn_fs_fs__deserialize_rep_header(void **out,
361                                   void *data,
362                                   apr_size_t data_len,
363                                   apr_pool_t *pool);
364
365 /*** Block of changes in a changed paths list. */
366 typedef struct svn_fs_fs__changes_list_t
367 {
368   /* Offset of the first element in CHANGES within the changed paths list
369      on disk. */
370   apr_off_t start_offset;
371
372   /* Offset of the first element behind CHANGES within the changed paths
373      list on disk. */
374   apr_off_t end_offset;
375
376   /* End of list reached? This may have false negatives in case the number
377      of elements in the list is a multiple of our block / range size. */
378   svn_boolean_t eol;
379
380   /* Array of #svn_fs_x__change_t * representing a consecutive sub-range of
381      elements in a changed paths list. */
382
383   /* number of entries in the array */
384   int count;
385
386   /* reference to the changes */
387   change_t **changes;
388
389 } svn_fs_fs__changes_list_t;
390
391 /**
392  * Implements #svn_cache__serialize_func_t for a #svn_fs_fs__changes_list_t.
393  */
394 svn_error_t *
395 svn_fs_fs__serialize_changes(void **data,
396                              apr_size_t *data_len,
397                              void *in,
398                              apr_pool_t *pool);
399
400 /**
401  * Implements #svn_cache__deserialize_func_t for a #svn_fs_fs__changes_list_t.
402  */
403 svn_error_t *
404 svn_fs_fs__deserialize_changes(void **out,
405                                void *data,
406                                apr_size_t data_len,
407                                apr_pool_t *pool);
408
409 /**
410  * Implements #svn_cache__serialize_func_t for #svn_mergeinfo_t objects.
411  */
412 svn_error_t *
413 svn_fs_fs__serialize_mergeinfo(void **data,
414                                apr_size_t *data_len,
415                                void *in,
416                                apr_pool_t *pool);
417
418 /**
419  * Implements #svn_cache__deserialize_func_t for #svn_mergeinfo_t objects.
420  */
421 svn_error_t *
422 svn_fs_fs__deserialize_mergeinfo(void **out,
423                                  void *data,
424                                  apr_size_t data_len,
425                                  apr_pool_t *pool);
426
427 #endif