add prepared statements and counters

This commit is contained in:
Alex Shvid 2015-03-12 01:27:12 -07:00
parent 019dafbf79
commit 39a463e4a6
7 changed files with 52 additions and 0 deletions

View file

@ -1,7 +1,9 @@
package casser; package casser;
import casser.core.Casser; import casser.core.Casser;
import casser.core.PreparedStreamStatement;
import casser.core.Session; import casser.core.Session;
import casser.tuple.Tuple1;
import casser.tuple.Tuple2; import casser.tuple.Tuple2;
public class Example { public class Example {
@ -35,6 +37,13 @@ public class Example {
session.delete().where(_user::getId, "==", 100L).async(); session.delete().where(_user::getId, "==", 100L).async();
PreparedStreamStatement<Tuple1<String>> ps = session.select(_user::getName).where(_user::getId, "==", null).prepare();
long cnt = ps.bind(100L).sync().count();
cnt = session.select(_user::getName).where(_user::getId, "==", 100L).count().sync();
} }
} }

View file

@ -0,0 +1,11 @@
package casser.core;
import casser.operation.AbstractOperation;
public class PreparedStatement<E> {
public AbstractOperation<E> bind(Object... params) {
return null;
}
}

View file

@ -0,0 +1,11 @@
package casser.core;
import casser.operation.AbstractStreamOperation;
public class PreparedStreamStatement<E> {
public AbstractStreamOperation<E> bind(Object... params) {
return null;
}
}

View file

@ -2,8 +2,14 @@ package casser.operation;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import casser.core.PreparedStreamStatement;
public abstract class AbstractOperation<E> { public abstract class AbstractOperation<E> {
public PreparedStreamStatement<E> prepare() {
return null;
}
public E sync() { public E sync() {
return null; return null;
} }

View file

@ -3,8 +3,14 @@ package casser.operation;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.stream.Stream; import java.util.stream.Stream;
import casser.core.PreparedStreamStatement;
public abstract class AbstractStreamOperation<E> { public abstract class AbstractStreamOperation<E> {
public PreparedStreamStatement<E> prepare() {
return null;
}
public Stream<E> sync() { public Stream<E> sync() {
return null; return null;
} }

View file

@ -0,0 +1,5 @@
package casser.operation;
public class CountOperation extends AbstractOperation<Long> {
}

View file

@ -15,6 +15,10 @@ public class SelectOperation<E> extends AbstractStreamOperation<E> {
return this; return this;
} }
public CountOperation count() {
return null;
}
public <R> SelectOperation<R> map(Function<E, R> fn) { public <R> SelectOperation<R> map(Function<E, R> fn) {
return null; return null;
} }