public EnumWriter(IStreamProvider streamProvider, string columnPath, Type columnType, IColumnWriter valueWriter) { _streamProvider = streamProvider; _columnPath = columnPath; _valueWriter = valueWriter; _dictionary = (IEnumColumnDictionary)Allocator.ConstructGenericOf(typeof(EnumColumnDictionary <>), columnType); _rowIndexWriter = new PrimitiveArrayWriter <byte>(streamProvider.OpenWrite(Path.Combine(_columnPath, RowIndexFileName))); }
private void BuildJoinDictionary(CancellationToken cancellationToken) { // Validate the RHS is a seekable table (only on build, so that Suggest doesn't fail) ISeekableXTable joinToSource = _joinToSource as ISeekableXTable; if (joinToSource == null) { throw new ArgumentException($"Join requires a single built Binary Table as the right side table."); } XArray allJoinToValues = _joinToSeekGetter(ArraySelector.All(joinToSource.Count)); _joinDictionary = (IJoinDictionary)Allocator.ConstructGenericOf(typeof(JoinDictionary <>), _joinColumnType, allJoinToValues.Count); _joinDictionary.Add(allJoinToValues, 0); }
public CoalesceTransformFunction(IXTable source, XDatabaseContext context) { while (context.Parser.HasAnotherArgument) { IXColumn column = context.Parser.NextColumn(source, context); _columns.Add(column); } ValidateAllTypesMatch(_columns); IXColumn firstColumn = _columns[0]; IndicesType = firstColumn.IndicesType; ColumnDetails = new ColumnDetails(nameof(Coalesce), firstColumn.ColumnDetails.Type); _coalescer = (ICoalescer)Allocator.ConstructGenericOf(typeof(Coalescer <>), firstColumn.ColumnDetails.Type); }
public void Allocator_Basics() { int[] buffer = null; int[] previous; // Verify allocation happens on first call Allocator.AllocateToSize(ref buffer, 10); Assert.IsNotNull(buffer); Assert.AreEqual(10, buffer.Length); // Verify no re-allocation if size already fine previous = buffer; Allocator.AllocateToSize(ref buffer, 5); Assert.AreEqual(10, buffer.Length); Assert.ReferenceEquals(buffer, previous); previous = buffer; Allocator.AllocateToSize(ref buffer, 10); Assert.AreEqual(10, buffer.Length); Assert.ReferenceEquals(buffer, previous); // Verify generic allocator works Array generic = null; Allocator.AllocateToSize(ref generic, 10, typeof(int)); Assert.IsNotNull(generic as int[]); Assert.AreEqual(10, generic.Length); Array string8 = null; Allocator.AllocateToSize(ref string8, 1, typeof(String8)); Assert.IsNotNull(string8 as String8[]); Assert.AreEqual(1, string8.Length); // Verify generic object creators work object list; list = Allocator.ConstructGenericOf(typeof(List <>), typeof(int)); Assert.AreEqual(typeof(List <int>), list.GetType()); Assert.AreEqual(0, ((List <int>)list).Capacity); list = Allocator.ConstructGenericOf(typeof(List <>), typeof(int), 1000); Assert.AreEqual(typeof(List <int>), list.GetType()); Assert.AreEqual(1000, ((List <int>)list).Capacity); }