public async Task <T> RunAsync <T>(IQueryConverter queryConverter, IScalarQuery <T> queryObject, CancellationToken cancellationToken) { var query = new Spec.Query(); query.token = GetNextToken(); query.type = Spec.Query.QueryType.START; query.query = queryObject.GenerateTerm(queryConverter); var response = await InternalRunQuery(query, cancellationToken); switch (response.type) { case Response.ResponseType.SUCCESS_SEQUENCE: case Response.ResponseType.SUCCESS_ATOM: if (response.response.Count != 1) { throw new RethinkDbRuntimeException(String.Format("Expected 1 object, received {0}", response.response.Count)); } return(queryConverter.Get <T>().ConvertDatum(response.response[0])); case Response.ResponseType.CLIENT_ERROR: case Response.ResponseType.COMPILE_ERROR: throw new RethinkDbInternalErrorException("Client error: " + response.response[0].r_str); case Response.ResponseType.RUNTIME_ERROR: throw new RethinkDbRuntimeException("Runtime error: " + response.response[0].r_str); default: throw new RethinkDbInternalErrorException("Unhandled response type: " + response.type); } }
public Term GenerateTerm(IQueryConverter queryConverter) { var replaceTerm = new Term() { type = Term.TermType.REPLACE, }; replaceTerm.args.Add(getTerm.GenerateTerm(queryConverter)); replaceTerm.args.Add(new Term() { type = Term.TermType.DATUM, datum = queryConverter.Get <T>().ConvertObject(newObject) }); AddOptionalArguments(replaceTerm); if (nonAtomic) { replaceTerm.optargs.Add(new Term.AssocPair() { key = "non_atomic", val = new Term() { type = Term.TermType.DATUM, datum = new Datum() { type = Datum.DatumType.R_BOOL, r_bool = nonAtomic } } }); } return(replaceTerm); }
public void TestFixtureSetUp() { datumConverterFactory = Substitute.For<IDatumConverterFactory>(); queryConverter = new QueryConverter(datumConverterFactory, expressionConverterFactory); var stringDatum = new Datum() { type = Datum.DatumType.R_STR, r_str = "Jackpot!", }; var stringDatumConverter = Substitute.For<IDatumConverter<string>>(); stringDatumConverter .ConvertObject("Jackpot!") .Returns(stringDatum); stringDatumConverter .ConvertDatum(Arg.Is<Datum>(d => d.type == stringDatum.type && d.r_str == stringDatum.r_str)) .Returns("Jackpot!"); IDatumConverter<string> value; datumConverterFactory .TryGet<string>(queryConverter, out value) .Returns(args => { args[1] = stringDatumConverter; return true; }); IDatumConverter value2; datumConverterFactory .TryGet(typeof(string), queryConverter, out value2) .Returns(args => { args[2] = stringDatumConverter; return true; }); }
public Term GenerateTerm(IQueryConverter queryConverter) { var term = new Term() { type = Term.TermType.SLICE, }; term.args.Add(sequenceQuery.GenerateTerm(queryConverter)); term.args.Add(new Term() { type = Term.TermType.DATUM, datum = new Datum() { type = Datum.DatumType.R_NUM, r_num = startIndex, } }); term.args.Add(new Term() { type = Term.TermType.DATUM, datum = new Datum() { type = Datum.DatumType.R_NUM, r_num = endIndex.GetValueOrDefault(int.MaxValue), } }); return(term); }
public Term GenerateTerm(IQueryConverter queryConverter) { var term = new Term() { type = Term.TermType.EQ_JOIN, }; term.args.Add(leftQuery.GenerateTerm(queryConverter)); term.args.Add(GetMemberName(queryConverter)); term.args.Add(rightQuery.GenerateTerm(queryConverter)); if (!String.IsNullOrEmpty(indexName)) { term.optargs.Add(new Term.AssocPair() { key = "index", val = new Term() { type = Term.TermType.DATUM, datum = new Datum() { type = Datum.DatumType.R_STR, r_str = indexName }, } }); } return(term); }
public Term GenerateTerm(IQueryConverter queryConverter) { var term = new Term() { type = Term.TermType.MAX, }; term.args.Add(tableQuery.GenerateTerm(queryConverter)); term.optargs.Add( new Term.AssocPair() { key = "index", val = new Term() { type = Term.TermType.DATUM, datum = new Datum() { type = Datum.DatumType.R_STR, r_str = indexName } } } ); return(term); }
public Term GenerateTerm(IQueryConverter queryConverter) { var getAllTerm = new Term() { type = Term.TermType.GET_ALL, }; getAllTerm.args.Add(tableTerm.GenerateTerm(queryConverter)); foreach (var key in keys) { getAllTerm.args.Add(new Term() { type = Term.TermType.DATUM, datum = queryConverter.Get <TKey>().ConvertObject(key) }); } if (!String.IsNullOrEmpty(indexName)) { getAllTerm.optargs.Add(new Term.AssocPair() { key = "index", val = new Term() { type = Term.TermType.DATUM, datum = new Datum() { type = Datum.DatumType.R_STR, r_str = indexName }, } }); } return(getAllTerm); }
public void TestFixtureSetUp() { datumConverterFactory = Substitute.For <IDatumConverterFactory>(); queryConverter = new QueryConverter(datumConverterFactory, expressionConverterFactory); var stringDatum = new Datum() { type = Datum.DatumType.R_STR, r_str = "Jackpot!", }; var stringDatumConverter = Substitute.For <IDatumConverter <string> >(); stringDatumConverter .ConvertObject("Jackpot!") .Returns(stringDatum); stringDatumConverter .ConvertDatum(Arg.Is <Datum>(d => d.type == stringDatum.type && d.r_str == stringDatum.r_str)) .Returns("Jackpot!"); IDatumConverter <string> value; datumConverterFactory .TryGet <string>(queryConverter, out value) .Returns(args => { args[1] = stringDatumConverter; return(true); }); }
public Task <T> RunAsync <T>(IQueryConverter queryConverter, IScalarQuery <T> queryObject, CancellationToken cancellationToken) { if (this.disposed) { throw new ObjectDisposedException("PooledConnectionWrapper"); } return(this.innerConnection.RunAsync <T>(queryConverter, queryObject, cancellationToken)); }
public IAsyncEnumerator <T> RunAsync <T>(IQueryConverter queryConverter, ISequenceQuery <T> queryObject) { if (this.disposed) { throw new ObjectDisposedException("ReliableConnectionWrapper"); } return(new RetryAsyncEnumeratorWrapper <T>(this, () => this.innerConnection.RunAsync(queryConverter, queryObject))); }
protected override void GenerateFunctionTerms(Term term, IQueryConverter queryConverter) { if (keyExpression.NodeType != ExpressionType.Lambda) { throw new NotSupportedException("Unsupported expression type"); } term.args.Add(ExpressionUtils.CreateFunctionTerm <TRecord, TKey>(queryConverter, keyExpression)); }
public QueryEnumerator(Connection connection, IQueryConverter queryConverter, ISequenceQuery <T> queryObject) { this.connection = connection; this.queryConverter = queryConverter; this.datumConverter = queryConverter.Get <T>(); this.queryObject = queryObject; this.stackTrace = new StackTrace(true); }
public IAsyncEnumerator <T> RunAsync <T>(IQueryConverter queryConverter, ISequenceQuery <T> queryObject) { if (this.disposed) { throw new ObjectDisposedException("PooledConnectionWrapper"); } return(this.innerConnection.RunAsync <T>(queryConverter, queryObject)); }
public Term GenerateTerm(IQueryConverter queryConverter) { var term = new Term() { type = Term.TermType.NOW, }; return(term); }
public Term GenerateTerm(IQueryConverter queryConverter) { var dbTerm = new Term() { type = Term.TermType.DB_LIST, }; return(dbTerm); }
public void TestFixtureSetUp() { datumConverterFactory = new AggregateDatumConverterFactory( PrimitiveDatumConverterFactory.Instance, DataContractDatumConverterFactory.Instance ); expressionConverterFactory = new RethinkDb.Expressions.DefaultExpressionConverterFactory(); queryConverter = new QueryConverter(datumConverterFactory, expressionConverterFactory); }
public Term GenerateTerm(IQueryConverter queryConverter) { var term = new Term() { type = Term.TermType.CHANGES, }; term.args.Add(changefeedCompatibleQuery.GenerateTerm(queryConverter)); return term; }
public Term GenerateTerm(IQueryConverter queryConverter) { var zipTerm = new Term() { type = Term.TermType.ZIP, }; zipTerm.args.Add(sequenceQuery.GenerateTerm(queryConverter)); return(zipTerm); }
public Term GenerateTerm(IQueryConverter queryConverter) { var term = new Term() { type = Term.TermType.UNGROUP, }; term.args.Add(groupingQuery.GenerateTerm(queryConverter)); return(term); }
public Term GenerateTerm(IQueryConverter queryConverter) { var indexList = new Term() { type = Term.TermType.INDEX_LIST, }; indexList.args.Add(tableTerm.GenerateTerm(queryConverter)); return(indexList); }
public Term GenerateTerm(IQueryConverter queryConverter) { var tableTerm = new Term() { type = Term.TermType.TABLE_LIST, }; tableTerm.args.Add(dbTerm.GenerateTerm(queryConverter)); return(tableTerm); }
public void TestFixtureSetUp() { datumConverterFactory = new AggregateDatumConverterFactory( PrimitiveDatumConverterFactory.Instance, TimeSpanDatumConverterFactory.Instance, DateTimeDatumConverterFactory.Instance ); expressionConverterFactory = new RethinkDb.Expressions.DefaultExpressionConverterFactory(); queryConverter = new QueryConverter(datumConverterFactory, expressionConverterFactory); }
public Term GenerateTerm(IQueryConverter queryConverter) { var term = new Term() { type = Term.TermType.DISTINCT, }; term.args.Add(sequenceQuery.GenerateTerm(queryConverter)); return(term); }
public Term GenerateTerm(IQueryConverter queryConverter) { var term = new Term() { type = Term.TermType.CHANGES, }; term.args.Add(tableQuery.GenerateTerm(queryConverter)); return(term); }
public Term GenerateTerm(IQueryConverter queryConverter) { var hasFieldsTerm = new Term() { type = Term.TermType.HAS_FIELDS, }; hasFieldsTerm.args.Add(query.GenerateTerm(queryConverter)); hasFieldsTerm.args.AddRange(GetMembers(queryConverter)); return(hasFieldsTerm); }
public Term GenerateTerm(IQueryConverter queryConverter) { var term = new Term() { type = Term.TermType.UNION, }; term.args.Add(query1.GenerateTerm(queryConverter)); term.args.Add(query2.GenerateTerm(queryConverter)); return(term); }
public Term GenerateTerm(IQueryConverter queryConverter) { var term = new Term() { type = Term.TermType.GROUP, }; term.args.Add(sequenceQuery.GenerateTerm(queryConverter)); GenerateFunctionTerms(term, queryConverter); return(term); }
public Term GenerateTerm(IQueryConverter queryConverter) { var reduceTerm = new Term() { type = Term.TermType.REDUCE, }; reduceTerm.args.Add(groupingQuery.GenerateTerm(queryConverter)); reduceTerm.args.Add(ExpressionUtils.CreateFunctionTerm <TRecord, TRecord, TRecord>(queryConverter, reduceFunction)); return(reduceTerm); }
public Term GenerateTerm(IQueryConverter queryConverter) { var term = new Term { type = Term.TermType.IS_EMPTY }; term.args.Add(sequenceQuery.GenerateTerm(queryConverter)); return(term); }
public Term GenerateTerm(IQueryConverter queryConverter) { var mapTerm = new Term() { type = Term.TermType.MAP, }; mapTerm.args.Add(groupingQuery.GenerateTerm(queryConverter)); mapTerm.args.Add(ExpressionUtils.CreateFunctionTerm <TOriginal, TTarget>(queryConverter, mapExpression)); return(mapTerm); }
public Term GenerateTerm(IQueryConverter queryConverter) { var mapTerm = new Term() { type = Term.TermType.CONCAT_MAP, }; mapTerm.args.Add(sequenceQuery.GenerateTerm(queryConverter)); mapTerm.args.Add(ExpressionUtils.CreateFunctionTerm <TOriginal, IEnumerable <TTarget> >(queryConverter, mapExpression)); return(mapTerm); }
public Term GenerateTerm(IQueryConverter queryConverter) { var getTerm = new Term() { type = Term.TermType.GET, }; getTerm.args.Add(tableTerm.GenerateTerm(queryConverter)); if (primaryKeyNumeric.HasValue) { getTerm.args.Add( new Term() { type = Term.TermType.DATUM, datum = new Datum() { type = Datum.DatumType.R_NUM, r_num = primaryKeyNumeric.Value, } } ); } else { getTerm.args.Add( new Term() { type = Term.TermType.DATUM, datum = new Datum() { type = Datum.DatumType.R_STR, r_str = primaryKeyString, } } ); } if (!String.IsNullOrEmpty(primaryAttribute)) { getTerm.optargs.Add(new Term.AssocPair() { key = "attribute", val = new Term() { type = Term.TermType.DATUM, datum = new Datum() { type = Datum.DatumType.R_STR, r_str = primaryAttribute, } } }); } return(getTerm); }