Oracle9i Data Cartridge Developer's Guide Release 2 (9.2) Part Number A96595-01 |
|
This chapter describes Java language ODCI (Oracle Data Cartridge Interface) Extensible Indexing Interfaces. For more complete details on Java functionality, refer to the Oracle9i Supplied Java Packages Reference.
The following interfaces are described:
ODCIGetInterfaces(ifclist OUT ODCIObjectList) RETURN NUMBER
The ODCIGetInterfaces
function is invoked when an INDEXTYPE
is created by a CREATE
INDEXTYPE...
statement or is altered.
Argument | Meaning |
---|---|
ifclist |
Contains information about the interfaces it supports |
This function should be implemented as a static type method.
This function must return 'SYS.ODCIINDEX2'
in the ODCIObjectList
if the indextype uses the second version of the ODCIIndex
interface, that is, the version described in this book.
In existing code that uses the previous, Oracle8i version of the ODCIIndex
interface, this function was required to return 'SYS.ODCIINDEX1'
to specify the Oracle8i version of the interface. That code will still work. To continue to use the Oracle8i interface, continue to have this function return 'SYS.ODCIINDEX1'
, and do not implement Oracle9i versions of any of the routines.
ODCIIndexAlter(ia ODCIIndexInfo, parms IN OUT VARCHAR2, alter_option NUMBER, env ODCIEnv) RETURN NUMBER
This method is invoked when a domain index or a domain index partition is altered using an ALTER INDEX
or an ALTER INDEX PARTITION
statement.
ODCIConst.Success
on success, or ODCIConst.Error
on error, or ODCIConst.Warning
.
ALTER
INDEX
statement can be invoked for domain indexes in multiple ways.
ALTER INDEX index_name PARAMETERS (parms);
or
ALTER INDEX index_name REBUILD PARAMETERS (parms);
The precise behavior in these two cases is defined by the implementor. One possibility is that the first statement would merely reorganize the index based on the parameters while the second would rebuild it from scratch.
OUT
value of the parms
argument can be set to resultant parameters string to be stored in the system catalogs.ALTER
INDEX
statement can also be used to rename a domain index in the following way:
ALTER INDEX index_name RENAME TO new_index_name
In this case, the new name of the domain index is passed to the parms
argument.
PARALLEL
clause is omitted, then the domain index or local domain index partition is rebuilt sequentially.PARALLEL
clause is specified, the parallel degree is passed to the ODCIIndexAlter
invocation in the IndexParaDegree
attribute of ODCIIndexInfo
, and the Parallel
bit of the IndexInfoFlags
attribute is set. The parallel degree is determined as follows:
ODCIIndexAlter
routine returns with the ODCIConst
.Success
, the index is valid and usable. If the ODCIIndexAlter
routine returns with ODCIConst
.Warning
, the index is valid and usable but a warning message is returned to the user. If ODCIIndexAlter
returns with an error (or exception), the domain index will be marked FAILED
.ODCIIndexAlter
routine is being executed, the domain index is marked LOADING
.AlterIndexUpdBlockRefs
alter option applies only to domain indexes on index-organized tables. When the end user executes an ALTER INDEX
<domain_index> UPDATE BLOCK REFERENCES
, ODCIIndexAlter
is called with the AlterIndexUpdBlockRefs
bit set to give the cartridge developer the opportunity to update guesses as to the block locations of rows, stored in logical rowids.ODCIIndexClose(self IN <impltype>, env ODCIEnv) RETURN NUMBER
This method is invoked to end the processing of an operator.
Argument | Meaning |
---|---|
self(IN) |
Is the value of the context returned by the previous invocation of |
env |
The environment handle passed to the routine |
ODCIIndexCreate(ia ODCIIndexInfo, parms VARCHAR2, env ODCIEnv) RETURN NUMBER
The ODCIIndexCreate
method is invoked when a domain index is created by a CREATE INDEX...INDEXTYPE IS...PARAMETERS...
statement issued by the user. The domain index that is created can be a non-partitioned index or a local partitioned domain index.
ODCIConst.Success
on successODCIConst.Error
on errorODCIConst.Warning
ODCIConst.ErrContinue
if the method is invoked at the partition level for creation of a local partitioned index, to continue to the next partition even in case of an errorODCIConst.Fatal
to signify that all dictionary entries for the index are cleaned up and that the CREATE INDEX
operation is rolled back. Returning this status code assumes that the cartridge code has not created any objects (or cleaned up any objects created).ODCIIndexCreate
routine should create objects (such as tables) to store the index data, generate the index data, and store the data in the index data tables.ODCIIndexCreate
procedure should handle creation of indexes on both empty and non-empty tables. If the base table is not empty, the ODCIIndexCreate
procedure can scan the entire table and generate index data.ODCIIndexCreate
is treated as an independent operation. The changes made by ODCIIndexCreate
are not guaranteed to be atomic.ODCIIndexCreate
invocation in the IndexParaDegree
attribute of ODCIIndexInfo
, and the Parallel
bit of the IndexInfoFlags
is set. The parallel degree is determined as follows:
ODCIIndexCreate
routine is being executed, the domain index is marked LOADING
.ODCIIndexCreate
routine returns with the ODCIConst
.Success
, the index is valid and usable. If the ODCIIndexCreate
routine returns with ODCIConst
.Warning
, the index is valid and usable but a warning message is returned to the user. If the ODCIIndexCreate
routine returns with an ODCIConst
.Error
(or exception), the domain index will be marked FAILED.
FAILED
domain indexes is DROP
INDEX
, TRUNCATE
TABLE
or ALTER
INDEX
REBUILD
.REF
attribute, do not dereference the REF
s while building your index. Dereferencing a REF
fetches data from a different table instance. If the data in the other table is modified, you will not be notified and your domain index will become incorrect.ODCIIndexCreate
method is invoked once, and the only valid return codes are ODCIConstSuccess
, ODCIConstWarning
or ODCIConstError
. The IndexPartition
and TablePartition
name are NULL
and callProperty
is also NULL
.
To create a local partitioned domain index, the ODCIIndexCreate
method is invoked N+2
times, where N is the number of local index partitions. The first and the final call handle operations on the top-level index object, and the intermediate N calls handle partition-level objects. In the first call, a table to hold the index level metadata can be created. In the intermediate calls, independent tables to hold partition level data can be created and populated, and in the last call, indexes can be built on the index metadata tables and so forth.
For local partitioned domain indexes, the first and the last call can return ODCIConstSuccess
, ODCIConstWarning
or ODCIConstError
. The intermediate N calls can return ODCIConstSuccess
, ODCIConstWarning
, ODCIConstError
or ODCIConstErrContiue
. If a partition level call returns ODCIConstError
, the partition is marked FAILED
, the index is marked FAILED
, and the create operation terminates at that point. If the call returns ODCIConstErrContinue
, the partition is marked FAILED
, and the method is invoked for the next partition.
This method is invoked during ALTER TABLE ADD PARTITION
too. In this case, there is only one call to ODCIIndexCreate
, the IndexPartition
and TablePartition
name are filled in, and the callProperty
is set to NULL
Since this routine handles multiple things (namely, creation of a non-partitioned index, creation of a local index and creation of a single index partition), you must take special care to code it appropriately.
ODCIIndexDelete(ia ODCIIndexInfo, rid VARCHAR2, oldval <icoltype>, env ODCIEnv) RETURN NUMBER
This procedure is invoked when a row is deleted from a table that has a domain index defined on one of its columns.
ODCIConst.Success
on success, or ODCIConst.Error
on error
ODCIIndexDelete
is invoked at the partition level, then the index partition name is filled in in the ODCIIndexInfo
argument.ODCIIndexDrop(ia ODCIIndexInfo, env ODCIEnv) RETURN NUMBER
The ODCIIndexDrop
procedure is invoked when a domain index is dropped explicitly using a DROP
INDEX
statement, or implicitly through a DROP
TABLE
, or DROP
USER
statement.
Argument | Meaning |
---|---|
ia |
Contains information about the indexed column |
env |
The environment handle passed to the routine |
ODCIConst.Success
on success, or ODCIConst.Error
on error, or ODCIConst.Warning
.
While dropping a local domain index, the first N+1
calls can return ODCIConst.ErrContinue
too.
ALTER TABLE DROP PARTITION
.
For dropping a non-partitioned index, the ODCIIndexDrop
is invoked once, with the IndexPartition
, TablePartition
and callProperty
set to NULL
.
For dropping a local domain index, the routine is invoked N+2 times, where N is the number of partitions.
For dropping a single index partition during ALTER TABLE DROP PARTITION
, this routine is invoked once with the IndexPartition
and the TablePartition
filled in and the callProperty
set to NULL
.
The old table and the old index partition's dictionary entries are deleted before the call to ODCIIndexDrop
, so the cartridge code for this routine should not rely on the existence of this data in the views.
FAILED
(due to abnormal termination of some DDL routine), the ODCIIndexDrop
routine should be capable of cleaning up partially created domain indexes. When the ODCIIndexDrop
routine is being executed, the domain index is marked LOADING
.ODCIIndexDrop
routine returns with an ODCIConst.Error
or exception, the DROP
INDEX
statement fails and the index is marked FAILED
. In that case, there is no mechanism to get rid of the domain index except by using the FORCE
option. If the ODCIIndexDrop
routine returns with ODCIConst
.Warning
in the case of an explicit DROP
INDEX
statement, the operation succeeds but a warning message is returned to the user.ODCIIndexDrop
is treated as an independent operation. The changes made by ODCIIndexDrop
are not guaranteed to be atomic.ODCIIndexExchangePartition( ia ODCIIndexInfo, ia1 ODCIIndexInfo, env ODCIEnv) RETURN NUMBER
This method is invoked when an ALTER TABLE EXCHANGE PARTITION...INCLUDING INDEXES
is issued on a partitioned table on which a local domain index is defined.
ODCIConst.Success
on success, or ODCIConst.Error
on error, or ODCIConst.Warning
.
The function should be implemented as a static type method.
This method should handle both converting a partition of a domain index into a non-partitioned domain index table and converting a non-partitioned index to a partition of a partitioned domain index.
ODCIIndexFetch(self IN [OUT] <impltype>, nrows IN NUMBER, rids OUT ODCIRidList, env ODCIEnv) RETURN NUMBER
This procedure is invoked repeatedly to retrieve the rows satisfying the operator predicate.
ODCIConst.Success
on success, or ODCIConst.Error
on error
ODCIIndexFetch
returns rows satisfying the operator predicate. That is, it returns the row identifiers of all the rows for which the operator return value falls within the specified bounds.ODCIIndexFetch
can return a maximum of nrows number of rows. The value of nrows passed in is decided by Oracle based on some internal factors. However, the ODCIIndexFetch
routine can return lesser than nrows number of rows. The row identifiers are returned through the output rids
array. A NULL
ROWID
(as an element of the rids
array) indicates that all satisfying rows have been returned.
Assume that there are 3000 rows which satisfy the operator predicate, and that the value of nrows
= 2000. The first invocation of ODCIIndexFetch
can return the first 2000 rows. The second invocation can return a rid
list consisting of the remaining 1000 rows followed by a NULL
element. The NULL
value in rid
list indicates that all satisfying rows have now been returned.
ODCIIndexGetMetadata(ia IN ODCIIndexInfo, version IN VARCHAR2, new_block OUT PLS_INTEGER) RETURN VARCHAR2;
This routine is called repeatedly to return a series of strings of PL/SQL code that comprise the non-dictionary metadata associated with the index in ia
. The routine can pass whatever information is required at import time--for example, policy, version, preferences, and so on. This method is optional unless implementation-specific metadata is required.
Developers of domain index implementation types in 8.1.3 must implement ODCIIndexGetMetadata
even if only to indicate that no PL/SQL metadata exists or that the index is not participating in fast rebuild.
This function should be implemented as a static type method.
The routine will be called repeatedly until the return string length is 0. If an index has no metadata to be exported using PL/SQL, it should return an empty string upon first call.
This routine can be used to build one or more blocks of anonymous PL/SQL code for execution by import.Each block returned will be invoked independently by import. That is, if a block fails for any reason at import time, subsequent blocks will still be invoked. Therefore any dependent code should be incorporated within a single block. The size of an individual block of PL/SQL code is limited only by the size of import's read buffer controlled by its BUFFER
parameter.
The execution of these PL/SQL blocks at import time will be considered part of the associated domain index's creation. Therefore, their execution will be dependent upon the successful import of the index's underlying base table and user's setting of import's INDEXES=Y/N
parameter, as is the creation of the index.
The routine should not pass back the BEGIN
/END
strings that open and close the individual blocks of PL/SQL code; export will add these to mark the individual units of execution.
The parameter version
is the version number of the currently executing export client. Since export and import can be used to downgrade a database to the previous functional point release, it also represents the minimum server version you can expect to find at import time; it may be higher, but never lower.
The cartridge developer can use this information to determine what version of information should be written to the dump file. For example, assume the current server version is 08.02.00.00.00
, but the export version handed in is 08.01.04.00.00
. If a cartridge's metadata changed formats between 8.1 and 8.2, it would know to write the data to the dump file in 8.1 format anticipating an import into an 8.1.4 system. Server versions starting at 8.2 and higher will have to know how to convert 8.1 format metadata.
Some points to be aware of:
RAWTOHEX
and HEXTORAW
.FROMUSER
-> TOUSER
schema replication feature. For example, a procedure prototype such as:
PROCEDURE AQ_CREATE ( schema IN VARCHAR2, que_name IN VARCHAR2) ...
Should be avoided since this will fail if you have remapped schema A to schema B on import. You can assume at import time that you are already connected to the target schema.
CONSISTENT=Y
. In this case, no writes are allowed from the export session. Therefore, this method must not write any database state.IGNORE=Y
parameter. Therefore, this method must produce PL/SQL code that is idempotent, or at least deterministic when executed multiple times.Foo
' and 'FOO
' are distinct objects. Database object names should be enclosed within double quotes ("") to preserve case.Any unrecoverable error should raise an exception allowing it to propagate back to get_domain_index_metadata
and thence back to export. This will cause export to terminate the creation of the current index's DDL in the dump file and to move on to the next index.
At import time, failure of the execution of any metadata PL/SQL block will cause the associated index to not be created under the assumption that the metadata creation is an integral part of the index creation.
ODCIIndexInsert(ia ODCIIndexInfo, rid VARCHAR2, newval <icoltype>, env ODCIEnv) RETURN NUMBER
This method is invoked when a new row is inserted into a table that has a domain index defined on one of its columns.
ODCIConst.Success
on success, or ODCIConst.Error
on error
This function should be implemented as a static type method.
This method should insert index data corresponding to the new row into the appropriate tables/files storing index data.
If ODCIIndexInsert
is invoked at the partition level, then the index partition name is filled in in the ODCIIndexInfo
argument.
ODCIIndexMergePartition(ia ODCIIndexInfo, part_name1 ODCIPartInfo, part_name2 ODCIPartInfo, parms VARCHAR2, env ODCIEnv) RETURN NUMBER
This method is invoked when a ALTER TABLE MERGE PARTITION
is issued on range partitioned table on which a local domain index is defined.
ODCIConst.Success
on success, or ODCIConst.Error
on error, or ODCIConst.Warning
.
The old table and the old index partitions' dictionary entries are deleted before the call to ODCIIndexMergePartition
, so the cartridge code for this routine should not rely on the existence of this data in the views.
ODCIIndexSplitPartition(ia ODCIIndexInfo, part_name1 ODCIPartInfo, part_name2 ODCIPartInfo, parms VARCHAR2, env ODCIEnv) RETURN NUMBER
This method is invoked when an ALTER TABLE SPLIT PARTITION
is invoked on a partitioned table on which a local domain index is defined.
ODCIConst.Success
on success, or ODCIConst.Error
on error, or ODCIConst.Warning
.
The function should be implemented as a static type method.
Cartridge writers need to drop the metadata corresponding to the partition that is split and create metadata for the two partitions that are created as a result of the split. The index data corresponding to these partitions need not be computed since the indexes are marked UNUSABLE
. When the user issues ALTER INDEX REBUILD PARTITION
to make the indexes usable, the indexes can be built.
The old table and the old index partition's dictionary entries are deleted before the call to ODCIIndexSplitPartition
, so the cartridge code for this routine should not rely on the existence of this data in the views.
ODCIIndexStart(sctx IN OUT <impltype>, ia ODCIIndexInfo, pi ODCIPredInfo, qi ODCIQueryInfo, strt <opbndtype>, stop <opbndtype>, <valargs>, env ODCIEnv) RETURN NUMBER
This procedure is invoked to start the evaluation of an operator on an indexed column.
ODCIConst.Success
on success, or ODCIConst.Error
on error
ODCIIndexStart
is invoked to begin the evaluation of an operator on an indexed column. In particular, the following conditions hold:
ODCIIndexInfo
parameter) supports the current operator.<valargs>
parameters.ODCIIndexStart
method should initialize the index scan as needed (using the operator-related information in the pi
argument) and prepare for the subsequent invocations of ODCIIndexFetch
.strt
, stop
parameters together with the bndflg
value in ODCIPredInfo
parameter specify the range of values within which the operator return value should lie.op
LIKE
val
, the ODCIIndexPrefixMatch
flag is set. In this case, the start key contains the value <val>
and the stop key value is irrelevant.op
= val
, the ODCIIndexExactMatch
flag is set. In this case, the start key contains the value <val>
and the stop key value is irrelevant.op
> val
, startkey
contains the value <val>
and stop key value is set to NULL
. If the predicate is of the form op
>= <val>
, the flag ODCIIndexIncludeStart
is also set.op
< val
, stop key contains the value <val> and the start key value is set to NULL
. If the predicate is of the form op
<= val
, the flag ODCIIndexIncludeStop
is also set.SELF
argument) which will then be passed back to the next query-time call. The next call will be to ODCIIndexFetch
if the evaluation continues, or to ODCIIndexStart
if the evaluation is restarted. The context value can be used to store the entire evaluation state or just a handle to the memory containing the state.ODCIIndexStart
methods need to be implemented, one for each distinct combination of value argument datatypes. For example, if an indextype supports three operators:
two ODCIIndexStart
routines would need to be implemented:
qi
parameter can be used to optimize the domain index scan, if possible. The query information includes hints that have been specified for the query and the list of relevant ancillary operators referenced in the query block.ODCIIndexTruncate(ia ODCIIndexInfo, env ODCIEnv) RETURN NUMBER
The ODCIIndexTruncate
procedure is invoked when a TRUNCATE
statement is issued against a table that has a domain index defined on one of its columns.
Argument | Meaning |
---|---|
ia |
Contains information about the indexed column |
env |
The environment handle passed to the routine |
ODCIConst.Success
on success, or ODCIConst.Error
on error, or ODCIConst.Warning
.
While truncating a local domain index, the first N+1 calls can return ODCIConst.ErrContinue
too.
ODCIIndexTruncate
routine is being executed, the domain index is marked LOADING
. If the ODCIIndexTruncate
routine returns with an ODCIConst
.Error
(or exception), the domain index will be marked FAILED
. The only operation permitted on FAILED
domain indexes is DROP
INDEX
, TRUNCATE
TABLE
or ALTER
INDEX
REBUILD
. If ODCIIndexTruncate
returns with ODCIConst
.Warning
, the operation succeeds but a warning message is returned to the user.ODCIIndexTruncate
is treated as an independent operation. The changes made by ODCIIndexTruncate
are not guaranteed to be atomic.ALTER TABLE TRUNCATE PARTITION
.
For truncating a non-partitioned index, the ODCIIndexTruncateis
invoked once, with the IndexPartition
, TablePartition
and callProperty
set to NULL
.
For truncating a local domain index, the routine is invoked N+2 times, where N is the number of partitions.
For truncating a single index partition during ALTER TABLE TRUNCATE PARTITION
, this routine is invoked once with the IndexPartition
and the TablePartition
filled in and the callProperty
set to NULL
.
ODCIIndexUpdate( ia ODCIIndexInfo, rid VARCHAR2, oldval <icoltype>, newval <icoltype>, env ODCIEnv)RETURN NUMBER
This method is invoked when a row is updated in a table that has a domain index defined on one of its columns.
ODCIConst.Success
on success, or ODCIConst.Error
on error
UPDATE
statement, a LOB value can be updated through a variety of "WRITE
" interfaces (see Oracle9i Application Developer's Guide - Large Objects (LOBs)). If a domain index is defined on a LOB
column or an object type containing a LOB
attribute, the ODCIIndexUpdate
routine is called when a LOB locator is implicitly or explicitly closed after one or more write operations.ODCIIndexUpdate
is invoked at the partition level, then the index partition name is filled in in the ODCIIndexInfo
argument.
|
Copyright © 1996, 2002 Oracle Corporation. All Rights Reserved. |
|