public void Test2iOperations() { const string indexName = "num"; const string key1 = "key1"; const string key2 = "key2"; var obj1 = new RiakObject(new RiakObjectId(TestBucketType, TestBucket, key1), Value); obj1.IntIndex(indexName).Add(1); var obj2 = new RiakObject(new RiakObjectId(TestBucketType, TestBucket, key2), Value); obj2.IntIndex(indexName).Add(2); Client.Put(obj1, new RiakPutOptions().SetDw(3)); Client.Put(obj2, new RiakPutOptions().SetDw(3)); // fetch 2i var indexId = new RiakIndexId(TestBucketType, TestBucket, indexName); var indexResult = Client.GetSecondaryIndex(indexId, 1, 2, new RiakIndexGetOptions().SetReturnTerms(true)); indexResult.IsSuccess.ShouldBeTrue(); var keyTerms = indexResult.Value.IndexKeyTerms.ToList(); var keys = keyTerms.Select(t => t.Key).ToList(); var terms = keyTerms.Select(t => t.Term).ToList(); keys.ShouldContain(key1); keys.ShouldContain(key2); terms.ShouldContain("1"); terms.ShouldContain("2"); }
public void QueryingExactMatch() { ids = PutObjectsWithIndexValues(); var idxId = new RiakIndexId("indexes", "people", "field1"); var rslt = client.GetSecondaryIndex(idxId, "val1"); CheckResult(rslt); Assert.AreEqual(1, rslt.Value.IndexKeyTerms.Count()); PrintKeys(rslt.Value); }
public void ReturnKeysViaDollarBucketIndex() { ids = PutObjectsWithIndexValues(); var idxId = new RiakIndexId("indexes", "people", "$bucket"); var rslt = client.GetSecondaryIndex(idxId, "_"); CheckResult(rslt); PrintKeys(rslt.Value); }
public void IndexingFourObjects() { ids = PutObjectsWithIndexValues(); var idxId = new RiakIndexId("indexes", "people", "field1"); var rslt = client.GetSecondaryIndex(idxId, "val1", "val4"); CheckResult(rslt); PrintKeys(rslt.Value); DeleteObjects(ids); }
public void QueryingBinaryRange() { ids = PutObjectsWithIndexValues(); var idxId = new RiakIndexId("indexes", "people", "field1"); var rslt = client.GetSecondaryIndex(idxId, "val2", "val4"); CheckResult(rslt); Assert.AreEqual(3, rslt.Value.IndexKeyTerms.Count()); PrintKeys(rslt.Value); }
public void QueryingIntegerIndex() { ids = PutObjectsWithIndexValues(); var idxId = new RiakIndexId("indexes", "people", "field2"); var rslt = client.GetSecondaryIndex(idxId, 1001); CheckResult(rslt); Assert.AreEqual(1, rslt.Value.IndexKeyTerms.Count()); PrintKeys(rslt.Value); }
static void Main(string[] args) { Console.WriteLine("Creating Data"); Customer customer = CreateCustomer(); IEnumerable <Order> orders = CreateOrders(customer); OrderSummary orderSummary = CreateOrderSummary(customer, orders); Console.WriteLine("Starting Client"); using (IRiakEndPoint endpoint = RiakCluster.FromConfig("riakConfig")) { IRiakClient client = endpoint.CreateClient(); Console.WriteLine("Storing Data"); client.Put(ToRiakObject(customer)); foreach (Order order in orders) { // NB: this adds secondary index data as well client.Put(ToRiakObject(order)); } client.Put(ToRiakObject(orderSummary)); Console.WriteLine("Fetching related data by shared key"); string key = "1"; var result = client.Get(customersBucketName, key); CheckResult(result); Console.WriteLine("Customer 1: {0}\n", GetValueAsString(result)); result = client.Get(orderSummariesBucketName, key); CheckResult(result); Console.WriteLine("OrderSummary 1: {0}\n", GetValueAsString(result)); Console.WriteLine("Index Queries"); // Query for order keys where the SalesPersonId index is set to 9000 var riakIndexId = new RiakIndexId(ordersBucketName, ordersSalesPersonIdIndexName); RiakResult <RiakIndexResult> indexRiakResult = client.GetSecondaryIndex(riakIndexId, 9000); // NB: *must* use 9000 as integer here. CheckResult(indexRiakResult); RiakIndexResult indexResult = indexRiakResult.Value; Console.WriteLine("Jane's orders (key values): {0}", string.Join(", ", indexResult.IndexKeyTerms.Select(ikt => ikt.Key))); // Query for orders where the OrderDate index is between 2013-10-01 and 2013-10-31 riakIndexId = new RiakIndexId(ordersBucketName, ordersOrderDateIndexName); indexRiakResult = client.GetSecondaryIndex(riakIndexId, "2013-10-01", "2013-10-31"); // NB: *must* use strings here. CheckResult(indexRiakResult); indexResult = indexRiakResult.Value; Console.WriteLine("October orders (key values): {0}", string.Join(", ", indexResult.IndexKeyTerms.Select(ikt => ikt.Key))); } }
public void QueryingIntegerRangeWithReturnTerms() { ids = PutObjectsWithIndexValues(); var idxId = new RiakIndexId("indexes", "people", "field2"); var options = new RiakIndexGetOptions(); options.SetReturnTerms(true); var rslt = client.GetSecondaryIndex(idxId, 1002, 1004, options); CheckResult(rslt); Assert.AreEqual(3, rslt.Value.IndexKeyTerms.Count()); PrintKeys(rslt.Value, printTerms: true); }
public void QueryingObjectsWithSecondaryIndexes() { PutJohnSmith(); var idxId = new RiakIndexId("default", "users", "twitter"); var rslt = client.GetSecondaryIndex(idxId, "jsmith123"); CheckResult(rslt); var idxRslt = rslt.Value; foreach (var keyTerm in idxRslt.IndexKeyTerms) { Console.WriteLine(keyTerm.Key); } }
public void IntIndexGetReturnsListOfKeys() { GenerateIntKeyObjects("IntIndex", (o, i) => o.IntIndex("age").Add(32)); var idxid = new RiakIndexId(LegacyBucket, "age"); var result = Client.GetSecondaryIndex(idxid, 32); Assert.IsTrue(result.IsSuccess, result.ErrorMessage); CollectionAssert.IsNotEmpty(result.Value.IndexKeyTerms); Assert.GreaterOrEqual(result.Value.IndexKeyTerms.Count(), DefaultKeyCount); foreach (var v in result.Value.IndexKeyTerms) { var key = ParseIntKeyWithPrefix(v); key.ShouldBeLessThan(DefaultKeyCount); key.ShouldBeGreaterThan(-1); } }
public void Streaming() { ids = PutObjectsWithIndexValues(); var idxId = new RiakIndexId("indexes", "people", "field2"); var rslt = client.StreamGetSecondaryIndex(idxId, 1001, 1004); CheckResult(rslt); ushort count = 0; foreach (var kt in rslt.Value.IndexKeyTerms) { PrintKeyTerm(kt); ++count; } Assert.AreEqual(4, count); }
private void button6_Click(object sender, EventArgs e) { Console.WriteLine("Index Queries"); // Query for order keys where the SalesPersonId index is set to 9000 var riakIndexId = new RiakIndexId(ordersBucketName, ordersSalesPersonIdIndexName); RiakResult <RiakIndexResult> indexRiakResult = client.GetSecondaryIndex(riakIndexId, 9000); // NB: *must* use 9000 as integer here. CheckResult(indexRiakResult); RiakIndexResult indexResult = indexRiakResult.Value; Console.WriteLine("Jane's orders (key values): {0}", string.Join(", ", indexResult.IndexKeyTerms.Select(ikt => ikt.Key))); // Query for orders where the OrderDate index is between 2013-10-01 and 2013-10-31 riakIndexId = new RiakIndexId(ordersBucketName, ordersOrderDateIndexName); indexRiakResult = client.GetSecondaryIndex(riakIndexId, "2013-10-01", "2013-10-31"); // NB: *must* use strings here. CheckResult(indexRiakResult); indexResult = indexRiakResult.Value; Console.WriteLine("October orders (key values): {0}", string.Join(", ", indexResult.IndexKeyTerms.Select(ikt => ikt.Key))); }
public void Pagination() { ids = PutObjectsWithIndexValues(); var idxId = new RiakIndexId("indexes", "people", "field2"); var options = new RiakIndexGetOptions(); options.SetMaxResults(2); var rslt = client.GetSecondaryIndex(idxId, 1002, 1004, options); CheckResult(rslt); Assert.AreEqual(2, rslt.Value.IndexKeyTerms.Count()); PrintKeys(rslt.Value); options.SetContinuation(rslt.Continuation); rslt = client.GetSecondaryIndex(idxId, 1002, 1004, options); CheckResult(rslt); Assert.AreEqual(1, rslt.Value.IndexKeyTerms.Count()); PrintKeys(rslt.Value); }
/// <summary> /// Initializes a new instance of the <see cref="RiakBinIndexEqualityInput"/> class. /// </summary> /// <param name="indexId"> /// The <see cref="RiakIndexId"/> that specifies which index to query. /// The output of that query will be used as input for the mapreduce job. /// </param> /// <param name="key">The index key to query for.</param> public RiakBinIndexEqualityInput(RiakIndexId indexId, string key) : base(indexId.ToBinIndexId()) { Key = key; }
/// <summary> /// Create a mapreduce input from a string secondary index match query. /// </summary> /// <param name="indexId">The <see cref="RiakIndexId"/> identifying the index to query.</param> /// <param name="key">The index key to match for the query.</param> /// <returns>A newly initialized and configured <see cref="RiakIndexInput"/>.</returns> public static RiakIndexInput Match(RiakIndexId indexId, string key) { return new RiakBinIndexEqualityInput(indexId, key); }
/// <summary> /// Create a mapreduce input from an integer secondary index match query. /// </summary> /// <param name="indexId">The <see cref="RiakIndexId"/> identifying the index to query.</param> /// <param name="key">The index key to match for the query.</param> /// <returns>A newly initialized and configured <see cref="RiakIndexInput"/>.</returns> public static RiakIndexInput Match(RiakIndexId indexId, BigInteger key) { return new RiakIntIndexEqualityInput(indexId, key); }
/// <summary> /// Create a mapreduce input from an integer secondary index range query. /// </summary> /// <param name="indexId">The <see cref="RiakIndexId"/> identifying the index to query.</param> /// <param name="start">The lower bound of the key range for the query.</param> /// <param name="end">The upper bound of the key range for the query.</param> /// <returns>A newly initialized and configured <see cref="RiakIndexInput"/>.</returns> public static RiakIndexInput Range(RiakIndexId indexId, BigInteger start, BigInteger end) { return new RiakIntIndexRangeInput(indexId, start, end); }
/// <summary> /// Initializes a new instance of the <see cref="RiakBinIndexRangeInput"/> class. /// </summary> /// <param name="indexId"> /// The <see cref="RiakIndexId"/> that specifies which index to query. /// The output of that query will be used as input for the mapreduce job. /// </param> /// <param name="start">The inclusive lower bound of the string range to query for.</param> /// <param name="end">The inclusive upper bound of the string range to query for.</param> public RiakBinIndexRangeInput(RiakIndexId indexId, string start, string end) : base(indexId.ToBinIndexId()) { Start = start; End = end; }
/// <summary> /// Create a mapreduce input from a string secondary index range query. /// </summary> /// <param name="indexId">The <see cref="RiakIndexId"/> identifying the index to query.</param> /// <param name="start">The lower bound of the key range for the query.</param> /// <param name="end">The upper bound of the key range for the query.</param> /// <returns>A newly initialized and configured <see cref="RiakIndexInput"/>.</returns> public static RiakIndexInput Range(RiakIndexId indexId, string start, string end) { return new RiakBinIndexRangeInput(indexId, start, end); }
public void QueryingIntegerRange() { ids = PutObjectsWithIndexValues(); var idxId = new RiakIndexId("indexes", "people", "field2"); var rslt = client.GetSecondaryIndex(idxId, 1002, 1004); CheckResult(rslt); Assert.AreEqual(3, rslt.Value.IndexKeyTerms.Count()); PrintKeys(rslt.Value); }
/// <summary> /// Create a mapreduce input from a string secondary index range query. /// </summary> /// <param name="indexId">The <see cref="RiakIndexId"/> identifying the index to query.</param> /// <param name="start">The lower bound of the key range for the query.</param> /// <param name="end">The upper bound of the key range for the query.</param> /// <returns>A newly initialized and configured <see cref="RiakIndexInput"/>.</returns> public static RiakIndexInput Range(RiakIndexId indexId, string start, string end) { return(new RiakBinIndexRangeInput(indexId, start, end)); }
/// <summary> /// Create a mapreduce input from an integer secondary index match query. /// </summary> /// <param name="indexId">The <see cref="RiakIndexId"/> identifying the index to query.</param> /// <param name="key">The index key to match for the query.</param> /// <returns>A newly initialized and configured <see cref="RiakIndexInput"/>.</returns> public static RiakIndexInput Match(RiakIndexId indexId, BigInteger key) { return(new RiakIntIndexEqualityInput(indexId, key)); }
/// <summary> /// Initializes a new instance of the <see cref="RiakIntIndexEqualityInput"/> class. /// </summary> /// <param name="indexId"> /// The <see cref="RiakIndexId"/> that specifies which index to query. /// The output of that query will be used as input for the mapreduce job. /// </param> /// <param name="key">The index key to query for.</param> public RiakIntIndexEqualityInput(RiakIndexId indexId, BigInteger key) : base(indexId.ToIntIndexId()) { Key = key; }
/// <summary> /// Create a mapreduce input from a string secondary index match query. /// </summary> /// <param name="indexId">The <see cref="RiakIndexId"/> identifying the index to query.</param> /// <param name="key">The index key to match for the query.</param> /// <returns>A newly initialized and configured <see cref="RiakIndexInput"/>.</returns> public static RiakIndexInput Match(RiakIndexId indexId, string key) { return(new RiakBinIndexEqualityInput(indexId, key)); }
/// <summary> /// Create a mapreduce input from an integer secondary index range query. /// </summary> /// <param name="indexId">The <see cref="RiakIndexId"/> identifying the index to query.</param> /// <param name="start">The lower bound of the key range for the query.</param> /// <param name="end">The upper bound of the key range for the query.</param> /// <returns>A newly initialized and configured <see cref="RiakIndexInput"/>.</returns> public static RiakIndexInput Range(RiakIndexId indexId, BigInteger start, BigInteger end) { return(new RiakIntIndexRangeInput(indexId, start, end)); }
protected RiakIndexInput(RiakIndexId indexId) { this.indexId = indexId; }
/// <summary> /// Initializes a new instance of the <see cref="RiakIntIndexRangeInput"/> class. /// </summary> /// <param name="indexId"> /// The <see cref="RiakIndexId"/> that specifies which index to query. /// The output of that query will be used as input for the mapreduce job. /// </param> /// <param name="start">The inclusive lower bound of the integer range to query for.</param> /// <param name="end">The inclusive upper bound of the integer range to query for.</param> public RiakIntIndexRangeInput(RiakIndexId indexId, BigInteger start, BigInteger end) : base(indexId.ToIntIndexId()) { Start = start; End = end; }
/// <inheritdoc/> public Task <RiakResult <RiakIndexResult> > GetSecondaryIndex(RiakIndexId index, string value, RiakIndexGetOptions options = null) { return(Task.Factory.StartNew(() => client.GetSecondaryIndex(index, value, options))); }
/// <inheritdoc/> public Task <RiakResult <RiakIndexResult> > GetSecondaryIndex(RiakIndexId index, BigInteger min, BigInteger max, RiakIndexGetOptions options = null) { return(Task.Factory.StartNew(() => client.GetSecondaryIndex(index, min, max, options))); }
/// <inheritdoc/> public Task <RiakResult <RiakStreamedIndexResult> > StreamGetSecondaryIndex(RiakIndexId index, BigInteger value, RiakIndexGetOptions options = null) { return(Task.Factory.StartNew(() => client.StreamGetSecondaryIndex(index, value, options))); }
/// <inheritdoc/> public Task <RiakResult <RiakStreamedIndexResult> > StreamGetSecondaryIndex(RiakIndexId index, string min, string max, RiakIndexGetOptions options = null) { return(Task.Factory.StartNew(() => client.StreamGetSecondaryIndex(index, min, max, options))); }
private void button9_Click(object sender, EventArgs e) { //1) listar empleados EmpleadoVM empleadoVM = null; RiakResult <IList <string> > listaKeysEmpleado = client.ListKeysFromIndex(empleadoBucketName); foreach (string key in listaKeysEmpleado.Value) { var result = client.Get(empleadoBucketName, key); CheckResult(result); empleadoVM = result.Value.GetObject <EmpleadoVM>(); Console.WriteLine("Empleado :" + empleadoVM.ToJson()); } // 5) Obtener el número de habitación, tipo y precio de las habitaciones que estén ocupadas en la actualidad (no tienen fecha de salida). var riakIndexId = new RiakIndexId(facturasBucketName, facturaFacturaSalidaDateIndexName); RiakResult <RiakIndexResult> indexRiakResult = client.GetSecondaryIndex(riakIndexId, DateTime.MinValue.ToString("yyyy-MM-dd")); CheckResult(indexRiakResult); var indexResult = indexRiakResult.Value; FacturaVM facturaVMRespuesta = null; foreach (var item in indexResult.IndexKeyTerms) { var result = client.Get(facturasBucketName, item.Key); CheckResult(result); facturaVMRespuesta = result.Value.GetObject <FacturaVM>(); Console.WriteLine("FACTURA-- (key values): NumHabitacion: {0}, Tipo: {1}, Precio: {2}, CodigoFactura: {3}", facturaVMRespuesta.Numero.Numero, facturaVMRespuesta.Numero.Tipo.Tipo, facturaVMRespuesta.Numero.Tipo.precio, facturaVMRespuesta.CodigoF); } Console.WriteLine("--------------------------"); //2) Obtener el nombre del jefe del servicio de "Restaurante". riakIndexId = new RiakIndexId(empleadoBucketName, empleadoServicioDescripcionIndexName); indexRiakResult = client.GetSecondaryIndex(riakIndexId, "restaurante"); CheckResult(indexRiakResult); indexResult = indexRiakResult.Value; EmpleadoVM empleadoVMRes = null; foreach (var item in indexResult.IndexKeyTerms) { var result = client.Get(empleadoBucketName, item.Key); CheckResult(result); empleadoVMRes = result.Value.GetObject <EmpleadoVM>(); Console.WriteLine("Nobre Jefe Ser Restaurante; {0} ", empleadoVMRes.Servicio.NumReg.Nombre); } Console.WriteLine("--------------------------"); //3) Obtener el nombre del jefe de "Jorge Alonso Alonso". riakIndexId = new RiakIndexId(empleadoBucketName, empleadoNombreIndexName); indexRiakResult = client.GetSecondaryIndex(riakIndexId, "Jorge Alonso Alonso"); CheckResult(indexRiakResult); indexResult = indexRiakResult.Value; EmpleadoVM empleadoVMRes1 = null; foreach (var item in indexResult.IndexKeyTerms) { var result = client.Get(empleadoBucketName, item.Key); CheckResult(result); empleadoVMRes1 = result.Value.GetObject <EmpleadoVM>(); Console.WriteLine("Nobre Jefe a cargo jorge alonso; {0} ", empleadoVMRes1.Servicio.NumReg.Nombre); } Console.WriteLine("--------------------------"); //4) Obtener un listado de los empleados y los servicios a los que están asignados, //exclusivamente para aquellos que tengan algún servicio asignado. riakIndexId = new RiakIndexId(empleadoBucketName, empleadoCodSIndexName); indexRiakResult = client.GetSecondaryIndex(riakIndexId, 1, 1000); CheckResult(indexRiakResult); indexResult = indexRiakResult.Value; EmpleadoVM empleadoVMRes2 = null; foreach (var item in indexResult.IndexKeyTerms) { var result = client.Get(empleadoBucketName, item.Key); CheckResult(result); empleadoVMRes2 = result.Value.GetObject <EmpleadoVM>(); Console.WriteLine("Nobre Empleado con Ser; {0} ", empleadoVMRes2.Nombre); } }