01: /*
02: * Copyright 2004-2008 H2 Group. Licensed under the H2 License, Version 1.0
03: * (http://h2database.com/html/license.html).
04: * Initial Developer: H2 Group
05: */
06: package org.h2.index;
07:
08: import java.sql.SQLException;
09:
10: import org.h2.engine.Session;
11: import org.h2.expression.FunctionCall;
12: import org.h2.message.Message;
13: import org.h2.result.LocalResult;
14: import org.h2.result.Row;
15: import org.h2.result.SearchRow;
16: import org.h2.table.FunctionTable;
17: import org.h2.table.IndexColumn;
18:
19: /**
20: * An index for a function that returns a result set. This index can only scan
21: * through all rows, search is not supported.
22: */
23: public class FunctionIndex extends BaseIndex {
24:
25: private FunctionTable functionTable;
26: private LocalResult result;
27:
28: public FunctionIndex(FunctionTable functionTable,
29: IndexColumn[] columns, FunctionCall function) {
30: super (functionTable, 0, null, columns, IndexType
31: .createNonUnique(true));
32: this .functionTable = functionTable;
33: }
34:
35: public void close(Session session) throws SQLException {
36: }
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)
47: throws SQLException {
48: // TODO sometimes result.reset() would be enough (but not when
49: // parameters are used)
50: result = functionTable.getResult(session);
51: return new FunctionCursor(result);
52: }
53:
54: public double getCost(Session session, int[] masks)
55: throws SQLException {
56: if (masks != null) {
57: throw Message.getUnsupportedException();
58: }
59: return Integer.MAX_VALUE;
60: // return functionTable.getRowCount(session) * 10;
61: }
62:
63: public void remove(Session session) throws SQLException {
64: throw Message.getUnsupportedException();
65: }
66:
67: public void truncate(Session session) throws SQLException {
68: throw Message.getUnsupportedException();
69: }
70:
71: public boolean needRebuild() {
72: return false;
73: }
74:
75: public void checkRename() throws SQLException {
76: throw Message.getUnsupportedException();
77: }
78:
79: public boolean canGetFirstOrLast() {
80: return false;
81: }
82:
83: public SearchRow findFirstOrLast(Session session, boolean first)
84: throws SQLException {
85: throw Message.getUnsupportedException();
86: }
87:
88: }
|