Ejemplo n.º 1
0
        public void createPartitionedTableAppender()
        {
            IDBConnectionPool pool = new ExclusiveDBConnectionPool("192.168.1.37", 8848, "admin", "123456", 5, true, true);
            IDBTask           conn = new BasicDBTask("dbPath = \"dfs://demohash\";if(existsDatabase(dbPath))    dropDatabase(dbPath); db = database(dbPath, HASH,[STRING, 2]);t= table(100:0,`id`valuie,[STRING,INT]);pt=db.createPartitionedTable(t,`pt,`id);");

            pool.execute(conn);


            PartitionedTableAppender appender = new PartitionedTableAppender("dfs://demohash", "pt", "id", pool);
            List <String>            colNames = new List <String>(2);

            colNames.Add("id");
            colNames.Add("value");
            List <IVector>    cols = new List <IVector>(2);
            BasicStringVector id   = new BasicStringVector(3);

            id.setString(0, "ORCA");
            id.setString(1, "YHOO");
            id.setString(2, "Ford");
            cols.Add(id);

            BasicIntVector value = new BasicIntVector(3);

            value.setInt(0, 10);
            value.setInt(1, 11);
            value.setInt(2, 12);
            cols.Add(value);

            int res = appender.append(new BasicTable(colNames, cols));

            Assert.AreEqual(3, res);
        }
Ejemplo n.º 2
0
        public void blob_imemory_table_upload()
        {
            DBConnection db = new DBConnection();

            db.connect(SERVER, PORT);
            db.run("share table(100:0, `id`memo, [INT,  BLOB])as st");
            List <String> colNames = new List <String>(2);

            colNames.Add("id");
            colNames.Add("str");
            List <IVector> cols = new List <IVector>(2);
            BasicIntVector id   = new BasicIntVector(2);

            id.setInt(1, 1);
            id.setInt(0, 1);

            BasicStringVector str = new BasicStringVector(2);
            String            tmp = "534656 unuk6.太阳能与看见了和和 规划局广告费 hudfgdg TYF  FEW 867R 8T至于金额及计划一 至于科技hudfgdg TYF  FEW 867R 8T至于金额及计划一 至于科技hudfgdg TYF  FEW 867R 8T至于金额及计划一 至于科技hudfgdg TYF  FEW 867R 8T至于金额及计划一 至于科技hudfgdg TYF  FEW 867R 8T至于金额及计划一 至于科技hudfgdg TYF  FEW 867R 8T至于金额及计划一 至于科技hudfgdg TYF  FEW 867R 8T至于金额及计划一 至于科技hudfgdg TYF  FEW 867R 8T至于金dd,/5额及计划一 至于科技hudfgdg TYF  FEW 867R 8T至于金额及计划一 至于科技hudfgdg TYF  FEW 867R 8T至于金额及计划一 至于科技";

            str.setString(0, tmp);
            str.setString(1, tmp);
            cols.Add(id);
            cols.Add(str);
            BasicTable     t   = new BasicTable(colNames, cols);
            List <IEntity> arg = new List <IEntity>()
            {
                t
            };

            db.run("tableInsert{st}", arg);

            BasicTable st = (BasicTable)db.run("st");
            // Console.WriteLine(((BasicTable)st).getColumn(2).get(0).getValue());
        }
Ejemplo n.º 3
0
        public static Task getTask()
        {
            return(new Task(() => {
                int i = 0;

                while (true)
                {
                    if (i == 20000000)
                    {
                        break;
                    }
                    Row row;

                    if (RowQueue.queue.TryTake(out row))
                    {
                        BasicIntVector v1 = (BasicIntVector)Program.bt.getColumn(0);
                        BasicStringVector v2 = (BasicStringVector)Program.bt.getColumn(1);
                        v1.setInt(i, (int)row["aid"]);
                        v2.setString(i, (string)row["namec"]);
                        i++;
                    }
                    if (i % 100000 == 0 && i > 0)
                    {
                        Console.WriteLine("100000 rows parsed! left " + RowQueue.queue.Count().ToString());
                    }
                }
            }));
        }
Ejemplo n.º 4
0
        private void addRow(Row row, int Pos)
        {
            BasicIntVector    v  = (BasicIntVector)cols[0];
            BasicStringVector v1 = (BasicStringVector)cols[1];

            v.setInt(Pos, (int)row[row.Columns[0]]);
            v1.setString(Pos, (string)row[row.Columns[1]]);
        }
Ejemplo n.º 5
0
        public void blob_imemory_table_upload_download_bigdata()
        {
            DBConnection db = new DBConnection();

            db.connect(SERVER, PORT);
            db.run("share table(blob(`d`f) as blob)as st");
            List <String> colNames = new List <String>(1);

            colNames.Add("str");
            List <IVector>    cols = new List <IVector>(1);
            BasicStringVector vec  = new BasicStringVector(1000);
            BasicString       str  = (BasicString)db.run("mt=table(take(1..1000000,1000) as id,take(`fyf``ftf`ddtjtydtyty`通常都是,1000) as str,take(`fyf``ftf`ddtjtydtyty`通常都是,1000) as str1," +
                                                         "take(`fyf``ftf`ddtjtydtyty`通常都是,1000) as str2);mt.toStdJson()");
            String tmp = str.getString();

            for (int i = 0; i < 1000; i++)
            {
                vec.setString(i, tmp + i.ToString());
            }
            cols.Add(vec);
            BasicTable     tb  = new BasicTable(colNames, cols);
            List <IEntity> arg = new List <IEntity>()
            {
                tb
            };

            // for (int i = 0; i < 100; i++)
            //  {
            db.run("tableInsert{st}", arg);
            // }

            BasicTable st = (BasicTable)db.run("st");

            Assert.AreEqual(1000, tb.rows());
            Assert.AreEqual(1, tb.columns());
            Assert.AreEqual(tmp + 8.ToString(), ((BasicTable)st).getColumn(0).get(10).getString());
        }