KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > h2 > index > MetaIndex


1 /*
2  * Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
3  * Initial Developer: H2 Group
4  */

5 package org.h2.index;
6
7 import java.sql.SQLException JavaDoc;
8
9 import org.h2.engine.Session;
10 import org.h2.message.Message;
11 import org.h2.result.Row;
12 import org.h2.result.SearchRow;
13 import org.h2.table.Column;
14 import org.h2.table.MetaTable;
15 import org.h2.util.ObjectArray;
16 import org.h2.value.Value;
17
18
19 /**
20  * @author Thomas
21  */

22
23 public class MetaIndex extends Index {
24
25     private MetaTable meta;
26     private boolean scan;
27     
28     public MetaIndex(MetaTable meta, Column[] columns, boolean scan) {
29         super(meta, 0, null, columns, IndexType.createNonUnique(true));
30         this.meta = meta;
31         this.scan = scan;
32     }
33     
34     public void close(Session session) throws SQLException JavaDoc {
35         // nothing to do
36
}
37
38     public void add(Session session, Row row) throws SQLException JavaDoc {
39         throw Message.getUnsupportedException();
40     }
41
42     public void remove(Session session, Row row) throws SQLException JavaDoc {
43         throw Message.getUnsupportedException();
44     }
45
46     public Cursor find(Session session, SearchRow first, SearchRow last) throws SQLException JavaDoc {
47         ObjectArray rows = meta.generateRows(session, first, last);
48         return new MetaCursor(rows);
49     }
50     
51     public int getCost(int[] masks) throws SQLException JavaDoc {
52         if(scan) {
53             return 10000;
54         }
55         return getCostRangeIndex(masks, 1000);
56     }
57
58     public void truncate(Session session) throws SQLException JavaDoc {
59         throw Message.getUnsupportedException();
60     }
61
62     public void remove(Session session) throws SQLException JavaDoc {
63         throw Message.getUnsupportedException();
64     }
65
66     public int getColumnIndex(Column col) {
67         if(scan) {
68             // the scan index cannot use any columns
69
return -1;
70         }
71         return super.getColumnIndex(col);
72     }
73
74     public void checkRename() throws SQLException JavaDoc {
75         throw Message.getUnsupportedException();
76     }
77
78     public boolean needRebuild() {
79         return false;
80     }
81     
82     public String JavaDoc getCreateSQL() {
83         return null;
84     }
85
86     public boolean canGetFirstOrLast(boolean first) {
87         return false;
88     }
89
90     public Value findFirstOrLast(Session session, boolean first) throws SQLException JavaDoc {
91         throw Message.getUnsupportedException();
92     }
93     
94 }
95
Popular Tags