public class ArchiveVTI
extends org.apache.derby.vti.ForwardingVTI
implements org.apache.derby.vti.AwareVTI, org.apache.derby.vti.RestrictedVTI
This table function acts like a union view on a set of archive tables. The idea is that the old contents of a main table are periodically moved to archive tables whose names start with $tableName$suffix. Each bulk move of rows results in the creation of a new archive table. The archive tables live in the same schema as the main table and have its shape. This table function unions the main table together with all of its archived snapshots. So, for instance, you might have the following set of tables, which this table function unions together:
T1 T1_ARCHIVE_1 T1_ARCHIVE_2 ... T1_ARCHIVE_N
This table function may appear in user documentation. If you change the behavior of this table function, make sure that you adjust the user documentation linked from DERBY-6117.
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
_archiveSuffix |
private java.lang.String[] |
_columnNames |
private java.sql.Connection |
_connection |
private org.apache.derby.vti.Restriction |
_restriction |
private int |
_tableIdx |
private java.util.ArrayList<java.lang.String> |
_tableNames |
private org.apache.derby.vti.VTIContext |
_vtiContext |
Constructor and Description |
---|
ArchiveVTI(java.lang.String archiveSuffix)
Construct from the suffix which flags all of the relevant tables.
|
Modifier and Type | Method and Description |
---|---|
static ArchiveVTI |
archiveVTI(java.lang.String archiveSuffix)
Entry point for creating an ArchiveVTI which is bound to a Derby table function
by a CREATE FUNCTION statement which looks like this:
create function t1( archiveSuffix varchar( 32672 ) ) returns table
(
keyCol int,
aCol int,
bCol int
)
language java parameter style derby_jdbc_result_set reads sql data
external name 'org.apache.derbyTesting.functionTests.tests.lang.ArchiveVTI.archiveVTI'
|
void |
close() |
private java.sql.Connection |
getConnection()
Get this database session's connection to the database.
|
org.apache.derby.vti.VTIContext |
getContext() |
private void |
getTableNames()
Get cursors on all the tables which we are going to union together.
|
void |
initScan(java.lang.String[] columnNames,
org.apache.derby.vti.Restriction restriction) |
private void |
loadResultSet()
Compile the query against the next table and use its ResultSet until
it's drained.
|
boolean |
next() |
void |
setContext(org.apache.derby.vti.VTIContext context) |
getAsciiStream, getBigDecimal, getBigDecimal, getBinaryStream, getBlob, getBoolean, getByte, getBytes, getCharacterStream, getClob, getDate, getDate, getDouble, getFloat, getInt, getLong, getMetaData, getObject, getShort, getString, getTime, getTime, getTimestamp, getTimestamp, getWrappedResultSet, isClosed, mapColumnNumber, wasNull, wrapResultSet
absolute, afterLast, beforeFirst, cancelRowUpdates, clearWarnings, deleteRow, findColumn, first, getArray, getArray, getAsciiStream, getBigDecimal, getBigDecimal, getBinaryStream, getBlob, getBoolean, getByte, getBytes, getCharacterStream, getClob, getConcurrency, getCursorName, getDate, getDate, getDouble, getFetchDirection, getFetchSize, getFloat, getHoldability, getInt, getLong, getNCharacterStream, getNCharacterStream, getNClob, getNClob, getNString, getNString, getObject, getObject, getObject, getObject, getObject, getRef, getRef, getReturnTableSignature, getRow, getRowId, getRowId, getShort, getSQLXML, getSQLXML, getStatement, getString, getTime, getTime, getTimestamp, getTimestamp, getType, getUnicodeStream, getUnicodeStream, getURL, getURL, getWarnings, insertRow, isAfterLast, isBeforeFirst, isFirst, isLast, isWrapperFor, last, moveToCurrentRow, moveToInsertRow, notImplemented, previous, refreshRow, relative, rowDeleted, rowInserted, rowUpdated, setFetchDirection, setFetchSize, unwrap, updateArray, updateArray, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateBigDecimal, updateBigDecimal, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBlob, updateBlob, updateBlob, updateBlob, updateBlob, updateBlob, updateBoolean, updateBoolean, updateByte, updateByte, updateBytes, updateBytes, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateClob, updateClob, updateClob, updateClob, updateClob, updateClob, updateDate, updateDate, updateDouble, updateDouble, updateFloat, updateFloat, updateInt, updateInt, updateLong, updateLong, updateNCharacterStream, updateNCharacterStream, updateNCharacterStream, updateNCharacterStream, updateNClob, updateNClob, updateNClob, updateNClob, updateNClob, updateNClob, updateNString, updateNString, updateNull, updateNull, updateObject, updateObject, updateObject, updateObject, updateRef, updateRef, updateRow, updateRowId, updateRowId, updateShort, updateShort, updateSQLXML, updateSQLXML, updateString, updateString, updateTime, updateTime, updateTimestamp, updateTimestamp
private java.sql.Connection _connection
private java.lang.String _archiveSuffix
private org.apache.derby.vti.VTIContext _vtiContext
private java.util.ArrayList<java.lang.String> _tableNames
private int _tableIdx
private java.lang.String[] _columnNames
private org.apache.derby.vti.Restriction _restriction
public ArchiveVTI(java.lang.String archiveSuffix) throws java.sql.SQLException
java.sql.SQLException
public static ArchiveVTI archiveVTI(java.lang.String archiveSuffix) throws java.sql.SQLException
Entry point for creating an ArchiveVTI which is bound to a Derby table function by a CREATE FUNCTION statement which looks like this:
create function t1( archiveSuffix varchar( 32672 ) ) returns table ( keyCol int, aCol int, bCol int ) language java parameter style derby_jdbc_result_set reads sql data external name 'org.apache.derbyTesting.functionTests.tests.lang.ArchiveVTI.archiveVTI'
archiveSuffix
- All of the archive tables have names of the form $tablename$archiveSuffix.java.sql.SQLException
public org.apache.derby.vti.VTIContext getContext()
getContext
in interface org.apache.derby.vti.AwareVTI
getContext
in class org.apache.derby.vti.VTITemplate
public void setContext(org.apache.derby.vti.VTIContext context)
setContext
in interface org.apache.derby.vti.AwareVTI
setContext
in class org.apache.derby.vti.VTITemplate
public void initScan(java.lang.String[] columnNames, org.apache.derby.vti.Restriction restriction) throws java.sql.SQLException
initScan
in interface org.apache.derby.vti.RestrictedVTI
java.sql.SQLException
public boolean next() throws java.sql.SQLException
next
in interface java.sql.ResultSet
next
in class org.apache.derby.vti.ForwardingVTI
java.sql.SQLException
public void close() throws java.sql.SQLException
close
in interface java.lang.AutoCloseable
close
in interface java.sql.ResultSet
close
in class org.apache.derby.vti.ForwardingVTI
java.sql.SQLException
private void getTableNames() throws java.sql.SQLException
Get cursors on all the tables which we are going to union together.
java.sql.SQLException
private void loadResultSet() throws java.sql.SQLException
Compile the query against the next table and use its ResultSet until it's drained.
java.sql.SQLException
private java.sql.Connection getConnection() throws java.sql.SQLException
Get this database session's connection to the database.
java.sql.SQLException
Apache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.