Esempio n. 1
0
 public PrimitiveColumn <T> Clone(PrimitiveColumn <long> mapIndices = null, bool invertMapIndices = false)
 {
     if (mapIndices is null)
     {
         PrimitiveColumnContainer <T> newColumnContainer = _columnContainer.Clone();
         return(new PrimitiveColumn <T>(Name, newColumnContainer));
     }
     else
     {
         if (mapIndices.Length != Length)
         {
             throw new ArgumentException(Strings.MismatchedColumnLengths, nameof(mapIndices));
         }
         PrimitiveColumn <T> ret = new PrimitiveColumn <T>(Name);
         if (invertMapIndices == false)
         {
             for (long i = 0; i < mapIndices.Length; i++)
             {
                 ret.Append(_columnContainer[mapIndices._columnContainer[i]]);
             }
         }
         else
         {
             for (long i = Length - 1; i >= 0; i--)
             {
                 ret.Append(_columnContainer[mapIndices._columnContainer[i]]);
             }
         }
         return(ret);
     }
 }
Esempio n. 2
0
        internal PrimitiveColumnContainer <bool> CloneAsBoolContainer()
        {
            var ret = new PrimitiveColumnContainer <bool>();

            foreach (DataFrameBuffer <T> buffer in Buffers)
            {
                DataFrameBuffer <bool> newBuffer = new DataFrameBuffer <bool>();
                ret.Buffers.Add(newBuffer);
                newBuffer.EnsureCapacity(buffer.Length);
                newBuffer.Span.Fill(false);
                newBuffer.Length = buffer.Length;
                ret.Length      += buffer.Length;
            }
            return(ret);
        }
Esempio n. 3
0
        public PrimitiveColumnContainer <T> Clone()
        {
            var ret = new PrimitiveColumnContainer <T>();

            foreach (DataFrameBuffer <T> buffer in Buffers)
            {
                DataFrameBuffer <T> newBuffer = new DataFrameBuffer <T>();
                ret.Buffers.Add(newBuffer);
                Span <T> span = buffer.Span;
                ret.Length += buffer.Length;
                for (int i = 0; i < buffer.Length; i++)
                {
                    newBuffer.Append(span[i]);
                }
            }
            return(ret);
        }
Esempio n. 4
0
        internal PrimitiveColumnContainer <decimal> CloneAsDecimalContainer()
        {
            var ret = new PrimitiveColumnContainer <decimal>();

            foreach (DataFrameBuffer <T> buffer in Buffers)
            {
                ret.Length += buffer.Length;
                DataFrameBuffer <decimal> newBuffer = new DataFrameBuffer <decimal>();
                ret.Buffers.Add(newBuffer);
                newBuffer.EnsureCapacity(buffer.Length);
                Span <T> span = buffer.Span;
                for (int i = 0; i < buffer.Length; i++)
                {
                    newBuffer.Append(DecimalConverter <T> .Instance.GetDecimal(span[i]));
                }
            }
            return(ret);
        }
Esempio n. 5
0
 public PrimitiveColumn <T> Clone(PrimitiveColumn <long> mapIndices = null, bool invertMapIndices = false)
 {
     if (mapIndices is null)
     {
         PrimitiveColumnContainer <T> newColumnContainer = _columnContainer.Clone();
         return(new PrimitiveColumn <T>(Name, newColumnContainer));
     }
     else
     {
         if (mapIndices.Length > Length)
         {
             throw new ArgumentException(Strings.MapIndicesExceedsColumnLenth, nameof(mapIndices));
         }
         PrimitiveColumn <T> ret = new PrimitiveColumn <T>(Name, mapIndices.Length);
         ret._columnContainer._modifyNullCountWhileIndexing = false;
         if (invertMapIndices == false)
         {
             for (long i = 0; i < mapIndices.Length; i++)
             {
                 T?value = _columnContainer[mapIndices._columnContainer[i].Value];
                 ret[i] = value;
                 if (!value.HasValue)
                 {
                     ret._columnContainer.NullCount++;
                 }
             }
         }
         else
         {
             long mapIndicesIndex = mapIndices.Length - 1;
             for (long i = 0; i < mapIndices.Length; i++)
             {
                 T?value = _columnContainer[mapIndices._columnContainer[mapIndicesIndex - i].Value];
                 ret[i] = value;
                 if (!value.HasValue)
                 {
                     ret._columnContainer.NullCount++;
                 }
             }
         }
         ret._columnContainer._modifyNullCountWhileIndexing = true;
         return(ret);
     }
 }
        internal PrimitiveColumnContainer <double> CloneAsDoubleContainer()
        {
            var ret = new PrimitiveColumnContainer <double>();

            foreach (DataFrameBuffer <T> buffer in Buffers)
            {
                ret.Length += buffer.Length;
                DataFrameBuffer <double> newBuffer = new DataFrameBuffer <double>();
                ret.Buffers.Add(newBuffer);
                newBuffer.EnsureCapacity(buffer.Length);
                Span <T> span = buffer.Span;
                for (int i = 0; i < buffer.Length; i++)
                {
                    newBuffer.Append(DoubleConverter <T> .Instance.GetDouble(span[i]));
                }
            }
            ret.NullBitMapBuffers = CloneNullBitMapBuffers();
            ret.NullCount         = NullCount;
            return(ret);
        }
Esempio n. 7
0
 public PrimitiveColumn(string name, ReadOnlyMemory <byte> buffer, ReadOnlyMemory <byte> nullBitMap, int length = 0, int nullCount = 0) : base(name, length, typeof(T))
 {
     _columnContainer = new PrimitiveColumnContainer <T>(buffer, nullBitMap, length, nullCount);
 }
Esempio n. 8
0
 public PrimitiveColumn(string name, long length = 0) : base(name, length, typeof(T))
 {
     _columnContainer = new PrimitiveColumnContainer <T>(length);
 }
Esempio n. 9
0
 public PrimitiveColumn(string name, IEnumerable <T> values) : base(name, 0, typeof(T))
 {
     _columnContainer = new PrimitiveColumnContainer <T>(values);
     Length           = _columnContainer.Length;
 }
Esempio n. 10
0
 internal PrimitiveColumn(string name, PrimitiveColumnContainer <T> column) : base(name, column.Length, typeof(T))
 {
     _columnContainer = column;
 }
Esempio n. 11
0
        internal PrimitiveColumn <decimal> CloneAsDecimalColumn()
        {
            PrimitiveColumnContainer <decimal> newColumnContainer = _columnContainer.CloneAsDecimalContainer();

            return(new PrimitiveColumn <decimal>(Name, newColumnContainer));
        }
Esempio n. 12
0
        internal PrimitiveColumn <double> CloneAsDoubleColumn()
        {
            PrimitiveColumnContainer <double> newColumnContainer = _columnContainer.CloneAsDoubleContainer();

            return(new PrimitiveColumn <double>(Name, newColumnContainer));
        }
Esempio n. 13
0
        internal PrimitiveColumn <bool> CloneAsBoolColumn()
        {
            PrimitiveColumnContainer <bool> newColumnContainer = _columnContainer.CloneAsBoolContainer();

            return(new PrimitiveColumn <bool>(Name, newColumnContainer));
        }
Esempio n. 14
0
 public PrimitiveColumn(string name, long length = 0, bool isNullable = true) : base(name, length, typeof(T))
 {
     _columnContainer = new PrimitiveColumnContainer <T>(length);
 }