]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - contrib/subversion/subversion/libsvn_fs_x/changes.h
MFC r275385 (by bapt):
[FreeBSD/stable/10.git] / contrib / subversion / subversion / libsvn_fs_x / changes.h
1 /* changes.h --- FSX changed paths lists container
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__CHANGES_H
24 #define SVN_LIBSVN_FS__CHANGES_H
25
26 #include "svn_io.h"
27 #include "fs.h"
28
29 /* Entries in a revision's change list tend to be widely redundant (similar
30  * changes to similar paths).  Even more so, change lists from a larger
31  * revision range also tend to overlap.
32  *
33  * In its serialized form, the svn_fs_x__changes_t container extracts most
34  * of that redundancy and the run-time representation is also much smaller
35  * than sum of the respective svn_fs_x__change_t* arrays.
36  *
37  * As with other containers, this one has two modes: 'construction', in
38  * which you may add data to it, and 'getter' in which there is only r/o
39  * access to the data.
40  */
41
42 /* An opaque collection of change lists (apr_array_header_t * of
43  * svn_fs_x__change_t *).
44  */
45 typedef struct svn_fs_x__changes_t svn_fs_x__changes_t;
46
47 /* Create and populate changes containers. */
48
49 /* Create and return a new changes container with an initial capacity of
50  * INITIAL_COUNT svn_fs_x__change_t objects.
51  * Allocate the result in RESULT_POOL.
52  */
53 svn_fs_x__changes_t *
54 svn_fs_x__changes_create(apr_size_t initial_count,
55                          apr_pool_t *result_pool);
56
57 /* Start a new change list CHANGES (implicitly terminating the previous one)
58  * and return its index in *LIST_INDEX.  Append all changes from LIST to
59  * that new change list.
60  */
61 svn_error_t *
62 svn_fs_x__changes_append_list(apr_size_t *list_index,
63                               svn_fs_x__changes_t *changes,
64                               apr_array_header_t *list);
65
66 /* Return a rough estimate in bytes for the serialized representation
67  * of CHANGES.
68  */
69 apr_size_t
70 svn_fs_x__changes_estimate_size(const svn_fs_x__changes_t *changes);
71
72 /* Read changes containers. */
73
74 /* From CHANGES, extract the change list with the given IDX.  Allocate
75  * the result in POOL and return it in *LIST.
76  */
77 svn_error_t *
78 svn_fs_x__changes_get_list(apr_array_header_t **list,
79                            const svn_fs_x__changes_t *changes,
80                            apr_size_t idx,
81                            apr_pool_t *pool);
82
83 /* I/O interface. */
84
85 /* Write a serialized representation of CHANGES to STREAM.
86  * Use SCRATCH_POOL for temporary allocations.
87  */
88 svn_error_t *
89 svn_fs_x__write_changes_container(svn_stream_t *stream,
90                                   const svn_fs_x__changes_t *changes,
91                                   apr_pool_t *scratch_pool);
92
93 /* Read a changes container from its serialized representation in STREAM.
94  * Allocate the result in RESULT_POOL and return it in *CHANGES_P.  Use
95  * SCRATCH_POOL for temporary allocations.
96  */
97 svn_error_t *
98 svn_fs_x__read_changes_container(svn_fs_x__changes_t **changes_p,
99                                  svn_stream_t *stream,
100                                  apr_pool_t *result_pool,
101                                  apr_pool_t *scratch_pool);
102
103 /* Implements #svn_cache__serialize_func_t for svn_fs_x__changes_t objects.
104  */
105 svn_error_t *
106 svn_fs_x__serialize_changes_container(void **data,
107                                       apr_size_t *data_len,
108                                       void *in,
109                                       apr_pool_t *pool);
110
111 /* Implements #svn_cache__deserialize_func_t for svn_fs_x__changes_t objects.
112  */
113 svn_error_t *
114 svn_fs_x__deserialize_changes_container(void **out,
115                                         void *data,
116                                         apr_size_t data_len,
117                                         apr_pool_t *pool);
118
119 /* Implements svn_cache__partial_getter_func_t for svn_fs_x__changes_t,
120  * setting *OUT to the change list (apr_array_header_t *) selected by
121  * the apr_uint32_t index passed in as *BATON.  This function is similar
122  * to svn_fs_x__changes_get_list but operates on the cache serialized
123  * representation of the container.
124  */
125 svn_error_t *
126 svn_fs_x__changes_get_list_func(void **out,
127                                 const void *data,
128                                 apr_size_t data_len,
129                                 void *baton,
130                                 apr_pool_t *pool);
131
132 #endif