public override void Write(Thrift.SchemaElement tse, BinaryWriter writer, ArrayView values, DataColumnStatistics statistics) { int n = 0; byte b = 0; byte[] buffer = new byte[values.Count / 8 + 1]; int ib = 0; foreach (bool flag in values.GetValuesAndReturnArray <bool>()) { if (flag) { b |= (byte)(1 << n); } n++; if (n == 8) { buffer[ib++] = b; n = 0; b = 0; } } if (n != 0) { buffer[ib] = b; } writer.Write(buffer); }
public override void Write(Thrift.SchemaElement tse, BinaryWriter writer, ArrayView values, DataColumnStatistics statistics) { foreach (Interval interval in values.GetValuesAndReturnArray <Interval>()) { writer.Write(interval.Months); writer.Write(interval.Days); writer.Write(interval.Millis); } }
private void WriteAsFixedLengthByteArray(Thrift.SchemaElement tse, BinaryWriter writer, ArrayView values) { foreach (decimal d in values.GetValuesAndReturnArray <decimal>()) { var bd = new BigDecimal(d, tse.Precision, tse.Scale); byte[] itemData = bd.ToByteArray(); tse.Type_length = itemData.Length; //always re-set type length as it can differ from default type length writer.Write(itemData); } }
private void WriteAsInt64(Thrift.SchemaElement tse, BinaryWriter writer, ArrayView values) { double scaleFactor = Math.Pow(10, tse.Scale); foreach (decimal d in values.GetValuesAndReturnArray <decimal>()) { try { long l = (long)(d * (decimal)scaleFactor); writer.Write(l); } catch (OverflowException) { throw new ParquetException( $"value '{d}' is too large to fit into scale {tse.Scale} and precision {tse.Precision}"); } } }