public void Dispose() { if (_convertedValueWriter != null) { _convertedValueWriter.Dispose(); _convertedValueWriter = null; } }
private void Upconvert(Type toType) { // Close the current writer _writer.Dispose(); _writer = null; // Determine previous and new file paths string columnValuesFullPath = PathForType(_columnPathPrefix, WritingAsType); string columnConvertedFullPath = PathForType(_columnPathPrefix, toType); // Build a writer for the larger type IColumnWriter writer = BuildDirectWriter(_streamProvider, toType, columnConvertedFullPath); // Convert already written values (if any) if (_rowCountWritten > 0) { // Build a converter to convert the values Func <XArray, XArray> converter = TypeConverterFactory.GetConverter(WritingAsType, toType); // Stream them in, convert them, and write them out using (IColumnReader reader = TypeProviderFactory.TryGetColumnReader(_streamProvider, WritingAsType, columnValuesFullPath)) { int rowCount = reader.Count; ArraySelector page = ArraySelector.All(0).NextPage(rowCount, 10240); while (page.Count > 0) { XArray original = reader.Read(page); XArray converted = converter(original); writer.Append(converted); page = page.NextPage(rowCount, 10240); } } } // Delete the original file _streamProvider.Delete(columnValuesFullPath); // Re-initialize for the new writer WritingAsType = toType; _writer = writer; _converter = (toType == typeof(int) ? null : TypeConverterFactory.GetConverter(typeof(int), toType)); }
private void Convert() { // Close the row index writer _rowIndexWriter.Dispose(); _rowIndexWriter = null; // If we wrote any rows we need to convert... if (_rowCountWritten > 0) { // Get the set of unique values and get rid of the value dictionary XArray values = _dictionary.Values(); // Convert the indices previously written into raw values Func <XArray, XArray> converter = TypeConverterFactory.GetConverter(typeof(byte), typeof(int)); using (IColumnReader rowIndexReader = new PrimitiveArrayReader <byte>(_streamProvider.OpenRead(Path.Combine(_columnPath, RowIndexFileName)))) { int rowCount = rowIndexReader.Count; ArraySelector page = ArraySelector.All(0).NextPage(rowCount, 10240); while (page.Count > 0) { // Read an XArray of indices and convert to int[] XArray rowIndices = converter(rowIndexReader.Read(page)); // Write the corresponding values // Reselect is safe because 'values' are converted to a contiguous array _valueWriter.Append(values.Reselect(ArraySelector.Map((int[])rowIndices.Array, rowIndices.Count))); page = page.NextPage(rowCount, 10240); } } } // Remove the Dictionary (so future rows are streamed out as-is) _dictionary = null; // Delete the row index file _streamProvider.Delete(Path.Combine(_columnPath, RowIndexFileName)); }
public void Dispose() { if (_valueWriter != null) { _valueWriter.Dispose(); _valueWriter = null; } if (_nullWriter != null) { _nullWriter.Dispose(); _nullWriter = null; } }
public void Dispose() { // If we're still an enum column, write the distinct values out if (_dictionary != null) { _valueWriter.Append(_dictionary.Values()); _dictionary = null; } if (_valueWriter != null) { _valueWriter.Dispose(); _valueWriter = null; } if (_rowIndexWriter != null) { _rowIndexWriter.Dispose(); _rowIndexWriter = null; } }