00001 /* 00002 00003 Copyright (c) 2002-2005, Yauheni Akhotnikau 00004 All rights reserved. 00005 00006 Redistribution and use in source and binary forms, with or without 00007 modification, are permitted provided that the following conditions are met: 00008 00009 - Redistributions of source code must retain the above copyright notice, this 00010 list of conditions and the following disclaimer. 00011 00012 - Redistributions in binary form must reproduce the above copyright notice, this 00013 list of conditions and the following disclaimer in the documentation and/or 00014 other materials provided with the distribution. 00015 00016 - The name of the author may not be used to endorse or promote products derived 00017 from this software without specific prior written permission. 00018 00019 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 00020 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00021 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 00022 EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00023 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 00024 OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00025 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00026 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 00027 IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 00028 OF SUCH DAMAGE. 00029 00030 */ 00031 00039 #if !defined( _OESS_1__DB__STORAGE__PAGE_INDEX_CALCULATOR_HPP_ ) 00040 #define _OESS_1__DB__STORAGE__PAGE_INDEX_CALCULATOR_HPP_ 00041 00042 #include <oess_1/defs/h/types.hpp> 00043 00044 #include <oess_1/db/h/declspec.hpp> 00045 00046 #include <oess_1/db/storage/h/chain_id.hpp> 00047 00048 namespace oess_1 { 00049 00050 namespace db { 00051 00052 namespace storage { 00053 00054 // 00055 // area_ordinal_t 00056 // 00057 00062 typedef oess_1::ushort_t area_ordinal_t; 00063 00064 // 00065 // segment_ordinal_t 00066 // 00067 00072 typedef oess_1::ushort_t segment_ordinal_t; 00073 00074 // 00075 // page_index_calculator_t 00076 // 00077 00088 class OESS_1__DB__TYPE page_index_calculator_t 00089 { 00090 public : 00092 page_index_calculator_t( 00094 oess_1::uint_t page_size, 00096 oess_1::uint_t chain_link_size ); 00097 00099 oess_1::uint_t 00100 common_header_page() const; 00101 00103 area_ordinal_t 00104 area_count() const; 00105 00107 segment_ordinal_t 00108 area_segment_count( 00109 const area_ordinal_t & area ) const; 00110 00112 oess_1::uint_t 00113 area_header_page( 00114 const area_ordinal_t & area ) const; 00115 00117 oess_1::uint_t 00118 segment_header_page( 00120 const area_ordinal_t & area, 00121 const segment_ordinal_t & segment ) const; 00122 00124 oess_1::uint_t 00125 segment_page_count() const; 00126 00128 oess_1::uint_t 00129 chain_link_on_page_count() const; 00130 00132 chain_id_t 00133 first_chain_link_on_page( 00135 oess_1::uint_t page_ordinal ) const; 00136 00138 area_ordinal_t 00139 chain_link_area( 00140 const chain_id_t & block ) const; 00141 00143 segment_ordinal_t 00144 chain_link_segment( 00145 const chain_id_t & block ) const; 00146 00148 oess_1::uint_t 00149 chain_link_page( 00150 const chain_id_t & block ) const; 00151 00153 oess_1::uint_t 00154 chain_link_page_offset( 00155 const chain_id_t & block ) const; 00156 00159 00162 chain_id_t 00163 first_chain_id() const; 00164 00165 private : 00167 oess_1::uint_t m_page_size; 00169 oess_1::uint_t m_chain_link_size; 00171 oess_1::uint_t m_page_chain_links; 00173 oess_1::uint_t m_areas; 00175 oess_1::uint_t m_area_segments; 00177 oess_1::uint_t m_last_area_segments; 00179 oess_1::uint_t m_area_pages; 00181 oess_1::uint_t m_segment_pages; 00182 }; 00183 00184 } /* namespace storage */ 00185 00186 } /* namespace db */ 00187 00188 } /* namespace oess_1 */ 00189 00190 #endif 00191