public static void Prepare(TestContext testContext) { Assembly assembly = Assembly.GetExecutingAssembly(); RegisterTask rtask = client.Register(null, assembly, "Aerospike.Test.Resources.filter_example.lua", "filter_example.lua", Language.LUA); rtask.Wait(); Policy policy = new Policy(); policy.totalTimeout = 0; // Do not timeout on index create. try { IndexTask itask = client.CreateIndex(policy, args.ns, args.set, indexName, binName, IndexType.STRING); itask.Wait(); } catch (AerospikeException ae) { if (ae.Result != ResultCode.INDEX_ALREADY_EXISTS) { throw; } } WriteRecord(keyPrefix + 1, "Charlie", "cpass"); WriteRecord(keyPrefix + 2, "Bill", "hknfpkj"); WriteRecord(keyPrefix + 3, "Doug", "dj6554"); }
public static void Prepare(TestContext testContext) { Policy policy = new Policy(); policy.totalTimeout = 0; // Do not timeout on index create. try { IndexTask itask = client.CreateIndex(policy, args.ns, setName, indexName, binName, IndexType.NUMERIC); itask.Wait(); } catch (AerospikeException ae) { if (ae.Result != ResultCode.INDEX_ALREADY_EXISTS) { throw; } } // Write records with string keys for (int i = 1; i <= size; i++) { Key key = new Key(args.ns, setName, keyPrefix + i); List <int> list = null; Dictionary <string, string> map = null; if (i == 1) { list = new List <int>(5); list.Add(1); list.Add(2); list.Add(4); list.Add(9); list.Add(20); // map will be null, which means mapbin will not exist in this record. } else if (i == 2) { list = new List <int>(3); list.Add(5); list.Add(9); list.Add(100); // map will be null, which means mapbin will not exist in this record. } else if (i == 3) { map = new Dictionary <string, string>(); map["A"] = "AAA"; map["B"] = "BBB"; map["C"] = "BBB"; // list will be null, which means listbin will not exist in this record. } else { list = new List <int>(0); map = new Dictionary <string, string>(0); } client.Put(null, key, new Bin(binName, i), new Bin("bin2", i), new Bin("listbin", list), new Bin("mapbin", map)); } }
public static void Prepare(TestContext testContext) { Policy policy = new Policy(); policy.totalTimeout = 0; // Do not timeout on index create. try { IndexTask task = client.CreateIndex(policy, args.ns, args.set, indexName, binName, IndexType.STRING); task.Wait(); } catch (AerospikeException ae) { if (ae.Result != ResultCode.INDEX_ALREADY_EXISTS) { throw; } } for (int i = 1; i <= size; i++) { Key key = new Key(args.ns, args.set, keyPrefix + i); Bin bin = new Bin(binName, valuePrefix + i); client.Put(null, key, bin); } }
public void Should_get_vcs_managers_for_each_stored_vcs_root_and_update_the_managers() { var fakeVcsManagerFactory = A.Fake<IVcsManagerFactory>(); var settings = new Settings { Id = Guid.NewGuid() }; var vcsRoots = new[] { new VcsRoot { Id = Guid.NewGuid() }, new VcsRoot { Id = Guid.NewGuid() } }; using(var session = _documentStore.OpenSession()) { session.Store(vcsRoots[0]); session.Store(vcsRoots[1]); session.Store(settings); session.SaveChanges(); } var indexController = new IndexTask(_documentStore, A.Fake<IIngester>(), fakeVcsManagerFactory); indexController.Run(); A.CallTo(() => fakeVcsManagerFactory.CreateVcsManagerFrom(A<Settings>.That.Matches(x => x.Id == settings.Id), A<VcsRoot>.That.Matches(x => x.Id == vcsRoots[0].Id))).MustHaveHappened(); A.CallTo(() => fakeVcsManagerFactory.CreateVcsManagerFrom(A<Settings>.That.Matches(x => x.Id == settings.Id), A<VcsRoot>.That.Matches(x => x.Id == vcsRoots[1].Id))).MustHaveHappened(); }
public static void Prepare(TestContext testContext) { Assembly assembly = Assembly.GetExecutingAssembly(); RegisterTask task = client.Register(null, assembly, "Aerospike.Test.Resources.sum_example.lua", "sum_example.lua", Language.LUA); task.Wait(); Policy policy = new Policy(); policy.totalTimeout = 0; // Do not timeout on index create. try { IndexTask itask = client.CreateIndex(policy, args.ns, args.set, indexName, binName, IndexType.NUMERIC); itask.Wait(); } catch (AerospikeException ae) { if (ae.Result != ResultCode.INDEX_ALREADY_EXISTS) { throw; } } for (int i = 1; i <= size; i++) { Key key = new Key(args.ns, args.set, keyPrefix + i); Bin bin = new Bin(binName, i); client.Put(null, key, bin); } }
public static void Prepare(TestContext testContext) { Policy policy = new Policy(); policy.timeout = 0; // Do not timeout on index create. IndexTask task = client.CreateIndex(policy, args.ns, args.set, indexName, binName, IndexType.NUMERIC); task.Wait(); }
private static void CreateIndex(AerospikeClient client, string ns, string set, string indexName, string binName) { Console.WriteLine("Create index"); Policy policy = new Policy(); policy.SetTimeout(0); // Do not timeout on index create. IndexTask task = client.CreateIndex(policy, ns, set, indexName, binName, IndexType.NUMERIC); task.Wait(); }
private void CreateIndex(AerospikeClient client, Arguments args, IndexCollectionType indexType, string indexName, string binName) { console.Info("Create GeoJSON {0} index: ns={1} set={2} index={3} bin={4}", indexType, args.ns, args.set, indexName, binName); Policy policy = new Policy(); policy.timeout = 0; // Do not timeout on index create. IndexTask task = client.CreateIndex(policy, args.ns, args.set, indexName, binName, IndexType.GEO2DSPHERE, indexType); task.Wait(); }
private void CreateIndex(AsyncClient client, Arguments args, string indexName, string binName) { console.Info("Create index: ns=" + args.ns + " set=" + args.set + " index=" + indexName + " bin=" + binName); Policy policy = new Policy(); policy.timeout = 0; // Do not timeout on index create. IndexTask task = client.CreateIndex(policy, args.ns, args.set, indexName, binName, IndexType.NUMERIC); task.Wait(); }
public void MakeIndexes() { IndexTask task = Client.CreateIndex(Policy, Options.Namespace, Options.Set.Collection, "nameCollectionInd", "Name", IndexType.STRING); task.Wait(); task = Client.CreateIndex(Policy, Options.Namespace, Options.Set.User, "loginUserInd", "Login", IndexType.STRING); task.Wait(); }
private void CreateIndex(AerospikeClient client, Arguments args, string indexName, string binName) { console.Info("Create index: ns={0} set={1} index={2} bin={3}", args.ns, args.set, indexName, binName); Policy policy = new Policy(); policy.timeout = 0; // Do not timeout on index create. IndexTask task = client.CreateIndex(policy, args.ns, args.set, indexName, binName, IndexType.NUMERIC); task.Wait(); }
} //scanTweetsCallback public void queryTweetsByUsername() { Console.WriteLine("\n********** Query Tweets By Username **********\n"); RecordSet rs = null; try { // Get username string username; Console.WriteLine("\nEnter username:"******"test", "tweets", "username_index", "username", IndexType.STRING); task.Wait(); string[] bins = { "tweet" }; Statement stmt = new Statement(); stmt.SetNamespace("test"); stmt.SetSetName("tweets"); stmt.SetIndexName("username_index"); stmt.SetBinNames(bins); stmt.SetFilters(Filter.Equal("username", username)); Console.WriteLine("\nHere's " + username + "'s tweet(s):\n"); rs = client.Query(null, stmt); while (rs.Next()) { Record r = rs.Record; Console.WriteLine(r.GetValue("tweet")); } } else { Console.WriteLine("ERROR: User record not found!"); } } finally { if (rs != null) { // Close record set rs.Close(); } } } //queryTweetsByUsername
/// <summary> /// 保存HTML /// </summary> /// <param name="args"></param> private static void SaveHtmlEvent(DataReceivedEventArgs args) { Regex reg = new Regex(@"(?m)<title[^>]*>(?<title>(?:\w|\W)*?)</title[^>]*>", RegexOptions.Multiline | RegexOptions.IgnoreCase); Match mc = reg.Match(args.Html); string m_title = String.Empty; if (mc.Success) { m_title = mc.Groups["title"].Value.Trim(); } Regex urlRegex = new Regex(@"(?i)http://(\w+\.){1,3}(com(\.cn)?|cn|net)\b"); //去除域名后 var shtml = urlRegex.Replace(args.Html, "/File"); try { lock (syncRoot) { //更新数据库 Articles article = new Articles(); article.Id = PrimaryKeyGen.GuidToLongId(); article.IsDelete = false; article.Url = args.Url; article.Title = m_title; article.Summary = m_title; article.Content = shtml; article.AddTime = DateTime.Now.ToString("yyyyMMdd hh:mm:ss"); var saveResult = _IArticlesService.Add(article); if (saveResult) { // 更新索引库 IndexTask task = new IndexTask(); task.TaskId = article.Id; task.Title = m_title; //去除回车,空格,换行 task.Content = HtmlConverts.ConvertHtml(shtml).Replace("\n", "").Replace(" ", "").Replace("\t", "").Replace("\r", "");; task.Summary = m_title; IndexManager.Instance.AddArticle(task); } } } catch (Exception ex) { log.ErrorFormat("Url:{0};\r\n错误信息{1}", args.Url, ex.InnerException.Message); } }
private IList <TaskMessage> ComputeStockState(Task.Interface.IMessageSender sender) { this.Log().Info("开始计算个股形态"); IList <stockcategory> cateList = cateService.FindAll(); IList <TaskMessage> msgList = new List <TaskMessage>(); TechCycle[] cycleList = new TechCycle[] { TechCycle.day, TechCycle.week, TechCycle.month }; foreach (var category in cateList) { IList <stock> stockList = stockService.GetStockByCategory(category.code); foreach (var stock in stockList) { this.Log().Info("计算股票:" + stock.name); foreach (var cycle in cycleList) { var task1 = new IndexTask { type = ObjectType.Stock, code = stock.code, cycle = cycle }; sender.Send(JsonConvert.SerializeObject(task1)); Thread.Sleep(100); } } } //string[] list = new string[] { "0600265" }; //foreach (var code in list) //{ // foreach (var cycle in cycleList) // { // var task1 = new IndexTask // { // type = ObjectType.Stock, // code = code, // cycle = cycle // }; // sender.Send(JsonConvert.SerializeObject(task1)); // } //} return(msgList); }
public static void Prepare(TestContext testContext) { Policy policy = new Policy(); policy.timeout = 0; // Do not timeout on index create. IndexTask task = client.CreateIndex(policy, args.ns, args.set, indexName, binName, IndexType.STRING); task.Wait(); for (int i = 1; i <= size; i++) { Key key = new Key(args.ns, args.set, keyPrefix + i); Bin bin = new Bin(binName, valuePrefix + i); client.Put(null, key, bin); } }
} //queryTweetsByUsername public void queryUsersByTweetCount() { Console.WriteLine("\n********** Query Users By Tweet Count Range **********\n"); RecordSet rs = null; try { // NOTE: Index creation has been included in here for convenience and to demonstrate the syntax // NOTE: The recommended way of creating indexes in production env is via AQL IndexTask task = client.CreateIndex(null, "test", "users", "tweetcount_index", "tweetcount", IndexType.NUMERIC); task.Wait(); // Get min and max tweet counts int min; int max; Console.WriteLine("\nEnter Min Tweet Count:"); min = int.Parse(Console.ReadLine()); Console.WriteLine("Enter Max Tweet Count:"); max = int.Parse(Console.ReadLine()); string[] bins = { "username", "tweetcount" }; Statement stmt = new Statement(); stmt.SetNamespace("test"); stmt.SetSetName("users"); stmt.SetIndexName("tweetcount_index"); stmt.SetBinNames(bins); stmt.SetFilters(Filter.Range("tweetcount", min, max)); Console.WriteLine("\nList of users with " + min + "-" + max + " tweets:\n"); rs = client.Query(null, stmt); while (rs.Next()) { Record r = rs.Record; Console.WriteLine(r.GetValue("username") + " has " + r.GetValue("tweetcount") + " tweets"); } } finally { if (rs != null) { // Close record set rs.Close(); } } } //queryUsersByTweetCount
public QueryCollectionInit() { Assembly assembly = typeof(QueryCollectionInit).GetTypeInfo().Assembly; RegisterTask rtask = client.Register(null, assembly, "AerospikeTest.record_example.lua", "record_example.lua", Language.LUA); rtask.Wait(); Policy policy = new Policy(); policy.totalTimeout = 0; // Do not timeout on index create. try { IndexTask task = client.CreateIndex(policy, args.ns, args.set, TestQueryCollection.indexName, TestQueryCollection.binName, IndexType.STRING, IndexCollectionType.MAPKEYS); task.Wait(); } catch (AerospikeException ae) { if (ae.Result != ResultCode.INDEX_ALREADY_EXISTS) { throw; } } for (int i = 1; i <= TestQueryCollection.size; i++) { Key key = new Key(args.ns, args.set, TestQueryCollection.keyPrefix + i); Dictionary <string, string> map = new Dictionary <string, string>(); map[TestQueryCollection.mapKeyPrefix + 1] = TestQueryCollection.mapValuePrefix + i; if (i % 2 == 0) { map[TestQueryCollection.mapKeyPrefix + 2] = TestQueryCollection.mapValuePrefix + i; } if (i % 3 == 0) { map[TestQueryCollection.mapKeyPrefix + 3] = TestQueryCollection.mapValuePrefix + i; } Bin bin = new Bin(TestQueryCollection.binName, map); client.Put(null, key, bin); } }
public AsyncQueryInit() { Policy policy = new Policy(); policy.totalTimeout = 0; // Do not timeout on index create. try { IndexTask task = client.CreateIndex(policy, args.ns, args.set, TestAsyncQuery.indexName, TestAsyncQuery.binName, IndexType.NUMERIC); task.Wait(); } catch (AerospikeException ae) { if (ae.Result != ResultCode.INDEX_ALREADY_EXISTS) { throw; } } }
public static void Prepare(TestContext testContext) { Policy policy = new Policy(); policy.socketTimeout = 0; // Do not timeout on index create. try { IndexTask task = client.CreateIndex(policy, args.ns, setName, indexName, binName, IndexType.GEO2DSPHERE); task.Wait(); } catch (AerospikeException ae) { if (ae.Result != ResultCode.INDEX_ALREADY_EXISTS) { throw ae; } } // Insert points for (int i = 1; i <= size; i++) { Key key = new Key(args.ns, setNamePoints, i); double lng = -122 + (0.1 * i); double lat = 37.5 + (0.1 * i); string loc = "{ \"type\": \"Point\", \"coordinates\": [" + lng + ", " + lat + "] }"; Bin bin = Bin.AsGeoJSON("loc", loc); client.Put(null, key, bin); } // Insert regions double[][] starbucks = new double[][] { new double[] { -122.1708441, 37.4241193 }, new double[] { -122.1492040, 37.4273569 }, new double[] { -122.1441078, 37.4268202 }, new double[] { -122.1251714, 37.4130590 }, new double[] { -122.0964289, 37.4218102 }, new double[] { -122.0776641, 37.4158199 }, new double[] { -122.0943475, 37.4114654 }, new double[] { -122.1122861, 37.4028493 }, new double[] { -122.0947230, 37.3909250 }, new double[] { -122.0831037, 37.3876090 }, new double[] { -122.0707119, 37.3787855 }, new double[] { -122.0303178, 37.3882739 }, new double[] { -122.0464861, 37.3786236 }, new double[] { -122.0582128, 37.3726980 }, new double[] { -122.0365083, 37.3676930 } }; for (int i = 0; i < starbucks.Length; i++) { Key key = new Key(args.ns, setNameRegions, i); string loc = "{ \"type\": \"AeroCircle\", \"coordinates\": [[" + starbucks[i][0] + ", " + starbucks[i][1] + "], 3000.0 ] }"; Bin bin = Bin.AsGeoJSON("loc", loc); client.Put(null, key, bin); } }
public static void Prepare(TestContext testContext) { Policy policy = new Policy(); policy.totalTimeout = 0; // Do not timeout on index create. try { IndexTask task = client.CreateIndex(policy, args.ns, args.set, indexName, binName, IndexType.NUMERIC); task.Wait(); } catch (AerospikeException ae) { if (ae.Result != ResultCode.INDEX_ALREADY_EXISTS) { throw; } } }
public static void Prepare(TestContext testContext) { Assembly assembly = Assembly.GetExecutingAssembly(); RegisterTask rtask = client.Register(null, assembly, "Aerospike.Test.Resources.record_example.lua", "record_example.lua", Language.LUA); rtask.Wait(); Policy policy = new Policy(); policy.totalTimeout = 0; // Do not timeout on index create. try { IndexTask task = client.CreateIndex(policy, args.ns, args.set, indexName, binName, IndexType.STRING, IndexCollectionType.MAPKEYS); task.Wait(); } catch (AerospikeException ae) { if (ae.Result != ResultCode.INDEX_ALREADY_EXISTS) { throw; } } for (int i = 1; i <= size; i++) { Key key = new Key(args.ns, args.set, keyPrefix + i); Dictionary <string, string> map = new Dictionary <string, string>(); map[mapKeyPrefix + 1] = mapValuePrefix + i; if (i % 2 == 0) { map[mapKeyPrefix + 2] = mapValuePrefix + i; } if (i % 3 == 0) { map[mapKeyPrefix + 3] = mapValuePrefix + i; } Bin bin = new Bin(binName, map); client.Put(null, key, bin); } }
protected void btnSave_Click(object sender, EventArgs e) { string action = Request["action"]; if (action == "Edit") { long id = Convert.ToInt64(Request["id"]); Article art = articleService.GetById(id); art.Title = txtTitle.Text; art.Msg = txtMsg.Text; // 更新数据库 articleService.Update(art); // 更新索引库 IndexTask task = new IndexTask(); task.TaskId = id; IndexManager.Instance.UpdateArticle(task); Response.Redirect("ArticleList.aspx"); } else if (action == "AddNew") { Article art = new Article(); art.Title = txtTitle.Text; art.Msg = txtMsg.Text; // 更新数据库 art = articleService.Add(art); // 更新索引库 IndexTask task = new IndexTask(); task.TaskId = art.Id; IndexManager.Instance.AddArticle(task); Response.Redirect("ArticleList.aspx"); } else { throw new Exception("action错误!"); } }
public static void Prepare(TestContext testContext) { Policy policy = new Policy(); policy.timeout = 0; // Do not timeout on index create. IndexTask itask = client.CreateIndex(policy, args.ns, args.set, indexName, binName, IndexType.NUMERIC); itask.Wait(); WritePolicy writePolicy = new WritePolicy(); writePolicy.sendKey = true; for (int i = 1; i <= size; i++) { Key key = new Key(args.ns, args.set, keyPrefix + i); Bin bin = new Bin(binName, i); client.Put(writePolicy, key, bin); } }
public static void Prepare(TestContext testContext) { Assembly assembly = Assembly.GetExecutingAssembly(); RegisterTask rtask = client.Register(null, assembly, "Aerospike.Test.Resources.record_example.lua", "record_example.lua", Language.LUA); rtask.Wait(); Policy policy = new Policy(); policy.timeout = 0; // Do not timeout on index create. IndexTask itask = client.CreateIndex(policy, args.ns, args.set, indexName, binName1, IndexType.NUMERIC); itask.Wait(); for (int i = 1; i <= size; i++) { Key key = new Key(args.ns, args.set, keyPrefix + i); client.Put(null, key, new Bin(binName1, i), new Bin(binName2, i)); } }
public void createSecondaryIndexes() { // NOTE: Index creation has been included in here for convenience and to demonstrate the syntax. The recommended way of creating indexes in production env is via AQL IndexTask task1 = client.CreateIndex(null, "test", "tweets", "username_index", "username", IndexType.STRING); task1.Wait(); Console.WriteLine("Done creating secondary index on: set=tweets, bin=username"); Console.WriteLine("\nCreating secondary index on: set=tweets, bin=ts. Hang on..."); IndexTask task2 = client.CreateIndex(null, "test", "tweets", "ts_index", "ts", IndexType.NUMERIC); task2.Wait(); Console.WriteLine("Done creating secondary index on: set=tweets, bin=ts"); Console.WriteLine("\nCreating secondary index on: set=users, bin=tweetcount. Hang on..."); IndexTask task3 = client.CreateIndex(null, "test", "users", "tweetcount_index", "tweetcount", IndexType.NUMERIC); task3.Wait(); Console.WriteLine("Done creating secondary index on: set=users, bin=tweetcount"); }
private void CreateIndex(AsyncClient client, Arguments args, string indexName, string binName) { console.Info("Create index: ns=" + args.ns + " set=" + args.set + " index=" + indexName + " bin=" + binName); Policy policy = new Policy(); policy.totalTimeout = 0; // Do not timeout on index create. try { IndexTask task = client.CreateIndex(policy, args.ns, args.set, indexName, binName, IndexType.NUMERIC); task.Wait(); } catch (AerospikeException ae) { if (ae.Result != ResultCode.INDEX_ALREADY_EXISTS) { throw; } } }
private void CreateIndex(AerospikeClient client, Arguments args, IndexCollectionType indexType, string indexName, string binName) { console.Info("Create GeoJSON {0} index: ns={1} set={2} index={3} bin={4}", indexType, args.ns, args.set, indexName, binName); Policy policy = new Policy(); policy.totalTimeout = 0; // Do not timeout on index create. try { IndexTask task = client.CreateIndex(policy, args.ns, args.set, indexName, binName, IndexType.GEO2DSPHERE, indexType); task.Wait(); } catch (AerospikeException ae) { if (ae.Result != ResultCode.INDEX_ALREADY_EXISTS) { throw; } } }
public void Should_pass_settings_and_vcs_roots_on_to_the_ingester() { var fakeIngester = A.Fake<IIngester>(); var settings = new Settings { Id = Guid.NewGuid() }; var vcsRoots = new[] { new VcsRoot { Id = Guid.NewGuid() } }; using(var session = _documentStore.OpenSession()) { session.Store(vcsRoots[0]); session.Store(settings); session.SaveChanges(); } var indexController = new IndexTask(_documentStore, fakeIngester, A.Fake<IVcsManagerFactory>()); indexController.Run(); A.CallTo(() => fakeIngester.Ingest(A<Settings>.That.Matches(x => x.Id == settings.Id), A<IEnumerable<VcsRoot>>.That.Matches(x => x.Single().Id == vcsRoots[0].Id))).MustHaveHappened(); }
private void ComputeCategoryState(Task.Interface.IMessageSender sender) { IList <stockcategory> cateList = cateService.FindAll(); TechCycle[] cycleList = new TechCycle[] { TechCycle.day, TechCycle.week, TechCycle.month }; this.Log().Info("开始计算行业形态"); foreach (var category in cateList) { this.Log().Info("计算行业:" + category.name); foreach (var cycle in cycleList) { var task1 = new IndexTask { type = ObjectType.Category, code = category.code, cycle = cycle }; sender.Send(JsonConvert.SerializeObject(task1)); Thread.Sleep(100); } } }
private void ComputeMarketState(Task.Interface.IMessageSender sender) { var objList = objService.FindAll(); TechCycle[] cycleList = new TechCycle[] { TechCycle.day, TechCycle.week, TechCycle.month }; this.Log().Info("开始计算大盘形态"); foreach (var obj in objList) { this.Log().Info("计算大盘:" + obj.name); foreach (var cycle in cycleList) { var task1 = new IndexTask { type = ObjectType.Object, code = obj.code, cycle = cycle }; sender.Send(JsonConvert.SerializeObject(task1)); Thread.Sleep(100); } } }
public static void Prepare(TestContext testContext) { Assembly assembly = Assembly.GetExecutingAssembly(); RegisterTask rtask = client.Register(null, assembly, "Aerospike.Test.Resources.record_example.lua", "record_example.lua", Language.LUA); rtask.Wait(); Policy policy = new Policy(); policy.totalTimeout = 0; // Do not timeout on index create. try { IndexTask itask = client.CreateIndex(policy, args.ns, args.set, indexName, binName1, IndexType.NUMERIC); itask.Wait(); } catch (AerospikeException ae) { if (ae.Result != ResultCode.INDEX_ALREADY_EXISTS) { throw; } } }
} //main public void aggregateUsersByTweetCountByRegion(AerospikeClient client) { ResultSet rs = null; try { int min; int max; Console.WriteLine("\nEnter Min Tweet Count:"); min = int.Parse(Console.ReadLine()); Console.WriteLine("Enter Max Tweet Count:"); max = int.Parse(Console.ReadLine()); Console.WriteLine("\nAggregating users with " + min + "-" + max + " tweets by region. Hang on...\n"); // NOTE: Index creation has been included in here for convenience and to demonstrate the syntax. // NOTE: The recommended way of creating indexes in production env is via AQL. IndexTask task = client.CreateIndex(null, "test", "testusers", "tweetcountindex", "tweetcount", IndexType.NUMERIC); task.Wait(); // NOTE: UDF registration has been included here for convenience and to demonstrate the syntax. // NOTE: The recommended way of registering UDFs in production env is via AQL string luaDirectory = @"..\..\udf"; LuaConfig.PackagePath = luaDirectory + @"\?.lua"; string filename = "aggregationByRegion.lua"; string path = Path.Combine(luaDirectory, filename); RegisterTask rt = client.Register(null, path, filename, Language.LUA); rt.Wait(); Statement stmt = new Statement(); stmt.SetNamespace("test"); stmt.SetSetName("testusers"); stmt.SetIndexName("tweetcountindex"); stmt.SetFilters(Filter.Range("tweetcount", min, max)); rs = client.QueryAggregate(null, stmt, "aggregationByRegion", "sum"); if (rs.Next()) { Dictionary <object, object> result = (Dictionary <object, object>)rs.Object; Console.WriteLine("Here's the breakdown...\n"); Console.WriteLine("Total Users in North: " + result["n"]); Console.WriteLine("Total Users in South: " + result["s"]); Console.WriteLine("Total Users in East: " + result["e"]); Console.WriteLine("Total Users in West: " + result["w"]); } } catch (AerospikeException e) { Console.WriteLine("AerospikeException - Message: " + e.Message); Console.WriteLine("AerospikeException - StackTrace: " + e.StackTrace); } finally { if (rs != null) { // Close record set rs.Close(); } } } //aggregateUsersByTweetCountByRegion
public void Should_update_the_managers_for_each_vcs_root() { var fakeVcsManagerFactory = A.Fake<IVcsManagerFactory>(); var fakeVcsManager = A.Fake<IVcsManager>(); var settings = new Settings(); var vcsRoots = new[] { new VcsRoot(), new VcsRoot() }; using (var session = _documentStore.OpenSession()) { session.Store(vcsRoots[0]); session.Store(vcsRoots[1]); session.Store(settings); session.SaveChanges(); } A.CallTo(() => fakeVcsManagerFactory.CreateVcsManagerFrom(null, null)).WithAnyArguments().Returns(fakeVcsManager); var indexController = new IndexTask(_documentStore, A.Fake<IIngester>(), fakeVcsManagerFactory); indexController.Run(); A.CallTo(() => fakeVcsManager.CreateOrUpdate()).MustHaveHappened(Repeated.Exactly.Twice); }