public void Delete(string logicalPath) { if (_inner.Attributes(logicalPath + ".zip").Exists) { _inner.Delete(logicalPath + ".zip"); } else { _inner.Delete(logicalPath); } }
public static void Delete(IStreamProvider streamProvider, string tableRootPath) { // Delete metadata first (the main marker we use to detect table presence) streamProvider.Delete(Path.Combine(tableRootPath, MetadataFileName)); // Delete the table streamProvider.DeleteWithRetries(tableRootPath); }
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)); }
public static void DeleteWithRetries(this IStreamProvider streamProvider, string logicalPath, int tryCount = 3) { Exception lastException = null; for (int i = 0; i < tryCount; ++i) { try { streamProvider.Delete(logicalPath); return; } catch (Exception ex) { lastException = ex; Thread.Sleep(2500); } } throw new TimeoutException($"Timed out trying to delete '{logicalPath}' after {tryCount:n0} tries.", lastException); }
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 static void Clean(this IStreamProvider streamProvider, bool reallyDelete, DateTime cutoff = default(DateTime)) { // By default, keep data from the last week (so Now, Yesterday, and Last Week 'as of' data is all available) if (cutoff == default(DateTime)) { cutoff = DateTime.UtcNow.AddDays(-8); } // Remove Sources and Tables older than the cutoff ItemVersions currentVersions; int countLeft; foreach (string tableName in streamProvider.Tables()) { // Find all Source versions currentVersions = streamProvider.ItemVersions(LocationType.Source, tableName); countLeft = currentVersions.Versions.Count; // Delete ones older than the cutoff, keeping the last three foreach (var version in currentVersions.Versions) { if (version.AsOfDate < cutoff) { if (countLeft <= 3) { break; } countLeft--; Trace.WriteLine($"DELETE {version.Path}"); if (reallyDelete) { // Delete the source streamProvider.Delete(version.Path); version.LocationType = LocationType.Table; // Delete the matching table, if found streamProvider.Delete(version.Path); } } } // Find all Table versions currentVersions = streamProvider.ItemVersions(LocationType.Table, tableName); countLeft = currentVersions.Versions.Count; // Delete ones older than the cutoff, keeping the last three foreach (var version in currentVersions.Versions) { if (version.AsOfDate < cutoff) { if (countLeft <= 3) { break; } countLeft--; Trace.WriteLine($"DELETE {version.Path}"); if (reallyDelete) { streamProvider.Delete(version.Path); } } } } }
public void Delete(string logicalPath) { _attributesCache.Remove(logicalPath); _inner.Delete(logicalPath); }