示例#1
0
 public Chunk(
     AvroReader avroReader,
     long blockOffset,
     long eventIndex)
 {
     _avroReader = avroReader;
     BlockOffset = blockOffset;
     EventIndex  = eventIndex;
 }
示例#2
0
 public Chunk(
     AvroReader avroReader,
     long blockOffset,
     long eventIndex,
     string chunkPath)
 {
     _avroReader = avroReader;
     BlockOffset = blockOffset;
     EventIndex  = eventIndex;
     ChunkPath   = chunkPath;
 }
示例#3
0
 public BlobQuickQueryStream(
     Stream avroStream,
     IProgress <long> progressHandler     = default,
     Action <BlobQueryError> errorHandler = default)
 {
     _avroStream      = avroStream;
     _avroReader      = new AvroReader(_avroStream);
     _bufferOffset    = 0;
     _bufferLength    = 0;
     _progressHandler = progressHandler;
     _errorHandler    = errorHandler;
 }
示例#4
0
        public async Task Tests()
        {
            List <TestCase> testCases = new List <TestCase>
            {
                new TestCase("test_null_0.avro", o => Assert.IsNull(o)),                                                // null
                new TestCase("test_null_1.avro", o => Assert.AreEqual(true, (bool)o)),                                  // bool
                new TestCase("test_null_2.avro", o => Assert.AreEqual("adsfasdf09809dsf-=adsf", (string)o)),            // string
                new TestCase("test_null_3.avro", o => Assert.AreEqual(Encoding.UTF8.GetBytes("12345abcd"), (byte[])o)), // byte[]
                new TestCase("test_null_4.avro", o => Assert.AreEqual(1234, (int)o)),                                   // int
                new TestCase("test_null_5.avro", o => Assert.AreEqual(1234L, (long)o)),                                 // long
                new TestCase("test_null_6.avro", o => Assert.AreEqual(1234.0, (float)o)),                               // float
                new TestCase("test_null_7.avro", o => Assert.AreEqual(1234.0, (double)o)),                              // fouble
                // Not supported today.
                //new TestCase("test_null_8.avro", o => Assert.AreEqual(Encoding.UTF8.GetBytes("B"), (byte[])o)), // fixed
                new TestCase("test_null_9.avro", o => Assert.AreEqual("B", (string)o)), // enum
                // Not supported today.
                // new TestCase("test_null_10.avro", o => Assert.AreEqual(new List<long>() { 1, 2, 3 }, (List<long>)o)), // array
                new TestCase("test_null_11.avro", o => Assert.AreEqual(
                                 new Dictionary <string, int>()
                {
                    { "a", 1 }, { "b", 3 }, { "c", 2 }
                }, (Dictionary <string, object>)o)),                      // dictionary
                new TestCase("test_null_12.avro", o => Assert.IsNull(o)), // union
                new TestCase("test_null_13.avro", o =>                    // record
                {
                    Dictionary <string, object> expected = new Dictionary <string, object>()
                    {
                        { "$schema", "Test" }, { "f", 5 }
                    };
                    Dictionary <string, object> actual = (Dictionary <string, object>)o;
                    Assert.AreEqual(expected.Count, actual.Count);
                    foreach (KeyValuePair <string, object> keyValuePair in actual)
                    {
                        Assert.AreEqual(expected[keyValuePair.Key], keyValuePair.Value);
                    }
                })
            };

            foreach (TestCase testCase in testCases)
            {
                // Arrange
                using FileStream stream = File.OpenRead(
                          $"{Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)}{Path.DirectorySeparatorChar}Resources{Path.DirectorySeparatorChar}{testCase.Path}");
                AvroReader avroReader = new AvroReader(stream);

                // Act
                object o = await avroReader.Next(async : true).ConfigureAwait(false);

                testCase.Predicate(o);
            }
        }
        public async Task AvroTest()
        {
            using Stream stream = File.OpenRead($"{Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)}{Path.DirectorySeparatorChar}Resources{Path.DirectorySeparatorChar}{""}");
            AvroReader avroReader = new AvroReader(stream);
            Chunk      chunk      = new Chunk(
                avroReader: avroReader,
                blockOffset: 0,
                eventIndex: 0,
                chunkPath: null);

            List <BlobChangeFeedEvent> events = new List <BlobChangeFeedEvent>();

            while (chunk.HasNext())
            {
                BlobChangeFeedEvent changeFeedEvent = await chunk.Next(async : true);

                events.Add(changeFeedEvent);
            }
        }
示例#6
0
 private AvroSchema(ISchemaInfo schemaInfo) : base(schemaInfo)
 {
     SchemaInfo = schemaInfo;
     Reader     = new AvroReader <T>(schema);
     Writer     = new AvroWriter <T>(schema);
 }