01: /*
02:
03: Derby - Class org.apache.derby.vti.IFastPath
04:
05: Licensed to the Apache Software Foundation (ASF) under one or more
06: contributor license agreements. See the NOTICE file distributed with
07: this work for additional information regarding copyright ownership.
08: The ASF licenses this file to You under the Apache License, Version 2.0
09: (the "License"); you may not use this file except in compliance with
10: the License. You may obtain a copy of the License at
11:
12: http://www.apache.org/licenses/LICENSE-2.0
13:
14: Unless required by applicable law or agreed to in writing, software
15: distributed under the License is distributed on an "AS IS" BASIS,
16: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: See the License for the specific language governing permissions and
18: limitations under the License.
19:
20: */
21:
22: package org.apache.derby.vti;
23:
24: import org.apache.derby.iapi.types.DataValueDescriptor;
25: import org.apache.derby.iapi.error.StandardException;
26: import java.sql.ResultSet;
27: import java.sql.SQLException;
28:
29: /**
30: An internal api for VTIs to allow VTI's written
31: in terms of the datatype system, e.g. returning rows.
32: This allows passing of data from the VTI into the
33: query engine without a conversion through a JDBC ResultSet.
34: */
35: public interface IFastPath {
36:
37: /**
38: Indicates nextRow() has completed its scan.
39: */
40: public int SCAN_COMPLETED = -1;
41: /**
42: Indicates nextRow() found a row..
43: */
44: public int GOT_ROW = 0;
45: /**
46: Indicates nextRow() has completed its scan but executeQuery must be called to
47: complete the query.
48: */
49: public int NEED_RS = 1;
50:
51: /**
52: Start a query.
53: Returns true if the VTI will start
54: out as a fast path query and thus rows will be returned
55: by nextRow().
56: Returns false if the engine must call the VTI's PreparedStatement.executeQuery()
57: method to execute as a regular ResultSet VTI.
58: */
59: public boolean executeAsFastPath() throws StandardException,
60: SQLException;
61:
62: /**
63: When operating in fast path mode return the next row into the passed in row parameter.
64: Returns GOT_ROW if a valid row is found.
65: Returns SCAN_COMPLETED if the scan is complete.
66: Returns NEED_RS if the rest of the query must be handled as a regular ResultSet VTI by
67: the engine calling the VTI's PreparedStatement.executeQuery()
68:
69: */
70: public int nextRow(DataValueDescriptor[] row)
71: throws StandardException, SQLException;
72:
73: /**
74: A call from the VTI execution layer back into the supplied VTI.
75: Presents the row just processed as an array of DataValueDescriptors.
76: This only called when the VTI is being executed as a regular ResultSet VTI
77: */
78: public void currentRow(ResultSet rs, DataValueDescriptor[] row)
79: throws StandardException, SQLException;
80:
81: /**
82: Called once the ResultSet returned by executeQuery() has emptied all of its
83: rows (next() has returned false).
84: */
85: public void rowsDone() throws StandardException, SQLException;
86: }
|