1 /* noderevs.h --- FSX node revision 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_X_NODEREVS_H 24 #define SVN_LIBSVN_FS_X_NODEREVS_H 25 26 #include "svn_io.h" 27 #include "fs.h" 28 29 /* A collection of related noderevs tends to be widely redundant (similar 30 * paths, predecessor ID matching anothers ID, shared representations etc.) 31 * Also, the binary representation of a noderev can be much shorter than 32 * the ordinary textual variant. 33 * 34 * In its serialized form, the svn_fs_x__noderevs_t container extracts 35 * most of that redundancy and the run-time representation is also much 36 * smaller than sum of the respective svn_fs_x__noderev_t objects. 37 * 38 * As with other containers, this one has two modes: 'construction', in 39 * which you may add data to it, and 'getter' in which there is only r/o 40 * access to the data. 41 */ 42 43 /* An opaque collection of node revisions. 44 */ 45 typedef struct svn_fs_x__noderevs_t svn_fs_x__noderevs_t; 46 47 /* Create and populate noderev containers. */ 48 49 /* Create and return a new noderevs container with an initial capacity of 50 * INITIAL_COUNT svn_fs_x__noderev_t objects. 51 * Allocate the result in RESULT_POOL. 52 */ 53 svn_fs_x__noderevs_t * 54 svn_fs_x__noderevs_create(int initial_count, 55 apr_pool_t *result_pool); 56 57 /* Add NODEREV to the CONTAINER. Return the index that identifies the new 58 * item in this container. 59 */ 60 apr_size_t 61 svn_fs_x__noderevs_add(svn_fs_x__noderevs_t *container, 62 svn_fs_x__noderev_t *noderev); 63 64 /* Return a rough estimate in bytes for the serialized representation 65 * of CONTAINER. 66 */ 67 apr_size_t 68 svn_fs_x__noderevs_estimate_size(const svn_fs_x__noderevs_t *container); 69 70 /* Read from noderev containers. */ 71 72 /* From CONTAINER, extract the noderev with the given IDX. Allocate 73 * the result in POOL and return it in *NODEREV_P. 74 */ 75 svn_error_t * 76 svn_fs_x__noderevs_get(svn_fs_x__noderev_t **noderev_p, 77 const svn_fs_x__noderevs_t *container, 78 apr_size_t idx, 79 apr_pool_t *result_pool); 80 81 /* I/O interface. */ 82 83 /* Write a serialized representation of CONTAINER to STREAM. 84 * Use SCRATCH_POOL for temporary allocations. 85 */ 86 svn_error_t * 87 svn_fs_x__write_noderevs_container(svn_stream_t *stream, 88 const svn_fs_x__noderevs_t *container, 89 apr_pool_t *scratch_pool); 90 91 /* Read a noderev container from its serialized representation in STREAM. 92 * Allocate the result in RESULT_POOL and return it in *CONTAINER. Use 93 * SCRATCH_POOL for temporary allocations. 94 */ 95 svn_error_t * 96 svn_fs_x__read_noderevs_container(svn_fs_x__noderevs_t **container, 97 svn_stream_t *stream, 98 apr_pool_t *result_pool, 99 apr_pool_t *scratch_pool); 100 101 /* Implements #svn_cache__serialize_func_t for svn_fs_x__noderevs_t 102 * objects. 103 */ 104 svn_error_t * 105 svn_fs_x__serialize_noderevs_container(void **data, 106 apr_size_t *data_len, 107 void *in, 108 apr_pool_t *pool); 109 110 /* Implements #svn_cache__deserialize_func_t for svn_fs_x__noderevs_t 111 * objects. 112 */ 113 svn_error_t * 114 svn_fs_x__deserialize_noderevs_container(void **out, 115 void *data, 116 apr_size_t data_len, 117 apr_pool_t *result_pool); 118 119 /* Implements svn_cache__partial_getter_func_t for svn_fs_x__noderevs_t, 120 * setting *OUT to the svn_fs_x__noderev_t selected by the apr_uint32_t index 121 * passed in as *BATON. This function is similar to svn_fs_x__noderevs_get 122 * but operates on the cache serialized representation of the container. 123 */ 124 svn_error_t * 125 svn_fs_x__noderevs_get_func(void **out, 126 const void *data, 127 apr_size_t data_len, 128 void *baton, 129 apr_pool_t *pool); 130 131 /* Implements svn_cache__partial_getter_func_t for the mergeinfo_count in 132 * the stored noderevs, setting *OUT to the apr_int64_t counter value of 133 * the noderev selected by the apr_uint32_t index passed in as *BATON. 134 */ 135 svn_error_t * 136 svn_fs_x__mergeinfo_count_get_func(void **out, 137 const void *data, 138 apr_size_t data_len, 139 void *baton, 140 apr_pool_t *pool); 141 142 #endif 143