Example #1
0
        public void testKeepWritingTask()
        {
            DBConnection conn = new DBConnection();

            conn.connect(SERVER, PORT, USER, PASSWORD, WRITE_FUNCTION_SCRIPT, true, HA_SITES);
            int    count      = 0;
            Random rnd        = new Random();
            string funcScript = String.Format("saveData{{{0}}}", TBNAME);

            Console.WriteLine(funcScript);
            for (int i = 0; i < 86400000; i++)
            {
                IList <IEntity>   args     = new List <IEntity>();
                DateTime          dt       = new DateTime(2021, 1, 1);
                BasicDateVector   bdv      = new BasicDateVector(new int[] { Utils.countDays(2021, 4, 7) });
                BasicTimeVector   btv      = new BasicTimeVector(new int[] { i });
                BasicStringVector bsv      = new BasicStringVector(new string[] { SYMBOLS[rnd.Next(3)] });
                BasicIntVector    bqv      = new BasicIntVector(new int[] { rnd.Next(80, 100) });
                BasicDoubleVector bpv      = new BasicDoubleVector(new double[] { rnd.NextDouble() });
                List <String>     colNames = new List <string>()
                {
                    "date", "time", "sym", "qty", "price"
                };
                List <IVector> cols = new List <IVector>()
                {
                    bdv, btv, bsv, bqv, bpv
                };
                BasicTable table1 = new BasicTable(colNames, cols);
                args.Add(table1);

                BasicInt re = (BasicInt)conn.run(funcScript, args);
                Console.WriteLine(re.getInt());
            }
        }
Example #2
0
    private BasicTable createBasicTable()
    {
        List <string> colNames = new List <string>();

        colNames.Add("cbool");
        colNames.Add("cchar");
        colNames.Add("cshort");
        colNames.Add("cint");
        colNames.Add("clong");
        colNames.Add("cdate");
        colNames.Add("cmonth");
        colNames.Add("ctime");
        colNames.Add("cminute");
        colNames.Add("csecond");
        colNames.Add("cdatetime");
        colNames.Add("ctimestamp");
        colNames.Add("cnanotime");
        colNames.Add("cnanotimestamp");
        colNames.Add("cfloat");
        colNames.Add("cdouble");
        colNames.Add("csymbol");
        colNames.Add("cstring");
        List <IVector> cols = new List <IVector>();


        //boolean
        byte[]             vbool = new byte[] { 1, 0 };
        BasicBooleanVector bbv   = new BasicBooleanVector(vbool);

        cols.Add(bbv);
        //char
        byte[]          vchar = new byte[] { (byte)'c', (byte)'a' };
        BasicByteVector bcv   = new BasicByteVector(vchar);

        cols.Add(bcv);
        //cshort
        short[]          vshort = new short[] { 32767, 29 };
        BasicShortVector bshv   = new BasicShortVector(vshort);

        cols.Add(bshv);
        //cint
        int[]          vint  = new int[] { 2147483647, 483647 };
        BasicIntVector bintv = new BasicIntVector(vint);

        cols.Add(bintv);
        //clong
        long[]          vlong  = new long[] { 2147483647, 483647 };
        BasicLongVector blongv = new BasicLongVector(vlong);

        cols.Add(blongv);
        //cdate
        int[]           vdate  = new int[] { Utils.countDays(new DateTime(2018, 2, 14)), Utils.countDays(new DateTime(2018, 8, 15)) };
        BasicDateVector bdatev = new BasicDateVector(vdate);

        cols.Add(bdatev);
        //cmonth
        int[]            vmonth  = new int[] { Utils.countMonths(new DateTime(2018, 2, 6)), Utils.countMonths(new DateTime(2018, 8, 11)) };
        BasicMonthVector bmonthv = new BasicMonthVector(vmonth);

        cols.Add(bmonthv);
        //ctime
        int[]           vtime  = new int[] { Utils.countMilliseconds(16, 46, 05, 123), Utils.countMilliseconds(18, 32, 05, 321) };
        BasicTimeVector btimev = new BasicTimeVector(vtime);

        cols.Add(btimev);
        //cminute
        int[]             vminute  = new int[] { Utils.countMinutes(new TimeSpan(16, 30, 00)), Utils.countMinutes(new TimeSpan(9, 30, 00)) };
        BasicMinuteVector bminutev = new BasicMinuteVector(vminute);

        cols.Add(bminutev);
        //csecond
        int[]             vsecond  = new int[] { Utils.countSeconds(new TimeSpan(16, 30, 00)), Utils.countSeconds(new TimeSpan(16, 30, 50)) };
        BasicSecondVector bsecondv = new BasicSecondVector(vsecond);

        cols.Add(bsecondv);
        //cdatetime
        int[] vdatetime = new int[] { Utils.countSeconds(new DateTime(2018, 9, 8, 9, 30, 01)), Utils.countSeconds(new DateTime(2018, 11, 8, 16, 30, 01)) };
        BasicDateTimeVector bdatetimev = new BasicDateTimeVector(vdatetime);

        cols.Add(bdatetimev);
        //ctimestamp
        long[] vtimestamp = new long[] { Utils.countMilliseconds(2018, 11, 12, 9, 30, 01, 123), Utils.countMilliseconds(2018, 11, 12, 16, 30, 01, 123) };
        BasicTimestampVector btimestampv = new BasicTimestampVector(vtimestamp);

        cols.Add(btimestampv);
        //cnanotime
        long[] vnanotime = new long[] { Utils.countNanoseconds(new TimeSpan(9, 30, 05, 1234567)), Utils.countNanoseconds(new TimeSpan(16, 30, 05, 9876543)) };
        BasicNanoTimeVector bnanotimev = new BasicNanoTimeVector(vnanotime);

        cols.Add(bnanotimev);
        //cnanotimestamp
        long[] vnanotimestamp = new long[] { Utils.countNanoseconds(new DateTime(2018, 11, 12, 9, 30, 05, 123)), Utils.countNanoseconds(new DateTime(2018, 11, 13, 16, 30, 05, 987)) };
        BasicNanoTimestampVector bnanotimestampv = new BasicNanoTimestampVector(vnanotimestamp);

        cols.Add(bnanotimestampv);
        //cfloat
        float[]          vfloat  = new float[] { 2147.483647f, 483.647f };
        BasicFloatVector bfloatv = new BasicFloatVector(vfloat);

        cols.Add(bfloatv);
        //cdouble
        double[]          vdouble  = new double[] { 214.7483647, 48.3647 };
        BasicDoubleVector bdoublev = new BasicDoubleVector(vdouble);

        cols.Add(bdoublev);
        //csymbol
        String[]          vsymbol  = new String[] { "GOOG", "MS" };
        BasicStringVector bsymbolv = new BasicStringVector(vsymbol);

        cols.Add(bsymbolv);
        //cstring
        String[]          vstring  = new String[] { "", "test string" };
        BasicStringVector bstringv = new BasicStringVector(vstring);

        cols.Add(bstringv);
        BasicTable t1 = new BasicTable(colNames, cols);

        return(t1);
    }