示例#1
0
        public void CursorAppendAndGetSampleTest()
        {
            //arrange
            myCoreService = CoreService.GetInstance();
            myCoreService.Init("mongodb://127.0.0.1:27017", "JDBC-test", "Experiment");
            myCoreService.ClearDb();
            var exp1  = new Experiment("exp1");
            var sig11 = new Signal("sig1-1");

            myCoreService.AddJdbcEntityToAsync(Guid.Empty, exp1).Wait();
            myCoreService.AddJdbcEntityToAsync(exp1.Id, sig11).Wait();
            var data = generateDummyData();

            //append signal
            for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    var oneDim = new List <double>(8);
                    for (int k = 0; k < 8; k++)
                    {
                        oneDim.Add(data[i, j, k]);
                    }
                    //notice that this has only 2 interations for 3 dimention arry
                    mongoEngine.AppendSampleAsync(sig11.Id, new List <long> {
                        i, j
                    }, oneDim).Wait();
                }
            }

            //get samples
            //expected data:
            //[213,214,215
            //223,224,225]
            //-----------
            //[313,314,315
            //323,324,325]
            //flatted!!
            var cursor = mongoEngine.GetCursorAsync <double>(sig11.Id, new List <long> {
                2, 1, 3
            },
                                                             new List <long> {
                2, 2, 3
            }).Result;

            //Assert  get
            //make a flatter array for assert
            var expectedSample = new double[2, 2, 3]
            {
                { { 213, 214, 215 }, { 223, 224, 225 } },
                { { 313, 314, 315 }, { 323, 324, 325 } }
            };
            var sample = cursor.Read(15).Result.ToList();
            var flat   = expectedSample.Cast <double>().ToList();

            CollectionAssert.AreEqual(flat, sample);
        }
示例#2
0
文件: Account.cs 项目: jtext-103/jcdb
 public void clearDb()
 {
     myCoreService.ClearDb();
     storageEngine.ClearDb();
 }
示例#3
0
 private static IMatrixStorageEngineInterface storageEngine = new CassandraEngine();//MongoEngine(); //CassandraEngine();
 private static void clearDb()
 {
     myCoreService.ClearDb();
     storageEngine.ClearDb();
 }
示例#4
0
 private static void clearDb()
 {
     myCoreService.ClearDb();
     mongoEngine.ClearDb();
 }
示例#5
0
 private static void clearDb()
 {
     myCoreService.ClearDb();
 }