Esempio n. 1
0
        public static void CompareBatches(RecordBatch expectedBatch, RecordBatch actualBatch)
        {
            SchemaComparer.Compare(expectedBatch.Schema, actualBatch.Schema);
            Assert.Equal(expectedBatch.Length, actualBatch.Length);
            Assert.Equal(expectedBatch.ColumnCount, actualBatch.ColumnCount);

            for (int i = 0; i < expectedBatch.ColumnCount; i++)
            {
                IArrowArray expectedArray = expectedBatch.Arrays.ElementAt(i);
                IArrowArray actualArray   = actualBatch.Arrays.ElementAt(i);

                actualArray.Accept(new ArrayComparer(expectedArray));
            }
        }
Esempio n. 2
0
        public static void CompareBatches(RecordBatch expectedBatch, RecordBatch actualBatch, bool strictCompare = true)
        {
            SchemaComparer.Compare(expectedBatch.Schema, actualBatch.Schema);
            Assert.Equal(expectedBatch.Length, actualBatch.Length);
            Assert.Equal(expectedBatch.ColumnCount, actualBatch.ColumnCount);

            for (int i = 0; i < expectedBatch.ColumnCount; i++)
            {
                IArrowArray expectedArray = expectedBatch.Arrays.ElementAt(i);
                IArrowArray actualArray   = actualBatch.Arrays.ElementAt(i);

                CompareArrays(expectedArray, actualArray, strictCompare);
            }
        }
            public void MetadataConstruction()
            {
                var metadata0 = new Dictionary <string, string> {
                    { "foo", "bar" }, { "bizz", "buzz" }
                };
                var metadata1 = new Dictionary <string, string> {
                    { "foo", "bar" }
                };
                var   metadata0Copy = new Dictionary <string, string>(metadata0);
                var   metadata1Copy = new Dictionary <string, string>(metadata1);
                Field f0            = new Field.Builder().Name("f0").DataType(Int32Type.Default).Build();
                Field f1            = new Field.Builder().Name("f1").DataType(UInt8Type.Default).Nullable(false).Build();
                Field f2            = new Field.Builder().Name("f2").DataType(StringType.Default).Build();
                Field f3            = new Field.Builder().Name("f2").DataType(StringType.Default).Metadata(metadata1Copy).Build();

                var schema0 = new Schema.Builder()
                              .Field(f0)
                              .Field(f1)
                              .Field(f2)
                              .Metadata(metadata0)
                              .Build();
                var schema1 = new Schema.Builder()
                              .Field(f0)
                              .Field(f1)
                              .Field(f2)
                              .Metadata(metadata1)
                              .Build();
                var schema2 = new Schema.Builder()
                              .Field(f0)
                              .Field(f1)
                              .Field(f2)
                              .Metadata(metadata0Copy)
                              .Build();
                var schema3 = new Schema.Builder()
                              .Field(f0)
                              .Field(f1)
                              .Field(f3)
                              .Metadata(metadata0Copy)
                              .Build();

                Assert.True(metadata0.Keys.SequenceEqual(schema0.Metadata.Keys) && metadata0.Values.SequenceEqual(schema0.Metadata.Values));
                Assert.True(metadata1.Keys.SequenceEqual(schema1.Metadata.Keys) && metadata1.Values.SequenceEqual(schema1.Metadata.Values));
                Assert.True(metadata0.Keys.SequenceEqual(schema2.Metadata.Keys) && metadata0.Values.SequenceEqual(schema2.Metadata.Values));
                SchemaComparer.Compare(schema0, schema2);
                Assert.Throws <EqualException>(() => SchemaComparer.Compare(schema0, schema1));
                Assert.Throws <EqualException>(() => SchemaComparer.Compare(schema2, schema1));
                Assert.Throws <EqualException>(() => SchemaComparer.Compare(schema2, schema3));
            }
        public void WritesEmptyFile()
        {
            RecordBatch originalBatch = TestData.CreateSampleRecordBatch(length: 1);

            var stream = new MemoryStream();
            var writer = new ArrowStreamWriter(stream, originalBatch.Schema);

            writer.WriteStart();
            writer.WriteEnd();

            stream.Position = 0;

            var         reader    = new ArrowStreamReader(stream);
            RecordBatch readBatch = reader.ReadNextRecordBatch();

            Assert.Null(readBatch);
            SchemaComparer.Compare(originalBatch.Schema, reader.Schema);
        }
        public async Task WritesEmptyFile()
        {
            RecordBatch originalBatch = TestData.CreateSampleRecordBatch(length: 1);

            var stream = new MemoryStream();
            var writer = new ArrowFileWriter(stream, originalBatch.Schema);

            writer.WriteStart();
            writer.WriteEnd();

            stream.Position = 0;

            var reader = new ArrowFileReader(stream);
            int count  = await reader.RecordBatchCountAsync();

            Assert.Equal(0, count);
            RecordBatch readBatch = reader.ReadNextRecordBatch();

            Assert.Null(readBatch);
            SchemaComparer.Compare(originalBatch.Schema, reader.Schema);
        }
Esempio n. 6
0
 private void CompareSchemas(Schema expectedSchema, Schema actualSchema)
 {
     Assert.True(SchemaComparer.Equals(expectedSchema, actualSchema));
 }