1 /*
2 Copyright (c) 2008 Health Market Science, Inc.
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with this library; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17 USA
18
19 You can contact Health Market Science at info@healthmarketscience.com
20 or at the following address:
21
22 Health Market Science
23 2700 Horizon Drive
24 Suite 200
25 King of Prussia, PA 19406
26 */
27
28 package com.healthmarketscience.jackcess;
29
30 import java.io.IOException;
31
32
33 /**
34 * Implementation of an Access table index which supports large indexes.
35 * @author James Ahlborn
36 */
37 public class BigIndex extends Index {
38
39 /** Cache which manages the index pages */
40 private final IndexPageCache _pageCache;
41
42 public BigIndex(Table table, int uniqueEntryCount,
43 int uniqueEntryCountOffset) {
44 super(table, uniqueEntryCount, uniqueEntryCountOffset);
45 _pageCache = new IndexPageCache(this);
46 }
47
48 @Override
49 protected void updateImpl() throws IOException {
50 _pageCache.write();
51 }
52
53 @Override
54 protected void readIndexEntries()
55 throws IOException
56 {
57 _pageCache.setRootPageNumber(getRootPageNumber());
58 }
59
60 @Override
61 protected DataPage findDataPage(Entry entry)
62 throws IOException
63 {
64 return _pageCache.findCacheDataPage(entry);
65 }
66
67 @Override
68 protected DataPage getDataPage(int pageNumber)
69 throws IOException
70 {
71 return _pageCache.getCacheDataPage(pageNumber);
72 }
73
74 @Override
75 public String toString() {
76 return super.toString() + "\n" + _pageCache.toString();
77 }
78
79 /**
80 * Used by unit tests to validate the internal status of the index.
81 */
82 void validate() throws IOException {
83 _pageCache.validate();
84 }
85
86 }