├── src ├── test │ ├── resources │ │ └── dbtest.properties │ └── java │ │ └── com │ │ └── rethinkdb │ │ ├── integration │ │ ├── ManipulatingDatabasesIT.java │ │ ├── LambdasITTest.java │ │ ├── SetInsertITTest.java │ │ ├── AbstractITTest.java │ │ ├── GroupIT.java │ │ ├── FetchDataIT.java │ │ ├── ManipulatingTablesIT.java │ │ ├── FilteringIT.java │ │ ├── StringsIT.java │ │ ├── DateITTest.java │ │ ├── JoinsIT.java │ │ ├── CursorIT.java │ │ └── ModifyDataIT.java │ │ └── test │ │ └── PopulateTestObject.java └── main │ ├── java │ └── com │ │ └── rethinkdb │ │ ├── model │ │ ├── RqlLambda.java │ │ ├── Bound.java │ │ ├── Durability.java │ │ ├── RqlFunction.java │ │ ├── RqlFunction2.java │ │ ├── MapObject.java │ │ └── ConflictStrategy.java │ │ ├── util │ │ └── ThreadUtil.java │ │ ├── RethinkDBConstants.java │ │ ├── ast │ │ ├── query │ │ │ ├── gen │ │ │ │ ├── MakeObj.java │ │ │ │ ├── Datum.java │ │ │ │ ├── Not.java │ │ │ │ ├── Var.java │ │ │ │ ├── Add.java │ │ │ │ ├── All.java │ │ │ │ ├── Any.java │ │ │ │ ├── Asc.java │ │ │ │ ├── Avg.java │ │ │ │ ├── Day.java │ │ │ │ ├── Div.java │ │ │ │ ├── Eq.java │ │ │ │ ├── Ge.java │ │ │ │ ├── Gt.java │ │ │ │ ├── Le.java │ │ │ │ ├── Lt.java │ │ │ │ ├── Min.java │ │ │ │ ├── Mod.java │ │ │ │ ├── Mul.java │ │ │ │ ├── Ne.java │ │ │ │ ├── Now.java │ │ │ │ ├── Nth.java │ │ │ │ ├── Sub.java │ │ │ │ ├── Sum.java │ │ │ │ ├── Date.java │ │ │ │ ├── Desc.java │ │ │ │ ├── Info.java │ │ │ │ ├── Json.java │ │ │ │ ├── Skip.java │ │ │ │ ├── Sync.java │ │ │ │ ├── Time.java │ │ │ │ ├── Year.java │ │ │ │ ├── Changes.java │ │ │ │ ├── FunCall.java │ │ │ │ ├── Hours.java │ │ │ │ ├── Limit.java │ │ │ │ ├── Match.java │ │ │ │ ├── Merge.java │ │ │ │ ├── Month.java │ │ │ │ ├── Pluck.java │ │ │ │ ├── Slice.java │ │ │ │ ├── Append.java │ │ │ │ ├── Branch.java │ │ │ │ ├── DbDrop.java │ │ │ │ ├── During.java │ │ │ │ ├── RObject.java │ │ │ │ ├── Random.java │ │ │ │ ├── Reduce.java │ │ │ │ ├── TypeOf.java │ │ │ │ ├── Upcase.java │ │ │ │ ├── Default.java │ │ │ │ ├── ForEach.java │ │ │ │ ├── ISO8601.java │ │ │ │ ├── Literal.java │ │ │ │ ├── Minutes.java │ │ │ │ ├── Prepend.java │ │ │ │ ├── Seconds.java │ │ │ │ ├── Ungroup.java │ │ │ │ ├── Without.java │ │ │ │ ├── CoerceTo.java │ │ │ │ ├── Contains.java │ │ │ │ ├── DbCreate.java │ │ │ │ ├── Distinct.java │ │ │ │ ├── Downcase.java │ │ │ │ ├── GetField.java │ │ │ │ ├── MakeArray.java │ │ │ │ ├── SetUnion.java │ │ │ │ ├── Timezone.java │ │ │ │ ├── UserError.java │ │ │ │ ├── DayOfWeek.java │ │ │ │ ├── DayOfYear.java │ │ │ │ ├── EpochTime.java │ │ │ │ ├── IndexesOf.java │ │ │ │ ├── SetInsert.java │ │ │ │ ├── TableDrop.java │ │ │ │ ├── TimeOfDay.java │ │ │ │ ├── ToISO8601.java │ │ │ │ ├── Difference.java │ │ │ │ ├── ImplicitVar.java │ │ │ │ ├── InTimezone.java │ │ │ │ ├── JavaScript.java │ │ │ │ ├── TableCreate.java │ │ │ │ ├── TableDropTL.java │ │ │ │ ├── TableListTL.java │ │ │ │ ├── ToEpochTime.java │ │ │ │ ├── SetDifference.java │ │ │ │ ├── TableCreateTL.java │ │ │ │ ├── SetIntersection.java │ │ │ │ ├── Max.java │ │ │ │ ├── Count.java │ │ │ │ ├── Get.java │ │ │ │ ├── IsEmpty.java │ │ │ │ ├── Split.java │ │ │ │ ├── ChangeAt.java │ │ │ │ ├── DeleteAt.java │ │ │ │ ├── InsertAt.java │ │ │ │ ├── Keys.java │ │ │ │ ├── SpliceAt.java │ │ │ │ ├── DbList.java │ │ │ │ ├── Zip.java │ │ │ │ ├── IndexList.java │ │ │ │ ├── TableList.java │ │ │ │ ├── Between.java │ │ │ │ ├── Union.java │ │ │ │ ├── Filter.java │ │ │ │ ├── Sample.java │ │ │ │ ├── OrderBy.java │ │ │ │ ├── HasFields.java │ │ │ │ ├── WithFields.java │ │ │ │ ├── Group.java │ │ │ │ ├── RMap.java │ │ │ │ ├── ConcatMap.java │ │ │ │ ├── GetAll.java │ │ │ │ ├── Insert.java │ │ │ │ ├── Update.java │ │ │ │ ├── Delete.java │ │ │ │ ├── Replace.java │ │ │ │ ├── EqJoin.java │ │ │ │ ├── IndexDrop.java │ │ │ │ ├── InnerJoin.java │ │ │ │ ├── OuterJoin.java │ │ │ │ ├── IndexWait.java │ │ │ │ ├── IndexStatus.java │ │ │ │ ├── IndexCreate.java │ │ │ │ ├── Func.java │ │ │ │ ├── DB.java │ │ │ │ └── Table.java │ │ │ ├── RqlUtil.java │ │ │ └── RqlQuery.java │ │ └── helper │ │ │ ├── Arguments.java │ │ │ └── OptionalArguments.java │ │ ├── RethinkDBException.java │ │ ├── response │ │ ├── model │ │ │ ├── IndexStatusResult.java │ │ │ ├── DDLResult.java │ │ │ ├── JoinResult.java │ │ │ └── DMLResult.java │ │ ├── GroupedResponseConverter.java │ │ ├── DBResultFactory.java │ │ └── DBResponseMapper.java │ │ ├── RethinkDB.java │ │ ├── Cursor.java │ │ ├── SocketChannelFacade.java │ │ └── RethinkDBConnection.java │ └── resources │ └── logback.xml ├── .gitignore └── README.md /src/test/resources/dbtest.properties: -------------------------------------------------------------------------------- 1 | hostname=localhost -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | /.classpath 3 | /.gradle/ 4 | /.project 5 | /.settings/ 6 | /build/ 7 | /rethinkdb_data/ 8 | /target/ 9 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/model/RqlLambda.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.model; 2 | 3 | public interface RqlLambda { 4 | } 5 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/model/Bound.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.model; 2 | 3 | /** 4 | * Bound settings used for between 5 | */ 6 | public enum Bound{ 7 | closed, // include bound 8 | open, // exclude bound 9 | } -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/model/Durability.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.model; 2 | 3 | /** 4 | * The durability setting used in various options like insert or table create 5 | */ 6 | public enum Durability { 7 | hard, soft 8 | } -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/model/RqlFunction.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.model; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | 5 | public interface RqlFunction extends RqlLambda { 6 | RqlQuery apply(RqlQuery row); 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/model/RqlFunction2.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.model; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | 5 | public interface RqlFunction2 extends RqlLambda { 6 | RqlQuery apply(RqlQuery row1, RqlQuery row2); 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/util/ThreadUtil.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.util; 2 | 3 | public class ThreadUtil { 4 | 5 | public static void sleep(long milis) { 6 | try { 7 | Thread.sleep(milis); 8 | } catch (InterruptedException e) { 9 | e.printStackTrace(); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/model/MapObject.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.model; 2 | 3 | import java.util.HashMap; 4 | 5 | public class MapObject extends HashMap { 6 | 7 | public MapObject() { 8 | } 9 | 10 | public MapObject with(String key, Object value) { 11 | put(key, value); 12 | return this; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/RethinkDBConstants.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb; 2 | 3 | public class RethinkDBConstants { 4 | public static final String DEFAULT_DB_NAME = "test"; 5 | public static final String DEFAULT_TABLE_NAME = "test"; 6 | public static final String DEFAULT_HOSTNAME = "localhost"; 7 | public static final int DEFAULT_PORT = 28015; 8 | public static final int DEFAULT_TIMEOUT = 20; 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/MakeObj.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.ArrayList; 7 | 8 | // extends RqlQuery 9 | public class MakeObj extends RqlQuery { 10 | 11 | public MakeObj(java.util.Map fields) { 12 | super(Q2L.Term.TermType.MAKE_OBJ, new ArrayList(), fields); 13 | } 14 | } -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/model/ConflictStrategy.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.model; 2 | 3 | /** 4 | * The durability setting used in various options like insert or table create 5 | */ 6 | public enum ConflictStrategy{ 7 | error, // Do not insert the new document and record the conflict as an error (default) 8 | replace, // replace the old document in its entirety with the new one 9 | update // update fields of the old document with fields from the new one 10 | } -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/RethinkDBException.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb; 2 | 3 | public class RethinkDBException extends RuntimeException { 4 | public RethinkDBException() { 5 | } 6 | 7 | public RethinkDBException(String message) { 8 | super(message); 9 | } 10 | 11 | public RethinkDBException(String message, Throwable cause) { 12 | super(message, cause); 13 | } 14 | 15 | public RethinkDBException(Throwable cause) { 16 | super(cause); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/helper/Arguments.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.helper; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Arrays; 5 | import java.util.List; 6 | 7 | public class Arguments extends ArrayList { 8 | public Arguments(Object arg1) { 9 | super(); 10 | add(arg1); 11 | } 12 | 13 | public Arguments(Object... args) { 14 | super(); 15 | addAll(Arrays.asList(args)); 16 | } 17 | 18 | public Arguments(List args) { 19 | super(); 20 | addAll(args); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Datum.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.ast.query.RqlUtil; 5 | import com.rethinkdb.proto.Q2L; 6 | 7 | public class Datum extends RqlQuery { 8 | private Object value; 9 | 10 | public Datum(Object value) { 11 | super(Q2L.Term.TermType.DATUM); 12 | this.value = value; 13 | } 14 | 15 | @Override 16 | protected Q2L.Term toTerm() { 17 | return Q2L.Term.newBuilder().setType(this.getTermType()).setDatum(RqlUtil.createDatum(value)).build(); 18 | } 19 | } -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Not.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlQuery 10 | public class Not extends RqlQuery { 11 | 12 | public Not(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Not(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.NOT, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Var.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlQuery 10 | public class Var extends RqlQuery { 11 | 12 | public Var(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Var(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.VAR, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/test/java/com/rethinkdb/integration/ManipulatingDatabasesIT.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.integration; 2 | 3 | import org.fest.assertions.Assertions; 4 | import org.junit.Test; 5 | 6 | public class ManipulatingDatabasesIT extends AbstractITTest { 7 | 8 | @Test 9 | public void createListAndDropDatabase() { 10 | Assertions.assertThat(r.dbList().run(con)).contains(dbName); 11 | r.dbDrop(dbName).run(con); 12 | Assertions.assertThat(r.dbList().run(con)).excludes(dbName); 13 | r.dbCreate(dbName).run(con); 14 | Assertions.assertThat(r.dbList().run(con)).contains(dbName); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Add.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlBiOperQuery 10 | public class Add extends RqlQuery { 11 | 12 | public Add(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Add(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.ADD, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/All.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlBoolOperQuery 10 | public class All extends RqlQuery { 11 | 12 | public All(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public All(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.ALL, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Any.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlBoolOperQuery 10 | public class Any extends RqlQuery { 11 | 12 | public Any(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Any(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.ANY, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Asc.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlTopLevelQuery 10 | public class Asc extends RqlQuery { 11 | 12 | public Asc(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Asc(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.ASC, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Avg.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlMethodQuery 10 | public class Avg extends RqlQuery { 11 | 12 | public Avg(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Avg(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.AVG, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Day.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlMethodQuery 10 | public class Day extends RqlQuery { 11 | 12 | public Day(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Day(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.DAY, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Div.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlBiOperQuery 10 | public class Div extends RqlQuery { 11 | 12 | public Div(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Div(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.DIV, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Eq.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlBiCompareOperQuery 10 | public class Eq extends RqlQuery { 11 | 12 | public Eq(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Eq(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.EQ, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Ge.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlBiCompareOperQuery 10 | public class Ge extends RqlQuery { 11 | 12 | public Ge(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Ge(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.GE, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Gt.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlBiCompareOperQuery 10 | public class Gt extends RqlQuery { 11 | 12 | public Gt(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Gt(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.GT, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Le.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlBiCompareOperQuery 10 | public class Le extends RqlQuery { 11 | 12 | public Le(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Le(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.LE, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Lt.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlBiCompareOperQuery 10 | public class Lt extends RqlQuery { 11 | 12 | public Lt(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Lt(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.LT, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Min.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlMethodQuery 10 | public class Min extends RqlQuery { 11 | 12 | public Min(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Min(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.MIN, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Mod.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlBiOperQuery 10 | public class Mod extends RqlQuery { 11 | 12 | public Mod(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Mod(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.MOD, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Mul.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlBiOperQuery 10 | public class Mul extends RqlQuery { 11 | 12 | public Mul(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Mul(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.MUL, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Ne.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlBiCompareOperQuery 10 | public class Ne extends RqlQuery { 11 | 12 | public Ne(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Ne(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.NE, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Now.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlTopLevelQuery 10 | public class Now extends RqlQuery { 11 | 12 | public Now(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Now(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.NOW, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Nth.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlBracketQuery 10 | public class Nth extends RqlQuery { 11 | 12 | public Nth(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Nth(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.NTH, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Sub.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlBiOperQuery 10 | public class Sub extends RqlQuery { 11 | 12 | public Sub(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Sub(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.SUB, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Sum.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlMethodQuery 10 | public class Sum extends RqlQuery { 11 | 12 | public Sum(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Sum(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.SUM, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Date.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlMethodQuery 10 | public class Date extends RqlQuery { 11 | 12 | public Date(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Date(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.DATE, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Desc.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlTopLevelQuery 10 | public class Desc extends RqlQuery { 11 | 12 | public Desc(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Desc(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.DESC, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Info.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlMethodQuery 10 | public class Info extends RqlQuery { 11 | 12 | public Info(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Info(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.INFO, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Json.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlTopLevelQuery 10 | public class Json extends RqlQuery { 11 | 12 | public Json(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Json(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.JSON, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Skip.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlMethodQuery 10 | public class Skip extends RqlQuery { 11 | 12 | public Skip(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Skip(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.SKIP, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Sync.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlMethodQuery 10 | public class Sync extends RqlQuery { 11 | 12 | public Sync(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Sync(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.SYNC, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Time.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlTopLevelQuery 10 | public class Time extends RqlQuery { 11 | 12 | public Time(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Time(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.TIME, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Year.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlMethodQuery 10 | public class Year extends RqlQuery { 11 | 12 | public Year(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Year(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.YEAR, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Changes.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlMethodQuery 10 | public class Changes extends RqlQuery { 11 | 12 | public Changes(List args, Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Changes(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.CHANGES, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/FunCall.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlQuery 10 | public class FunCall extends RqlQuery { 11 | 12 | public FunCall(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public FunCall(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.FUNCALL, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Hours.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlMethodQuery 10 | public class Hours extends RqlQuery { 11 | 12 | public Hours(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Hours(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.HOURS, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Limit.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlMethodQuery 10 | public class Limit extends RqlQuery { 11 | 12 | public Limit(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Limit(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.LIMIT, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Match.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlMethodQuery 10 | public class Match extends RqlQuery { 11 | 12 | public Match(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Match(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.MATCH, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Merge.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlMethodQuery 10 | public class Merge extends RqlQuery { 11 | 12 | public Merge(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Merge(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.MERGE, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Month.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlMethodQuery 10 | public class Month extends RqlQuery { 11 | 12 | public Month(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Month(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.MONTH, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Pluck.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlMethodQuery 10 | public class Pluck extends RqlQuery { 11 | 12 | public Pluck(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Pluck(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.PLUCK, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Slice.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlBracketQuery 10 | public class Slice extends RqlQuery { 11 | 12 | public Slice(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Slice(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.SLICE, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Append.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlMethodQuery 10 | public class Append extends RqlQuery { 11 | 12 | public Append(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Append(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.APPEND, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Branch.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlTopLevelQuery 10 | public class Branch extends RqlQuery { 11 | 12 | public Branch(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Branch(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.BRANCH, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/DbDrop.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlTopLevelQuery 10 | public class DbDrop extends RqlQuery { 11 | 12 | public DbDrop(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public DbDrop(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.DB_DROP, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/During.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlMethodQuery 10 | public class During extends RqlQuery { 11 | 12 | public During(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public During(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.DURING, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/RObject.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlMethodQuery 10 | public class RObject extends RqlQuery { 11 | 12 | public RObject(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public RObject(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.OBJECT, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Random.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlTopLevelQuery 10 | public class Random extends RqlQuery { 11 | 12 | public Random(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Random(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.RANDOM, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Reduce.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlMethodQuery 10 | public class Reduce extends RqlQuery { 11 | 12 | public Reduce(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Reduce(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.REDUCE, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/TypeOf.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlMethodQuery 10 | public class TypeOf extends RqlQuery { 11 | 12 | public TypeOf(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public TypeOf(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.TYPEOF, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Upcase.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlMethodQuery 10 | public class Upcase extends RqlQuery { 11 | 12 | public Upcase(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Upcase(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.UPCASE, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Default.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlMethodQuery 10 | public class Default extends RqlQuery { 11 | 12 | public Default(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Default(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.DEFAULT, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/ForEach.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlMethodQuery 10 | public class ForEach extends RqlQuery { 11 | 12 | public ForEach(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public ForEach(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.FOREACH, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/ISO8601.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlTopLevelQuery 10 | public class ISO8601 extends RqlQuery { 11 | 12 | public ISO8601(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public ISO8601(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.ISO8601, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Literal.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlTopLevelQuery 10 | public class Literal extends RqlQuery { 11 | 12 | public Literal(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Literal(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.LITERAL, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Minutes.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlMethodQuery 10 | public class Minutes extends RqlQuery { 11 | 12 | public Minutes(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Minutes(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.MINUTES, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Prepend.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlMethodQuery 10 | public class Prepend extends RqlQuery { 11 | 12 | public Prepend(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Prepend(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.PREPEND, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Seconds.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlMethodQuery 10 | public class Seconds extends RqlQuery { 11 | 12 | public Seconds(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Seconds(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.SECONDS, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Ungroup.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlMethodQuery 10 | public class Ungroup extends RqlQuery { 11 | 12 | public Ungroup(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Ungroup(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.UNGROUP, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Without.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlMethodQuery 10 | public class Without extends RqlQuery { 11 | 12 | public Without(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Without(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.WITHOUT, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/CoerceTo.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlMethodQuery 10 | public class CoerceTo extends RqlQuery { 11 | 12 | public CoerceTo(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public CoerceTo(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.COERCE_TO, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Contains.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlMethodQuery 10 | public class Contains extends RqlQuery { 11 | 12 | public Contains(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Contains(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.CONTAINS, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/DbCreate.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlTopLevelQuery 10 | public class DbCreate extends RqlQuery { 11 | 12 | public DbCreate(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public DbCreate(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.DB_CREATE, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Distinct.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlMethodQuery 10 | public class Distinct extends RqlQuery { 11 | 12 | public Distinct(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Distinct(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.DISTINCT, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Downcase.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlMethodQuery 10 | public class Downcase extends RqlQuery { 11 | 12 | public Downcase(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Downcase(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.DOWNCASE, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/GetField.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlBracketQuery 10 | public class GetField extends RqlQuery { 11 | 12 | public GetField(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public GetField(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.GET_FIELD, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/MakeArray.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlQuery 10 | public class MakeArray extends RqlQuery { 11 | 12 | public MakeArray(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public MakeArray(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.MAKE_ARRAY, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/SetUnion.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlMethodQuery 10 | public class SetUnion extends RqlQuery { 11 | 12 | public SetUnion(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public SetUnion(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.SET_UNION, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Timezone.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlMethodQuery 10 | public class Timezone extends RqlQuery { 11 | 12 | public Timezone(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Timezone(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.TIMEZONE, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/UserError.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlTopLevelQuery 10 | public class UserError extends RqlQuery { 11 | 12 | public UserError(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public UserError(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.ERROR, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/DayOfWeek.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlMethodQuery 10 | public class DayOfWeek extends RqlQuery { 11 | 12 | public DayOfWeek(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public DayOfWeek(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.DAY_OF_WEEK, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/DayOfYear.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlMethodQuery 10 | public class DayOfYear extends RqlQuery { 11 | 12 | public DayOfYear(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public DayOfYear(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.DAY_OF_YEAR, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/EpochTime.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlTopLevelQuery 10 | public class EpochTime extends RqlQuery { 11 | 12 | public EpochTime(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public EpochTime(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.EPOCH_TIME, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/IndexesOf.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlMethodQuery 10 | public class IndexesOf extends RqlQuery { 11 | 12 | public IndexesOf(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public IndexesOf(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.INDEXES_OF, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/SetInsert.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlMethodQuery 10 | public class SetInsert extends RqlQuery { 11 | 12 | public SetInsert(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public SetInsert(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.SET_INSERT, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/TableDrop.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlMethodQuery 10 | public class TableDrop extends RqlQuery { 11 | 12 | public TableDrop(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public TableDrop(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.TABLE_DROP, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/TimeOfDay.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlMethodQuery 10 | public class TimeOfDay extends RqlQuery { 11 | 12 | public TimeOfDay(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public TimeOfDay(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.TIME_OF_DAY, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/ToISO8601.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlMethodQuery 10 | public class ToISO8601 extends RqlQuery { 11 | 12 | public ToISO8601(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public ToISO8601(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.TO_ISO8601, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Difference.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlMethodQuery 10 | public class Difference extends RqlQuery { 11 | 12 | public Difference(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public Difference(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.DIFFERENCE, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/ImplicitVar.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlQuery 10 | public class ImplicitVar extends RqlQuery { 11 | 12 | public ImplicitVar(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public ImplicitVar(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.IMPLICIT_VAR, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/InTimezone.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlMethodQuery 10 | public class InTimezone extends RqlQuery { 11 | 12 | public InTimezone(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public InTimezone(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.IN_TIMEZONE, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/JavaScript.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlTopLevelQuery 10 | public class JavaScript extends RqlQuery { 11 | 12 | public JavaScript(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public JavaScript(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.JAVASCRIPT, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/TableCreate.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlMethodQuery 10 | public class TableCreate extends RqlQuery { 11 | 12 | public TableCreate(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public TableCreate(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.TABLE_CREATE, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/TableDropTL.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlTopLevelQuery 10 | public class TableDropTL extends RqlQuery { 11 | 12 | public TableDropTL(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public TableDropTL(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.TABLE_DROP, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/TableListTL.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlTopLevelQuery 10 | public class TableListTL extends RqlQuery { 11 | 12 | public TableListTL(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public TableListTL(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.TABLE_LIST, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/ToEpochTime.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlMethodQuery 10 | public class ToEpochTime extends RqlQuery { 11 | 12 | public ToEpochTime(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public ToEpochTime(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.TO_EPOCH_TIME, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/SetDifference.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlMethodQuery 10 | public class SetDifference extends RqlQuery { 11 | 12 | public SetDifference(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public SetDifference(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.SET_DIFFERENCE, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/TableCreateTL.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlTopLevelQuery 10 | public class TableCreateTL extends RqlQuery { 11 | 12 | public TableCreateTL(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public TableCreateTL(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.TABLE_CREATE, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/SetIntersection.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | // extends RqlMethodQuery 10 | public class SetIntersection extends RqlQuery { 11 | 12 | public SetIntersection(List args, java.util.Map optionalArgs) { 13 | this(null, args, optionalArgs); 14 | } 15 | 16 | public SetIntersection(RqlQuery prev, List args, Map optionalArgs) { 17 | super(prev, Q2L.Term.TermType.SET_INTERSECTION, args, optionalArgs); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/response/model/IndexStatusResult.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.response.model; 2 | 3 | public class IndexStatusResult { 4 | private String index; 5 | private boolean ready; 6 | 7 | /** 8 | * the index name 9 | */ 10 | public String getIndex() { 11 | return index; 12 | } 13 | 14 | /** 15 | * is index ready 16 | */ 17 | public boolean isReady() { 18 | return ready; 19 | } 20 | 21 | @Override 22 | public String toString() { 23 | return "IndexStatusResult{" + 24 | "index='" + index + '\'' + 25 | ", ready=" + ready + 26 | '}'; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/helper/OptionalArguments.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.helper; 2 | 3 | import java.util.HashMap; 4 | import java.util.List; 5 | 6 | public class OptionalArguments extends HashMap { 7 | 8 | public OptionalArguments() { 9 | super(); 10 | } 11 | 12 | public OptionalArguments with(String key, Object value) { 13 | if (value != null) { 14 | put(key, value); 15 | } 16 | return this; 17 | } 18 | 19 | public OptionalArguments with(String key, List value) { 20 | if (value != null) { 21 | put(key, value); 22 | } 23 | return this; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/response/model/DDLResult.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.response.model; 2 | 3 | public class DDLResult { 4 | private int created; 5 | private int dropped; 6 | 7 | /** 8 | * The number of created entities 9 | */ 10 | public int getCreated() { 11 | return created; 12 | } 13 | 14 | /** 15 | * The number of dropped entities 16 | */ 17 | public int getDropped() { 18 | return dropped; 19 | } 20 | 21 | @Override 22 | public String toString() { 23 | return "GenericDBResult{" + 24 | "created=" + created + 25 | ", dropped=" + dropped + 26 | "}"; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Max.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.RethinkDBConnection; 4 | import com.rethinkdb.ast.query.RqlQuery; 5 | import com.rethinkdb.proto.Q2L; 6 | 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | // extends RqlMethodQuery 11 | public class Max extends RqlQuery { 12 | 13 | public Max(List args, java.util.Map optionalArgs) { 14 | this(null, args, optionalArgs); 15 | } 16 | 17 | public Max(RqlQuery prev, List args, Map optionalArgs) { 18 | super(prev, Q2L.Term.TermType.MAX, args, optionalArgs); 19 | } 20 | 21 | public T runTyped(RethinkDBConnection connection) { 22 | return (T)super.run(connection); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/response/GroupedResponseConverter.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.response; 2 | 3 | import com.rethinkdb.RethinkDBException; 4 | 5 | import java.util.HashMap; 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | public class GroupedResponseConverter { 10 | public static Map convert(Map map) { 11 | if (!"GROUPED_DATA".equals(map.get("$reql_type$"))) { 12 | throw new RethinkDBException("Expected grouped data but found something else"); 13 | } 14 | 15 | Map result = new HashMap(); 16 | List data = (List) map.get("data"); 17 | for (List group : data) { 18 | result.put((K)group.get(0), (V)group.get(1)); 19 | } 20 | return result; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/response/model/JoinResult.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.response.model; 2 | 3 | import java.util.Map; 4 | 5 | public class JoinResult { 6 | private Map left; 7 | private Map right; 8 | 9 | /** 10 | * The left object in the join 11 | * @return left object 12 | */ 13 | public Map getLeft() { 14 | return left; 15 | } 16 | 17 | /** 18 | * The right object in the join 19 | * @return right object 20 | */ 21 | public Map getRight() { 22 | return right; 23 | } 24 | 25 | @Override 26 | public String toString() { 27 | return "JoinResult{" + 28 | "left=" + left + 29 | ", right=" + right + 30 | '}'; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Count.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.RethinkDBConnection; 4 | import com.rethinkdb.ast.query.RqlQuery; 5 | import com.rethinkdb.proto.Q2L; 6 | 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | // extends RqlMethodQuery 11 | public class Count extends RqlQuery { 12 | 13 | public Count(List args, java.util.Map optionalArgs) { 14 | this(null, args, optionalArgs); 15 | } 16 | 17 | public Count(RqlQuery prev, List args, Map optionalArgs) { 18 | super(prev, Q2L.Term.TermType.COUNT, args, optionalArgs); 19 | } 20 | 21 | @Override 22 | public Long run(RethinkDBConnection connection) { 23 | return ((Double)super.run(connection)).longValue(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Get.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.RethinkDBConnection; 4 | import com.rethinkdb.ast.query.RqlQuery; 5 | import com.rethinkdb.proto.Q2L; 6 | 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | // extends RqlMethodQuery 11 | public class Get extends RqlQuery { 12 | 13 | public Get(List args, java.util.Map optionalArgs) { 14 | this(null, args, optionalArgs); 15 | } 16 | 17 | public Get(RqlQuery prev, List args, Map optionalArgs) { 18 | super(prev, Q2L.Term.TermType.GET, args, optionalArgs); 19 | } 20 | 21 | @Override 22 | public Map run(RethinkDBConnection connection) { 23 | return (Map)super.run(connection); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/IsEmpty.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.RethinkDBConnection; 4 | import com.rethinkdb.ast.query.RqlQuery; 5 | import com.rethinkdb.proto.Q2L; 6 | 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | // extends RqlMethodQuery 11 | public class IsEmpty extends RqlQuery { 12 | 13 | public IsEmpty(List args, java.util.Map optionalArgs) { 14 | this(null, args, optionalArgs); 15 | } 16 | 17 | public IsEmpty(RqlQuery prev, List args, Map optionalArgs) { 18 | super(prev, Q2L.Term.TermType.IS_EMPTY, args, optionalArgs); 19 | } 20 | 21 | @Override 22 | public Boolean run(RethinkDBConnection connection) { 23 | return (Boolean) super.run(connection); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Split.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.RethinkDBConnection; 4 | import com.rethinkdb.ast.query.RqlQuery; 5 | import com.rethinkdb.proto.Q2L; 6 | 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | // extends RqlMethodQuery 11 | public class Split extends RqlQuery { 12 | 13 | public Split(List args, java.util.Map optionalArgs) { 14 | this(null, args, optionalArgs); 15 | } 16 | 17 | public Split(RqlQuery prev, List args, Map optionalArgs) { 18 | super(prev, Q2L.Term.TermType.SPLIT, args, optionalArgs); 19 | } 20 | 21 | @Override 22 | public List run(RethinkDBConnection connection) { 23 | return (List) super.run(connection); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/ChangeAt.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.RethinkDBConnection; 4 | import com.rethinkdb.ast.query.RqlQuery; 5 | import com.rethinkdb.proto.Q2L; 6 | 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | // extends RqlMethodQuery 11 | public class ChangeAt extends RqlQuery { 12 | 13 | public ChangeAt(List args, java.util.Map optionalArgs) { 14 | this(null, args, optionalArgs); 15 | } 16 | 17 | public ChangeAt(RqlQuery prev, List args, Map optionalArgs) { 18 | super(prev, Q2L.Term.TermType.CHANGE_AT, args, optionalArgs); 19 | } 20 | 21 | @Override 22 | public List run(RethinkDBConnection connection) { 23 | return (List) super.run(connection); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/DeleteAt.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.RethinkDBConnection; 4 | import com.rethinkdb.ast.query.RqlQuery; 5 | import com.rethinkdb.proto.Q2L; 6 | 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | // extends RqlMethodQuery 11 | public class DeleteAt extends RqlQuery { 12 | 13 | public DeleteAt(List args, java.util.Map optionalArgs) { 14 | this(null, args, optionalArgs); 15 | } 16 | 17 | public DeleteAt(RqlQuery prev, List args, Map optionalArgs) { 18 | super(prev, Q2L.Term.TermType.DELETE_AT, args, optionalArgs); 19 | } 20 | 21 | @Override 22 | public List run(RethinkDBConnection connection) { 23 | return (List) super.run(connection); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/InsertAt.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.RethinkDBConnection; 4 | import com.rethinkdb.ast.query.RqlQuery; 5 | import com.rethinkdb.proto.Q2L; 6 | 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | // extends RqlMethodQuery 11 | public class InsertAt extends RqlQuery { 12 | 13 | public InsertAt(List args, java.util.Map optionalArgs) { 14 | this(null, args, optionalArgs); 15 | } 16 | 17 | public InsertAt(RqlQuery prev, List args, Map optionalArgs) { 18 | super(prev, Q2L.Term.TermType.INSERT_AT, args, optionalArgs); 19 | } 20 | 21 | @Override 22 | public List run(RethinkDBConnection connection) { 23 | return (List) super.run(connection); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Keys.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.RethinkDBConnection; 4 | import com.rethinkdb.ast.query.RqlQuery; 5 | import com.rethinkdb.proto.Q2L; 6 | 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | // extends RqlMethodQuery 11 | public class Keys extends RqlQuery { 12 | 13 | public Keys(List args, java.util.Map optionalArgs) { 14 | this(null, args, optionalArgs); 15 | } 16 | 17 | public Keys(RqlQuery prev, List args, Map optionalArgs) { 18 | super(prev, Q2L.Term.TermType.KEYS, args, optionalArgs); 19 | } 20 | 21 | @Override 22 | public List run(RethinkDBConnection connection) { 23 | return (List) super.run(connection); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/SpliceAt.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.RethinkDBConnection; 4 | import com.rethinkdb.ast.query.RqlQuery; 5 | import com.rethinkdb.proto.Q2L; 6 | 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | // extends RqlMethodQuery 11 | public class SpliceAt extends RqlQuery { 12 | 13 | public SpliceAt(List args, java.util.Map optionalArgs) { 14 | this(null, args, optionalArgs); 15 | } 16 | 17 | public SpliceAt(RqlQuery prev, List args, Map optionalArgs) { 18 | super(prev, Q2L.Term.TermType.SPLICE_AT, args, optionalArgs); 19 | } 20 | 21 | @Override 22 | public List run(RethinkDBConnection connection) { 23 | return (List) super.run(connection); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/test/java/com/rethinkdb/test/PopulateTestObject.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.test; 2 | 3 | import java.util.List; 4 | 5 | public class PopulateTestObject { 6 | private int anInt; 7 | private double aDouble; 8 | private float aFloat; 9 | private List aStringList; 10 | private String aString; 11 | private String aNull; 12 | 13 | public int getAnInt() { 14 | return anInt; 15 | } 16 | 17 | public double getaDouble() { 18 | return aDouble; 19 | } 20 | 21 | public float getaFloat() { 22 | return aFloat; 23 | } 24 | 25 | public List getaStringList() { 26 | return aStringList; 27 | } 28 | 29 | public String getaString() { 30 | return aString; 31 | } 32 | 33 | public String getaNull() { 34 | return aNull; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/DbList.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.RethinkDBConnection; 4 | import com.rethinkdb.ast.query.RqlQuery; 5 | import com.rethinkdb.proto.Q2L; 6 | 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | // extends RqlTopLevelQuery 11 | public class DbList extends RqlQuery { 12 | 13 | public DbList(List args, java.util.Map optionalArgs) { 14 | this(null, args, optionalArgs); 15 | } 16 | 17 | public DbList(RqlQuery prev, List args, Map optionalArgs) { 18 | super(prev, Q2L.Term.TermType.DB_LIST, args, optionalArgs); 19 | } 20 | 21 | @Override 22 | public List run(RethinkDBConnection connection) { 23 | return (List) super.run(connection); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Zip.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.RethinkDBConnection; 4 | import com.rethinkdb.ast.query.RqlQuery; 5 | import com.rethinkdb.proto.Q2L; 6 | 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | // extends RqlMethodQuery 11 | public class Zip extends RqlQuery { 12 | 13 | public Zip(List args, java.util.Map optionalArgs) { 14 | this(null, args, optionalArgs); 15 | } 16 | 17 | public Zip(RqlQuery prev, List args, Map optionalArgs) { 18 | super(prev, Q2L.Term.TermType.ZIP, args, optionalArgs); 19 | } 20 | 21 | @Override 22 | public List> run(RethinkDBConnection connection) { 23 | return (List>)super.run(connection); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/IndexList.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.RethinkDBConnection; 4 | import com.rethinkdb.ast.query.RqlQuery; 5 | import com.rethinkdb.proto.Q2L; 6 | 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | // extends RqlMethodQuery 11 | public class IndexList extends RqlQuery { 12 | 13 | public IndexList(List args, java.util.Map optionalArgs) { 14 | this(null, args, optionalArgs); 15 | } 16 | 17 | public IndexList(RqlQuery prev, List args, Map optionalArgs) { 18 | super(prev, Q2L.Term.TermType.INDEX_LIST, args, optionalArgs); 19 | } 20 | 21 | @Override 22 | public List run(RethinkDBConnection connection) { 23 | return (List) super.run(connection); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/TableList.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.RethinkDBConnection; 4 | import com.rethinkdb.ast.query.RqlQuery; 5 | import com.rethinkdb.proto.Q2L; 6 | 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | // extends RqlMethodQuery 11 | public class TableList extends RqlQuery { 12 | 13 | public TableList(List args, java.util.Map optionalArgs) { 14 | this(null, args, optionalArgs); 15 | } 16 | 17 | public TableList(RqlQuery prev, List args, Map optionalArgs) { 18 | super(prev, Q2L.Term.TermType.TABLE_LIST, args, optionalArgs); 19 | } 20 | 21 | @Override 22 | public List run(RethinkDBConnection connection) { 23 | return (List) super.run(connection); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Between.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.RethinkDBConnection; 4 | import com.rethinkdb.ast.query.RqlQuery; 5 | import com.rethinkdb.proto.Q2L; 6 | 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | // extends RqlMethodQuery 11 | public class Between extends RqlQuery { 12 | 13 | public Between(List args, java.util.Map optionalArgs) { 14 | this(null, args, optionalArgs); 15 | } 16 | 17 | public Between(RqlQuery prev, List args, Map optionalArgs) { 18 | super(prev, Q2L.Term.TermType.BETWEEN, args, optionalArgs); 19 | } 20 | 21 | @Override 22 | public List> run(RethinkDBConnection connection) { 23 | return (List>)super.run(connection); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Union.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.RethinkDBConnection; 4 | import com.rethinkdb.ast.query.RqlQuery; 5 | import com.rethinkdb.proto.Q2L; 6 | 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | // extends RqlMethodQuery 11 | public class Union extends RqlQuery { 12 | 13 | public Union(List args, java.util.Map optionalArgs) { 14 | this(null, args, optionalArgs); 15 | } 16 | 17 | public Union(RqlQuery prev, List args, Map optionalArgs) { 18 | super(prev, Q2L.Term.TermType.UNION, args, optionalArgs); 19 | } 20 | 21 | @Override 22 | public List> run(RethinkDBConnection connection) { 23 | return (List>) super.run(connection); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Filter.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.RethinkDBConnection; 4 | import com.rethinkdb.ast.query.RqlQuery; 5 | import com.rethinkdb.proto.Q2L; 6 | 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | // extends RqlMethodQuery 11 | public class Filter extends RqlQuery { 12 | 13 | public Filter(List args, java.util.Map optionalArgs) { 14 | this(null, args, optionalArgs); 15 | } 16 | 17 | public Filter(RqlQuery prev, List args, Map optionalArgs) { 18 | super(prev, Q2L.Term.TermType.FILTER, args, optionalArgs); 19 | } 20 | 21 | @Override 22 | public List> run(RethinkDBConnection connection) { 23 | return (List>)super.run(connection); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Sample.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.RethinkDBConnection; 4 | import com.rethinkdb.ast.query.RqlQuery; 5 | import com.rethinkdb.proto.Q2L; 6 | 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | // extends RqlMethodQuery 11 | public class Sample extends RqlQuery { 12 | 13 | public Sample(List args, java.util.Map optionalArgs) { 14 | this(null, args, optionalArgs); 15 | } 16 | 17 | public Sample(RqlQuery prev, List args, Map optionalArgs) { 18 | super(prev, Q2L.Term.TermType.SAMPLE, args, optionalArgs); 19 | } 20 | 21 | @Override 22 | public List> run(RethinkDBConnection connection) { 23 | return (List>) super.run(connection); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/OrderBy.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.RethinkDBConnection; 4 | import com.rethinkdb.ast.query.RqlQuery; 5 | import com.rethinkdb.proto.Q2L; 6 | 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | // extends RqlMethodQuery 11 | public class OrderBy extends RqlQuery { 12 | 13 | public OrderBy(List args, java.util.Map optionalArgs) { 14 | this(null, args, optionalArgs); 15 | } 16 | 17 | public OrderBy(RqlQuery prev, List args, Map optionalArgs) { 18 | super(prev, Q2L.Term.TermType.ORDERBY, args, optionalArgs); 19 | } 20 | 21 | @Override 22 | public List> run(RethinkDBConnection connection) { 23 | return (List>) super.run(connection); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/HasFields.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.RethinkDBConnection; 4 | import com.rethinkdb.ast.query.RqlQuery; 5 | import com.rethinkdb.proto.Q2L; 6 | 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | // extends RqlMethodQuery 11 | public class HasFields extends RqlQuery { 12 | 13 | public HasFields(List args, java.util.Map optionalArgs) { 14 | this(null, args, optionalArgs); 15 | } 16 | 17 | public HasFields(RqlQuery prev, List args, Map optionalArgs) { 18 | super(prev, Q2L.Term.TermType.HAS_FIELDS, args, optionalArgs); 19 | } 20 | 21 | @Override 22 | public List> run(RethinkDBConnection connection) { 23 | return (List>) super.run(connection); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/WithFields.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.RethinkDBConnection; 4 | import com.rethinkdb.ast.query.RqlQuery; 5 | import com.rethinkdb.proto.Q2L; 6 | 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | // extends RqlMethodQuery 11 | public class WithFields extends RqlQuery { 12 | 13 | public WithFields(List args, java.util.Map optionalArgs) { 14 | this(null, args, optionalArgs); 15 | } 16 | 17 | public WithFields(RqlQuery prev, List args, Map optionalArgs) { 18 | super(prev, Q2L.Term.TermType.WITH_FIELDS, args, optionalArgs); 19 | } 20 | 21 | @Override 22 | public List> run(RethinkDBConnection connection) { 23 | return (List>) super.run(connection); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Group.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.RethinkDBConnection; 4 | import com.rethinkdb.ast.query.RqlQuery; 5 | import com.rethinkdb.proto.Q2L; 6 | 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | // extends RqlMethodQuery 11 | public class Group extends RqlQuery { 12 | 13 | public Group(List args, java.util.Map optionalArgs) { 14 | this(null, args, optionalArgs); 15 | } 16 | 17 | public Group(RqlQuery prev, List args, Map optionalArgs) { 18 | super(prev, Q2L.Term.TermType.GROUP, args, optionalArgs); 19 | } 20 | 21 | // @Override 22 | // public Map>> run(RethinkDBConnection connection) { 23 | // return (Map>>) ((Map)super.run(connection)).get("data"); 24 | // } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/RMap.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.RethinkDBConnection; 4 | import com.rethinkdb.ast.query.RqlQuery; 5 | import com.rethinkdb.proto.Q2L; 6 | 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | // extends RqlMethodQuery 11 | public class RMap extends RqlQuery { 12 | 13 | public RMap(List args, java.util.Map optionalArgs) { 14 | this(null, args, optionalArgs); 15 | } 16 | 17 | public RMap(RqlQuery prev, List args, Map optionalArgs) { 18 | super(prev, Q2L.Term.TermType.MAP, args, optionalArgs); 19 | } 20 | 21 | @Override 22 | public List run(RethinkDBConnection connection) { 23 | return (List)super.run(connection); 24 | } 25 | 26 | public List runTyped(RethinkDBConnection connection) { 27 | return (List)super.run(connection); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/ConcatMap.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.RethinkDBConnection; 4 | import com.rethinkdb.ast.query.RqlQuery; 5 | import com.rethinkdb.proto.Q2L; 6 | 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | // extends RqlMethodQuery 11 | public class ConcatMap extends RqlQuery { 12 | 13 | public ConcatMap(List args, java.util.Map optionalArgs) { 14 | this(null, args, optionalArgs); 15 | } 16 | 17 | public ConcatMap(RqlQuery prev, List args, Map optionalArgs) { 18 | super(prev, Q2L.Term.TermType.CONCATMAP, args, optionalArgs); 19 | } 20 | 21 | @Override 22 | public List run(RethinkDBConnection connection) { 23 | return (List)super.run(connection); 24 | } 25 | 26 | public List runTyped(RethinkDBConnection connection) { 27 | return (List)super.run(connection); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/GetAll.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.Cursor; 4 | import com.rethinkdb.RethinkDBConnection; 5 | import com.rethinkdb.ast.helper.Arguments; 6 | import com.rethinkdb.ast.helper.OptionalArguments; 7 | import com.rethinkdb.ast.query.RqlQuery; 8 | import com.rethinkdb.proto.Q2L; 9 | 10 | import java.util.List; 11 | import java.util.Map; 12 | 13 | // extends RqlMethodQuery 14 | public class GetAll extends RqlQuery { 15 | 16 | public GetAll(List args, java.util.Map optionalArgs) { 17 | this(null, args, optionalArgs); 18 | } 19 | 20 | public GetAll(RqlQuery prev, List args, Map optionalArgs) { 21 | super(prev, Q2L.Term.TermType.GET_ALL, args, optionalArgs); 22 | } 23 | 24 | @Override 25 | public Cursor> run(RethinkDBConnection connection) { 26 | return connection.runForCursor(toTerm()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Insert.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.RethinkDBConnection; 4 | import com.rethinkdb.ast.query.RqlQuery; 5 | import com.rethinkdb.proto.Q2L; 6 | import com.rethinkdb.response.DBResponseMapper; 7 | import com.rethinkdb.response.model.DMLResult; 8 | 9 | import java.util.List; 10 | import java.util.Map; 11 | 12 | // extends RqlMethodQuery 13 | public class Insert extends RqlQuery { 14 | 15 | public Insert(List args, java.util.Map optionalArgs) { 16 | this(null, args, optionalArgs); 17 | } 18 | 19 | public Insert(RqlQuery prev, List args, Map optionalArgs) { 20 | super(prev, Q2L.Term.TermType.INSERT, args, optionalArgs); 21 | } 22 | 23 | @Override 24 | public DMLResult run(RethinkDBConnection connection) { 25 | return DBResponseMapper.populateObject(new DMLResult(), (Map) super.run(connection)); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Update.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.RethinkDBConnection; 4 | import com.rethinkdb.ast.query.RqlQuery; 5 | import com.rethinkdb.proto.Q2L; 6 | import com.rethinkdb.response.DBResponseMapper; 7 | import com.rethinkdb.response.model.DMLResult; 8 | 9 | import java.util.List; 10 | import java.util.Map; 11 | 12 | // extends RqlMethodQuery 13 | public class Update extends RqlQuery { 14 | 15 | public Update(List args, java.util.Map optionalArgs) { 16 | this(null, args, optionalArgs); 17 | } 18 | 19 | public Update(RqlQuery prev, List args, Map optionalArgs) { 20 | super(prev, Q2L.Term.TermType.UPDATE, args, optionalArgs); 21 | } 22 | 23 | @Override 24 | public DMLResult run(RethinkDBConnection connection) { 25 | return DBResponseMapper.populateObject(new DMLResult(), (Map) super.run(connection)); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Delete.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.RethinkDBConnection; 4 | import com.rethinkdb.ast.query.RqlQuery; 5 | import com.rethinkdb.proto.Q2L; 6 | import com.rethinkdb.response.DBResponseMapper; 7 | import com.rethinkdb.response.model.DMLResult; 8 | 9 | import java.util.List; 10 | import java.util.Map; 11 | 12 | // extends RqlMethodQuery 13 | public class Delete extends RqlQuery { 14 | 15 | public Delete(List args, java.util.Map optionalArgs) { 16 | this(null, args, optionalArgs); 17 | } 18 | 19 | public Delete(RqlQuery prev, List args, Map optionalArgs) { 20 | super(prev, Q2L.Term.TermType.DELETE, args, optionalArgs); 21 | } 22 | 23 | 24 | @Override 25 | public DMLResult run(RethinkDBConnection connection) { 26 | return DBResponseMapper.populateObject(new DMLResult(), (Map) super.run(connection)); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Replace.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.RethinkDBConnection; 4 | import com.rethinkdb.ast.query.RqlQuery; 5 | import com.rethinkdb.proto.Q2L; 6 | import com.rethinkdb.response.DBResponseMapper; 7 | import com.rethinkdb.response.model.DMLResult; 8 | 9 | import java.util.List; 10 | import java.util.Map; 11 | 12 | // extends RqlMethodQuery 13 | public class Replace extends RqlQuery { 14 | 15 | public Replace(List args, java.util.Map optionalArgs) { 16 | this(null, args, optionalArgs); 17 | } 18 | 19 | public Replace(RqlQuery prev, List args, Map optionalArgs) { 20 | super(prev, Q2L.Term.TermType.REPLACE, args, optionalArgs); 21 | } 22 | 23 | @Override 24 | public DMLResult run(RethinkDBConnection connection) { 25 | return DBResponseMapper.populateObject(new DMLResult(), (Map) super.run(connection)); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/EqJoin.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.RethinkDBConnection; 4 | import com.rethinkdb.ast.query.RqlQuery; 5 | import com.rethinkdb.proto.Q2L; 6 | import com.rethinkdb.response.DBResponseMapper; 7 | import com.rethinkdb.response.model.JoinResult; 8 | 9 | import java.util.List; 10 | import java.util.Map; 11 | 12 | // extends RqlMethodQuery 13 | public class EqJoin extends RqlQuery { 14 | 15 | public EqJoin(List args, java.util.Map optionalArgs) { 16 | this(null, args, optionalArgs); 17 | } 18 | 19 | public EqJoin(RqlQuery prev, List args, Map optionalArgs) { 20 | super(prev, Q2L.Term.TermType.EQ_JOIN, args, optionalArgs); 21 | } 22 | 23 | @Override 24 | public List run(RethinkDBConnection connection) { 25 | return DBResponseMapper.populateList(JoinResult.class, (List>) super.run(connection)); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/IndexDrop.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.RethinkDBConnection; 4 | import com.rethinkdb.ast.query.RqlQuery; 5 | import com.rethinkdb.proto.Q2L; 6 | import com.rethinkdb.response.DBResponseMapper; 7 | import com.rethinkdb.response.model.DDLResult; 8 | 9 | import java.util.List; 10 | import java.util.Map; 11 | 12 | // extends RqlMethodQuery 13 | public class IndexDrop extends RqlQuery { 14 | 15 | public IndexDrop(List args, java.util.Map optionalArgs) { 16 | this(null, args, optionalArgs); 17 | } 18 | 19 | public IndexDrop(RqlQuery prev, List args, Map optionalArgs) { 20 | super(prev, Q2L.Term.TermType.INDEX_DROP, args, optionalArgs); 21 | } 22 | 23 | @Override 24 | public DDLResult run(RethinkDBConnection connection) { 25 | return DBResponseMapper.populateObject(new DDLResult(), (Map) super.run(connection)); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/InnerJoin.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.RethinkDBConnection; 4 | import com.rethinkdb.ast.query.RqlQuery; 5 | import com.rethinkdb.proto.Q2L; 6 | import com.rethinkdb.response.DBResponseMapper; 7 | import com.rethinkdb.response.model.JoinResult; 8 | 9 | import java.util.List; 10 | import java.util.Map; 11 | 12 | // extends RqlMethodQuery 13 | public class InnerJoin extends RqlQuery { 14 | 15 | public InnerJoin(List args, java.util.Map optionalArgs) { 16 | this(null, args, optionalArgs); 17 | } 18 | 19 | public InnerJoin(RqlQuery prev, List args, Map optionalArgs) { 20 | super(prev, Q2L.Term.TermType.INNER_JOIN, args, optionalArgs); 21 | } 22 | 23 | @Override 24 | public List run(RethinkDBConnection connection) { 25 | return DBResponseMapper.populateList(JoinResult.class, (List>) super.run(connection)); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/OuterJoin.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.RethinkDBConnection; 4 | import com.rethinkdb.ast.query.RqlQuery; 5 | import com.rethinkdb.proto.Q2L; 6 | import com.rethinkdb.response.DBResponseMapper; 7 | import com.rethinkdb.response.model.JoinResult; 8 | 9 | import java.util.List; 10 | import java.util.Map; 11 | 12 | // extends RqlMethodQuery 13 | public class OuterJoin extends RqlQuery { 14 | 15 | public OuterJoin(List args, java.util.Map optionalArgs) { 16 | this(null, args, optionalArgs); 17 | } 18 | 19 | public OuterJoin(RqlQuery prev, List args, Map optionalArgs) { 20 | super(prev, Q2L.Term.TermType.OUTER_JOIN, args, optionalArgs); 21 | } 22 | 23 | 24 | @Override 25 | public List run(RethinkDBConnection connection) { 26 | return DBResponseMapper.populateList(JoinResult.class, (List>) super.run(connection)); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/IndexWait.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.RethinkDBConnection; 4 | import com.rethinkdb.ast.query.RqlQuery; 5 | import com.rethinkdb.proto.Q2L; 6 | import com.rethinkdb.response.DBResponseMapper; 7 | import com.rethinkdb.response.model.IndexStatusResult; 8 | 9 | import java.util.List; 10 | import java.util.Map; 11 | 12 | // extends RqlMethodQuery 13 | public class IndexWait extends RqlQuery { 14 | 15 | public IndexWait(List args, java.util.Map optionalArgs) { 16 | this(null, args, optionalArgs); 17 | } 18 | 19 | public IndexWait(RqlQuery prev, List args, Map optionalArgs) { 20 | super(prev, Q2L.Term.TermType.INDEX_WAIT, args, optionalArgs); 21 | } 22 | 23 | @Override 24 | public List run(RethinkDBConnection connection) { 25 | return DBResponseMapper.populateList(IndexStatusResult.class, (List>) super.run(connection)); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/IndexStatus.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.RethinkDBConnection; 4 | import com.rethinkdb.ast.query.RqlQuery; 5 | import com.rethinkdb.proto.Q2L; 6 | import com.rethinkdb.response.DBResponseMapper; 7 | import com.rethinkdb.response.model.IndexStatusResult; 8 | 9 | import java.util.List; 10 | import java.util.Map; 11 | 12 | // extends RqlMethodQuery 13 | public class IndexStatus extends RqlQuery { 14 | 15 | public IndexStatus(List args, java.util.Map optionalArgs) { 16 | this(null, args, optionalArgs); 17 | } 18 | 19 | public IndexStatus(RqlQuery prev, List args, Map optionalArgs) { 20 | super(prev, Q2L.Term.TermType.INDEX_STATUS, args, optionalArgs); 21 | } 22 | 23 | @Override 24 | public List run(RethinkDBConnection connection) { 25 | return DBResponseMapper.populateList(IndexStatusResult.class, (List>) super.run(connection)); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/IndexCreate.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.RethinkDBConnection; 4 | import com.rethinkdb.ast.query.RqlQuery; 5 | import com.rethinkdb.proto.Q2L; 6 | import com.rethinkdb.response.DBResponseMapper; 7 | import com.rethinkdb.response.model.DDLResult; 8 | import com.rethinkdb.response.model.DMLResult; 9 | 10 | import java.util.List; 11 | import java.util.Map; 12 | 13 | // extends RqlMethodQuery 14 | public class IndexCreate extends RqlQuery { 15 | 16 | public IndexCreate(List args, java.util.Map optionalArgs) { 17 | this(null, args, optionalArgs); 18 | } 19 | 20 | public IndexCreate(RqlQuery prev, List args, Map optionalArgs) { 21 | super(prev, Q2L.Term.TermType.INDEX_CREATE, args, optionalArgs); 22 | } 23 | 24 | @Override 25 | public DDLResult run(RethinkDBConnection connection) { 26 | return DBResponseMapper.populateObject(new DDLResult(), (Map) super.run(connection)); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/response/DBResultFactory.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.response; 2 | 3 | import com.rethinkdb.RethinkDBException; 4 | import com.rethinkdb.proto.Q2L; 5 | 6 | public class DBResultFactory { 7 | 8 | private DBResultFactory() { 9 | } 10 | 11 | public static T convert(Q2L.Response response) { 12 | 13 | switch (response.getType()) { 14 | case SUCCESS_ATOM: 15 | return DBResponseMapper.fromDatumObject(response.getResponse(0)); 16 | case SUCCESS_PARTIAL: 17 | case SUCCESS_FEED: 18 | case SUCCESS_SEQUENCE: 19 | return (T) DBResponseMapper.fromDatumObjectList(response.getResponseList()); 20 | case WAIT_COMPLETE: 21 | throw new UnsupportedOperationException(); 22 | case CLIENT_ERROR: 23 | case COMPILE_ERROR: 24 | case RUNTIME_ERROR: 25 | throw new RethinkDBException(response.getType() + ": " + response.getResponse(0).getRStr()); 26 | 27 | default: 28 | throw new RethinkDBException("Unknown Response Type: " + response.getType()); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/test/java/com/rethinkdb/integration/LambdasITTest.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.integration; 2 | 3 | import com.google.common.collect.Lists; 4 | import com.rethinkdb.model.MapObject; 5 | import com.rethinkdb.model.RqlFunction; 6 | import com.rethinkdb.ast.query.RqlQuery; 7 | import org.fest.assertions.Assertions; 8 | import org.junit.Before; 9 | import org.junit.Test; 10 | 11 | import java.util.List; 12 | import java.util.Map; 13 | 14 | public class LambdasITTest extends AbstractITTest { 15 | 16 | @Before 17 | public void setUpSimpleTable() { 18 | r.db(dbName).table(tableName).insert(Lists.>newArrayList( 19 | new MapObject().with("name", "superman").with("age", 30), 20 | new MapObject().with("name", "spiderman").with("age", 23), 21 | new MapObject().with("name", "heman").with("age", 55)) 22 | ).run(con); 23 | } 24 | 25 | @Test 26 | public void testMap() { 27 | List ages = r.db(dbName).table(tableName).map(new RqlFunction() { 28 | @Override 29 | public RqlQuery apply(RqlQuery row) { 30 | return row.field("age").add(20); 31 | } 32 | }).run(con()); 33 | 34 | Assertions.assertThat(ages).contains(50.0, 43.0, 75.0); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/test/java/com/rethinkdb/integration/SetInsertITTest.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.integration; 2 | 3 | import com.rethinkdb.model.MapObject; 4 | import com.rethinkdb.response.model.DMLResult; 5 | import org.fest.assertions.Assertions; 6 | import org.junit.Test; 7 | 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | public class SetInsertITTest extends AbstractITTest { 12 | 13 | @Test 14 | public void testSetInsert() { 15 | DMLResult insertResult = r 16 | .db(dbName) 17 | .table(tableName) 18 | .insert(new MapObject() 19 | .with("tags", new ArrayList())) 20 | .run(con); 21 | String id = insertResult.getGenerated_keys().get(0); 22 | 23 | ArrayList newTags = new ArrayList(); 24 | newTags.add("newTag"); 25 | 26 | DMLResult updateResult = r 27 | .db(dbName) 28 | .table(tableName) 29 | .get(id) 30 | .update(new MapObject() 31 | .with("tags", r.row().field("tags").setInsert(newTags))) 32 | .run(con); 33 | 34 | Assertions.assertThat((List)r.db(dbName).table(tableName).run(con).get(0).get("tags")).contains("newTag"); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Func.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.helper.Arguments; 4 | import com.rethinkdb.model.RqlFunction; 5 | import com.rethinkdb.ast.query.RqlQuery; 6 | import com.rethinkdb.ast.query.RqlUtil; 7 | import com.rethinkdb.model.RqlFunction2; 8 | import com.rethinkdb.model.RqlLambda; 9 | import com.rethinkdb.proto.Q2L; 10 | 11 | // extends RqlQuery 12 | public class Func extends RqlQuery { 13 | 14 | public Func(RqlLambda function) { 15 | super(Q2L.Term.TermType.FUNC, null, null); 16 | 17 | if (function instanceof RqlFunction) { 18 | super.init( 19 | null, 20 | new Arguments( 21 | new MakeArray(new Arguments(1), null), 22 | RqlUtil.toRqlQuery(((RqlFunction)function).apply(new Var(new Arguments(1), null))) 23 | ), 24 | null 25 | ); 26 | } 27 | else { 28 | super.init( 29 | null, 30 | new Arguments( 31 | new MakeArray(new Arguments(1,2), null), 32 | RqlUtil.toRqlQuery(((RqlFunction2)function).apply(new Var(new Arguments(1), null), new Var(new Arguments(2), null))) 33 | ), 34 | null 35 | ); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/DB.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.rethinkdb.ast.helper.Arguments; 4 | import com.rethinkdb.ast.helper.OptionalArguments; 5 | import com.rethinkdb.ast.query.RqlQuery; 6 | import com.rethinkdb.model.Durability; 7 | import com.rethinkdb.proto.Q2L; 8 | 9 | import java.util.List; 10 | 11 | // extends RqlTopLevelQuery 12 | public class DB extends RqlQuery { 13 | 14 | public DB(List args, java.util.Map optionalArgs) { 15 | super(Q2L.Term.TermType.DB, args, optionalArgs); 16 | } 17 | 18 | public TableCreate tableCreate(String tableName) { 19 | return tableCreate(tableName, null, null, null); 20 | } 21 | 22 | /** 23 | * Create table with tableName, primaryKey, Durability on a specific dataCenter. 24 | * 25 | * @param tableName tableName (mandatory) 26 | * @param primaryKey primary key (leave null for default) 27 | * @param durability durability (leave null for default) 28 | * @param datacenter datacenter (leave null for default) 29 | */ 30 | public TableCreate tableCreate(String tableName, String primaryKey, Durability durability, String datacenter) { 31 | OptionalArguments optionalArguments = new OptionalArguments() 32 | .with("datacenter", datacenter) 33 | .with("primary_key", primaryKey) 34 | .with("durability", durability == null ? null : durability.toString()); 35 | 36 | return new TableCreate(this, new Arguments(tableName), optionalArguments); 37 | } 38 | 39 | /** 40 | * drop table 41 | * 42 | * @param tableName table name 43 | */ 44 | public TableDrop tableDrop(String tableName) { 45 | return new TableDrop(this, new Arguments(tableName), null); 46 | } 47 | 48 | /** 49 | * list tables 50 | */ 51 | public TableList tableList() { 52 | return new TableList(this, null, null); 53 | 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/test/java/com/rethinkdb/integration/AbstractITTest.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.integration; 2 | 3 | import com.rethinkdb.RethinkDB; 4 | import com.rethinkdb.RethinkDBConnection; 5 | import com.rethinkdb.RethinkDBException; 6 | import com.rethinkdb.ast.query.RqlQuery; 7 | import com.rethinkdb.model.Durability; 8 | import org.junit.After; 9 | import org.junit.AfterClass; 10 | import org.junit.Before; 11 | import org.junit.BeforeClass; 12 | 13 | import java.io.IOException; 14 | import java.util.Properties; 15 | 16 | public abstract class AbstractITTest { 17 | 18 | protected RqlQuery r = RqlQuery.R; 19 | 20 | protected static RethinkDBConnection con; 21 | 22 | protected static final String dbName = "test_db_123"; 23 | protected static final String tableName = "test_table_123"; 24 | 25 | @Before 26 | public void createDb() { 27 | try { 28 | r.dbCreate(dbName).run(con); 29 | con.use(dbName); 30 | r.db(dbName).tableCreate(tableName,null, Durability.hard, null).run(con); 31 | } catch (RethinkDBException ex) { 32 | ex.printStackTrace(); 33 | } 34 | } 35 | 36 | @After 37 | public void dropDb() { 38 | try { 39 | r.dbDrop(dbName).run(con); 40 | } catch (RethinkDBException ex) { 41 | ex.printStackTrace(); 42 | } 43 | } 44 | 45 | @BeforeClass 46 | public static void initCon() { 47 | con = con(); 48 | } 49 | 50 | @AfterClass 51 | public static void tearDownCon() { 52 | con.close(); 53 | } 54 | 55 | public static RethinkDBConnection con() { 56 | try { 57 | Properties props = new Properties(); 58 | props.load(AbstractITTest.class.getResourceAsStream("/dbtest.properties")); 59 | return RethinkDB.r.connect(props.getProperty("hostname"), Integer.parseInt(props.getProperty("port"))); 60 | } catch (IOException e) { 61 | throw new RuntimeException("Couldn't load db properties", e); 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/test/java/com/rethinkdb/integration/GroupIT.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.integration; 2 | 3 | import com.google.common.collect.Lists; 4 | import com.rethinkdb.ast.query.RqlQuery; 5 | import com.rethinkdb.model.MapObject; 6 | import com.rethinkdb.model.RqlFunction; 7 | import com.rethinkdb.model.RqlFunction2; 8 | import org.fest.assertions.Assertions; 9 | import org.junit.Before; 10 | import org.junit.Test; 11 | 12 | import java.util.List; 13 | 14 | public class GroupIT extends AbstractITTest { 15 | 16 | @Before 17 | public void setUpSimpleTable() { 18 | r.db(dbName).table(tableName).insert( 19 | new MapObject().with("id", 2).with("player", "Bob").with("points", 15).with("type", "ranked"), 20 | new MapObject().with("id", 5).with("player", "Alice").with("points", 7).with("type", "free"), 21 | new MapObject().with("id", 11).with("player", "Bob").with("points", 10).with("type", "free"), 22 | new MapObject().with("id", 12).with("player", "Alice").with("points", 2).with("type", "free") 23 | ).run(con); 24 | } 25 | 26 | @Test 27 | public void testDocsGroup() { 28 | Assertions.assertThat( 29 | r.table(tableName).map(new RqlFunction() { 30 | @Override 31 | public RqlQuery apply(RqlQuery row) { 32 | return r.expr(1); 33 | } 34 | }).reduce(new RqlFunction2() { 35 | @Override 36 | public RqlQuery apply(RqlQuery row1, RqlQuery row2) { 37 | return row1.add(row2); 38 | } 39 | }).run(con) 40 | ).isEqualTo(4.0); 41 | } 42 | 43 | @Test 44 | public void testSum() { 45 | Assertions.assertThat(r.expr(Lists.newArrayList(3, 5, 7)).sum().run(con)).isEqualTo(15.0); 46 | } 47 | 48 | @Test 49 | public void testHasFields() { 50 | Assertions.assertThat(r.table(tableName).hasFields(Lists.newArrayList("points")).run(con)).hasSize(4); 51 | } 52 | 53 | @Test 54 | public void testInsertAt() { 55 | Assertions.assertThat(r.expr(Lists.newArrayList("a","b")).insertAt(1,"c").run(con)).hasSize(3); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/RethinkDB.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | 5 | /** 6 | * The starting point for all interaction with RethinkDB. This singleton corresponds to r 7 | * in the documentation and is used to open a connection or generate a query. i.e: 8 | *
 9 |  *     {@code RethinkDB.r.connect("hostname", 28015); }
10 |  * 
11 | * Or 12 | *
13 |  *     {@code RethinkDB.r.dbCreate("test") }
14 |  * 
15 | */ 16 | public class RethinkDB extends RqlQuery { 17 | 18 | /** 19 | * The Singleton to use to begin interacting with RethinkDB Driver 20 | */ 21 | public static RethinkDB r = new RethinkDB(); 22 | 23 | private RethinkDB() { 24 | super(null, null); 25 | } 26 | 27 | /** 28 | * Connect with default hostname and default port and default timeout 29 | * 30 | * @return connection 31 | */ 32 | public RethinkDBConnection connect() { 33 | return new RethinkDBConnection(); 34 | } 35 | 36 | /** 37 | * connect with given hostname and default port and default timeout 38 | * 39 | * @param hostname hostname 40 | * @return connection 41 | */ 42 | public RethinkDBConnection connect(String hostname) { 43 | return new RethinkDBConnection(hostname); 44 | } 45 | 46 | /** 47 | * connect with given hostname and port and default timeout 48 | * 49 | * @param hostname hostname 50 | * @param port port 51 | * @return connection 52 | */ 53 | public RethinkDBConnection connect(String hostname, int port) { 54 | return new RethinkDBConnection(hostname, port); 55 | } 56 | 57 | /** 58 | * connect with given hostname, port and authentication key and default timeout 59 | * 60 | * @param hostname hostname 61 | * @param port port 62 | * @param authKey authentication key 63 | * @return connection 64 | */ 65 | public RethinkDBConnection connect(String hostname, int port, String authKey) { 66 | return new RethinkDBConnection(hostname, port, authKey); 67 | } 68 | 69 | /** 70 | * connect with given hostname, port, authentication key and timeout 71 | * 72 | * @param hostname hostname 73 | * @param port port 74 | * @param authKey authentication key 75 | * @param timeout the maximum time to wait attempting to connect 76 | * @return connection 77 | */ 78 | public RethinkDBConnection connect(String hostname, int port, String authKey, int timeout) { 79 | return new RethinkDBConnection(hostname, port, authKey, timeout); 80 | } 81 | 82 | 83 | } 84 | -------------------------------------------------------------------------------- /src/test/java/com/rethinkdb/integration/FetchDataIT.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.integration; 2 | 3 | import com.google.common.collect.Lists; 4 | import com.rethinkdb.model.MapObject; 5 | import org.fest.assertions.Assertions; 6 | import org.junit.Test; 7 | 8 | import java.util.List; 9 | import java.util.Map; 10 | 11 | public class FetchDataIT extends AbstractITTest { 12 | 13 | @Test 14 | public void testGetByPKString() { 15 | Assertions.assertThat( r.table(tableName).get("test").run(con) ).isNull(); 16 | 17 | r.db(dbName).table(tableName).insert( new MapObject().with("id", "test") ).run(con); 18 | 19 | Assertions.assertThat( r.table(tableName).get("test").run(con) ).isNotNull(); 20 | } 21 | 22 | @Test 23 | public void testGetByPKNumber() { 24 | Assertions.assertThat( r.table(tableName).get(1).run(con) ).isNull(); 25 | 26 | r.db(dbName).table(tableName).insert( new MapObject().with("id", 1) ).run(con); 27 | 28 | Assertions.assertThat( r.table(tableName).get(1).run(con) ).isNotNull(); 29 | } 30 | 31 | @Test 32 | public void testGetAll() { 33 | Assertions.assertThat( r.table(tableName).getAll(Lists.newArrayList(1, 2)).run(con) ).isEmpty(); 34 | 35 | r.db(dbName).table(tableName).insert( new MapObject().with("id", 1) ).run(con); 36 | 37 | Assertions.assertThat( r.table(tableName).getAll(Lists.newArrayList(1,2)).run(con) ).hasSize(1); 38 | 39 | r.db(dbName).table(tableName).insert( new MapObject().with("id", 2) ).run(con); 40 | 41 | Assertions.assertThat( r.table(tableName).getAll(Lists.newArrayList(1,2)).run(con) ).hasSize(2); 42 | } 43 | 44 | @Test 45 | public void testWithFields() { 46 | r.db(dbName).table(tableName).insert( new MapObject().with("id", 1).with("name", "john").with("age",22) ).run(con); 47 | 48 | List> result = r.table(tableName).withFields("name","age").run(con); 49 | Assertions.assertThat(result).hasSize(1); 50 | Assertions.assertThat(result.get(0).get("id")).isNull(); 51 | Assertions.assertThat(result.get(0).get("name")).isEqualTo("john"); 52 | } 53 | 54 | @Test 55 | public void testWithOneFields() { 56 | r.db(dbName).table(tableName).insert( new MapObject().with("id", 1).with("name", "john").with("age",22) ).run(con); 57 | 58 | List> result = (List>) r.table(tableName).withFields("name").run(con); 59 | Assertions.assertThat(result).hasSize(1); 60 | Assertions.assertThat(result.get(0).get("name")).isEqualTo("john"); 61 | } 62 | 63 | @Test 64 | public void testGetAllCustomIndex() { 65 | // TODO add this test when we have ablitity to add indexes to tables 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/test/java/com/rethinkdb/integration/ManipulatingTablesIT.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.integration; 2 | 3 | import com.rethinkdb.model.MapObject; 4 | import com.rethinkdb.response.model.DMLResult; 5 | import org.fest.assertions.Assertions; 6 | import org.junit.Test; 7 | 8 | import java.util.ArrayList; 9 | 10 | public class ManipulatingTablesIT extends AbstractITTest { 11 | 12 | @Test 13 | public void createListAndDropTable() { 14 | Assertions.assertThat(r.db(dbName).tableList().run(con)).contains(tableName); 15 | r.db(dbName).tableDrop(tableName).run(con); 16 | Assertions.assertThat(r.db(dbName).tableList().run(con)).excludes(tableName); 17 | r.db(dbName).tableCreate(tableName).run(con); 18 | Assertions.assertThat(r.db(dbName).tableList().run(con)).contains(tableName); 19 | } 20 | 21 | @Test 22 | public void createTableWithPrimaryKey() { 23 | String customPKTable = "customPKTable"; 24 | 25 | r.db(dbName).tableCreate(customPKTable, "myId", null, null).run(con); 26 | DMLResult res1 = r.db(dbName).table(customPKTable).insert(new MapObject().with("myId", 1)).run(con); 27 | DMLResult res2 = r.db(dbName).table(customPKTable).insert(new MapObject().with("myId", 1)).run(con); 28 | 29 | Assertions.assertThat(res1.getInserted()).isEqualTo(1); 30 | Assertions.assertThat(res2.getInserted()).isEqualTo(0); // duplicate id 31 | } 32 | 33 | @Test 34 | public void testIndexList() { 35 | Assertions.assertThat(r.db(dbName).table(tableName).indexCreate("wee").run(con).getCreated()).isEqualTo(1); 36 | Assertions.assertThat(r.db(dbName).table(tableName).indexList().run(con())).containsExactly("wee"); 37 | Assertions.assertThat(r.db(dbName).table(tableName).indexDrop("wee").run(con).getDropped()).isEqualTo(1); 38 | Assertions.assertThat(r.db(dbName).table(tableName).indexList().run(con())).isEmpty(); 39 | } 40 | 41 | @Test 42 | public void testTableInfo() { 43 | Assertions.assertThat(r.db(dbName).table(tableName).info().run(con)) 44 | .isEqualTo(new MapObject() 45 | .with("db", new MapObject() 46 | .with("name", dbName) 47 | .with("type", "DB")) 48 | .with("indexes", new ArrayList(0)) 49 | .with("name", tableName) 50 | .with("primary_key", "id") 51 | .with("type", "TABLE") 52 | ); 53 | } 54 | 55 | @Test 56 | public void testIndexStatus() { 57 | Assertions.assertThat(r.db(dbName).table(tableName).indexCreate("wee").run(con).getCreated()).isEqualTo(1); 58 | Assertions.assertThat(r.db(dbName).table(tableName).indexStatus().run(con()).get(0).isReady()).isTrue(); 59 | } 60 | 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/test/java/com/rethinkdb/integration/FilteringIT.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.integration; 2 | 3 | import com.google.common.collect.Lists; 4 | import com.rethinkdb.model.MapObject; 5 | import com.rethinkdb.model.RqlFunction; 6 | import com.rethinkdb.ast.query.RqlQuery; 7 | import org.fest.assertions.Assertions; 8 | import org.junit.Before; 9 | import org.junit.Test; 10 | 11 | import java.util.List; 12 | import java.util.Map; 13 | 14 | public class FilteringIT extends AbstractITTest { 15 | 16 | @Before 17 | public void setUpSimpleTable() { 18 | r.db(dbName).table(tableName).insert( 19 | new MapObject().with("name", "superman").with("age", 30), 20 | new MapObject().with("name", "spiderman").with("age", 23), 21 | new MapObject().with("name", "heman").with("age", 55) 22 | ).run(con); 23 | } 24 | 25 | @Test 26 | public void testGT() { 27 | Assertions.assertThat( 28 | r.db(dbName).table(tableName).filter(new RqlFunction() { 29 | @Override 30 | public RqlQuery apply(RqlQuery row) { 31 | return row.field("age").gt(30); 32 | } 33 | } 34 | ).run(con()) 35 | ).hasSize(1); 36 | } 37 | 38 | @Test 39 | public void testGTandLT() { 40 | Assertions.assertThat( 41 | r.db(dbName).table(tableName).filter(new RqlFunction() { 42 | 43 | @Override 44 | public RqlQuery apply(RqlQuery row) { 45 | return r.or( 46 | r.and( 47 | row.field("age").gt(20), 48 | row.field("age").lt(30) 49 | ), 50 | row .field("name").eq("heman") 51 | ); 52 | } 53 | } 54 | ).run(con).size() 55 | ).isEqualTo(2); 56 | } 57 | 58 | @Test 59 | public void testOrder() { 60 | List run = r.db(dbName).table(tableName).orderByField("age").map(new RqlFunction() { 61 | @Override 62 | public RqlQuery apply(RqlQuery row) { 63 | return row.field("age"); 64 | } 65 | }).runTyped(con); 66 | 67 | Assertions.assertThat(run).containsExactly(23.0,30.0,55.0); 68 | } 69 | 70 | 71 | @Test 72 | public void testOrderDesc() { 73 | List run = r.db(dbName).table(tableName).orderBy(r.desc("age"), r.asc("name")).map(new RqlFunction() { 74 | @Override 75 | public RqlQuery apply(RqlQuery row) { 76 | return row.field("age"); 77 | } 78 | }).runTyped(con); 79 | 80 | Assertions.assertThat(run).containsExactly(55.0,30.0,23.0); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/test/java/com/rethinkdb/integration/StringsIT.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.integration; 2 | 3 | import com.google.common.collect.Lists; 4 | import com.rethinkdb.model.MapObject; 5 | import com.rethinkdb.model.RqlFunction; 6 | import com.rethinkdb.ast.query.RqlQuery; 7 | import org.fest.assertions.Assertions; 8 | import org.junit.Before; 9 | import org.junit.Test; 10 | 11 | import java.util.List; 12 | import java.util.Map; 13 | 14 | public class StringsIT extends AbstractITTest { 15 | 16 | @Before 17 | public void setUpSimpleTable() { 18 | r.db(dbName).table(tableName).insert(Lists.>newArrayList( 19 | new MapObject().with("name", "Superman").with("age", 30), 20 | new MapObject().with("name", "Spiderman").with("age", 23), 21 | new MapObject().with("name", "Heman").with("age", 55) 22 | )).run(con); 23 | } 24 | 25 | @Test 26 | public void testUpcase() { 27 | List strings = r.db(dbName).table(tableName).map(new RqlFunction() { 28 | @Override 29 | public RqlQuery apply(RqlQuery row) { 30 | return row.field("name").upcase(); 31 | } 32 | }).runTyped(con); 33 | 34 | Assertions.assertThat(strings).contains("SUPERMAN", "SPIDERMAN", "HEMAN"); 35 | } 36 | 37 | @Test 38 | public void testDowncase() { 39 | List strings = r.db(dbName).table(tableName).map(new RqlFunction() { 40 | @Override 41 | public RqlQuery apply(RqlQuery row) { 42 | return row.field("name").downcase(); 43 | } 44 | }).runTyped(con); 45 | 46 | Assertions.assertThat(strings).contains("superman", "spiderman", "heman"); 47 | } 48 | 49 | @Test 50 | public void testSplit() { 51 | String splitTable = "splitTable"; 52 | r.db(dbName).tableCreate(splitTable).run(con); 53 | r.db(dbName).table(splitTable).insert(new MapObject().with("name", "aaa bbb")).run(con); 54 | 55 | List> strings = r.db(dbName).table(splitTable).map(new RqlFunction() { 56 | @Override 57 | public RqlQuery apply(RqlQuery row) { 58 | return row.field("name").split(" "); 59 | } 60 | }).runTyped(con()); 61 | 62 | Assertions.assertThat(strings.get(0).get(0)).isEqualToIgnoringCase("aaa"); 63 | } 64 | 65 | @Test 66 | public void testMatch() { 67 | Map dbObj = new MapObject().with("id", 1).with("field1", "abc"); 68 | r.db(dbName).table(tableName).insert(dbObj).run(con); 69 | 70 | List list = r.db(dbName).table(tableName).filter(new RqlFunction() { 71 | @Override 72 | public RqlQuery apply(RqlQuery row) { 73 | return row.field("field1").match("a.c"); 74 | } 75 | }).run(con()); 76 | 77 | Assertions.assertThat(list).hasSize(1); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/test/java/com/rethinkdb/integration/DateITTest.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.integration; 2 | 3 | import com.rethinkdb.ast.query.RqlQuery; 4 | import com.rethinkdb.model.MapObject; 5 | import com.rethinkdb.model.RqlFunction; 6 | import org.fest.assertions.Assertions; 7 | import org.junit.Test; 8 | import org.junit.Ignore; 9 | 10 | import java.text.ParseException; 11 | import java.text.SimpleDateFormat; 12 | import java.util.Date; 13 | import java.util.List; 14 | import java.util.Map; 15 | 16 | public class DateITTest extends AbstractITTest { 17 | 18 | private static SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy"); 19 | 20 | @Test 21 | public void testNow() { 22 | r.table(tableName).insert(new MapObject().with("date", r.now())).run(con); 23 | 24 | Assertions.assertThat(r.table(tableName).run(con).get(0).get("date")).isInstanceOf(Date.class); 25 | } 26 | 27 | @Test 28 | public void testSaveDate() { 29 | r.table(tableName).insert(new MapObject().with("date", new Date())).run(con); 30 | 31 | Assertions.assertThat(r.table(tableName).run(con).get(0).get("date")).isInstanceOf(Date.class); 32 | } 33 | 34 | 35 | @Ignore("This should be fixed.") 36 | @Test 37 | public void testTime() { 38 | r.table(tableName).insert(new MapObject().with("date", r.time(2001, 10, 10))).run(con); 39 | 40 | Assertions.assertThat(sdf.format(r.table(tableName).run(con).get(0).get("date"))).isEqualToIgnoringCase("10-10-2001"); 41 | } 42 | 43 | @Test 44 | public void testEpochTime() throws ParseException { 45 | r.table(tableName).insert(new MapObject().with("date", r.epochTime(sdf.parse("10-10-2001").getTime() / 1000))).run(con); 46 | 47 | Assertions.assertThat(sdf.format(r.table(tableName).run(con).get(0).get("date"))).isEqualToIgnoringCase("10-10-2001"); 48 | } 49 | 50 | @Test 51 | public void testInclusive() throws ParseException { 52 | r.table(tableName).insert(new MapObject().with("date", r.time(2001, 10, 10))).run(con); 53 | r.table(tableName).insert(new MapObject().with("date", r.time(2002, 10, 10))).run(con); 54 | r.table(tableName).insert(new MapObject().with("date", r.time(2003, 10, 10))).run(con); 55 | 56 | List> dates = r.table(tableName).filter(new RqlFunction() { 57 | @Override 58 | public RqlQuery apply(RqlQuery row) { 59 | return row.field("date") 60 | .during(r.time(2001, 10, 10), r.time(2003, 10, 10), false, false); 61 | } 62 | }).run(con); 63 | 64 | Assertions.assertThat(dates).hasSize(1); 65 | 66 | dates = r.table(tableName).filter(new RqlFunction() { 67 | @Override 68 | public RqlQuery apply(RqlQuery row) { 69 | return row.field("date") 70 | .during(r.time(2001, 10, 10), r.time(2003, 10, 10), true, true); 71 | } 72 | }).run(con); 73 | 74 | Assertions.assertThat(dates).hasSize(3); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/response/model/DMLResult.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.response.model; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | public class DMLResult { 7 | private int inserted; 8 | private int replaced; 9 | private int unchanged; 10 | private int errors; 11 | private String first_error; 12 | private int deleted; 13 | private int skipped; 14 | private List generated_keys; 15 | private Map old_val; 16 | private Map new_val; 17 | 18 | public DMLResult() { 19 | } 20 | 21 | @Override 22 | public String toString() { 23 | return "InsertResult{" + 24 | "inserted=" + inserted + 25 | ", replaced=" + replaced + 26 | ", unchanged=" + unchanged + 27 | ", errors=" + errors + 28 | ", first_error=" + first_error + 29 | ", deleted=" + deleted + 30 | ", skipped=" + skipped + 31 | ", generated_keys=" + generated_keys + 32 | ", old_val=" + old_val + 33 | ", new_val=" + new_val + 34 | '}'; 35 | } 36 | 37 | /** 38 | * the number of documents that were succesfully inserted. 39 | */ 40 | public int getInserted() { 41 | return inserted; 42 | } 43 | 44 | /** 45 | * the number of documents that were updated when upsert is used. 46 | */ 47 | public int getReplaced() { 48 | return replaced; 49 | } 50 | 51 | /** 52 | * the number of documents that would have been modified, except that the new value was the same as the old value when doing an upsert. 53 | */ 54 | public int getUnchanged() { 55 | return unchanged; 56 | } 57 | 58 | /** 59 | * the number of errors encountered while performing the insert. 60 | */ 61 | public int getErrors() { 62 | return errors; 63 | } 64 | 65 | /** 66 | * if errors were encountered, contains the text of the first error. 67 | */ 68 | public String getFirst_error() { 69 | return first_error; 70 | } 71 | 72 | /** 73 | * always 0 for an insert operation 74 | */ 75 | public int getDeleted() { 76 | return deleted; 77 | } 78 | 79 | /** 80 | * always 0 for an insert operation 81 | */ 82 | public int getSkipped() { 83 | return skipped; 84 | } 85 | 86 | /** 87 | * a list of generated primary keys in case the primary keys for some documents were missing (capped to 100000). 88 | */ 89 | public List getGenerated_keys() { 90 | return generated_keys; 91 | } 92 | 93 | /** 94 | * if returnVals is set to true, contains null. 95 | * 96 | * @return old value 97 | */ 98 | public Map getOld_val() { 99 | return old_val; 100 | } 101 | 102 | /** 103 | * if returnVals is set to true, contains the inserted/updated document. 104 | * 105 | * @return new value 106 | */ 107 | public Map getNew_val() { 108 | return new_val; 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /src/test/java/com/rethinkdb/integration/JoinsIT.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.integration; 2 | 3 | import com.google.common.collect.Lists; 4 | import com.rethinkdb.ast.query.RqlQuery; 5 | import com.rethinkdb.model.MapObject; 6 | import com.rethinkdb.model.RqlFunction; 7 | import com.rethinkdb.model.RqlFunction2; 8 | import com.rethinkdb.response.model.JoinResult; 9 | import org.fest.assertions.Assertions; 10 | import org.junit.Before; 11 | import org.junit.Test; 12 | 13 | import java.util.List; 14 | import java.util.Map; 15 | 16 | public class JoinsIT extends AbstractITTest { 17 | 18 | private String tableChildren = "femaleSuperHeros"; 19 | 20 | @Before 21 | public void setUpSimpleTable() { 22 | r.db(dbName).table(tableName).insert(Lists.>newArrayList( 23 | new MapObject().with("name", "Superman").with("age", 30), 24 | new MapObject().with("name", "Spiderman").with("age", 23), 25 | new MapObject().with("name", "Heman").with("age", 55) 26 | )).run(con); 27 | 28 | r.db(dbName).tableCreate(tableChildren).run(con()); 29 | 30 | r.db(dbName).table(tableChildren).insert(Lists.>newArrayList( 31 | new MapObject().with("name", "Spidergirl").with("age", 23), 32 | new MapObject().with("name", "Xena").with("age", 55) 33 | )).run(con); 34 | } 35 | 36 | @Test 37 | public void testInnerJoin() { 38 | List result = r.db(dbName).table(tableName).innerJoin( 39 | r.db(dbName).table(tableChildren), 40 | new RqlFunction2() { 41 | @Override 42 | public RqlQuery apply(RqlQuery row1, RqlQuery row2) { 43 | return row1.field("age").eq(row2.field("age")); 44 | } 45 | } 46 | ).run(con); 47 | 48 | Assertions.assertThat(result).hasSize(2); 49 | 50 | for (JoinResult joinResult : result) { 51 | Assertions.assertThat(joinResult.getLeft().get("age")).isEqualTo(joinResult.getRight().get("age")); 52 | } 53 | } 54 | 55 | @Test 56 | public void testOuterJoin() { 57 | List result = r.db(dbName).table(tableName).outerJoin( 58 | r.db(dbName).table(tableChildren), 59 | new RqlFunction2() { 60 | @Override 61 | public RqlQuery apply(RqlQuery row1, RqlQuery row2) { 62 | return row1.field("age").eq(row2.field("age")); 63 | } 64 | } 65 | ).run(con); 66 | 67 | Assertions.assertThat(result).hasSize(3); 68 | } 69 | 70 | @Test 71 | public void testZip() { 72 | List> result = r.db(dbName).table(tableName).outerJoin( 73 | r.db(dbName).table(tableChildren), 74 | new RqlFunction2() { 75 | @Override 76 | public RqlQuery apply(RqlQuery row1, RqlQuery row2) { 77 | return row1.field("age").eq(row2.field("age")); 78 | } 79 | } 80 | ).zip().run(con); 81 | 82 | Assertions.assertThat(result).hasSize(3); 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/Cursor.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb; 2 | 3 | import java.util.*; 4 | 5 | import com.rethinkdb.proto.Q2L.Response; 6 | import com.rethinkdb.proto.Q2L.Response.ResponseType; 7 | import com.rethinkdb.response.DBResultFactory; 8 | 9 | 10 | public class Cursor implements Iterator { 11 | 12 | private List currentBatch; 13 | private RethinkDBConnection connection; 14 | private Response response; 15 | public final long token; 16 | private boolean closed; 17 | private boolean ended; 18 | 19 | public final boolean isFeed; 20 | 21 | public Cursor(RethinkDBConnection connection, Response response) { 22 | this.connection = connection; 23 | this.response = response; 24 | this.currentBatch = (List) DBResultFactory.convert(response); 25 | this.isFeed = response.getType() == ResponseType.SUCCESS_FEED; 26 | this.token = response.getToken(); 27 | } 28 | 29 | public boolean isClosed() { 30 | closed = closed 31 | || connection.isClosed() 32 | || response.getType() != ResponseType.SUCCESS_PARTIAL 33 | && response.getType() != ResponseType.SUCCESS_FEED; 34 | return closed; 35 | } 36 | 37 | protected long getToken() { 38 | return response.getToken(); 39 | } 40 | 41 | @Override 42 | public boolean hasNext() { 43 | if (currentBatch.size() > 0) { 44 | return true; 45 | } else if (!isClosed()) { 46 | if (isFeed) { 47 | return true; 48 | } else if (response.getType() == ResponseType.SUCCESS_PARTIAL) { 49 | loadNextBatch(); 50 | return hasNext(); 51 | } 52 | } 53 | return false; 54 | } 55 | 56 | private void loadNextBatch() { 57 | response = connection.getNext(response.getToken()); 58 | 59 | ended = response.getType() != ResponseType.SUCCESS_FEED && 60 | response.getType() != ResponseType.SUCCESS_PARTIAL; 61 | System.out.println(response.getType().toString() + ":" + response.getToken()); 62 | Object converted = DBResultFactory.convert(response); 63 | currentBatch.addAll((java.util.Collection) converted); 64 | } 65 | 66 | public void close() { 67 | if(!isClosed() 68 | && (response.getType() == ResponseType.SUCCESS_FEED 69 | || response.getType() == ResponseType.SUCCESS_PARTIAL)) { 70 | connection.closeCursor(this); 71 | closed = true; 72 | } 73 | } 74 | 75 | private T _next(){ 76 | return currentBatch.remove(0); 77 | } 78 | 79 | @Override 80 | public T next() { 81 | if (currentBatch.size() > 0) { 82 | return _next(); 83 | } else if (!isClosed()){ 84 | while(!ended && currentBatch.size() == 0){ 85 | loadNextBatch(); 86 | } 87 | if(currentBatch.size() != 0) { 88 | return _next(); 89 | } 90 | } 91 | throw new NoSuchElementException("There are no more elements to get"); 92 | } 93 | 94 | @Override 95 | public void remove() { 96 | throw new UnsupportedOperationException(); 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NOTICE 2 | 3 | This driver is not officially supported by Dropbox. It is used solely by the Analytics Product team, and contains only minor bugfixes/improvements needed for our use. 4 | 5 | 6 | ## Introduction 7 | 8 | [Full Documentation here](http://npiv.github.io/rethink-java-doc/html/) 9 | 10 | ## Maven Central 11 | 12 | Include in your pom with 13 | 14 | ```xml 15 | 16 | com.rethinkdb 17 | rethink-java-driver 18 | 0.3 19 | 20 | ``` 21 | 22 | ## Examples 23 | 24 | The driver supports java 1.6 and up. But to truly get the benefit of the lambda support java 8 is recommended. 25 | 26 | in java 8 one can do something Like 27 | 28 | ```java 29 | 30 | RethinkDB r = RethinkDB.r; 31 | RethinkDBConnection con = r.connect(); 32 | 33 | r.db("test").tableCreate("heros").run(con); 34 | con.use("test"); 35 | 36 | r.table("heros").insert( 37 | new MapObject().with("name", "Heman").with("age", 33).with("skill", "sword"), 38 | new MapObject().with("name", "Spiderman").with("age", 27).with("skill", "jumping"), 39 | new MapObject().with("name", "Superman").with("age", 133).with("skill", "flying"), 40 | new MapObject().with("name", "Xena").with("age", 29).with("skill", "wowza") 41 | ).run(con); 42 | 43 | System.out.println( 44 | r.table("heros").filter(hero->hero.field("age").gt(100)).pluck("age").run(con) 45 | ); // [{age=133.0}] 46 | 47 | System.out.println( 48 | r.table("heros").orderBy(r.desc("age")).map(hero -> hero.field("name").upcase()).run(con) 49 | ); // [SUPERMAN, HEMAN, XENA, SPIDERMAN] 50 | 51 | System.out.println( 52 | r.table("heros").update(row -> 53 | r.branch( 54 | row.field("age").gt(100), 55 | new MapObject().with("newAttribute", "old"), 56 | new MapObject().with("newAttribute", "young") 57 | ) 58 | ).run(con) 59 | ); // DMLResult{inserted=0, replaced=4, unchanged=0, errors=0, first_error=null, deleted=0, skipped=0, generated_keys=null, old_val=null, new_val=null} 60 | 61 | System.out.println( 62 | r.table("heros").pluck("name","newAttribute").run(con) 63 | ); // [ 64 | // {newAttribute=young, name=Xena}, 65 | // {newAttribute=young, name=Spiderman}, 66 | // {newAttribute=old, name=Superman}, 67 | // {newAttribute=young, name=Heman} 68 | // ] 69 | 70 | 71 | ``` 72 | 73 | See API Documentation and more examples here: [http://npiv.github.io/rethink-java-doc/html](http://npiv.github.io/rethink-java-doc/html/) 74 | 75 | ### Apache License 2.0 76 | ``` 77 | Copyright [2015] [Dropbox] 78 | Copyright [2014] [Nick Verlinde] 79 | 80 | Licensed under the Apache License, Version 2.0 (the "License"); 81 | you may not use this file except in compliance with the License. 82 | You may obtain a copy of the License at 83 | 84 | http://www.apache.org/licenses/LICENSE-2.0 85 | 86 | Unless required by applicable law or agreed to in writing, software 87 | distributed under the License is distributed on an "AS IS" BASIS, 88 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 89 | See the License for the specific language governing permissions and 90 | limitations under the License. 91 | ``` 92 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/gen/Table.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query.gen; 2 | 3 | import com.google.common.collect.Lists; 4 | import com.rethinkdb.RethinkDBConnection; 5 | import com.rethinkdb.ast.helper.Arguments; 6 | import com.rethinkdb.ast.helper.OptionalArguments; 7 | import com.rethinkdb.ast.query.RqlQuery; 8 | import com.rethinkdb.ast.query.RqlUtil; 9 | import com.rethinkdb.model.ConflictStrategy; 10 | import com.rethinkdb.model.Durability; 11 | import com.rethinkdb.model.RqlFunction; 12 | import com.rethinkdb.proto.Q2L; 13 | 14 | import java.util.Arrays; 15 | import java.util.HashMap; 16 | import java.util.List; 17 | import java.util.Map; 18 | 19 | // extends RqlQuery 20 | public class Table extends RqlQuery { 21 | 22 | public Table(RqlQuery prev, List args, java.util.Map optionalArgs) { 23 | super(prev, Q2L.Term.TermType.TABLE, args, optionalArgs); 24 | } 25 | 26 | public Insert insert(Map dbObject, Durability durability, Boolean returnVals, ConflictStrategy conflict) { 27 | return insert(Lists.newArrayList(dbObject), durability, returnVals, conflict); 28 | } 29 | public Insert insert(Map... dbObject) { 30 | return insert(Arrays.asList(dbObject), null, null, null); 31 | } 32 | 33 | public Insert insert(List> dbObjects) { 34 | return insert(dbObjects, null, null, null); 35 | } 36 | 37 | public Insert insert(List> dbObjects, Durability durability, Boolean returnVals, ConflictStrategy conflict) { 38 | Map optionalArgs = new HashMap(); 39 | 40 | if (returnVals != null && returnVals == true) { 41 | optionalArgs.put("return_vals", true); 42 | } 43 | if (conflict != null) { 44 | optionalArgs.put("conflict", conflict.toString()); 45 | } 46 | if (durability != null) { 47 | optionalArgs.put("durability", durability.toString()); 48 | } 49 | 50 | return new Insert(this, new Arguments(Lists.newArrayList(dbObjects)), optionalArgs); 51 | } 52 | 53 | public Get get(Object key) { 54 | return new Get(this, new Arguments(key), null); 55 | } 56 | 57 | public GetAll getAll(List keys, String index) { 58 | return new GetAll(this, new Arguments(keys), new OptionalArguments().with("index", index)); 59 | } 60 | public GetAll getAll(List keys) { 61 | return getAll(keys, null); 62 | } 63 | 64 | public IndexCreate indexCreate(String name) { 65 | return indexCreate(name, null, null); 66 | } 67 | 68 | public IndexCreate indexCreate(String name, RqlFunction function, Boolean multi) { 69 | Arguments args = new Arguments(name); 70 | if (function != null) args.add(RqlUtil.funcWrap(function)); 71 | return new IndexCreate(this, args, new OptionalArguments().with("multi",multi)); 72 | } 73 | 74 | public IndexDrop indexDrop(String name) { 75 | return new IndexDrop(this, new Arguments(name), null); 76 | } 77 | 78 | public IndexList indexList() { 79 | return new IndexList(this, null, null); 80 | } 81 | 82 | public IndexStatus indexStatus(String... indexNames) { 83 | return new IndexStatus(this, new Arguments(indexNames), null); 84 | } 85 | 86 | public IndexWait indexWait(String... indexNames) { 87 | return new IndexWait(this, new Arguments(indexNames), null); 88 | } 89 | 90 | public Info info(){ 91 | return new Info(this, null, null); 92 | } 93 | 94 | public Changes changes() { 95 | return new Changes(this, null, null); 96 | } 97 | 98 | @Override 99 | public List> run(RethinkDBConnection connection) { 100 | return (List>) super.run(connection); 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /src/test/java/com/rethinkdb/integration/CursorIT.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.integration; 2 | 3 | import com.google.common.collect.Lists; 4 | import com.rethinkdb.Cursor; 5 | import com.rethinkdb.RethinkDBConnection; 6 | import com.rethinkdb.RethinkDBException; 7 | import com.rethinkdb.ast.query.RqlQuery; 8 | import com.rethinkdb.ast.query.gen.Table; 9 | import com.rethinkdb.model.ConflictStrategy; 10 | import com.rethinkdb.model.Durability; 11 | import com.rethinkdb.model.MapObject; 12 | import org.fest.assertions.Assertions; 13 | import org.junit.After; 14 | import org.junit.Test; 15 | 16 | import java.util.HashMap; 17 | import java.util.List; 18 | import java.util.Map; 19 | 20 | public class CursorIT extends AbstractITTest { 21 | 22 | @Test 23 | public void testSimpleCursor() { 24 | r.db(dbName).table(tableName).insert( new MapObject().with("id", 1) ).run(con); 25 | 26 | Assertions.assertThat( r.table(tableName).getAll(Lists.newArrayList(1,2)).run(con) ).hasSize(1); 27 | 28 | r.db(dbName).table(tableName).insert( new MapObject().with("id", 2) ).run(con); 29 | 30 | Assertions.assertThat( r.table(tableName).getAll(Lists.newArrayList(1,2)).run(con) ).hasSize(2); 31 | } 32 | 33 | 34 | @Test 35 | public void testWith1001Entries() throws InterruptedException { 36 | 37 | List> obs = Lists.newArrayList(); 38 | for (int i = 0; i < 1001; i++) { 39 | final long counted = i; 40 | obs.add(new HashMap() {{ put("counter", counted); }}); 41 | } 42 | r.db(dbName).table(tableName).insert(obs, Durability.soft, false, ConflictStrategy.error).run(con); 43 | 44 | Assertions.assertThat( r.db(dbName).table(tableName).run(con) ).hasSize(1001); 45 | } 46 | 47 | @Test 48 | public void testNonChangeFeedCursor(){ 49 | Cursor cursor = r.db(dbName).table(tableName).runForCursor(con); 50 | Assertions.assertThat(cursor.isFeed).isFalse(); 51 | } 52 | 53 | @Test 54 | public void testChangeFeedCursor() { 55 | Cursor cursor = r.db(dbName).table(tableName).changes().runForCursor(con); 56 | Assertions.assertThat(cursor.isFeed).isTrue(); 57 | } 58 | 59 | @Test 60 | public void testChangeFeed() { 61 | 62 | final String id = "testChangeFeed"; 63 | final MapObject first = new MapObject().with("id", id); 64 | final MapObject second = new MapObject().with("id", id).with("foo", "bar"); 65 | final Table table = r.db(dbName).table(tableName); 66 | 67 | // Start listening on changefeed 68 | Cursor cursor = table.changes().runForCursor(con); 69 | 70 | // Make a new connection to create changes 71 | RethinkDBConnection con2 = con(); 72 | table.insert(first).run(con2); 73 | table.get(id).update(second).run(con2); 74 | con2.close(); 75 | 76 | // Check out the changefeed 77 | Assertions.assertThat(cursor.next()).isEqualTo( 78 | new MapObject() 79 | .with("old_val", null) 80 | .with("new_val", first) 81 | ); 82 | Assertions.assertThat(cursor.next()).isEqualTo( 83 | new MapObject() 84 | .with("old_val", first) 85 | .with("new_val", second) 86 | ); 87 | } 88 | 89 | @Test(expected=RethinkDBException.class, timeout=10000) 90 | public void testChangeFeedTableDeleted() { 91 | final String id = "testChangeFeedTableDeleted"; 92 | final Table table = r.db(dbName).table(tableName); 93 | 94 | Cursor cursor = table.changes().runForCursor(con); 95 | Assertions.assertThat(cursor.isClosed()).isFalse(); 96 | 97 | // Drop the table we're watching for changes on 98 | RethinkDBConnection con2 = con(); 99 | r.db(dbName).tableDrop(tableName).run(con2); 100 | con2.close(); 101 | 102 | // trigger an exception 103 | cursor.next(); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/SocketChannelFacade.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb; 2 | 3 | import com.google.protobuf.InvalidProtocolBufferException; 4 | import com.rethinkdb.proto.Q2L; 5 | import com.rethinkdb.util.ThreadUtil; 6 | 7 | import java.io.IOException; 8 | import java.net.InetSocketAddress; 9 | import java.net.StandardSocketOptions; 10 | import java.nio.ByteBuffer; 11 | import java.nio.ByteOrder; 12 | import java.nio.channels.SocketChannel; 13 | 14 | public class SocketChannelFacade { 15 | private SocketChannel socketChannel; 16 | 17 | public void connect(String hostname, int port) { 18 | try { 19 | socketChannel = SocketChannel.open(); 20 | socketChannel.configureBlocking(true); 21 | socketChannel.setOption(StandardSocketOptions.TCP_NODELAY, true); 22 | socketChannel.connect(new InetSocketAddress(hostname, port)); 23 | } catch (IOException e) { 24 | throw new RethinkDBException(e); 25 | } 26 | } 27 | 28 | private void _write(ByteBuffer buffer) { 29 | try { 30 | buffer.flip(); 31 | while (buffer.hasRemaining()) { 32 | socketChannel.write(buffer); 33 | } 34 | } catch (IOException e) { 35 | throw new RethinkDBException(e); 36 | } 37 | } 38 | 39 | private ByteBuffer _read(int i, boolean strict) { 40 | ByteBuffer buffer = ByteBuffer.allocate(i); 41 | buffer.order(ByteOrder.LITTLE_ENDIAN); 42 | try { 43 | int totalRead = 0; 44 | int read = socketChannel.read(buffer); 45 | totalRead += read; 46 | 47 | while (strict && read != 0 && read != i) { 48 | read = socketChannel.read(buffer); 49 | totalRead+=read; 50 | } 51 | 52 | if (totalRead != i && strict) { 53 | throw new RethinkDBException("Error receiving data, expected " + i + " bytes but received " + totalRead); 54 | } 55 | 56 | buffer.flip(); 57 | return buffer; 58 | } catch (IOException e) { 59 | throw new RethinkDBException(e); 60 | } 61 | } 62 | 63 | public void writeLEInt(int i) { 64 | ByteBuffer buffer = ByteBuffer.allocate(4); 65 | buffer.order(ByteOrder.LITTLE_ENDIAN); 66 | buffer.putInt(i); 67 | _write(buffer); 68 | } 69 | 70 | // public int readLEInt() { 71 | // ByteBuffer buffer = _read(4, true); 72 | // ThreadUtil.sleep(1); // TODO: this resolves an issue, need to figure out if there is a delay on rethink side, 73 | // // and or if this can be considered normal 74 | // return buffer.getInt(); 75 | // } 76 | 77 | public void writeStringWithLength(String s) { 78 | writeLEInt(s.length()); 79 | 80 | ByteBuffer buffer = ByteBuffer.allocate(s.length()); 81 | buffer.put(s.getBytes()); 82 | _write(buffer); 83 | } 84 | 85 | public String readString() { 86 | return new String(_read(5000, false).array()); 87 | } 88 | 89 | public void write(byte[] bytes) { 90 | writeLEInt(bytes.length); 91 | 92 | ByteBuffer buffer = ByteBuffer.allocate(bytes.length); 93 | buffer.put(bytes); 94 | 95 | _write(buffer); 96 | } 97 | 98 | public Q2L.Response read() { 99 | try { 100 | ByteBuffer datalen = ByteBuffer.allocate(4); 101 | datalen.order(ByteOrder.LITTLE_ENDIAN); 102 | int bytesRead = socketChannel.read(datalen); 103 | if (bytesRead != 4) { 104 | throw new RethinkDBException("Error receiving data, expected 4 bytes but received " + bytesRead); 105 | } 106 | datalen.flip(); 107 | int len = datalen.getInt(); 108 | 109 | ByteBuffer buf = ByteBuffer.allocate(len); 110 | bytesRead = 0; 111 | while (bytesRead != len) { 112 | bytesRead += socketChannel.read(buf); 113 | } 114 | buf.flip(); 115 | return Q2L.Response.parseFrom(buf.array()); 116 | } 117 | catch (IOException ex) { 118 | throw new RethinkDBException("IO Exception ",ex); 119 | } 120 | } 121 | 122 | public boolean isClosed(){ 123 | return !socketChannel.isOpen(); 124 | } 125 | 126 | public void close() { 127 | try { 128 | socketChannel.close(); 129 | } catch (IOException e) { 130 | throw new RethinkDBException(e); 131 | } 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/RqlUtil.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query; 2 | 3 | import com.rethinkdb.RethinkDB; 4 | import com.rethinkdb.RethinkDBException; 5 | import com.rethinkdb.model.RqlFunction; 6 | import com.rethinkdb.ast.query.gen.Datum; 7 | import com.rethinkdb.ast.query.gen.Func; 8 | import com.rethinkdb.ast.query.gen.MakeArray; 9 | import com.rethinkdb.ast.query.gen.MakeObj; 10 | import com.rethinkdb.model.RqlLambda; 11 | import com.rethinkdb.proto.Q2L; 12 | 13 | import java.lang.*; 14 | import java.text.DateFormat; 15 | import java.text.SimpleDateFormat; 16 | import java.util.*; 17 | 18 | 19 | public class RqlUtil { 20 | /** 21 | * Coerces objects from their native type to RqlQuery 22 | * 23 | * @param val val 24 | * @return RqlQuery 25 | */ 26 | public static RqlQuery toRqlQuery(java.lang.Object val) { 27 | return toRqlQuery(val, 20); 28 | } 29 | 30 | private static RqlQuery toRqlQuery(java.lang.Object val, int remainingDepth) { 31 | if (val instanceof RqlQuery) { 32 | return (RqlQuery) val; 33 | } 34 | 35 | if (val instanceof List) { 36 | List innerValues = new ArrayList(); 37 | for (java.lang.Object innerValue : (List) val) { 38 | innerValues.add(toRqlQuery(innerValue, remainingDepth - 1)); 39 | } 40 | return new MakeArray(innerValues, null); 41 | } 42 | 43 | if (val instanceof Map) { 44 | Map obj = new HashMap(); 45 | for (Map.Entry entry : (Set) ((Map) val).entrySet()) { 46 | if (!(entry.getKey() instanceof String)) { 47 | throw new RethinkDBException("Object key can only be strings"); 48 | } 49 | 50 | obj.put((String) entry.getKey(), toRqlQuery(entry.getValue())); 51 | } 52 | return new MakeObj(obj); 53 | } 54 | 55 | if (val instanceof RqlLambda) { 56 | return new Func((RqlLambda) val); 57 | } 58 | 59 | if (val instanceof Date) { 60 | TimeZone tz = TimeZone.getTimeZone("UTC"); 61 | DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mmZ"); 62 | df.setTimeZone(tz); 63 | return RethinkDB.R.ISO8601(df.format((Date) val)); 64 | } 65 | 66 | return new Datum(val); 67 | } 68 | 69 | 70 | /* 71 | Called on arguments that should be functions 72 | */ 73 | public static RqlQuery funcWrap(java.lang.Object o) { 74 | final RqlQuery rqlQuery = toRqlQuery(o); 75 | 76 | if (hasImplicitVar(rqlQuery)) { 77 | return new Func(new RqlFunction() { 78 | @Override 79 | public RqlQuery apply(RqlQuery row) { 80 | return rqlQuery; 81 | } 82 | }); 83 | } else { 84 | return rqlQuery; 85 | } 86 | } 87 | 88 | 89 | public static boolean hasImplicitVar(RqlQuery node) { 90 | if (node.getTermType() == Q2L.Term.TermType.IMPLICIT_VAR) { 91 | return true; 92 | } 93 | for (RqlQuery arg : node.getArgs()) { 94 | if (hasImplicitVar(arg)) { 95 | return true; 96 | } 97 | } 98 | for (Map.Entry kv : node.getOptionalArgs().entrySet()) { 99 | if (hasImplicitVar(kv.getValue())) { 100 | return true; 101 | } 102 | } 103 | 104 | return false; 105 | } 106 | 107 | public static Q2L.Datum createDatum(java.lang.Object value) { 108 | Q2L.Datum.Builder builder = Q2L.Datum.newBuilder(); 109 | 110 | if (value == null) { 111 | return builder 112 | .setType(Q2L.Datum.DatumType.R_NULL) 113 | .build(); 114 | } 115 | 116 | if (value instanceof String) { 117 | return builder 118 | .setType(Q2L.Datum.DatumType.R_STR) 119 | .setRStr((String) value) 120 | .build(); 121 | } 122 | 123 | if (value instanceof Number) { 124 | return builder 125 | .setType(Q2L.Datum.DatumType.R_NUM) 126 | .setRNum(((Number) value).doubleValue()) 127 | .build(); 128 | } 129 | 130 | if (value instanceof Boolean) { 131 | return builder 132 | .setType(Q2L.Datum.DatumType.R_BOOL) 133 | .setRBool((Boolean) value) 134 | .build(); 135 | } 136 | 137 | if (value instanceof Collection) { 138 | Q2L.Datum.Builder arr = builder 139 | .setType(Q2L.Datum.DatumType.R_ARRAY); 140 | 141 | for (java.lang.Object o : (Collection) value) { 142 | arr.addRArray(createDatum(o)); 143 | } 144 | 145 | return arr.build(); 146 | 147 | } 148 | 149 | throw new RethinkDBException("Unknown Value can't create datatype for : " + value.getClass()); 150 | } 151 | 152 | } 153 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/RethinkDBConnection.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb; 2 | 3 | import com.rethinkdb.proto.Q2L; 4 | import com.rethinkdb.response.DBResultFactory; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | 8 | import java.util.List; 9 | import java.util.concurrent.atomic.AtomicInteger; 10 | 11 | public class RethinkDBConnection { 12 | private static final Logger logger = LoggerFactory.getLogger(RethinkDBConnection.class); 13 | 14 | private static final AtomicInteger tokenGenerator = new AtomicInteger(); 15 | 16 | private String hostname; 17 | private String authKey; 18 | private int port; 19 | private int timeout; 20 | private String dbName = null; 21 | 22 | private SocketChannelFacade socket = new SocketChannelFacade(); 23 | 24 | public RethinkDBConnection() { 25 | this(RethinkDBConstants.DEFAULT_HOSTNAME); 26 | } 27 | 28 | public RethinkDBConnection(String hostname) { 29 | this(hostname, RethinkDBConstants.DEFAULT_PORT); 30 | } 31 | 32 | public RethinkDBConnection(String hostname, int port) { 33 | this(hostname, port, ""); 34 | } 35 | 36 | public RethinkDBConnection(String hostname, int port, String authKey) { 37 | this(hostname, port, authKey, RethinkDBConstants.DEFAULT_TIMEOUT); 38 | } 39 | 40 | public RethinkDBConnection(String hostname, int port, String authKey, int timeout) { 41 | this.hostname = hostname; 42 | this.port = port; 43 | this.authKey = authKey; 44 | this.timeout = timeout; 45 | reconnect(); 46 | } 47 | 48 | // TODO: use timeout 49 | public void reconnect() { 50 | socket.connect(hostname, port); 51 | socket.writeLEInt(Q2L.VersionDummy.Version.V0_2.getNumber()); 52 | socket.writeStringWithLength(authKey); 53 | 54 | String result = socket.readString(); 55 | if (!result.startsWith("SUCCESS")) { 56 | throw new RethinkDBException(result); 57 | } 58 | } 59 | 60 | // TODO: When partial implemented add option to wait for jobs to finish 61 | public void close() { 62 | socket.close(); 63 | } 64 | 65 | public boolean isClosed(){ 66 | return socket.isClosed(); 67 | } 68 | 69 | public void use(String dbName) { 70 | this.dbName = dbName; 71 | } 72 | 73 | 74 | protected Q2L.Response getNext(long token) { 75 | Q2L.Query query = Q2L.Query 76 | .newBuilder() 77 | .setToken(token) 78 | .setType(Q2L.Query.QueryType.CONTINUE) 79 | .build(); 80 | return execute(query); 81 | } 82 | 83 | protected void closeCursor(Cursor cursor) { 84 | Q2L.Query query = Q2L.Query 85 | .newBuilder() 86 | .setToken(cursor.getToken()) 87 | .setType(Q2L.Query.QueryType.CONTINUE) 88 | .build(); 89 | execute(query); 90 | } 91 | 92 | public Cursor runForCursor(Q2L.Term term) { 93 | 94 | Q2L.Query.Builder queryBuilder = startQuery(term); 95 | 96 | Q2L.Response response = execute(queryBuilder.build()); 97 | 98 | return new Cursor(this, response); 99 | } 100 | 101 | public T run(Q2L.Term term) { 102 | Q2L.Query.Builder queryBuilder = startQuery(term); 103 | 104 | return DBResultFactory.convert(execute(queryBuilder.build())); 105 | } 106 | 107 | // set the global option dbName if user chose one through use 108 | private void setDbOptionIfNeeded(Q2L.Query.Builder q, String db) { 109 | if (db == null) return; 110 | 111 | if (!hasDBSet(q)) { 112 | q.addGlobalOptargs( 113 | Q2L.Query.AssocPair.newBuilder() 114 | .setKey("db") 115 | .setVal(Q2L.Term.newBuilder() 116 | .setType(Q2L.Term.TermType.DB) 117 | .addArgs(Q2L.Term.newBuilder() 118 | .setType(Q2L.Term.TermType.DATUM) 119 | .setDatum( 120 | Q2L.Datum.newBuilder() 121 | .setType(Q2L.Datum.DatumType.R_STR) 122 | .setRStr(db).build() 123 | ) 124 | ).build()) 125 | ); 126 | } 127 | } 128 | 129 | private boolean hasDBSet(Q2L.Query.Builder q) { 130 | for (Q2L.Query.AssocPair assocPair : q.getGlobalOptargsList()) { 131 | if (assocPair.getKey().equals("db")) { 132 | return true; 133 | } 134 | } 135 | return false; 136 | } 137 | 138 | private Q2L.Query.Builder startQuery(Q2L.Term term) { 139 | Q2L.Query.Builder queryBuilder = Q2L.Query 140 | .newBuilder() 141 | .setToken(tokenGenerator.incrementAndGet()) 142 | .setType(Q2L.Query.QueryType.START) 143 | .setQuery(term); 144 | 145 | setDbOptionIfNeeded(queryBuilder, this.dbName); 146 | 147 | return queryBuilder; 148 | } 149 | 150 | private Q2L.Response execute(Q2L.Query query) { 151 | logger.debug("running {} ", query); 152 | socket.write(query.toByteArray()); 153 | return socket.read(); 154 | } 155 | 156 | } 157 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/response/DBResponseMapper.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.response; 2 | 3 | import com.rethinkdb.RethinkDBException; 4 | import com.rethinkdb.ast.query.gen.Timezone; 5 | import com.rethinkdb.proto.Q2L; 6 | 7 | import java.lang.reflect.Field; 8 | import java.util.*; 9 | 10 | public class DBResponseMapper { 11 | 12 | /** 13 | * Maps a ProtoBuf Datum object to a java object 14 | * 15 | * @param datum datum 16 | * @return DBObject 17 | */ 18 | public static T fromDatumObject(Q2L.Datum datum) { 19 | // Null is Null 20 | if (datum.getType() == Q2L.Datum.DatumType.R_NULL) { 21 | return null; 22 | } 23 | 24 | // Number, Str, bool go to simple java datatypes 25 | if (datum.getType() == Q2L.Datum.DatumType.R_NUM || 26 | datum.getType() == Q2L.Datum.DatumType.R_STR || 27 | datum.getType() == Q2L.Datum.DatumType.R_BOOL) { 28 | return (T)handleType(datum); 29 | } 30 | 31 | // R_OBJECT is Map 32 | if (datum.getType() == Q2L.Datum.DatumType.R_OBJECT) { 33 | Map repr = new HashMap(); 34 | for (Q2L.Datum.AssocPair assocPair : datum.getRObjectList()) { 35 | 36 | if (assocPair.getKey().equals("$reql_type$") && "TIME".equals(assocPair.getVal().getRStr())) { 37 | return (T)asDate(datum); 38 | } 39 | 40 | repr.put(assocPair.getKey(), handleType(assocPair.getVal())); 41 | } 42 | return (T)repr; 43 | } 44 | 45 | // Array goes to List 46 | if (datum.getType() == Q2L.Datum.DatumType.R_ARRAY) { 47 | return (T)makeArray(datum.getRArrayList()); 48 | } 49 | 50 | throw new RethinkDBException("Can't map datum to JavaObject for {}" + datum.getType()); 51 | 52 | } 53 | 54 | private static Date asDate(Q2L.Datum datum) { 55 | String timezone = ""; 56 | Double epoch_time = 0.0; 57 | 58 | for (Q2L.Datum.AssocPair assocPair : datum.getRObjectList()) { 59 | 60 | if (assocPair.getKey().equals("epoch_time")) { 61 | epoch_time = assocPair.getVal().getRNum(); 62 | } 63 | if (assocPair.getKey().equals("timezone")) { 64 | timezone = assocPair.getVal().getRStr(); 65 | } 66 | 67 | } 68 | 69 | try { 70 | Calendar calendar = Calendar.getInstance(); 71 | calendar.setTimeInMillis(epoch_time.longValue() * 1000); 72 | calendar.setTimeZone(TimeZone.getTimeZone(timezone)); 73 | return calendar.getTime(); 74 | } 75 | catch (Exception ex) { 76 | throw new RethinkDBException("Error handling date",ex); 77 | } 78 | } 79 | 80 | /** 81 | * Maps a list of Datum Objects to a list of java objects 82 | * 83 | * @param datums datum objects 84 | * @return DBObject 85 | */ 86 | public static List fromDatumObjectList(List datums) { 87 | List results = new ArrayList(); 88 | for (Q2L.Datum datum : datums) { 89 | results.add((T)fromDatumObject(datum)); 90 | } 91 | return results; 92 | } 93 | 94 | private static Object handleType(Q2L.Datum val) { 95 | switch (val.getType()) { 96 | case R_OBJECT: 97 | return fromDatumObject(val); 98 | case R_STR: 99 | return val.getRStr(); 100 | case R_BOOL: 101 | return val.getRBool(); 102 | case R_NULL: 103 | return null; 104 | case R_NUM: 105 | return val.getRNum(); 106 | case R_ARRAY: 107 | return makeArray(val.getRArrayList()); 108 | case R_JSON: 109 | default: 110 | throw new RuntimeException("Not implemented" + val.getType()); 111 | } 112 | } 113 | 114 | private static List makeArray(List elements) { 115 | List objects = new ArrayList(); 116 | for (Q2L.Datum element : elements) { 117 | objects.add(handleType(element)); 118 | } 119 | return objects; 120 | } 121 | 122 | /** 123 | * Populates the fields in to based on values out of from 124 | * 125 | * @param to the object to map into 126 | * @param from the object to map from 127 | * @param the type of the into object 128 | * @return the into object 129 | */ 130 | public static T populateObject(T to, Map from) { 131 | for (Field field : to.getClass().getDeclaredFields()) { 132 | try { 133 | field.setAccessible(true); 134 | 135 | Object result = convertField(field, from); 136 | if (result != null || !field.getType().isPrimitive()) { 137 | field.set(to, result); 138 | } 139 | 140 | } catch (IllegalAccessException e) { 141 | throw new RethinkDBException("Error populating from DBObject: " + field.getName(), e); 142 | } 143 | } 144 | return to; 145 | } 146 | 147 | public static List populateList(Class clazz, List> from) { 148 | List results = new ArrayList(); 149 | for (Map stringObjectMap : from) { 150 | try { 151 | results.add(populateObject(clazz.newInstance(),stringObjectMap)); 152 | } catch (InstantiationException e) { 153 | throw new RethinkDBException("Error instantiating " + clazz, e); 154 | } catch (IllegalAccessException e) { 155 | throw new RethinkDBException("Illegal access on " + clazz, e); 156 | } 157 | } 158 | return results; 159 | } 160 | 161 | 162 | 163 | private static Object convertField(Field toField, Map from) { 164 | if (from.get(toField.getName()) == null) { 165 | return null; 166 | } 167 | if (toField.getType().equals(Integer.class) || toField.getType().equals(int.class)) { 168 | return ((Number) from.get(toField.getName())).intValue(); 169 | } 170 | if (toField.getType().equals(Float.class) || toField.getType().equals(float.class)) { 171 | return ((Number) from.get(toField.getName())).floatValue(); 172 | } 173 | return from.get(toField.getName()); 174 | } 175 | 176 | 177 | } 178 | -------------------------------------------------------------------------------- /src/test/java/com/rethinkdb/integration/ModifyDataIT.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.integration; 2 | 3 | import com.rethinkdb.model.ConflictStrategy; 4 | import com.rethinkdb.model.MapObject; 5 | import com.rethinkdb.model.RqlFunction; 6 | import com.rethinkdb.ast.query.RqlQuery; 7 | import com.rethinkdb.model.Durability; 8 | import com.rethinkdb.response.model.DMLResult; 9 | import org.fest.assertions.Assertions; 10 | import org.junit.Test; 11 | 12 | import java.util.ArrayList; 13 | import java.util.Arrays; 14 | import java.util.List; 15 | import java.util.Map; 16 | 17 | public class ModifyDataIT extends AbstractITTest { 18 | 19 | @Test 20 | public void testInsertList() { 21 | List> objects = new ArrayList>(); 22 | for (int i = 0; i < 10; i++) { 23 | objects.add(new MapObject().with("abc", i)); 24 | } 25 | r.db(dbName).table(tableName).insert(objects).run(con); 26 | 27 | // TODO runForType here 28 | List> result = (List>) r.db(dbName).table(tableName).run(con); 29 | 30 | List setKeys = new ArrayList(); 31 | for (Map map : result) { 32 | setKeys.add((Double) map.get("abc")); 33 | } 34 | 35 | Assertions.assertThat(setKeys).contains(0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0); 36 | } 37 | 38 | @Test 39 | public void doubleInsertFailsWithoutUpsert() { 40 | DMLResult firstResult = r.db(dbName).table(tableName) 41 | .insert(new MapObject().with("id", 1)).run(con); 42 | DMLResult secondResult = r.db(dbName).table(tableName) 43 | .insert(new MapObject().with("id", 1).with("field", "a")).run(con); 44 | 45 | Assertions.assertThat(firstResult.getInserted()).isEqualTo(1); 46 | 47 | Assertions.assertThat(secondResult.getReplaced()).isEqualTo(0); 48 | Assertions.assertThat(secondResult.getInserted()).isEqualTo(0); 49 | } 50 | 51 | @Test 52 | public void doubleInsertWorksWithUpsert() { 53 | DMLResult firstResult = r.db(dbName).table(tableName) 54 | .insert(new MapObject().with("id", 1), Durability.hard, false, ConflictStrategy.replace).run(con); 55 | DMLResult secondResult = r.db(dbName).table(tableName) 56 | .insert(new MapObject().with("id", 1).with("field", "a"), Durability.hard, false, ConflictStrategy.replace).run(con); 57 | 58 | Assertions.assertThat(firstResult.getInserted()).isEqualTo(1); 59 | 60 | Assertions.assertThat(secondResult.getReplaced()).isEqualTo(1); 61 | Assertions.assertThat(secondResult.getInserted()).isEqualTo(0); 62 | } 63 | 64 | 65 | @Test 66 | public void updateFromTable() { 67 | r.db(dbName).table(tableName).insert(new MapObject().with("id", 1)).run(con); 68 | r.db(dbName).table(tableName).insert(new MapObject().with("id", 2)).run(con); 69 | 70 | DMLResult result = r.db(dbName).table(tableName).update(new MapObject().with("name", "test")).run(con); 71 | 72 | Assertions.assertThat(result.getReplaced()).isEqualTo(2); 73 | } 74 | 75 | @Test 76 | public void updateFromGet() { 77 | r.db(dbName).table(tableName).insert(new MapObject().with("id", 1)).run(con); 78 | 79 | DMLResult result = r.db(dbName).table(tableName).get(1).update(new MapObject().with("name", "test")).run(con); 80 | 81 | Assertions.assertThat(result.getReplaced()).isEqualTo(1); 82 | } 83 | 84 | 85 | @Test 86 | public void updateWithLambdaInObject() { 87 | r.db(dbName).table(tableName).insert(new MapObject().with("id", 1).with("age", 1)).run(con); 88 | r.db(dbName).table(tableName).insert(new MapObject().with("id", 2).with("age", 2)).run(con); 89 | 90 | DMLResult result = RqlQuery.R.db(dbName).table(tableName) 91 | .update(new MapObject().with("age", r.row().field("age").add(22))).run(con); 92 | 93 | Assertions.assertThat(result.getReplaced()).isEqualTo(2); 94 | } 95 | 96 | @Test 97 | public void updateBranch() { 98 | r.db(dbName).table(tableName).insert(new MapObject().with("id", 1).with("age", 1)).run(con); 99 | 100 | DMLResult result = RqlQuery.R.db(dbName).table(tableName) 101 | .update( 102 | new RqlFunction() { 103 | @Override 104 | public RqlQuery apply(RqlQuery row) { 105 | return r.branch( 106 | row.field("age").gt(0), 107 | new MapObject().with("born", true), 108 | new MapObject().with("born", false) 109 | ); 110 | } 111 | } 112 | ).run(con); 113 | 114 | Assertions.assertThat(result.getReplaced()).isEqualTo(1); 115 | } 116 | 117 | 118 | @Test 119 | public void testReplace() { 120 | Map replacement = new MapObject().with("id", 1).with("field1", "abc"); 121 | 122 | DMLResult result = r.db(dbName).table(tableName).replace(replacement).run(con); 123 | Assertions.assertThat(result.getReplaced()).isEqualTo(0); 124 | 125 | r.db(dbName).table(tableName).insert(new MapObject().with("id", 1)).run(con); 126 | 127 | result = r.db(dbName).table(tableName).replace(replacement).run(con); 128 | Assertions.assertThat(result.getReplaced()).isEqualTo(1); 129 | } 130 | 131 | @Test 132 | public void testReplace_Without() { // as lambda 133 | Map dbObj = new MapObject().with("id", 1).with("field1", "abc"); 134 | r.db(dbName).table(tableName).insert(dbObj).run(con); 135 | 136 | DMLResult result = r.db(dbName).table(tableName).replace(new RqlFunction() { 137 | @Override 138 | public RqlQuery apply(RqlQuery row) { 139 | return row.without("field1"); 140 | } 141 | }).run(con); 142 | 143 | Assertions.assertThat(result.getReplaced()).isEqualTo(1); 144 | } 145 | 146 | @Test 147 | public void testReplace_pluck() { // as lambda 148 | Map dbObj = new MapObject() 149 | .with("id", 1) 150 | .with("field1", "abc") 151 | .with("field2", "def"); 152 | 153 | r.db(dbName).table(tableName).insert(dbObj).run(con); 154 | 155 | List> result = (List>) r.db(dbName).table(tableName).pluck(Arrays.asList("field1", "field2")).run(con); 156 | Assertions.assertThat(result.get(0).get("field1")).isEqualTo("abc"); 157 | Assertions.assertThat(result.get(0).get("field2")).isEqualTo("def"); 158 | 159 | result = (List>) r.db(dbName).table(tableName).pluck(Arrays.asList("field2")).run(con); 160 | Assertions.assertThat(result.get(0).get("field1")).isNull(); 161 | Assertions.assertThat(result.get(0).get("field2")).isEqualTo("def"); 162 | 163 | } 164 | 165 | @Test 166 | public void testWithout() { // as normal function 167 | Map dbObj = new MapObject().with("id", 1).with("field1", "abc"); 168 | r.db(dbName).table(tableName).insert(dbObj).run(con); 169 | 170 | List> objects = (List>) r.db(dbName).table(tableName).without("field1").run(con); 171 | 172 | Assertions.assertThat(objects.get(0).get("field1")).isNull(); 173 | Assertions.assertThat(objects.get(0).get("id")).isEqualTo(1.0); 174 | } 175 | 176 | @Test 177 | public void testCountAndDelete() { 178 | Map dbObj = new MapObject().with("id", 1); 179 | r.db(dbName).table(tableName).insert(dbObj).run(con); 180 | 181 | Assertions.assertThat(r.table(tableName).count().run(con)).isEqualTo(1); 182 | r.db(dbName).table(tableName).delete().run(con); 183 | Assertions.assertThat(r.table(tableName).count().run(con)).isEqualTo(0); 184 | 185 | } 186 | 187 | @Test 188 | public void testSync() { 189 | r.table(tableName).sync(); // no crash 190 | } 191 | 192 | 193 | 194 | } 195 | -------------------------------------------------------------------------------- /src/main/java/com/rethinkdb/ast/query/RqlQuery.java: -------------------------------------------------------------------------------- 1 | package com.rethinkdb.ast.query; 2 | 3 | import com.google.common.collect.Lists; 4 | import com.rethinkdb.Cursor; 5 | import com.rethinkdb.RethinkDBConnection; 6 | import com.rethinkdb.ast.helper.Arguments; 7 | import com.rethinkdb.ast.helper.OptionalArguments; 8 | import com.rethinkdb.ast.query.gen.Date; 9 | import com.rethinkdb.model.Bound; 10 | import com.rethinkdb.model.Durability; 11 | import com.rethinkdb.model.RqlFunction; 12 | import com.rethinkdb.ast.query.gen.*; 13 | import com.rethinkdb.model.RqlFunction2; 14 | import com.rethinkdb.proto.Q2L; 15 | import com.rethinkdb.response.GroupedResponseConverter; 16 | import sun.security.krb5.internal.crypto.Des; 17 | 18 | import java.security.Key; 19 | import java.util.*; 20 | 21 | public class RqlQuery { 22 | 23 | public static RqlQuery R = new RqlQuery(null, null); 24 | 25 | private Q2L.Term.TermType termType; 26 | protected List args = new ArrayList(); 27 | protected java.util.Map optionalArgs = new HashMap(); 28 | 29 | // ** Protected Methods ** // 30 | 31 | protected RqlQuery(Q2L.Term.TermType termType, List args) { 32 | this(termType, args, new HashMap()); 33 | } 34 | 35 | protected RqlQuery(Q2L.Term.TermType termType) { 36 | this(termType, new ArrayList(), new HashMap()); 37 | } 38 | 39 | protected RqlQuery(Q2L.Term.TermType termType, List args, java.util.Map optionalArgs) { 40 | this(null, termType, args, optionalArgs); 41 | } 42 | 43 | public RqlQuery(RqlQuery previous, Q2L.Term.TermType termType, List args, Map optionalArgs) { 44 | this.termType = termType; 45 | 46 | init(previous, args, optionalArgs); 47 | } 48 | 49 | protected void init(RqlQuery previous, List args, Map optionalArgs) { 50 | if (previous != null && previous.termType != null) { 51 | this.args.add(previous); 52 | } 53 | 54 | if (args != null) { 55 | for (Object arg : args) { 56 | this.args.add(RqlUtil.toRqlQuery(arg)); 57 | } 58 | } 59 | 60 | if (optionalArgs != null) { 61 | for (Map.Entry kv : optionalArgs.entrySet()) { 62 | this.optionalArgs.put(kv.getKey(), RqlUtil.toRqlQuery(kv.getValue())); 63 | } 64 | } 65 | } 66 | 67 | protected Q2L.Term.TermType getTermType() { 68 | return termType; 69 | } 70 | 71 | protected List getArgs() { 72 | return args; 73 | } 74 | 75 | protected Map getOptionalArgs() { 76 | return optionalArgs; 77 | } 78 | 79 | protected Q2L.Term toTerm() { 80 | Q2L.Term.Builder termBuilder = Q2L.Term.newBuilder().setType(termType); 81 | for (RqlQuery arg : args) { 82 | termBuilder.addArgs(arg.toTerm()); 83 | } 84 | for (Map.Entry kv : optionalArgs.entrySet()) { 85 | termBuilder.addOptargs( 86 | Q2L.Term.AssocPair.newBuilder() 87 | .setKey(kv.getKey()) 88 | .setVal(kv.getValue().toTerm()) 89 | ).build(); 90 | } 91 | return termBuilder.build(); 92 | } 93 | 94 | // ** Public API **// 95 | 96 | public Object run(RethinkDBConnection connection) { 97 | return connection.run(toTerm()); 98 | } 99 | 100 | public Cursor runForCursor(RethinkDBConnection connection) { 101 | return connection.runForCursor(toTerm()); 102 | } 103 | 104 | public Map runForGroup(RethinkDBConnection connection) { 105 | return GroupedResponseConverter.convert((Map) run(connection)); 106 | } 107 | 108 | public DbCreate dbCreate(String dbName) { 109 | return new DbCreate(new Arguments(dbName), null); 110 | } 111 | 112 | public DbDrop dbDrop(String dbName) { 113 | return new DbDrop(new Arguments(dbName), null); 114 | } 115 | 116 | public DbList dbList() { 117 | return new DbList(null, null); 118 | } 119 | 120 | public RqlQuery eq(Object... queries) { 121 | return new Eq(this,Arrays.asList(queries), null); 122 | } 123 | 124 | public RqlQuery ne(Object... queries) { 125 | return new Ne(this,Arrays.asList(queries), null); 126 | } 127 | 128 | public RqlQuery lt(Object... queries) { 129 | return new Lt(this,Arrays.asList(queries), null); 130 | } 131 | 132 | public RqlQuery le(Object... queries) { 133 | return new Le(this,Arrays.asList(queries), null); 134 | } 135 | 136 | public RqlQuery gt(Object... queries) { 137 | return new Gt(this,Arrays.asList(queries), null); 138 | } 139 | 140 | public RqlQuery ge(Object... queries) { 141 | return new Ge(this,Arrays.asList(queries), null); 142 | } 143 | 144 | public RqlQuery add(Object... queries) { 145 | return new Add(this, Arrays.asList(queries), null); 146 | } 147 | 148 | public RqlQuery sub(Object... queries) { 149 | return new Sub(this, Arrays.asList(queries), null); 150 | } 151 | 152 | public RqlQuery mul(Object... queries) { 153 | return new Mul(this,Arrays.asList(queries), null); 154 | } 155 | 156 | public RqlQuery div(Object... queries) { 157 | return new Div(this,Arrays.asList(queries), null); 158 | } 159 | 160 | public RqlQuery mod(Object... queries) { 161 | return new Mod(this,Arrays.asList(queries), null); 162 | } 163 | 164 | public RqlQuery and(Object... queries) { 165 | return new All(this,Arrays.asList(queries), null); 166 | } 167 | 168 | public RqlQuery or(Object... queries) { 169 | return new Any(this,Arrays.asList(queries), null); 170 | } 171 | 172 | public RqlQuery not(Object... queries) { 173 | return new Not(this,Arrays.asList(queries), null); 174 | } 175 | 176 | public DB db(String db) { 177 | return new DB(new Arguments(db), null); 178 | } 179 | 180 | public Update update(Map object, Boolean nonAtomic, Durability durability, Boolean returnVals) { 181 | return new Update(this, new Arguments(RqlUtil.funcWrap(object)), 182 | new OptionalArguments() 183 | .with("non_atomic", nonAtomic) 184 | .with("durability", durability) 185 | .with("return_vals", returnVals) 186 | ); 187 | } 188 | 189 | public Update update(Map object) { 190 | return update(object, null, null, null); 191 | } 192 | 193 | public Update update(RqlFunction function, Boolean nonAtomic, Durability durability, Boolean returnVals) { 194 | return new Update(this, new Arguments(RqlUtil.funcWrap(function)), 195 | new OptionalArguments() 196 | .with("non_atomic", nonAtomic) 197 | .with("durability", durability) 198 | .with("return_vals", returnVals) 199 | ); 200 | } 201 | 202 | public Update update(RqlFunction function) { 203 | return update(function, null, null, null); 204 | } 205 | 206 | 207 | public ImplicitVar row() { 208 | return new ImplicitVar(null, null, null); 209 | } 210 | 211 | public GetField field(String field) { 212 | return new GetField(this, new Arguments(field), null); 213 | } 214 | 215 | public RMap map(RqlFunction function) { 216 | return new RMap(this, new Arguments(new Func(function)), null); 217 | } 218 | 219 | public ConcatMap concatMap(RqlFunction function) { 220 | return new ConcatMap(this, new Arguments(RqlUtil.funcWrap(function)), null); 221 | } 222 | 223 | public OrderBy orderBy(RqlFunction function) { 224 | return orderBy(null, function); 225 | } 226 | 227 | public OrderBy orderBy(List fields, String index) { 228 | return orderBy(index, fields.toArray()); 229 | } 230 | 231 | public OrderBy orderBy(Object... fields) { 232 | return orderBy(null, fields); 233 | } 234 | 235 | public OrderBy orderByIndex(String index) { 236 | return orderBy(index, null); 237 | } 238 | 239 | public OrderBy orderByIndex(Object index) { 240 | return new OrderBy(this, new Arguments(), new OptionalArguments().with("index", index)); 241 | } 242 | 243 | public OrderBy orderByField(String field) { 244 | return orderBy((String)null, field); 245 | } 246 | 247 | private OrderBy orderBy(String index, Object... fields) { 248 | List args = new ArrayList(); 249 | for (Object field : fields) { 250 | if (field instanceof Asc || field instanceof Desc) { 251 | args.add(field); 252 | } 253 | else { 254 | args.add(RqlUtil.funcWrap(field)); 255 | } 256 | } 257 | return new OrderBy(this, new Arguments(args), new OptionalArguments().with("index", index)); 258 | } 259 | 260 | public Get get(String key) { 261 | return new Get(this, new Arguments(key), null); 262 | } 263 | 264 | public GetAll get(List keys) { 265 | return get(keys, null); 266 | } 267 | 268 | public GetAll get(List keys, String index) { 269 | return new GetAll(this, new Arguments(keys), new OptionalArguments().with("index", index)); 270 | } 271 | 272 | public Filter filter(RqlFunction function) { return new Filter(this, new Arguments(new Func(function)), null); } 273 | 274 | public Filter filter(RqlQuery query) { return new Filter(this, new Arguments(query), null); } 275 | 276 | public Between between(String lowerKey, String upperKey) { 277 | return new Between(this, new Arguments(lowerKey, upperKey), null); 278 | } 279 | 280 | public Between between(String lowerKey, String upperKey, String index, Bound leftBound, Bound rightBound) { 281 | return new Between(this, new Arguments(lowerKey, upperKey), 282 | new OptionalArguments().with("index", index) 283 | .with("left_bound", leftBound.name()) 284 | .with("right_bound", rightBound.name())); 285 | } 286 | 287 | public Table table(String tableName) { 288 | return new Table(this, new Arguments(tableName), null); 289 | } 290 | 291 | public Upcase upcase() { 292 | return new Upcase(this, null, null); 293 | } 294 | 295 | public Downcase downcase() { 296 | return new Downcase(this, null, null); 297 | } 298 | 299 | public Split split(String s) { 300 | return new Split(this, new Arguments(s), null); 301 | } 302 | 303 | public Replace replace(Map replacement) { 304 | return new Replace(this, new Arguments(replacement), null); 305 | } 306 | 307 | public Replace replace(RqlFunction function) { 308 | return new Replace(this, new Arguments(new Func(function)), null); 309 | } 310 | 311 | public RqlQuery without(String... fields) { 312 | return without(Lists.newArrayList(fields)); 313 | } 314 | 315 | public RqlQuery without(List field) { 316 | return new Without(this, new Arguments(field), null); 317 | } 318 | 319 | public Pluck pluck(String... fields) { 320 | return pluck(Lists.newArrayList(fields)); 321 | } 322 | 323 | public Pluck pluck(List fields) { 324 | return new Pluck(this, new Arguments(fields), null); 325 | } 326 | 327 | public Branch branch(RqlQuery predicate, Map trueBranch, Map falseBranch) { 328 | return new Branch(predicate, new Arguments(trueBranch, falseBranch), null); 329 | } 330 | 331 | public Append append(Object t) { 332 | return new Append(this, new Arguments(t), null); 333 | } 334 | 335 | public Prepend prepend(Object t) { 336 | return new Prepend(this, new Arguments(t), null); 337 | } 338 | 339 | public Difference difference(List ts) { 340 | return new Difference(this, new Arguments(ts), null); 341 | } 342 | 343 | public Delete delete() { 344 | return delete(null, null); 345 | } 346 | 347 | public Delete delete(Durability durability, Boolean withVals) { 348 | return new Delete(this, null, new OptionalArguments().with("durability", durability != null ? durability.toString() : null).with("with_vals", withVals)); 349 | } 350 | 351 | public Count count() { 352 | return new Count(this, null, null); 353 | } 354 | 355 | public Sync sync() { 356 | return new Sync(this, null, null); 357 | } 358 | 359 | public Match match(String regexp) { 360 | return new Match(this, new Arguments(regexp), null); 361 | } 362 | 363 | public RqlQuery expr(Object expr) { 364 | return RqlUtil.toRqlQuery(expr); 365 | } 366 | 367 | public WithFields withFields(String... fields) { 368 | return new WithFields(this, new Arguments(fields), null); 369 | } 370 | 371 | public InnerJoin innerJoin(RqlQuery other, RqlFunction2 predicate) { 372 | return new InnerJoin(this, new Arguments(other, RqlUtil.funcWrap(predicate)), null); 373 | } 374 | 375 | public OuterJoin outerJoin(RqlQuery other, RqlFunction2 predicate) { 376 | return new OuterJoin(this, new Arguments(other, RqlUtil.funcWrap(predicate)), null); 377 | } 378 | 379 | public EqJoin eqJoin(String leftAttribute, Table otherTable) { 380 | return eqJoin(leftAttribute, otherTable, null); 381 | } 382 | 383 | public EqJoin eqJoin(String leftAttribute, Table otherTable, String indexId) { 384 | return new EqJoin(this, new Arguments(leftAttribute, otherTable), new OptionalArguments().with("index",indexId)); 385 | } 386 | 387 | public EqJoin eqJoin(RqlFunction leftAttribute, Table otherTable) { 388 | return eqJoin(leftAttribute, otherTable, null); 389 | } 390 | 391 | public EqJoin eqJoin(RqlFunction leftAttribute, Table otherTable, String indexId) { 392 | return new EqJoin(this, new Arguments(RqlUtil.funcWrap(leftAttribute), otherTable), new OptionalArguments().with("index",indexId)); 393 | } 394 | 395 | public Zip zip() { 396 | return new Zip(this, null, null); 397 | } 398 | 399 | 400 | public Desc desc(String key) { 401 | return new Desc(this, new Arguments(key), null); 402 | } 403 | 404 | public Asc asc(String key) { 405 | return new Asc(this, new Arguments(key), null); 406 | } 407 | 408 | public Skip skip(int n) { 409 | return new Skip(this, new Arguments(n), null); 410 | } 411 | 412 | public Limit limit(int n) { 413 | return new Limit(this, new Arguments(n), null); 414 | } 415 | 416 | public IndexesOf indexesOf(Object value) { 417 | return new IndexesOf(this, new Arguments(value), null); 418 | } 419 | 420 | public IndexesOf indexesOf(RqlQuery predicate) { 421 | return new IndexesOf(this, new Arguments(RqlUtil.funcWrap(predicate)), null); 422 | } 423 | 424 | public IsEmpty isEmpty() { 425 | return new IsEmpty(this, null, null); 426 | } 427 | 428 | public Union union(RqlQuery other) { 429 | return new Union(this, new Arguments(other), null); 430 | } 431 | 432 | public Sample sample(int size) { 433 | return new Sample(this, new Arguments(size), null); 434 | } 435 | 436 | public Max max(String field) { 437 | return new Max(this, new Arguments(field), null); 438 | } 439 | 440 | public Max max(RqlFunction func) { 441 | return new Max(this, new Arguments(RqlUtil.funcWrap(func)), null); 442 | } 443 | 444 | public Min min(String field) { 445 | return new Min(this, new Arguments(field), null); 446 | } 447 | 448 | public Min min(RqlFunction func) { 449 | return new Min(this, new Arguments(RqlUtil.funcWrap(func)), null); 450 | } 451 | 452 | public Group group(RqlFunction func) { 453 | return group(func, null); 454 | } 455 | public Group group(RqlFunction func, String index) { 456 | return new Group(this, new Arguments(RqlUtil.funcWrap(func)), new OptionalArguments().with("index",index)); 457 | } 458 | public Group group(String field) { 459 | return group(field, null); 460 | } 461 | public Group group(String field, List index) { 462 | return new Group(this, new Arguments(field), new OptionalArguments().with("index",index)); 463 | } 464 | 465 | public Ungroup ungroup() { 466 | return new Ungroup(this, null, null); 467 | } 468 | 469 | public Reduce reduce(RqlFunction2 func) { 470 | return new Reduce(this, new Arguments(RqlUtil.funcWrap(func)), null); 471 | } 472 | 473 | public Sum sum() { 474 | return new Sum(this, null, null); 475 | } 476 | 477 | public Avg avg() { 478 | return new Avg(this, null, null); 479 | } 480 | 481 | public Min min() { 482 | return new Min(this, null, null); 483 | } 484 | 485 | public Max max() { 486 | return new Max(this, null, null); 487 | } 488 | 489 | public Distinct distinct() { 490 | return new Distinct(this, null, null); 491 | } 492 | 493 | public Contains contains(List objects) { 494 | List args = new ArrayList(); 495 | for (Object object : objects) { 496 | args.add(RqlUtil.funcWrap(object)); 497 | } 498 | return new Contains(this, args, null); 499 | } 500 | 501 | public SetInsert setInsert(List objects) { 502 | return new SetInsert(this, new Arguments(objects), null); 503 | } 504 | 505 | public SetUnion setUnion(List objects) { 506 | return new SetUnion(this, new Arguments(objects), null); 507 | } 508 | 509 | public SetIntersection setIntersection(List objects) { 510 | return new SetIntersection(this, new Arguments(objects), null); 511 | } 512 | 513 | public SetDifference setDifference(List objects) { 514 | return new SetDifference(this, new Arguments(objects), null); 515 | } 516 | 517 | public HasFields hasFields(List fields) { 518 | return new HasFields(this, new Arguments(fields), null); 519 | } 520 | 521 | public InsertAt insertAt(int index, Object value) { 522 | return new InsertAt(this, new Arguments(index, value), null); 523 | } 524 | 525 | public SpliceAt spliceAt(int index, List values) { 526 | return new SpliceAt(this, new Arguments(index, values), null); 527 | } 528 | 529 | public DeleteAt deleteAt(int index) { 530 | return new DeleteAt(this, new Arguments(index), null); 531 | } 532 | 533 | public DeleteAt deleteAt(int index, int endIndex) { 534 | return new DeleteAt(this, new Arguments(index, endIndex), null); 535 | } 536 | 537 | public ChangeAt changeAt(int index, Object value) { 538 | return new ChangeAt(this, new Arguments(index, value), null); 539 | } 540 | 541 | public Keys keys() { 542 | return new Keys(this, null, null); 543 | } 544 | 545 | public Now now() { return new Now(this, null, null); } 546 | 547 | public Date date() { return new Date(this, null, null); } 548 | 549 | public Time time(int year, int month, int day) { 550 | return time(year,month,day,"Z"); 551 | } 552 | 553 | public Time time(int year, int month, int day, String timezone) { 554 | return new Time(this, new Arguments(year,month,day, timezone), null); 555 | } 556 | 557 | public Time time(int year, int month, int day, int hour, int minute, int second) { 558 | return time(year,month,day,hour,minute,second); 559 | } 560 | 561 | public Time time(int year, int month, int day, int hour, int minute, int second, String timezone) { 562 | return new Time(this, new Arguments(year,month,day,hour,minute,second, timezone), null); 563 | } 564 | 565 | public EpochTime epochTime(long time) { 566 | return new EpochTime(this, new Arguments(time), null); 567 | } 568 | 569 | public ISO8601 ISO8601(String iso) { 570 | return new ISO8601(this, new Arguments(iso), null); 571 | } 572 | 573 | public InTimezone inTimezone(String tz) { 574 | return new InTimezone(this, new Arguments(tz), null); 575 | } 576 | 577 | public Timezone timezone(String tz) { 578 | return new Timezone(this, new Arguments(tz), null); 579 | } 580 | 581 | public During during(RqlQuery left, RqlQuery right, boolean leftInclusive, boolean rightInclusive) { 582 | return new During(this, new Arguments(left, right), new OptionalArguments() 583 | .with("left_bound", !leftInclusive ? "open" : "closed") 584 | .with("right_bound", !rightInclusive ? "open" : "closed") 585 | ); 586 | } 587 | 588 | public TimeOfDay timeOfDay() { 589 | return new TimeOfDay(this, null, null); 590 | } 591 | 592 | public Year year() { 593 | return new Year(this, null, null); 594 | } 595 | 596 | public Month month() { 597 | return new Month(this, null, null); 598 | } 599 | 600 | public Day day() { 601 | return new Day(this, null, null); 602 | } 603 | 604 | public DayOfWeek dayOfWeek() { 605 | return new DayOfWeek(this, null, null); 606 | } 607 | 608 | public DayOfYear dayOfYear() { 609 | return new DayOfYear(this, null, null); 610 | } 611 | 612 | public Hours hours() { 613 | return new Hours(this, null, null); 614 | } 615 | 616 | public Minutes minutes() { 617 | return new Minutes(this, null, null); 618 | } 619 | 620 | public Seconds seconds() { 621 | return new Seconds(this, null, null); 622 | } 623 | 624 | public ToISO8601 toISO8601() { 625 | return new ToISO8601(this, null, null); 626 | } 627 | 628 | public ToEpochTime toEpochTime() { 629 | return new ToEpochTime(this, null, null); 630 | } 631 | 632 | } 633 | --------------------------------------------------------------------------------