temp_serializer.h revision 299742
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 */
33const char*
34svn_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 */
41void
42svn_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 */
48void
49svn_fs_fs__noderev_deserialize(void *buffer,
50                               node_revision_t **noderev_p);
51
52
53/**
54 * Adds position information to the the raw window data in WINDOW.
55 */
56typedef 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} svn_fs_fs__raw_cached_window_t;
64
65/**
66 * Implements #svn_cache__serialize_func_t for
67 * #svn_fs_fs__raw_cached_window_t.
68 */
69svn_error_t *
70svn_fs_fs__serialize_raw_window(void **buffer,
71                                apr_size_t *buffer_size,
72                                void *item,
73                                apr_pool_t *pool);
74
75/**
76 * Implements #svn_cache__deserialize_func_t for
77 * #svn_fs_fs__raw_cached_window_t.
78 */
79svn_error_t *
80svn_fs_fs__deserialize_raw_window(void **item,
81                                  void *buffer,
82                                  apr_size_t buffer_size,
83                                  apr_pool_t *pool);
84
85/**
86 * #svn_txdelta_window_t is not sufficient for caching the data it
87 * represents because data read process needs auxiliary information.
88 */
89typedef struct
90{
91  /* the txdelta window information cached / to be cached */
92  svn_txdelta_window_t *window;
93
94  /* the revision file read pointer position right after reading the window */
95  apr_off_t end_offset;
96} svn_fs_fs__txdelta_cached_window_t;
97
98/**
99 * Implements #svn_cache__serialize_func_t for
100 * #svn_fs_fs__txdelta_cached_window_t.
101 */
102svn_error_t *
103svn_fs_fs__serialize_txdelta_window(void **buffer,
104                                    apr_size_t *buffer_size,
105                                    void *item,
106                                    apr_pool_t *pool);
107
108/**
109 * Implements #svn_cache__deserialize_func_t for
110 * #svn_fs_fs__txdelta_cached_window_t.
111 */
112svn_error_t *
113svn_fs_fs__deserialize_txdelta_window(void **item,
114                                      void *buffer,
115                                      apr_size_t buffer_size,
116                                      apr_pool_t *pool);
117
118/**
119 * Implements #svn_cache__serialize_func_t for a manifest
120 * (@a in is an #apr_array_header_t of apr_off_t elements).
121 */
122svn_error_t *
123svn_fs_fs__serialize_manifest(void **data,
124                              apr_size_t *data_len,
125                              void *in,
126                              apr_pool_t *pool);
127
128/**
129 * Implements #svn_cache__deserialize_func_t for a manifest
130 * (@a *out is an #apr_array_header_t of apr_off_t elements).
131 */
132svn_error_t *
133svn_fs_fs__deserialize_manifest(void **out,
134                                void *data,
135                                apr_size_t data_len,
136                                apr_pool_t *pool);
137
138/**
139 * Implements #svn_cache__serialize_func_t for a properties hash
140 * (@a in is an #apr_hash_t of svn_string_t elements, keyed by const char*).
141 */
142svn_error_t *
143svn_fs_fs__serialize_properties(void **data,
144                                apr_size_t *data_len,
145                                void *in,
146                                apr_pool_t *pool);
147
148/**
149 * Implements #svn_cache__deserialize_func_t for a properties hash
150 * (@a *out is an #apr_hash_t of svn_string_t elements, keyed by const char*).
151 */
152svn_error_t *
153svn_fs_fs__deserialize_properties(void **out,
154                                  void *data,
155                                  apr_size_t data_len,
156                                  apr_pool_t *pool);
157
158/**
159 * Implements #svn_cache__serialize_func_t for #svn_fs_id_t
160 */
161svn_error_t *
162svn_fs_fs__serialize_id(void **data,
163                        apr_size_t *data_len,
164                        void *in,
165                        apr_pool_t *pool);
166
167/**
168 * Implements #svn_cache__deserialize_func_t for #svn_fs_id_t
169 */
170svn_error_t *
171svn_fs_fs__deserialize_id(void **out,
172                          void *data,
173                          apr_size_t data_len,
174                          apr_pool_t *pool);
175
176/**
177 * Implements #svn_cache__serialize_func_t for #node_revision_t
178 */
179svn_error_t *
180svn_fs_fs__serialize_node_revision(void **buffer,
181                                   apr_size_t *buffer_size,
182                                   void *item,
183                                   apr_pool_t *pool);
184
185/**
186 * Implements #svn_cache__deserialize_func_t for #node_revision_t
187 */
188svn_error_t *
189svn_fs_fs__deserialize_node_revision(void **item,
190                                     void *buffer,
191                                     apr_size_t buffer_size,
192                                     apr_pool_t *pool);
193
194/**
195 * Implements #svn_cache__serialize_func_t for a directory contents array
196 */
197svn_error_t *
198svn_fs_fs__serialize_dir_entries(void **data,
199                                 apr_size_t *data_len,
200                                 void *in,
201                                 apr_pool_t *pool);
202
203/**
204 * Implements #svn_cache__deserialize_func_t for a directory contents array
205 */
206svn_error_t *
207svn_fs_fs__deserialize_dir_entries(void **out,
208                                   void *data,
209                                   apr_size_t data_len,
210                                   apr_pool_t *pool);
211
212/**
213 * Implements #svn_cache__partial_getter_func_t.  Set (apr_off_t) @a *out
214 * to the element indexed by (apr_int64_t) @a *baton within the
215 * serialized manifest array @a data and @a data_len. */
216svn_error_t *
217svn_fs_fs__get_sharded_offset(void **out,
218                              const void *data,
219                              apr_size_t data_len,
220                              void *baton,
221                              apr_pool_t *pool);
222
223/**
224 * Implements #svn_cache__partial_getter_func_t for a single
225 * #svn_fs_dirent_t within a serialized directory contents hash,
226 * identified by its name (const char @a *baton).
227 */
228svn_error_t *
229svn_fs_fs__extract_dir_entry(void **out,
230                             const void *data,
231                             apr_size_t data_len,
232                             void *baton,
233                             apr_pool_t *pool);
234
235/**
236 * Describes the change to be done to a directory: Set the entry
237 * identify by @a name to the value @a new_entry. If the latter is
238 * @c NULL, the entry shall be removed if it exists. Otherwise it
239 * will be replaced or automatically added, respectively.
240 */
241typedef struct replace_baton_t
242{
243  /** name of the directory entry to modify */
244  const char *name;
245
246  /** directory entry to insert instead */
247  svn_fs_dirent_t *new_entry;
248} replace_baton_t;
249
250/**
251 * Implements #svn_cache__partial_setter_func_t for a single
252 * #svn_fs_dirent_t within a serialized directory contents hash,
253 * identified by its name in the #replace_baton_t in @a baton.
254 */
255svn_error_t *
256svn_fs_fs__replace_dir_entry(void **data,
257                             apr_size_t *data_len,
258                             void *baton,
259                             apr_pool_t *pool);
260
261/**
262 * Implements #svn_cache__serialize_func_t for a #svn_fs_fs__rep_header_t.
263 */
264svn_error_t *
265svn_fs_fs__serialize_rep_header(void **data,
266                                apr_size_t *data_len,
267                                void *in,
268                                apr_pool_t *pool);
269
270/**
271 * Implements #svn_cache__deserialize_func_t for a #svn_fs_fs__rep_header_t.
272 */
273svn_error_t *
274svn_fs_fs__deserialize_rep_header(void **out,
275                                  void *data,
276                                  apr_size_t data_len,
277                                  apr_pool_t *pool);
278
279/**
280 * Implements #svn_cache__serialize_func_t for an #apr_array_header_t of
281 * #change_t *.
282 */
283svn_error_t *
284svn_fs_fs__serialize_changes(void **data,
285                             apr_size_t *data_len,
286                             void *in,
287                             apr_pool_t *pool);
288
289/**
290 * Implements #svn_cache__deserialize_func_t for an #apr_array_header_t of
291 * #change_t *.
292 */
293svn_error_t *
294svn_fs_fs__deserialize_changes(void **out,
295                               void *data,
296                               apr_size_t data_len,
297                               apr_pool_t *pool);
298
299/**
300 * Implements #svn_cache__serialize_func_t for #svn_mergeinfo_t objects.
301 */
302svn_error_t *
303svn_fs_fs__serialize_mergeinfo(void **data,
304                               apr_size_t *data_len,
305                               void *in,
306                               apr_pool_t *pool);
307
308/**
309 * Implements #svn_cache__deserialize_func_t for #svn_mergeinfo_t objects.
310 */
311svn_error_t *
312svn_fs_fs__deserialize_mergeinfo(void **out,
313                                 void *data,
314                                 apr_size_t data_len,
315                                 apr_pool_t *pool);
316
317#endif
318