public class H2Utils extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
BINARY_DEFAULT_PRECISION
The default precision for a binary/varbinary value.
|
static int |
BOOLEAN_DEFAULT_PRECISION
The default precision for a boolean value (see
ValueBoolean). |
static int |
BYTE_DEFAULT_PRECISION
The default precision for a byte value (see
ValueByte). |
static int |
DATE_DEFAULT_PRECISION
The default precision for a date value (see
ValueDate). |
static int |
DECIMAL_DEFAULT_PRECISION
The default precision for a decimal value.
|
static int |
DECIMAL_DEFAULT_SCALE
The default scale for a decimal value.
|
static int |
DFLT_HASH_JOIN_MAX_TABLE_SIZE
Default hash join max table size.
|
static int |
DOUBLE_DEFAULT_PRECISION
The default precision for a double value (see
ValueDouble). |
static org.gridgain.internal.h2.table.IndexColumn[] |
EMPTY_COLUMNS |
static int |
GEOMETRY_DEFAULT_PRECISION
The default precision for a geometry value.
|
static String |
IGNITE_SQL_ALLOW_IMPLICIT_PK
Allow run CREATE TABLE statement without explicitly specifying a PK.
|
static int |
INTEGER_DEFAULT_PRECISION
The default precision for a integer value (see
ValueInt). |
static int |
LONG_DEFAULT_PRECISION
The default precision for a long value (see
ValueLong). |
static int |
REAL_DEFAULT_PRECISION
The default precision for real value (see
ValueFloat). |
static int |
SHORT_DEFAULT_PRECISION
The default precision for a short value (see
ValueShort). |
static int |
STRING_DEFAULT_PRECISION
The default precision for a char/varchar value.
|
static int |
TIME_DEFAULT_PRECISION
The default precision for a time value (see
ValueTime). |
static int |
TIMESTAMP_DEFAULT_PRECISION
The default precision for a timestamp value (see
ValueTimestamp). |
static int |
TIMESTAMP_DEFAULT_SCALE
The default scale for a timestamp value (see
ValueTimestamp). |
static List<GridQueryFieldMetadata> |
UPDATE_RESULT_META
Dummy metadata for update result.
|
static int |
UUID_DEFAULT_PRECISION
The default precision for a uuid value (see
ValueUuid). |
| Modifier and Type | Method and Description |
|---|---|
static void |
addUniqueColumns(List<org.gridgain.internal.h2.table.IndexColumn> dest,
List<org.gridgain.internal.h2.table.IndexColumn> src)
Add only new columns to destination list.
|
static void |
bindParameters(PreparedStatement stmt,
@Nullable Collection<Object> params)
Binds parameters to prepared statement.
|
static <Z> void |
bubbleUp(Z[] arr,
int off,
Comparator<Z> cmp) |
static long |
calculateMemoryDelta(org.gridgain.internal.h2.value.ValueRow distinctRowKey,
Object[] oldRow,
Object[] newRow)
Calculates memory delta when old row was replaced with a new one.
|
static boolean |
checkAndStartNotStartedCache(GridKernalContext ctx,
GridH2Table tbl)
Check that given table has not started cache and start it for such case.
|
static void |
checkQuery(IgniteH2Indexing idx,
List<Integer> cacheIds,
Collection<QueryTable> tbls)
Check if query is valid.
|
static List<Integer> |
collectCacheIds(IgniteH2Indexing idx,
@Nullable Integer mainCacheId,
Collection<QueryTable> tbls)
Collect cache identifiers from two-step query.
|
static boolean |
collectMvccEnabled(IgniteH2Indexing idx,
List<Integer> cacheIds)
Collect MVCC enabled flag.
|
static boolean |
containsColumn(List<org.gridgain.internal.h2.table.IndexColumn> cols,
org.gridgain.internal.h2.table.IndexColumn col) |
static boolean |
containsKeyColumn(GridH2RowDescriptor desc,
List<org.gridgain.internal.h2.table.IndexColumn> cols)
Check whether columns list contains key or key alias column.
|
static QueryContext |
context(Connection c) |
static QueryContext |
context(org.gridgain.internal.h2.engine.Session ses) |
static Object |
convert(Object val,
IgniteH2Indexing idx,
int type)
Convert value to column's expected type by means of H2.
|
static GridH2IndexBase |
createSpatialIndex(GridH2Table tbl,
String idxName,
org.gridgain.internal.h2.table.IndexColumn[] cols)
Create spatial index.
|
static boolean |
equals(org.gridgain.internal.h2.table.IndexColumn c1,
org.gridgain.internal.h2.table.IndexColumn c2) |
static String |
generateFieldsQueryString(String qry,
String tableAlias,
H2TableDescriptor tbl)
Generate SqlFieldsQuery string from SqlQuery.
|
static org.gridgain.internal.h2.store.DataHandler |
getHandler(GridKernalContext ctx) |
static int |
getTypeFromClass(Class<?> x)
Maps java class on H2's Value type that is supported by Ignite.
|
static String |
indexColumnsSql(org.gridgain.internal.h2.table.IndexColumn[] idxCols)
Generate String represenation of given indexed columns.
|
static String |
indexCreateSql(String fullTblName,
GridH2IndexBase h2Idx,
boolean ifNotExists)
Generate
CREATE INDEX SQL statement for given params. |
static String |
indexDropSql(String schemaName,
String idxName,
boolean ifExists)
Generate
CREATE INDEX SQL statement for given params. |
static boolean |
isConvertableToColumnType(Class<?> cls,
int colType) |
static boolean |
isNullValue(org.gridgain.internal.h2.value.Value v)
Test if specified value is null.
|
static List<GridQueryFieldMetadata> |
meta(ResultSetMetaData rsMeta) |
static List<JdbcParameterMeta> |
parametersMeta(ParameterMetaData h2ParamsMeta)
Converts h2 parameters metadata to Ignite one.
|
static void |
registerAggregateFunction(IgniteLogger log,
ConnectionManager connMgr,
String fnName,
Class<? extends org.gridgain.internal.h2.api.AggregateFunction> cls)
Register custom aggregate function.
|
static void |
registerSqlFunctions(IgniteLogger log,
ConnectionManager connMgr,
String schema,
Class<?>[] clss)
Register custom SQL functions.
|
static void |
resetSession(H2PooledConnection conn)
Clean up session for further reuse.
|
static int |
resolveDefaultPrecisionIfUndefined(GridQueryProperty prop)
Gets the precision for the descriptor.
|
static int |
resolveDefaultScaleIfUndefined(GridQueryProperty prop)
Gets the scale for the descriptor.
|
static GridH2RetryException |
retryException(String msg)
Create retry exception for distributed join.
|
static long |
rowSizeInBytes(Object[] row) |
static org.gridgain.internal.h2.engine.Session |
session(Connection c) |
static org.gridgain.internal.h2.engine.Session |
session(H2PooledConnection c) |
static void |
setupConnection(H2PooledConnection conn,
org.apache.ignite.internal.processors.query.h2.H2QueryContext qctx,
boolean distributedJoins,
boolean enforceJoinOrder,
boolean lazy) |
static void |
setupConnection(H2PooledConnection conn,
QueryContext qctx,
boolean distributedJoins,
boolean enforceJoinOrder) |
static String |
tableCreateSql(H2TableDescriptor tbl)
Prepare SQL statement for CREATE TABLE command.
|
static GridH2RowMessage |
toRowMessage(org.gridgain.internal.h2.result.Row row) |
static List<org.gridgain.internal.h2.table.IndexColumn> |
treeIndexColumns(GridH2RowDescriptor desc,
List<org.gridgain.internal.h2.table.IndexColumn> cols,
org.gridgain.internal.h2.table.IndexColumn keyCol,
org.gridgain.internal.h2.table.IndexColumn affCol) |
static @NotNull org.gridgain.internal.h2.table.IndexColumn[] |
unwrapKeyColumns(GridH2Table tbl,
org.gridgain.internal.h2.table.IndexColumn[] idxCols)
Create list of index columns.
|
static void |
validateTypeDescriptor(GridQueryTypeDescriptor type)
Validates properties described by query types.
|
static String |
withQuotes(String str)
Add quotes around the name.
|
static org.gridgain.internal.h2.value.Value |
wrap(CacheObjectValueContext coCtx,
Object obj,
int type)
Wraps object to respective
Value. |
static QueryCursorImpl<List<?>> |
zeroCursor() |
public static final int DFLT_HASH_JOIN_MAX_TABLE_SIZE
@TestOnly public static final String IGNITE_SQL_ALLOW_IMPLICIT_PK
public static final int STRING_DEFAULT_PRECISION
public static final int BINARY_DEFAULT_PRECISION
public static final int GEOMETRY_DEFAULT_PRECISION
public static final int DECIMAL_DEFAULT_PRECISION
public static final int DECIMAL_DEFAULT_SCALE
public static final int BOOLEAN_DEFAULT_PRECISION
ValueBoolean).public static final int BYTE_DEFAULT_PRECISION
ValueByte).public static final int SHORT_DEFAULT_PRECISION
ValueShort).public static final int INTEGER_DEFAULT_PRECISION
ValueInt).public static final int LONG_DEFAULT_PRECISION
ValueLong).public static final int DOUBLE_DEFAULT_PRECISION
ValueDouble).public static final int REAL_DEFAULT_PRECISION
ValueFloat).public static final int UUID_DEFAULT_PRECISION
ValueUuid).public static final int TIME_DEFAULT_PRECISION
ValueTime).public static final int DATE_DEFAULT_PRECISION
ValueDate).public static final int TIMESTAMP_DEFAULT_PRECISION
ValueTimestamp).public static final int TIMESTAMP_DEFAULT_SCALE
ValueTimestamp).public static final List<GridQueryFieldMetadata> UPDATE_RESULT_META
public static final org.gridgain.internal.h2.table.IndexColumn[] EMPTY_COLUMNS
public static boolean equals(org.gridgain.internal.h2.table.IndexColumn c1,
org.gridgain.internal.h2.table.IndexColumn c2)
c1 - First column.c2 - Second column.true If they are the same.public static boolean containsColumn(List<org.gridgain.internal.h2.table.IndexColumn> cols, org.gridgain.internal.h2.table.IndexColumn col)
cols - Columns list.col - Column to find.true If found.public static boolean containsKeyColumn(GridH2RowDescriptor desc, List<org.gridgain.internal.h2.table.IndexColumn> cols)
desc - Row descriptor.cols - Columns list.public static String tableCreateSql(H2TableDescriptor tbl)
tbl - Table descriptor.public static String indexCreateSql(String fullTblName, GridH2IndexBase h2Idx, boolean ifNotExists)
CREATE INDEX SQL statement for given params.fullTblName - Fully qualified table name.h2Idx - H2 index.ifNotExists - Quietly skip index creation if it exists.public static String indexColumnsSql(org.gridgain.internal.h2.table.IndexColumn[] idxCols)
idxCols - Indexed columns.public static String indexDropSql(String schemaName, String idxName, boolean ifExists)
CREATE INDEX SQL statement for given params.schemaName - Quoted schema name.idxName - Index name.ifExists - Quietly skip index drop if it exists.public static List<org.gridgain.internal.h2.table.IndexColumn> treeIndexColumns(GridH2RowDescriptor desc, List<org.gridgain.internal.h2.table.IndexColumn> cols, org.gridgain.internal.h2.table.IndexColumn keyCol, org.gridgain.internal.h2.table.IndexColumn affCol)
desc - Row descriptor.cols - Columns list.keyCol - Primary key column.affCol - Affinity key column.public static GridH2IndexBase createSpatialIndex(GridH2Table tbl, String idxName, org.gridgain.internal.h2.table.IndexColumn[] cols)
tbl - Table.idxName - Index name.cols - Columns.public static String withQuotes(String str)
str - String.public static List<GridQueryFieldMetadata> meta(ResultSetMetaData rsMeta) throws SQLException
rsMeta - Metadata.SQLException - If failed.public static List<JdbcParameterMeta> parametersMeta(ParameterMetaData h2ParamsMeta) throws IgniteCheckedException
h2ParamsMeta - parameters metadata returned by h2.IgniteCheckedExceptionpublic static org.gridgain.internal.h2.engine.Session session(H2PooledConnection c)
c - Connection.public static org.gridgain.internal.h2.engine.Session session(Connection c)
c - Connection.public static void setupConnection(H2PooledConnection conn, QueryContext qctx, boolean distributedJoins, boolean enforceJoinOrder)
conn - Connection to use.qctx - Query context.distributedJoins - If distributed joins are enabled.enforceJoinOrder - Enforce join order of tables.public static void setupConnection(H2PooledConnection conn, org.apache.ignite.internal.processors.query.h2.H2QueryContext qctx, boolean distributedJoins, boolean enforceJoinOrder, boolean lazy)
conn - Connection to use.qctx - Query context.distributedJoins - If distributed joins are enabled.enforceJoinOrder - Enforce join order of tables.lazy - Lazy query execution mode.public static void resetSession(H2PooledConnection conn)
conn - Connection to use.public static Object convert(Object val, IgniteH2Indexing idx, int type) throws IgniteCheckedException
val - Source value.idx - Row descriptor.type - Expected column type to convert to.IgniteCheckedException - if failed.public static boolean isNullValue(org.gridgain.internal.h2.value.Value v)
v - Value to test.true if value is null, false - otherwise.public static QueryCursorImpl<List<?>> zeroCursor()
public static void addUniqueColumns(List<org.gridgain.internal.h2.table.IndexColumn> dest, List<org.gridgain.internal.h2.table.IndexColumn> src)
dest - List of index columns to add new elements from src list.src - List of IndexColumns to add to dest list.public static boolean checkAndStartNotStartedCache(GridKernalContext ctx, GridH2Table tbl)
tbl - Table to check on not started cache.true in case not started and has been started.public static boolean isConvertableToColumnType(Class<?> cls, int colType)
cls - The class whose convertibility is to be tested.colType - Column target type.wrap(CacheObjectValueContext, Object, int)public static org.gridgain.internal.h2.value.Value wrap(CacheObjectValueContext coCtx, Object obj, int type) throws IgniteCheckedException
Value.
Note, implicit type conversions must be also included into CONVERTABLE_TYPES.obj - Object.type - Value type.IgniteCheckedException - If failed.isConvertableToColumnType(Class, int)public static int getTypeFromClass(Class<?> x)
x - java class to map on H2's type.Value.JAVA_OBJECT otherwise.Value,
DataType.getTypeFromClass(Class)public static int resolveDefaultPrecisionIfUndefined(GridQueryProperty prop)
prop - Query entity field descriptor.public static int resolveDefaultScaleIfUndefined(GridQueryProperty prop)
prop - Query entity field descriptor.public static void validateTypeDescriptor(GridQueryTypeDescriptor type) throws IgniteCheckedException
type - Type descriptor.IgniteCheckedException - If validation failed.public static String generateFieldsQueryString(String qry, String tableAlias, H2TableDescriptor tbl) throws IgniteCheckedException
qry - Query string.tableAlias - table alias.tbl - Table to use.IgniteCheckedException - In case of error.public static GridH2RowMessage toRowMessage(org.gridgain.internal.h2.result.Row row)
row - Row.public static GridH2RetryException retryException(String msg)
msg - Message.public static void bindParameters(PreparedStatement stmt, @Nullable @Nullable Collection<Object> params) throws IgniteCheckedException
stmt - Prepared statement.params - Parameters collection.IgniteCheckedException - If failed.public static <Z> void bubbleUp(Z[] arr,
int off,
Comparator<Z> cmp)
arr - Array.off - Offset.cmp - Comparator.public static List<Integer> collectCacheIds(IgniteH2Indexing idx, @Nullable @Nullable Integer mainCacheId, Collection<QueryTable> tbls)
mainCacheId - Id of main cache.public static boolean collectMvccEnabled(IgniteH2Indexing idx, List<Integer> cacheIds)
idx - Indexing.cacheIds - Cache IDs.True if indexing is enabled.public static void checkQuery(IgniteH2Indexing idx, List<Integer> cacheIds, Collection<QueryTable> tbls)
idx - Indexing.cacheIds - Cache IDs.tbls - Tables.@NotNull public static @NotNull org.gridgain.internal.h2.table.IndexColumn[] unwrapKeyColumns(GridH2Table tbl, org.gridgain.internal.h2.table.IndexColumn[] idxCols)
tbl - GridH2Table instanceidxCols - List of index columns.public static QueryContext context(org.gridgain.internal.h2.engine.Session ses)
ses - H2 session.public static QueryContext context(Connection c)
c - Connection.public static long rowSizeInBytes(Object[] row)
row - Data row.public static long calculateMemoryDelta(org.gridgain.internal.h2.value.ValueRow distinctRowKey,
Object[] oldRow,
Object[] newRow)
distinctRowKey - Distinct row key.oldRow - Old row.newRow - New row.public static org.gridgain.internal.h2.store.DataHandler getHandler(GridKernalContext ctx)
ctx - Kernal context/public static void registerSqlFunctions(IgniteLogger log, ConnectionManager connMgr, String schema, Class<?>[] clss) throws IgniteCheckedException
schema - Schema.clss - Classes.IgniteCheckedException - If failed.public static void registerAggregateFunction(IgniteLogger log, ConnectionManager connMgr, String fnName, Class<? extends org.gridgain.internal.h2.api.AggregateFunction> cls) throws IgniteCheckedException
fnName - SQL function name.cls - Function implementation class.IgniteCheckedException - If failed.
Follow @ApacheIgnite
Ignite Database and Caching Platform : ver. 8.9.17-p1 Release Date : November 27 2025