001: /*
002:
003: Derby - Class org.apache.derby.iapi.sql.execute.ExecutionFactory
004:
005: Licensed to the Apache Software Foundation (ASF) under one or more
006: contributor license agreements. See the NOTICE file distributed with
007: this work for additional information regarding copyright ownership.
008: The ASF licenses this file to you under the Apache License, Version 2.0
009: (the "License"); you may not use this file except in compliance with
010: the License. You may obtain a copy of the License at
011:
012: http://www.apache.org/licenses/LICENSE-2.0
013:
014: Unless required by applicable law or agreed to in writing, software
015: distributed under the License is distributed on an "AS IS" BASIS,
016: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: See the License for the specific language governing permissions and
018: limitations under the License.
019:
020: */
021:
022: package org.apache.derby.iapi.sql.execute;
023:
024: import org.apache.derby.iapi.sql.Activation;
025:
026: import org.apache.derby.iapi.error.StandardException;
027: import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
028: import org.apache.derby.iapi.sql.Activation;
029: import org.apache.derby.iapi.sql.ResultColumnDescriptor;
030: import org.apache.derby.iapi.sql.ResultDescription;
031:
032: import org.apache.derby.iapi.store.access.DynamicCompiledOpenConglomInfo;
033: import org.apache.derby.iapi.store.access.Qualifier;
034: import org.apache.derby.iapi.sql.dictionary.IndexRowGenerator;
035: import org.apache.derby.iapi.store.access.StaticCompiledOpenConglomInfo;
036: import org.apache.derby.iapi.store.access.TransactionController;
037: import java.util.Properties;
038: import org.apache.derby.iapi.services.io.FormatableBitSet;
039:
040: import org.apache.derby.iapi.services.loader.GeneratedMethod;
041: import org.apache.derby.iapi.services.context.ContextManager;
042:
043: import org.apache.derby.catalog.TypeDescriptor;
044: import org.apache.derby.catalog.UUID;
045:
046: /**
047: This is the factory for creating a factories needed by
048: execution per connection, and the context to hold them.
049: <p>
050: There is expected to be one of these configured per database.
051: <p>
052: If a factory is needed outside of execution (say,
053: data dictionary or compilation), then it belongs in the
054: LanguageConnectionContext.
055:
056: @see org.apache.derby.iapi.sql.conn.LanguageConnectionContext
057: @author ames
058: */
059: public interface ExecutionFactory {
060:
061: /**
062: Module name for the monitor's module locating system.
063: */
064: String MODULE = "org.apache.derby.iapi.sql.execute.ExecutionFactory";
065:
066: /**
067: Only one result set factory is needed for a database
068: in the system.
069: We require that an execution factory be configured for
070: each database. Each execution factory then needs to
071: know about the result set factory it is maintaining
072: for its database, so that it can provide it through
073: calls to this method.
074: So, we reuse the result set factory by making it
075: available to each connection
076: in that connection's execution context.
077:
078: @return the result set factory for this database.
079: */
080: ResultSetFactory getResultSetFactory();
081:
082: /**
083: We want an execution context so that we can push it onto
084: the stack. We could instead require the implementation
085: push it onto the stack for us, but this way we know
086: which context object exactly was pushed onto the stack.
087:
088: @param cm the context manager
089: */
090: ExecutionContext newExecutionContext(ContextManager cm);
091:
092: /**
093: * Create an execution time ResultColumnDescriptor from a
094: * compile time RCD.
095: *
096: * @param compileRCD The compile time RCD.
097: *
098: * @return The execution time ResultColumnDescriptor
099: */
100: ResultColumnDescriptor getResultColumnDescriptor(
101: ResultColumnDescriptor compileRCD);
102:
103: /**
104: * Create a result description given parameters for it.
105: */
106: ResultDescription getResultDescription(
107: ResultColumnDescriptor[] columns, String statementType);
108:
109: /**
110: * Get an array of ScanQualifiers for a scan. ScanQualifiers are used
111: * with the DataDictionary.
112: *
113: * @param numQualifiers The number of ScanQualifiers to get.
114: */
115: ScanQualifier[][] getScanQualifier(int numQualifiers);
116:
117: /**
118: * Release a ScanQualifier[] (back to the pool or free it).
119: */
120:
121: void releaseScanQualifier(ScanQualifier[][] scanQualifiers);
122:
123: /**
124: * Get a Qualifier to use with a scan of a conglomerate.
125: *
126: * @param columnId The store id of the column to qualify
127: * @param operator One of Orderable.ORDER_OP_EQUALS,
128: * Orderable.ORDER_OP_LESSTHAN,
129: * or Orderable.ORDER_OP_LESSOREQUALS
130: * @param orderableGetter A generated method that returns the
131: * Orderable to be compared with the column
132: * @param activation The Activation that acts as the receiver for the
133: * generated method
134: * @param orderedNulls True means that null == null for the sake of
135: * this Qualifier
136: * @param unknownRV The value to return if the comparison between
137: * the column and the Orderable value returns the
138: * unknown truth value
139: * @param negateCompareResult True means to negate the result of the comparison.
140: * So, for example, to do a > comparison, you would
141: * pass ORDER_OP_LESSOREQUALS and set negate to true.
142: * @param variantType The variantType for the qualifier's orderable.
143: * (Determines whether or not to cache the value.)
144: *
145: * @return A new Qualifier
146: */
147: Qualifier getQualifier(int columnId, int operator,
148: GeneratedMethod orderableGetter, Activation activation,
149: boolean orderedNulls, boolean unknownRV,
150: boolean negateCompareResult, int variantType);
151:
152: /**
153: Create a new RowChanger for performing update and delete
154: operations based on full before and after rows.
155:
156: @param heapConglom Conglomerate # for the heap
157: @param heapSCOCI The SCOCI for the heap.
158: @param heapDCOCI The DCOCI for the heap.
159: @param irgs the IndexRowGenerators for the table's indexes. We use
160: positions in this array as local id's for indexes. To support updates,
161: only indexes that change need be included.
162: @param indexCIDS the conglomerateids for the table's idexes.
163: indexCIDS[ix] corresponds to the same index as irgs[ix].
164: @param indexSCOCIs the SCOCIs for the table's idexes.
165: indexSCOCIs[ix] corresponds to the same index as irgs[ix].
166: @param indexDCOCIs the DCOCIs for the table's idexes.
167: indexDCOCIs[ix] corresponds to the same index as irgs[ix].
168: @param numberOfColumns Number of columns in a full row.
169: @param tc the transaction controller
170: @param streamStorableHeapColIds Column ids of stream storable
171: columns. (0 based, Only needed for sync. null if none or
172: not needed).
173: @param activation The Activation.
174: @exception StandardException Thrown on error
175: */
176: public RowChanger getRowChanger(long heapConglom,
177: StaticCompiledOpenConglomInfo heapSCOCI,
178: DynamicCompiledOpenConglomInfo heapDCOCI,
179: IndexRowGenerator[] irgs, long[] indexCIDS,
180: StaticCompiledOpenConglomInfo[] indexSCOCIs,
181: DynamicCompiledOpenConglomInfo[] indexDCOCIs,
182: int numberOfColumns, TransactionController tc,
183: int[] changedColumnIds, int[] streamStorableHeapColIds,
184: Activation activation) throws StandardException;
185:
186: /**
187: Create a new RowChanger for doing insert update and delete
188: operations based on partial before and after.
189:
190: @param heapConglom Conglomerate # for the heap
191: @param heapSCOCI The SCOCI for the heap.
192: @param heapDCOCI The DCOCI for the heap.
193: @param irgs the IndexRowGenerators for the table's indexes. We use
194: positions in this array as local id's for indexes. To support updates,
195: only indexes that change need be included.
196: @param indexCIDS the conglomerateids for the table's idexes.
197: indexCIDS[ix] corresponds to the same index as irgs[ix].
198: @param indexSCOCIs the SCOCIs for the table's idexes.
199: indexSCOCIs[ix] corresponds to the same index as irgs[ix].
200: @param indexDCOCIs the DCOCIs for the table's idexes.
201: indexDCOCIs[ix] corresponds to the same index as irgs[ix].
202: @param numberOfColumns Number of columns in partial row.
203: @param tc the transaction controller
204: @param changedColumnIds array of 1 based ints of columns
205: to be updated. Used by update only.
206: @param baseRowReadList the columns in the base row that were
207: read (1 based)
208: @param baseRowReadMap baseRowReadMap[heapColId]->readRowColId
209: (0 based)
210: @param streamStorableColIds Column ids of stream storable
211: columns. (0 based, Only needed for sync. null if none or
212: not needed).
213: @param activation The Activation.
214:
215: @exception StandardException Thrown on error
216: */
217: public RowChanger getRowChanger(long heapConglom,
218: StaticCompiledOpenConglomInfo heapSCOCI,
219: DynamicCompiledOpenConglomInfo heapDCOCI,
220: IndexRowGenerator[] irgs, long[] indexCIDS,
221: StaticCompiledOpenConglomInfo[] indexSCOCIs,
222: DynamicCompiledOpenConglomInfo[] indexDCOCIs,
223: int numberOfColumns, TransactionController tc,
224: int[] changedColumnIds, FormatableBitSet baseRowReadList,
225: int[] baseRowReadMap, int[] streamStorableColIds,
226: Activation activation) throws StandardException;
227:
228: // Methods from old RowFactory interface
229: /**
230: This returns a new row that is storable but not indexable
231: */
232: public ExecRow getValueRow(int numColumns);
233:
234: /**
235: This returns an indexable row
236: */
237: public ExecIndexRow getIndexableRow(int numColumns);
238:
239: /**
240: This returns the value row as an indexable row
241: */
242: public ExecIndexRow getIndexableRow(ExecRow valueRow);
243:
244: /**
245: This returns the value row as an indexable row, reusing the passed
246: in ExecIndexRow if non-null.
247: */
248: //public ExecIndexRow getIndexableRow(ExecRow valueRow, ExecIndexRow sourceExecIndexRow);
249:
250: /**
251: Packages up a clump of constants which the Plugin uses at execute()
252: time for COPY PUBLICATION.
253: */
254: public Object getJdbcCopyConstants(int[][] paramReferences,
255: TypeDescriptor[][] columnTypes,
256: int[][] publishedTableSchemaCounts);
257:
258: /**
259: Packages up a clump of constants which the Plugin uses at execute()
260: time for CREATE PUBLICATION.
261: */
262: public Object getJdbcCreateConstants(UUID[] publishedJarFileIDs,
263: Object publishedItems, int[][] tableSchemaCounts);
264:
265: }
|