use of org.h2.table.IndexColumn in project ignite by apache.
the class GridH2TreeIndex method toString.
/** {@inheritDoc} */
@Override
public String toString() {
SB sb = new SB((indexType.isUnique() ? "Unique index '" : "Index '") + getName() + "' [");
boolean first = true;
for (IndexColumn col : getIndexColumns()) {
if (first)
first = false;
else
sb.a(", ");
sb.a(col.getSQL());
}
sb.a(" ]");
return sb.toString();
}
use of org.h2.table.IndexColumn in project ignite by apache.
the class GridSqlQuerySplitter method extractPartitionFromEquality.
/**
* Analyses the equality operation and extracts the partition if possible
*
* @param op AST equality operation.
* @param ctx Kernal Context.
* @return partition info, or {@code null} if none identified
*/
private static CacheQueryPartitionInfo extractPartitionFromEquality(GridSqlOperation op, GridKernalContext ctx) throws IgniteCheckedException {
assert op.operationType() == GridSqlOperationType.EQUAL;
GridSqlElement left = op.child(0);
GridSqlElement right = op.child(1);
if (!(left instanceof GridSqlColumn))
return null;
if (!(right instanceof GridSqlConst) && !(right instanceof GridSqlParameter))
return null;
GridSqlColumn column = (GridSqlColumn) left;
assert column.column().getTable() instanceof GridH2Table;
GridH2Table tbl = (GridH2Table) column.column().getTable();
GridH2RowDescriptor desc = tbl.rowDescriptor();
IndexColumn affKeyCol = tbl.getAffinityKeyColumn();
int colId = column.column().getColumnId();
if ((affKeyCol == null || colId != affKeyCol.column.getColumnId()) && !desc.isKeyColumn(colId))
return null;
if (right instanceof GridSqlConst) {
GridSqlConst constant = (GridSqlConst) right;
return new CacheQueryPartitionInfo(ctx.affinity().partition(tbl.cacheName(), constant.value().getObject()), null, null, -1, -1);
}
GridSqlParameter param = (GridSqlParameter) right;
return new CacheQueryPartitionInfo(-1, tbl.cacheName(), tbl.getName(), column.column().getType(), param.index());
}
use of org.h2.table.IndexColumn in project ignite by apache.
the class H2Tree method compare.
/**
* {@inheritDoc}
*/
@SuppressWarnings("ForLoopReplaceableByForEach")
@Override
protected int compare(BPlusIO<SearchRow> io, long pageAddr, int idx, SearchRow row) throws IgniteCheckedException {
if (inlineSize() == 0)
return compareRows(getRow(io, pageAddr, idx), row);
else {
int off = io.offset(idx);
int fieldOff = 0;
int lastIdxUsed = 0;
for (int i = 0; i < inlineIdxs.size(); i++) {
InlineIndexHelper inlineIdx = inlineIdxs.get(i);
Value v2 = row.getValue(inlineIdx.columnIndex());
if (v2 == null)
return 0;
int c = inlineIdx.compare(pageAddr, off + fieldOff, inlineSize() - fieldOff, v2, comp);
if (c == -2)
break;
lastIdxUsed++;
if (c != 0)
return c;
fieldOff += inlineIdx.fullSize(pageAddr, off + fieldOff);
if (fieldOff > inlineSize())
break;
}
if (lastIdxUsed == cols.length)
return 0;
SearchRow rowData = getRow(io, pageAddr, idx);
for (int i = lastIdxUsed, len = cols.length; i < len; i++) {
IndexColumn col = cols[i];
int idx0 = col.column.getColumnId();
Value v2 = row.getValue(idx0);
if (v2 == null) {
// Can't compare further.
return 0;
}
Value v1 = rowData.getValue(idx0);
int c = compareValues(v1, v2);
if (c != 0)
return InlineIndexHelper.fixSort(c, col.sortType);
}
return 0;
}
}
use of org.h2.table.IndexColumn in project ignite by apache.
the class GridH2IndexBase method toSearchRowMessage.
/**
* @param row Search row.
* @return Row message.
*/
private GridH2RowMessage toSearchRowMessage(SearchRow row) {
if (row == null)
return null;
List<GridH2ValueMessage> vals = new ArrayList<>(indexColumns.length);
for (IndexColumn idxCol : indexColumns) {
Value val = row.getValue(idxCol.column.getColumnId());
if (val == null)
break;
try {
vals.add(GridH2ValueMessageFactory.toMessage(val));
} catch (IgniteCheckedException e) {
throw new CacheException(e);
}
}
GridH2RowMessage res = new GridH2RowMessage();
res.values(vals);
return res;
}
use of org.h2.table.IndexColumn in project ignite by apache.
the class H2TreeIndex method getAvailableInlineColumns.
/**
* @param cols Columns array.
* @return List of {@link InlineIndexHelper} objects.
*/
private List<InlineIndexHelper> getAvailableInlineColumns(IndexColumn[] cols) {
List<InlineIndexHelper> res = new ArrayList<>();
for (IndexColumn col : cols) {
if (!InlineIndexHelper.AVAILABLE_TYPES.contains(col.column.getType()))
break;
InlineIndexHelper idx = new InlineIndexHelper(col.column.getType(), col.column.getColumnId(), col.sortType, table.getCompareMode());
res.add(idx);
}
return res;
}
Aggregations