private XArray Get(int count) { if (IsNull) { return(XArray.Null(_array, count)); } return(XArray.Single(_array, count)); }
public ConstantColumn(IXTable source, object value, Type type, bool wasUnwrappedLiteral = false) { Source = source; Allocator.AllocateToSize(ref _array, 1, type); _array.SetValue(value, 0); IsNull = (value == null || value.Equals("null")); _xArray = (IsNull ? XArray.Null(_array, 1) : XArray.Single(_array, 1)); WasUnwrappedLiteral = wasUnwrappedLiteral; ColumnDetails = new ColumnDetails(string.Empty, type); }
public Func <XArray> CurrentGetter() { _isSubscribed = true; return(() => { if (_currentGetter != null) { return _currentGetter(); } return XArray.Null(_nullArray, _table.CurrentRowCount); }); }
private XArray Get() { return(_isNull ? XArray.Null(_array, _source.CurrentRowCount) : XArray.Single(_array, _source.CurrentRowCount)); }
public XArray Divide(XArray left, XArray right) { long[] leftArray = (long[])left.Array; long[] rightArray = (long[])right.Array; int count = left.Count; if (right.Count != count) { throw new InvalidOperationException("Computations must get the same number of rows from each argument."); } bool areAnyNull = false; // Allocate for results Allocator.AllocateToSize(ref _buffer, count); Allocator.AllocateToSize(ref _isNull, count); // Check how the XArrays are configured and run the fastest loop possible for the configuration. if (left.HasNulls || right.HasNulls) { for (int i = 0; i < count; ++i) { int index1 = left.Index(i); int index2 = right.Index(i); bool rowIsNull = (left.HasNulls && left.NullRows[index1]) || (right.HasNulls && right.NullRows[index2]); DivideSafe(leftArray[index1], rightArray[index2], out _buffer[i], out _isNull[i], ref areAnyNull); _isNull[i] |= rowIsNull; areAnyNull |= rowIsNull; } } else if (left.Selector.Indices != null || right.Selector.Indices != null) { for (int i = 0; i < left.Count; ++i) { DivideSafe(leftArray[left.Index(i)], rightArray[right.Index(i)], out _buffer[i], out _isNull[i], ref areAnyNull); } } else if (!right.Selector.IsSingleValue && !left.Selector.IsSingleValue) { int leftStart = left.Selector.StartIndexInclusive; int rightStart = right.Selector.StartIndexInclusive; for (int i = 0; i < count; ++i) { DivideSafe(leftArray[i + leftStart], rightArray[i + rightStart], out _buffer[i], out _isNull[i], ref areAnyNull); } } else if (!left.Selector.IsSingleValue) { int leftStart = left.Selector.StartIndexInclusive; long rightValue = rightArray[right.Selector.StartIndexInclusive]; for (int i = 0; i < count; ++i) { DivideSafe(leftArray[i + leftStart], rightValue, out _buffer[i], out _isNull[i], ref areAnyNull); } } else if (!right.Selector.IsSingleValue) { long leftValue = leftArray[left.Selector.StartIndexInclusive]; int rightStart = right.Selector.StartIndexInclusive; for (int i = 0; i < count; ++i) { DivideSafe(leftValue, rightArray[i + rightStart], out _buffer[i], out _isNull[i], ref areAnyNull); } } else { DivideSafe(leftArray[left.Selector.StartIndexInclusive], rightArray[right.Selector.StartIndexInclusive], out _buffer[0], out _isNull[0], ref areAnyNull); return(areAnyNull ? XArray.Null(_buffer, count) : XArray.Single(_buffer, count)); } return(XArray.All(_buffer, count, (areAnyNull ? _isNull : null))); }