コード例 #1
0
        public static RegionTestData CreateTestDataAndUploadItToAzure(RegionInputTestData regionInputData)
        {
            List <Person> peopleBatch   = new List <Person>();
            List <Person> peopleToQuery = new List <Person>();

            for (int counter = 1; counter <= regionInputData.RegionPopulation; counter++)
            {
                var newPerson = new Person(regionInputData.RegionName);
                peopleBatch.Add(newPerson);

                if (regionInputData.PeopleToQueryIndexes.Contains(counter))
                {
                    // this person will be queried later on
                    peopleToQuery.Add(newPerson);
                }

                if (counter % Parameters.AzureBatchSize == 0 || counter == regionInputData.RegionPopulation)
                {
                    // end of the batch or of the list
                    InsertBatchIntoTable(peopleBatch);
                    peopleBatch.Clear();
                }
            }

            Console.WriteLine($"Uploaded {regionInputData.RegionPopulation.ToString("##,#")} people for region: '{regionInputData.RegionName}'");

            return(new RegionTestData()
            {
                RegionName = regionInputData.RegionName,
                RegionPopulation = regionInputData.RegionPopulation,
                PeopleToQueryDataset = peopleToQuery,
                AverageEntitySizeForQueriedEntitiesInByte = TestUtils.CalculateAverageEntitySize(peopleToQuery),
            });
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: pcarcereri/Playground
        private static IList <RegionInputTestData> GenerateTestInputData()
        {
            var testInputData = new ConcurrentBag <RegionInputTestData>();

            Parallel.ForEach(Parameters.ItalianRegionToPopulation, (regionNameToPopulation) =>
            {
                var region = new RegionInputTestData()
                {
                    RegionName       = regionNameToPopulation.Key,
                    RegionPopulation = regionNameToPopulation.Value,
                };

                HashSet <int> indexesOfRandomPeopleToQuery = ListUtils.GenerateListOfRandomIndexes(
                    listLenght: Parameters.NumberOfPeopleToQueryPerRegion,
                    maxIndex: region.RegionPopulation);
                region.PeopleToQueryIndexes = indexesOfRandomPeopleToQuery;

                testInputData.Add(region);
            });

            return(testInputData.ToList());
        }