public KeyedDataStore(DimensionSet dimensionSet, RecyclableMemoryStreamManager memoryStreamManager, MemoryStream initialData, int dataKeyCount, PersistedDataType initialDataType, string sourceTag = "unknown with data") { this.allocationStack = #if COLLECT_STACKS sourceTag + " " + Environment.StackTrace; #else string.Empty; #endif this.DimensionSet = dimensionSet; this.memoryStreamManager = memoryStreamManager; if (initialData != null && dataKeyCount > 0) { this.mergedData = this.CreateDataFromStream(initialData, initialDataType, dataKeyCount); } else { this.mergedData = new QueryableSingleValueData(null, DimensionSet.Empty); if (initialData != null) { initialData.Dispose(); } } this.multiValue = (new TInternal()).MultiValue; }
private QueryableData CreateDataFromStream(MemoryStream stream, PersistedDataType initialDataType, int keyCount) { var internalData = new TInternal(); if (internalData.MultiValue) { return(new QueryableMultiValueData(initialDataType, stream, this.DimensionSet, keyCount)); } return(new QueryableSingleValueData(stream, this.DimensionSet)); }
public PersistedDataHeader(string name, DateTime start, DateTime end, PersistedDataType dataType, IEnumerable <PersistedDataSource> sources, DimensionSet dimensionSet, uint dataCount) { this.Name = name; this.StartTime = new DateTimeOffset(start, TimeSpan.Zero); this.EndTime = new DateTimeOffset(end, TimeSpan.Zero); this.DataType = dataType; this.Sources = new List <PersistedDataSource>(sources); this.DimensionSet = dimensionSet; this.DataCount = dataCount; }
public PersistedDataHeader(string name, DateTime start, DateTime end, PersistedDataType dataType, IEnumerable<PersistedDataSource> sources, DimensionSet dimensionSet, uint dataCount) { this.Name = name; this.StartTime = new DateTimeOffset(start, TimeSpan.Zero); this.EndTime = new DateTimeOffset(end, TimeSpan.Zero); this.DataType = dataType; this.Sources = new List<PersistedDataSource>(sources); this.DimensionSet = dimensionSet; this.DataCount = dataCount; }
internal const long CompressionFlag = 1 << 63; // Bit used to indicate that subsequent data will be in compressed form. internal static Type GetTypeFromPersistedTypeCode(PersistedDataType typeCode) { switch (typeCode) { case PersistedDataType.HitCount: return typeof(InternalHitCount); case PersistedDataType.VariableEncodedHistogram: return typeof(InternalHistogram); default: throw new InvalidDataException("Unknown typecode"); } }
internal static Type GetTypeFromPersistedTypeCode(PersistedDataType typeCode) { switch (typeCode) { case PersistedDataType.HitCount: return(typeof(InternalHitCount)); case PersistedDataType.VariableEncodedHistogram: return(typeof(InternalHistogram)); default: throw new InvalidDataException("Unknown typecode"); } }
public static IBufferedValueArray Create(PersistedDataType type, byte[] sourceBuffer, int startOffset, int existingDataLength) { // legacy types are fixed-length encoded. New default is VLE switch (type) { case PersistedDataType.HitCount: return(new FixedLengthBufferedValueArray <ulong>(sourceBuffer, startOffset, existingDataLength)); case PersistedDataType.VariableEncodedHistogram: return(new VariableLengthBufferedValueArray(sourceBuffer, startOffset, existingDataLength)); default: throw new InvalidDataException("Unknown data type specfieid."); } }
public KeyedDataStore <TInternal> LoadData <TInternal>() where TInternal : class, IInternalData, new() { PersistedDataType dataType = this.Header.DataType; KeyedDataStore <TInternal> store = this.LoadAndValidateData((ms, buffer, length) => { var newStore = new KeyedDataStore <TInternal>( this.DimensionSet, this.memoryStreamManager, ms, (int)this.pendingObjects, dataType, "new"); this.pendingObjects -= (uint)newStore.Count; return(newStore); }); return(store); }
public QueryableMultiValueData(PersistedDataType type, MemoryStream source, DimensionSet dimensionSet, int keyCount) : base(dimensionSet) { if (source.Length == 0) { this.keys = new BufferedKeyedData <uint>(null, 0, 0, dimensionSet); source.Dispose(); } else { this.keyStream = source; this.valueStream = null; var keyPortionLength = (int)BufferedKeyedData <uint> .GetBufferSizeForKeyCount(keyCount, dimensionSet); var sourceBuffer = source.GetBuffer(); var sourceLength = (int)source.Length; this.keys = new BufferedKeyedData <uint>(sourceBuffer, 0, keyPortionLength, dimensionSet); this.values = BufferedValueArray.Create(type, sourceBuffer, keyPortionLength, sourceLength - keyPortionLength); } }