1 5 package org.h2.index; 6 7 import java.sql.SQLException ; 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 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 { 35 } 37 38 public void add(Session session, Row row) throws SQLException { 39 throw Message.getUnsupportedException(); 40 } 41 42 public void remove(Session session, Row row) throws SQLException { 43 throw Message.getUnsupportedException(); 44 } 45 46 public Cursor find(Session session, SearchRow first, SearchRow last) throws SQLException { 47 ObjectArray rows = meta.generateRows(session, first, last); 48 return new MetaCursor(rows); 49 } 50 51 public int getCost(int[] masks) throws SQLException { 52 if(scan) { 53 return 10000; 54 } 55 return getCostRangeIndex(masks, 1000); 56 } 57 58 public void truncate(Session session) throws SQLException { 59 throw Message.getUnsupportedException(); 60 } 61 62 public void remove(Session session) throws SQLException { 63 throw Message.getUnsupportedException(); 64 } 65 66 public int getColumnIndex(Column col) { 67 if(scan) { 68 return -1; 70 } 71 return super.getColumnIndex(col); 72 } 73 74 public void checkRename() throws SQLException { 75 throw Message.getUnsupportedException(); 76 } 77 78 public boolean needRebuild() { 79 return false; 80 } 81 82 public String 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 { 91 throw Message.getUnsupportedException(); 92 } 93 94 } 95 | Popular Tags |