/// <summary> /// Create secondary index and query on it and apply aggregation user defined function. /// </summary> public override void RunExample(AerospikeClient client, Arguments args) { if (!args.hasUdf) { console.Info("Query functions are not supported by the connected Aerospike server."); return; } string packageContents = @" local function reducer(val1,val2) return val1 + val2 end function sum_single_bin(stream,name) local function mapper(rec) return rec[name] end return stream : map(mapper) : reduce(reducer) end "; string indexName = "aggindex"; string keyPrefix = "aggkey"; string binName = args.GetBinName("aggbin"); int size = 10; Register(client, args, packageContents); CreateIndex(client, args, indexName, binName); WriteRecords(client, args, keyPrefix, binName, size); RunQuery(client, args, indexName, binName, packageContents); client.DropIndex(args.policy, args.ns, args.set, indexName); }
/// <summary> /// Create secondary index and query on list bins. /// </summary> public override void RunExample(AerospikeClient client, Arguments args) { string indexName = "qlindex"; string keyPrefix = "qlkey"; string binName = "listbin"; int size = 20; CreateIndex(client, args, indexName, binName); WriteRecords(client, args, keyPrefix, binName, size); RunQuery(client, args, indexName, binName); client.DropIndex(args.policy, args.ns, args.set, indexName); }
private void RunListExample(AerospikeClient client, Arguments args) { string indexName = "geo_list"; string keyPrefix = "list"; string binName = "geo_list_bin"; string binName2 = "geo_uniq_bin"; int size = 1000; // create collection index on list CreateIndex(client, args, IndexCollectionType.LIST, indexName, binName); WriteListRecords(client, args, keyPrefix, binName, binName2, size); RunQuery(client, args, binName, binName2, IndexCollectionType.LIST); client.DropIndex(args.policy, args.ns, args.set, indexName); DeleteRecords(client, args, keyPrefix, size); }
private void RunMapKeyExample(AerospikeClient client, Arguments args) { string indexName = "geo_mapkey"; string keyPrefix = "mapkey"; string mapValuePrefix = "mk"; string binName = "geo_mkey_bin"; string binName2 = "geo_uniq_bin"; int size = 1000; // create collection index on mapKey CreateIndex(client, args, IndexCollectionType.MAPKEYS, indexName, binName); WriteMapKeyRecords(client, args, keyPrefix, binName, binName2, mapValuePrefix, size); RunQuery(client, args, binName, binName2, IndexCollectionType.MAPKEYS); client.DropIndex(args.policy, args.ns, args.set, indexName); DeleteRecords(client, args, keyPrefix, size); }
/// <summary> /// Query on a secondary index with a filter and then apply an additional filter in the /// user defined function. /// </summary> public override void RunExample(AerospikeClient client, Arguments args) { if (!args.hasUdf) { console.Info("Query functions are not supported by the connected Aerospike server."); return; } string indexName = "profileindex"; string keyPrefix = "profilekey"; string binName = args.GetBinName("name"); Register(client, args); CreateIndex(client, args, indexName, binName); WriteRecords(client, args, keyPrefix, binName); RunQuery(client, args, indexName, binName); client.DropIndex(args.policy, args.ns, args.set, indexName); }
/// <summary> /// Perform secondary index queries with predicate filters. /// </summary> public override void RunExample(AerospikeClient client, Arguments args) { if (!args.hasUdf) { console.Info("Query functions are not supported by the connected Aerospike server."); return; } string indexName = "predidx"; string binName = "idxbin"; int size = 50; CreateIndex(client, args, indexName, binName); WriteRecords(client, args, binName, size); RunQuery1(client, args, binName); RunQuery2(client, args, binName); RunQuery3(client, args, binName); client.DropIndex(args.policy, args.ns, args.set, indexName); }
/// <summary> /// Geospatial query examples. /// </summary> public override void RunExample(AerospikeClient client, Arguments args) { if (!args.hasGeo) { console.Info("Geospatial functions are not supported by the connected Aerospike server."); return; } string indexName = "queryindexloc"; string keyPrefix = "querykeyloc"; string binName = args.GetBinName("querybinloc"); int size = 20; CreateIndex(client, args, indexName, binName); WriteRecords(client, args, keyPrefix, binName, size); RunQuery(client, args, indexName, binName); RunRadiusQuery(client, args, indexName, binName); client.DropIndex(args.policy, args.ns, args.set, indexName); }
/// <summary> /// Apply user defined function on records that match the query filter. /// </summary> public override void RunExample(AerospikeClient client, Arguments args) { if (!args.hasUdf) { console.Info("Query functions are not supported by the connected Aerospike server."); return; } string indexName = "qeindex1"; string keyPrefix = "qekey"; string binName1 = args.GetBinName("qebin1"); string binName2 = args.GetBinName("qebin2"); int size = 10; Register(client, args); CreateIndex(client, args, indexName, binName1); WriteRecords(client, args, keyPrefix, binName1, binName2, size); RunQueryExecute(client, args, indexName, binName1, binName2); ValidateRecords(client, args, indexName, binName1, binName2, size); client.DropIndex(args.policy, args.ns, args.set, indexName); }