예제 #1
0
        public void Append(XArray xarray)
        {
            // Write the values (without the null markers; we're writing those here)
            _valueWriter.Append(xarray.WithoutNulls());

            // Track the row count written so we know how many null=false values to write when we first see a null
            _rowCountWritten += xarray.Count;

            // If there are no nulls in this set and none previously, no null markers need to be written
            if (!xarray.HasNulls && _nullWriter == null)
            {
                return;
            }

            if (_nullWriter == null)
            {
                // Check whether any rows in the set are actually null; the source may contain nulls but the filtered rows might not
                bool areAnyNulls = false;
                for (int i = 0; i < xarray.Count && !areAnyNulls; ++i)
                {
                    areAnyNulls |= xarray.NullRows[xarray.Index(i)];
                }

                // If there are not actually any null rows in this set, don't write null output yet
                if (!areAnyNulls)
                {
                    return;
                }

                // Open a new file to write IsNull booleans
                string nullsPath = Path.Combine(_columnPath, "Vn.b8.bin");
                _nullWriter = new PrimitiveArrayWriter <bool>(_streamProvider.OpenWrite(nullsPath));

                // Write false for every value so far
                int previousCount = _rowCountWritten - xarray.Count;
                Allocator.AllocateToSize(ref _falseArray, 1024);
                for (int i = 0; i < previousCount; i += 1024)
                {
                    int rowCount = Math.Min(1024, previousCount - i);
                    _nullWriter.Append(XArray.All(_falseArray, rowCount));
                }
            }

            if (!xarray.HasNulls)
            {
                // If this xarray doesn't have any nulls, write false for every value in this page
                Allocator.AllocateToSize(ref _falseArray, xarray.Count);
                _nullWriter.Append(XArray.All(_falseArray, xarray.Count));
            }
            else
            {
                // Write the actual true/false values for this page
                _nullWriter.Append(XArray.All(xarray.NullRows).Reselect(xarray.Selector));
            }
        }
예제 #2
0
        public void Dispose()
        {
            if (_bytesWriter != null)
            {
                _bytesWriter.Dispose();
                _bytesWriter = null;
            }

            if (_positionsWriter != null)
            {
                _positionsWriter.Dispose();
                _positionsWriter = null;
            }
        }
예제 #3
0
        public void Dispose()
        {
            if (_valueWriter != null)
            {
                _valueWriter.Dispose();
                _valueWriter = null;
            }

            if (_nullWriter != null)
            {
                _nullWriter.Dispose();
                _nullWriter = null;
            }
        }
예제 #4
0
 public String8ColumnWriter(IStreamProvider streamProvider, string columnPath)
 {
     _streamProvider  = streamProvider;
     _bytesWriter     = _streamProvider.OpenWrite(Path.Combine(columnPath, "V.s.bin"));
     _positionsWriter = new PrimitiveArrayWriter <int>(streamProvider.OpenWrite(Path.Combine(columnPath, "Vp.i32.bin")));
 }