1 /*=========================================================================== 2 * 3 * PUBLIC DOMAIN NOTICE 4 * National Center for Biotechnology Information 5 * 6 * This software/database is a "United States Government Work" under the 7 * terms of the United States Copyright Act. It was written as part of 8 * the author's official duties as a United States Government employee and 9 * thus cannot be copyrighted. This software/database is freely available 10 * to the public for use. The National Library of Medicine and the U.S. 11 * Government have not placed any restriction on its use or reproduction. 12 * 13 * Although all reasonable efforts have been taken to ensure the accuracy 14 * and reliability of the software and data, the NLM and the U.S. 15 * Government do not and cannot warrant the performance or results that 16 * may be obtained by using this software or data. The NLM and the U.S. 17 * Government disclaim all warranties, express or implied, including 18 * warranties of performance, merchantability or fitness for any particular 19 * purpose. 20 * 21 * Please cite the author in any work or product based on this material. 22 * 23 * =========================================================================== 24 * 25 */ 26 27 #ifndef _h_colidx_priv_ 28 #define _h_colidx_priv_ 29 30 #ifndef _h_kfs_directory_ 31 #include <kfs/directory.h> 32 #endif 33 34 #include <kfs/md5.h> 35 36 #ifndef _h_colfmt_priv_ 37 #include "colfmt-priv.h" 38 #endif 39 40 #ifndef _h_colidx0_priv_ 41 #include "wcolidx0-priv.h" 42 #endif 43 44 #ifndef _h_colidx1_priv_ 45 #include "wcolidx1-priv.h" 46 #endif 47 48 #ifndef _h_colidx2_priv_ 49 #include "wcolidx2-priv.h" 50 #endif 51 52 #ifdef __cplusplus 53 extern "C" { 54 #endif 55 56 57 /*-------------------------------------------------------------------------- 58 * forwards 59 */ 60 struct KMD5SumFmt; 61 62 63 /*-------------------------------------------------------------------------- 64 * KColumnIdx 65 * the index fork 66 */ 67 typedef struct KColumnIdx KColumnIdx; 68 struct KColumnIdx 69 { 70 /* first active id within db 71 and first id on upper limit 72 i.e. outside of db such that 73 id_upper - id_first == num_ids */ 74 int64_t id_first; 75 int64_t id_upper; 76 77 /* struct KFile * f; */ 78 uint32_t vers; 79 80 /* level 0 index */ 81 KColumnIdx0 idx0; 82 83 /* level 1 index */ 84 KColumnIdx1 idx1; 85 86 /* level 2 index */ 87 KColumnIdx2 idx2; 88 89 /* commit counter */ 90 uint32_t commit_count; 91 }; 92 93 /* Create 94 */ 95 rc_t KColumnIdxCreate ( KColumnIdx *self, 96 KDirectory *dir, struct KMD5SumFmt *md5, KCreateMode mode, 97 uint64_t *data_eof, size_t pgsize, int32_t checksum ); 98 99 /* Open 100 */ 101 rc_t KColumnIdxOpenRead ( KColumnIdx *self, const KDirectory *dir, 102 uint64_t *data_eof, size_t *pgsize, 103 int32_t *checksum ); 104 rc_t KColumnIdxOpenUpdate ( KColumnIdx *self, KDirectory *dir, 105 KMD5SumFmt *md5, uint64_t *data_eof, size_t *pgsize, 106 int32_t *checksum ); 107 108 /* Whack 109 */ 110 rc_t KColumnIdxWhack ( KColumnIdx *self, 111 uint64_t data_eof, size_t pgsize, int32_t checksum ); 112 113 /* Version 114 */ 115 rc_t KColumnIdxVersion ( const KColumnIdx *self, uint32_t *version ); 116 #define KColumnIdxVersion( self, version ) \ 117 KColumnIdx1Version ( & ( self ) -> idx1, version ) 118 119 /* ByteOrder 120 */ 121 rc_t KColumnIdxByteOrder ( const KColumnIdx *self, bool *reversed ); 122 #define KColumnIdxByteOrder( self, reversed ) \ 123 KColumnIdx1ByteOrder ( & ( self ) -> idx1, reversed ) 124 125 /* IdRange 126 * returns range of ids contained within 127 */ 128 rc_t KColumnIdxIdRange ( const KColumnIdx *self, 129 int64_t *first, int64_t *last ); 130 131 /* FindFirstRowId 132 */ 133 rc_t KColumnIdxFindFirstRowId ( const KColumnIdx * self, 134 int64_t * found, int64_t start ); 135 136 /* LocateBlob 137 * locate an existing blob 138 */ 139 rc_t KColumnIdxLocateBlob ( const KColumnIdx *self, 140 KColBlobLoc *loc, int64_t first, int64_t last ); 141 142 /* Commit 143 * writes a new blob location to idx0 144 * updates idx1 with header information 145 * this should be the final step in committing a write operation 146 */ 147 rc_t KColumnIdxCommit ( KColumnIdx *self, struct KMD5SumFmt *md5, 148 const KColBlobLoc *loc, uint32_t commit_freq, 149 uint64_t data_eof, size_t pgsize, int32_t checksum ); 150 151 /* CommitDone 152 * finalizes a commit 153 */ 154 rc_t KColumnIdxCommitDone ( KColumnIdx * self ); 155 156 /* Reindex 157 */ 158 rc_t KColumnIdxReindex ( KColumnIdx *self, struct KMD5SumFmt *md5, 159 uint32_t commit_freq, uint64_t data_eof, size_t pgsize, int32_t checksum ); 160 161 162 #ifdef __cplusplus 163 } 164 #endif 165 166 #endif /* _h_colidx_priv_ */ 167