Beispiel #1
0
 public PrimitiveColumnContainer(long length = 0)
 {
     while (length > 0)
     {
         if (Buffers.Count == 0)
         {
             Buffers.Add(new DataFrameBuffer <T>());
             NullBitMapBuffers.Add(new DataFrameBuffer <byte>());
         }
         DataFrameBuffer <T> lastBuffer = Buffers[Buffers.Count - 1];
         if (lastBuffer.Length == lastBuffer.MaxCapacity)
         {
             lastBuffer = new DataFrameBuffer <T>();
             Buffers.Add(lastBuffer);
             NullBitMapBuffers.Add(new DataFrameBuffer <byte>());
         }
         int allocatable = (int)Math.Min(length, lastBuffer.MaxCapacity);
         lastBuffer.EnsureCapacity(allocatable);
         DataFrameBuffer <byte> lastNullBitMapBuffer = NullBitMapBuffers[NullBitMapBuffers.Count - 1];
         lastNullBitMapBuffer.EnsureCapacity((int)Math.Ceiling(allocatable / 8.0));
         lastBuffer.Length           = allocatable;
         lastNullBitMapBuffer.Length = allocatable;
         length -= allocatable;
         Length += lastBuffer.Length;
     }
 }
Beispiel #2
0
        internal PrimitiveDataFrameColumnContainer <bool> CreateBoolContainerForCompareOps()
        {
            var ret = new PrimitiveDataFrameColumnContainer <bool>();

            foreach (var 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);
        }
Beispiel #3
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);
        }
Beispiel #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);
        }
        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);
        }
Beispiel #6
0
        public void AppendMany(T?value, long count)
        {
            if (!value.HasValue)
            {
                NullCount += count;
            }

            while (count > 0)
            {
                if (Buffers.Count == 0)
                {
                    Buffers.Add(new DataFrameBuffer <T>());
                    NullBitMapBuffers.Add(new DataFrameBuffer <byte>());
                }
                DataFrameBuffer <T> lastBuffer = Buffers[Buffers.Count - 1];
                if (lastBuffer.Length == lastBuffer.MaxCapacity)
                {
                    lastBuffer = new DataFrameBuffer <T>();
                    Buffers.Add(lastBuffer);
                    NullBitMapBuffers.Add(new DataFrameBuffer <byte>());
                }
                int allocatable = (int)Math.Min(count, lastBuffer.MaxCapacity);
                lastBuffer.EnsureCapacity(allocatable);
                lastBuffer.Span.Slice(lastBuffer.Length, allocatable).Fill(value ?? default);
                lastBuffer.Length += allocatable;
                Length            += allocatable;

                DataFrameBuffer <byte> lastNullBitMapBuffer = NullBitMapBuffers[NullBitMapBuffers.Count - 1];
                int nullBitMapAllocatable = (int)(((uint)allocatable + 7) / 8);
                lastNullBitMapBuffer.EnsureCapacity(nullBitMapAllocatable);
                _modifyNullCountWhileIndexing = false;
                for (long i = Length - count; i < Length; i++)
                {
                    SetValidityBit(i, value.HasValue ? true : false);
                }
                _modifyNullCountWhileIndexing = true;
                lastNullBitMapBuffer.Length  += nullBitMapAllocatable;
                count -= allocatable;
            }
        }