Package org.h2.mvstore.db
Class MVTempResult
- java.lang.Object
-
- org.h2.mvstore.db.MVTempResult
-
- All Implemented Interfaces:
ResultExternal
- Direct Known Subclasses:
MVPlainTempResult
,MVSortedTempResult
public abstract class MVTempResult extends java.lang.Object implements ResultExternal
Temporary result.A separate MVStore in a temporary file is used for each result. The file is removed when this result and all its copies are closed.
TempFileDeleter
is also used to delete this file if results are not closed properly.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
MVTempResult.CloseImpl
-
Field Summary
Fields Modifier and Type Field Description (package private) int
childCount
Count of child results.private MVTempResult.CloseImpl
closeable
Closeable to close the storage.(package private) boolean
closed
Whether this result is closed.private Database
database
(package private) Expression[]
expressions
Column expressions.private java.lang.ref.Reference<?>
fileRef
Reference to the record in the temporary file deleter.(package private) MVTempResult
parent
Parent store for copies.(package private) int
resultColumnCount
Total count of columns.(package private) int
rowCount
Count of rows.(package private) MVStore
store
MVStore.private TempFileDeleter
tempFileDeleter
Temporary file deleter.(package private) int
visibleColumnCount
Count of visible columns.
-
Constructor Summary
Constructors Constructor Description MVTempResult(Database database, Expression[] expressions, int visibleColumnCount, int resultColumnCount)
Creates a new temporary result.MVTempResult(MVTempResult parent)
Creates a shallow copy of the result.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
addRows(java.util.Collection<Value[]> rows)
Add a number of rows to the result.void
close()
Close this object and delete the temporary file.private void
closeChild()
private void
delete()
static ResultExternal
of(Database database, Expression[] expressions, boolean distinct, int[] distinctIndexes, int visibleColumnCount, int resultColumnCount, SortOrder sort)
Creates MVStore-based temporary result.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.h2.result.ResultExternal
addRow, contains, createShallowCopy, next, removeRow, reset
-
-
-
-
Field Detail
-
database
private final Database database
-
store
final MVStore store
MVStore.
-
expressions
final Expression[] expressions
Column expressions.
-
visibleColumnCount
final int visibleColumnCount
Count of visible columns.
-
resultColumnCount
final int resultColumnCount
Total count of columns.
-
rowCount
int rowCount
Count of rows. Used only in a root results, copies always have 0 value.
-
parent
final MVTempResult parent
Parent store for copies. Ifnull
this result is a root result.
-
childCount
int childCount
Count of child results.
-
closed
boolean closed
Whether this result is closed.
-
tempFileDeleter
private final TempFileDeleter tempFileDeleter
Temporary file deleter.
-
closeable
private final MVTempResult.CloseImpl closeable
Closeable to close the storage.
-
fileRef
private final java.lang.ref.Reference<?> fileRef
Reference to the record in the temporary file deleter.
-
-
Constructor Detail
-
MVTempResult
MVTempResult(MVTempResult parent)
Creates a shallow copy of the result.- Parameters:
parent
- parent result
-
MVTempResult
MVTempResult(Database database, Expression[] expressions, int visibleColumnCount, int resultColumnCount)
Creates a new temporary result.- Parameters:
database
- databaseexpressions
- column expressionsvisibleColumnCount
- count of visible columnsresultColumnCount
- total count of columns
-
-
Method Detail
-
of
public static ResultExternal of(Database database, Expression[] expressions, boolean distinct, int[] distinctIndexes, int visibleColumnCount, int resultColumnCount, SortOrder sort)
Creates MVStore-based temporary result.- Parameters:
database
- databaseexpressions
- expressionsdistinct
- is output distinctdistinctIndexes
- indexes of distinct columns for DISTINCT ON resultsvisibleColumnCount
- count of visible columnsresultColumnCount
- the number of columns including visible columns and additional virtual columns for ORDER BY and DISTINCT ON clausessort
- sort order, ornull
- Returns:
- temporary result
-
addRows
public int addRows(java.util.Collection<Value[]> rows)
Description copied from interface:ResultExternal
Add a number of rows to the result.- Specified by:
addRows
in interfaceResultExternal
- Parameters:
rows
- the list of rows to add- Returns:
- the new number of rows in this object
-
close
public void close()
Description copied from interface:ResultExternal
Close this object and delete the temporary file.- Specified by:
close
in interfaceResultExternal
-
closeChild
private void closeChild()
-
delete
private void delete()
-
-