use of com.palantir.atlasdb.keyvalue.dbkvs.impl.FullQuery in project atlasdb by palantir.
the class RangePredicateHelperTest method startRowInclusiveReverse.
@Test
public void startRowInclusiveReverse() {
FullQuery.Builder builder = FullQuery.builder();
RangePredicateHelper.create(true, DBType.ORACLE, builder).startRowInclusive(ROW_NAME);
FullQuery query = builder.build();
assertThat(query.getQuery(), equalTo(" AND row_name <= ? "));
assertThat(query.getArgs(), arrayContaining((Object) ROW_NAME));
}
use of com.palantir.atlasdb.keyvalue.dbkvs.impl.FullQuery in project atlasdb by palantir.
the class RangePredicateHelperTest method startCellInclusiveForwardOracle.
@Test
public void startCellInclusiveForwardOracle() {
FullQuery.Builder builder = FullQuery.builder();
RangePredicateHelper.create(false, DBType.ORACLE, builder).startCellInclusive(ROW_NAME, COL_NAME);
FullQuery query = builder.build();
assertThat(query.getQuery(), equalTo(" AND (row_name >= ? AND (row_name > ? OR col_name >= ?))"));
assertThat(query.getArgs(), arrayContaining(ROW_NAME, ROW_NAME, COL_NAME));
}
use of com.palantir.atlasdb.keyvalue.dbkvs.impl.FullQuery in project atlasdb by palantir.
the class RangePredicateHelperTest method endRowExclusiveEmpty.
@Test
public void endRowExclusiveEmpty() {
FullQuery.Builder builder = FullQuery.builder();
RangePredicateHelper.create(false, DBType.ORACLE, builder).endRowExclusive(PtBytes.EMPTY_BYTE_ARRAY);
FullQuery query = builder.build();
assertThat(query.getQuery(), isEmptyString());
assertThat(query.getArgs(), emptyArray());
}
use of com.palantir.atlasdb.keyvalue.dbkvs.impl.FullQuery in project atlasdb by palantir.
the class OracleOverflowValueLoader method getNewOverflowQuery.
private FullQuery getNewOverflowQuery(ConnectionSupplier conns, TableReference tableRef, ArrayHandler arg) {
String overflowTableName = getOverflowTableName(conns, tableRef);
String query = " /* SELECT_OVERFLOW (" + overflowTableName + ") */ " + " SELECT" + " /*+ USE_NL(t o) LEADING(t o) INDEX(o " + PrimaryKeyConstraintNames.get(overflowTableName) + ") */ " + " o.id, o.val " + " FROM " + overflowTableName + " o," + " TABLE(CAST(? AS " + structArrayPrefix() + "CELL_TS_TABLE)) t " + " WHERE t.max_ts = o.id ";
return new FullQuery(query).withArg(arg);
}
use of com.palantir.atlasdb.keyvalue.dbkvs.impl.FullQuery in project atlasdb by palantir.
the class OracleQueryFactory method getRowsColumnRangeSubQuery.
@Override
protected FullQuery getRowsColumnRangeSubQuery(byte[] row, long ts, BatchColumnRangeSelection columnRangeSelection) {
String query = " /* GET_ROWS_COLUMN_RANGE (" + tableName + ") */ " + "SELECT s.row_name, s.col_name, s.ts" + getValueSubselect("s", true) + " FROM ( SELECT m.row_name, m.col_name, max(m.ts) as ts" + getValueSubselectForGroupBy("m") + " FROM " + tableName + " m" + " WHERE m.row_name = ?" + " AND m.ts < ? " + (columnRangeSelection.getStartCol().length > 0 ? " AND m.col_name >= ?" : "") + (columnRangeSelection.getEndCol().length > 0 ? " AND m.col_name < ?" : "") + " GROUP BY m.row_name, m.col_name" + " ORDER BY m.row_name ASC, m.col_name ASC ) s WHERE rownum <= " + columnRangeSelection.getBatchHint();
FullQuery fullQuery = new FullQuery(query).withArg(row).withArg(ts);
if (columnRangeSelection.getStartCol().length > 0) {
fullQuery = fullQuery.withArg(columnRangeSelection.getStartCol());
}
if (columnRangeSelection.getEndCol().length > 0) {
fullQuery = fullQuery.withArg(columnRangeSelection.getEndCol());
}
return fullQuery;
}
Aggregations