Esempio n. 1
0
        public void TestTableFromRecordBatches()
        {
            RecordBatch         recordBatch1  = TestData.CreateSampleRecordBatch(length: 10, true);
            RecordBatch         recordBatch2  = TestData.CreateSampleRecordBatch(length: 10, true);
            IList <RecordBatch> recordBatches = new List <RecordBatch>()
            {
                recordBatch1, recordBatch2
            };

            Table table1 = Table.TableFromRecordBatches(recordBatch1.Schema, recordBatches);

            Assert.Equal(20, table1.RowCount);
            Assert.Equal(21, table1.ColumnCount);

            FixedSizeBinaryType type = new FixedSizeBinaryType(17);
            Field  newField1         = new Field(type.Name, type, false);
            Schema newSchema1        = recordBatch1.Schema.SetField(20, newField1);

            Assert.Throws <ArgumentException>(() => Table.TableFromRecordBatches(newSchema1, recordBatches));

            List <Field> fields = new List <Field>();

            Field.Builder fieldBuilder = new Field.Builder();
            fields.Add(fieldBuilder.Name("Ints").DataType(Int32Type.Default).Nullable(true).Build());
            fieldBuilder = new Field.Builder();
            fields.Add(fieldBuilder.Name("Strings").DataType(StringType.Default).Nullable(true).Build());
            StructType structType = new StructType(fields);

            Field  newField2  = new Field(structType.Name, structType, false);
            Schema newSchema2 = recordBatch1.Schema.SetField(16, newField2);

            Assert.Throws <ArgumentException>(() => Table.TableFromRecordBatches(newSchema2, recordBatches));
        }
Esempio n. 2
0
            public void Visit(FixedSizeBinaryType actualType)
            {
                Assert.IsAssignableFrom <FixedSizeBinaryType>(_expectedType);
                var expectedType = (FixedSizeBinaryType)_expectedType;

                Assert.Equal(expectedType.ByteWidth, actualType.ByteWidth);
            }
            private ArrayData GetDecimalArrayData(FixedSizeBinaryType type)
            {
                ArrowBuffer validityBuffer = GetValidityBuffer(out int nullCount);

                var json = JsonFieldData.Data.GetRawText();

                string[] values = JsonSerializer.Deserialize <string[]>(json, s_options);

                Span <byte> buffer = stackalloc byte[type.ByteWidth];

                ArrowBuffer.Builder <byte> valueBuilder = new ArrowBuffer.Builder <byte>();
                foreach (string value in values)
                {
                    buffer.Fill(0);

                    BigInteger bigInteger = BigInteger.Parse(value);
                    if (!bigInteger.TryWriteBytes(buffer, out int bytesWritten, false, !BitConverter.IsLittleEndian))
                    {
                        throw new InvalidDataException($"Decimal data was too big to fit into {type.BitWidth} bits.");
                    }

                    if (bigInteger.Sign == -1)
                    {
                        buffer.Slice(bytesWritten).Fill(255);
                    }

                    valueBuilder.Append(buffer);
                }
                ArrowBuffer valueBuffer = valueBuilder.Build(default);
Esempio n. 4
0
 public void Visit(FixedSizeBinaryType actualType)
 {
     if (_expectedType is FixedSizeBinaryType expectedType &&
         expectedType.ByteWidth == actualType.ByteWidth)
     {
         _dataTypeMatch = true;
     }
 }
Esempio n. 5
0
            public void Visit(FixedSizeBinaryType type)
            {
                ArrowBuffer.Builder <byte> valueBuilder = new ArrowBuffer.Builder <byte>();

                int valueSize = type.BitWidth;

                for (int i = 0; i < Length; i++)
                {
                    valueBuilder.Append(Enumerable.Repeat((byte)i, valueSize).ToArray());
                }

                ArrowBuffer validityBuffer = ArrowBuffer.Empty;
                ArrowBuffer valueBuffer    = valueBuilder.Build(default);
Esempio n. 6
0
 public void Visit(FixedSizeBinaryType array) => throw new NotImplementedException();
Esempio n. 7
0
 public void Visit(FixedSizeBinaryType type)
 {
     Result = FieldType.Build(
         Flatbuf.Type.FixedSizeBinary,
         Flatbuf.FixedSizeBinary.CreateFixedSizeBinary(Builder, type.ByteWidth));
 }