Beispiel #1
0
        static void Stat3Get_(FuncContext fctx, int argc, Mem[] argv)
        {
            int        n = Vdbe.Value_Int(argv[1]);
            Stat3Accum p = (Stat3Accum)Vdbe.Value_Blob(argv[0]);

            Debug.Assert(p != null);
            if (p.a.length <= n)
            {
                return;
            }
            switch (argc)
            {
            case 2: Vdbe.Result_Int64(fctx, p.a[n].Rowid); break;

            case 3: Vdbe.Result_Int64(fctx, p.a[n].Eq); break;

            case 4: Vdbe.Result_Int64(fctx, p.a[n].Lt); break;

            default: Vdbe.Result_Int64(fctx, p.a[n].DLt); break;
            }
        }
Beispiel #2
0
        static void Stat3Init_(FuncContext fctx, int argc, Mem[][] argv)
        {
            tRowcnt    rows       = (tRowcnt)Vdbe.Value_Int64(argv[0]);
            int        maxSamples = Vdbe.Value_Int(argv[1]);
            int        n          = maxSamples;
            Stat3Accum p          = new Stat3Accum
            {
                a          = new array_t <Stat3Accum.Stat3Sample>(new Stat3Accum.Stat3Sample[n]),
                Rows       = rows,
                MaxSamples = maxSamples,
                PSamples   = (uint)(rows / (maxSamples / 3 + 1) + 1),
            };

            if (p == null)
            {
                Vdbe.Result_ErrorNoMem(fctx);
                return;
            }
            SysEx.Randomness(-1, p.Prn);
            Vdbe.Result_Blob(fctx, p, -1, C._free);
        }