Example #1
0
        public static IVector TransformColumn(IVector vector, IVectorBuilder vectorBuilder, IVecConstructionCmd vectorConstr)
        {
            var boxedVector = BoxVector(vector, vectorBuilder);
            var newVec      = vectorBuilder.Build(vectorConstr, new IVector <object>[] { boxedVector });

            return(newVec);
        }
Example #2
0
        public static IVector <T> CreateRowVector <T>(IVectorBuilder vectorBuilder, long rowKeyCount, long colKeyCount, Func <object, T> mapper, IVector <IVector> data)
        {
            var boxedData     = data.Select(v => BoxVector(v, vectorBuilder)).Data.Values.ToArray();
            var vectorsConstr = new List <IVecConstructionCmd>();

            for (long i = 0; i < colKeyCount; i++)
            {
                vectorsConstr.Add(new Return(i));
            }

            var cmd = new Combine(rowKeyCount, vectorsConstr);

            var boxedVec = vectorBuilder.Build(cmd, boxedData);
            var resVec   = boxedVec.Select(v => mapper.Invoke(v));

            return(resVec);
        }
Example #3
0
        public static Series <K, int> Diff <K>(this Series <K, int> series, int offset)
        {
            Series <K, int> series1  = series;
            int             num      = offset;
            Series <K, int> series2  = series1;
            IVectorBuilder  instance = FVectorBuilderimplementation.VectorBuilder.Instance;
            Tuple <IIndex <K>, VectorConstruction> tuple = series2.Index.Builder.Shift <K>(new Tuple <IIndex <K>, VectorConstruction>(series2.Index, VectorConstruction.NewReturn(0)), num);
            VectorConstruction vectorConstruction1       = tuple.Item2;
            IIndex <K>         index = tuple.Item1;
            VectorConstruction vectorConstruction2 = series2.Index.Builder.Shift <K>(new Tuple <IIndex <K>, VectorConstruction>(series2.Index, VectorConstruction.NewReturn(0)), -num).Item2;
            VectorConstruction vectorConstruction3 = VectorConstruction.NewCombine((Lazy <long>)LazyExtensions.Create <long>((FSharpFunc <Unit, M0>) new SeriesExtensions.Diff2 <K>(index)), FSharpList <VectorConstruction> .Cons(vectorConstruction2, FSharpList <VectorConstruction> .Cons(vectorConstruction1, FSharpList <VectorConstruction> .get_Empty())), VectorListTransform.NewBinary((IBinaryTransform) new SeriesExtensions.Diff5((FSharpFunc <OptionalValue <int>, FSharpFunc <OptionalValue <int>, OptionalValue <int> > >) new SeriesExtensions.Diff4((FSharpFunc <int, FSharpFunc <int, int> >) new SeriesExtensions.Diff3()))));
            IVector <int>      vector = instance.Build <int>(index.AddressingScheme, vectorConstruction3, new IVector <int>[1]
            {
                series2.Vector
            });

            return(new Series <K, int>(index, vector, instance, series2.Index.Builder));
        }
Example #4
0
        public IVector <T> Build <T>(IVecConstructionCmd vectorConstruction, IVector <T>[] vectors)
        {
            if (vectorConstruction.GetType() == typeof(Return))
            {
                var vcReturn = (Return)vectorConstruction;
                return(vectors[vcReturn.VectorLocation]);
            }
            else if (vectorConstruction.GetType() == typeof(Combine))
            {
                var combine    = (Combine)vectorConstruction;
                var data       = combine.VecConstructionCmds.Select(vc => (IVector)VectorBuilderInstance.Build(vc, vectors)).ToArray();
                var frameData  = VectorBuilderInstance.Create(data);
                var rowReaders = new object[combine.Size];
                for (long i = 0; i < combine.Size; i++)
                {
                    rowReaders[i] = new RowReaderVector <object>(frameData, VectorBuilderInstance, i);
                }

                var objVec = new ArrayVector <object>(new ArrayVectorData <object>(rowReaders));
                //var objectSeq = new ObjectSequence<T>(objVec);
                return(Vector.unboxVector <T>(objVec, VectorBuilderInstance));
            }
            else if (vectorConstruction.GetType() == typeof(GetRange))
            {
                var cmd = (GetRange)vectorConstruction;
                //TODO
                var range      = (IntervalOf <Int64>)cmd.RangeBoundary;
                var newVecData = this.buildArrayVector(cmd.VecConstructionCmd, vectors);
                var newData    = new T[(range.End - range.Start + 1)];

                long idx = 0;
                for (long i = range.Start; i <= range.End; i++)
                {
                    newData[idx] = newVecData[i];
                    idx++;
                }
                return(new ArrayVector <T>(new ArrayVectorData <T>(newData)));
            }
            else
            {
                return(null);
            }
        }