Add ALLOW FILTERING in the cases Cassandra requires it based on query. More result info formatting.
This commit is contained in:
parent
962145bf46
commit
d1fe54b0ce
3 changed files with 26 additions and 7 deletions
|
@ -122,9 +122,10 @@ public abstract class Operation<E> {
|
|||
ConsistencyLevel cl = ei.getAchievedConsistencyLevel();
|
||||
int se = ei.getSpeculativeExecutions();
|
||||
String warn = ei.getWarnings().stream().collect(Collectors.joining(", "));
|
||||
String ri = String.format("%s %s %s %s %sd%s%s spec-retries: %d", "C* v" + qh.getCassandraVersion(),
|
||||
qh.getAddress().toString(), qh.getDatacenter(), qh.getRack(),
|
||||
(oh != null && !oh.equals("")) ? "[" + oh + "] " : "",
|
||||
String ri = String.format("%s %s %s %s %s %s%sspec-retries: %d",
|
||||
"server v" + qh.getCassandraVersion(), qh.getAddress().toString(),
|
||||
(oh != null && !oh.equals("")) ? " [tried: " + oh + "]" : "", qh.getDatacenter(),
|
||||
qh.getRack(),
|
||||
(cl != null)
|
||||
? (" consistency: " + cl.name() + (cl.isDCLocal() ? " DC " : "")
|
||||
+ (cl.isSerial() ? " SC " : ""))
|
||||
|
|
|
@ -289,8 +289,23 @@ public final class SelectOperation<E> extends AbstractFilterStreamOperation<E, S
|
|||
|
||||
for (Filter<?> filter : filters.values()) {
|
||||
where.and(filter.getClause(sessionOps.getValuePreparer()));
|
||||
if (filter.getNode().getProperty().caseSensitiveIndex()) {
|
||||
HelenusProperty prop = filter.getNode().getProperty();
|
||||
boolean isFirstIndex = true;
|
||||
switch (prop.getColumnType()) {
|
||||
case PARTITION_KEY :
|
||||
case CLUSTERING_COLUMN :
|
||||
break;
|
||||
default :
|
||||
// When using non-Cassandra-standard 2i types or when using more than one
|
||||
// indexed column or non-indexed columns the query must include ALLOW FILTERING.
|
||||
if (prop.caseSensitiveIndex()) {
|
||||
allowFiltering = true;
|
||||
} else if (prop.getIndexName() != null) {
|
||||
allowFiltering |= !isFirstIndex;
|
||||
isFirstIndex = false;
|
||||
} else {
|
||||
allowFiltering = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import static net.helenus.core.Query.eq;
|
|||
|
||||
import java.util.UUID;
|
||||
|
||||
import com.datastax.driver.core.ConsistencyLevel;
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
@ -54,7 +55,8 @@ public class UnitOfWorkTest extends AbstractEmbeddedCassandraTest {
|
|||
|
||||
@BeforeClass
|
||||
public static void beforeTest() {
|
||||
session = Helenus.init(getSession()).showCql().add(Widget.class).autoCreateDrop().get();
|
||||
session = Helenus.init(getSession()).showCql().add(Widget.class).autoCreateDrop().consistencyLevel(
|
||||
ConsistencyLevel.ONE).idempotentQueryExecution(true).get();
|
||||
widget = session.dsl(Widget.class);
|
||||
}
|
||||
|
||||
|
@ -71,7 +73,8 @@ public class UnitOfWorkTest extends AbstractEmbeddedCassandraTest {
|
|||
uow.setPurpose("testSelectAfterSelect");
|
||||
|
||||
// This should read from the database and return a Widget.
|
||||
w2 = session.<Widget>select(widget).where(widget::id, eq(key)).single().sync(uow).orElse(null);
|
||||
w2 = session.<Widget>select(widget).where(widget::id, eq(key)).single()
|
||||
.sync(uow).orElse(null);
|
||||
|
||||
// This should read from the cache and get the same instance of a Widget.
|
||||
w3 = session.<Widget>select(widget).where(widget::id, eq(key)).single().sync(uow).orElse(null);
|
||||
|
|
Loading…
Reference in a new issue