public static void DoExperiment3() { var file = MemoryMappedFile.CreateOrOpen("testFile-headers", HeaderSize); var accessor = file.CreateViewAccessor(0, HeaderSize); ulong readOffset = 0; accessor.Read <ulong>(0, out readOffset); var x = 3; ConsumerRecord[] readConsumerRecords = new ConsumerRecord[x]; accessor.ReadArray <ConsumerRecord>(MaxWriteOffsetHeaderSize, readConsumerRecords, 0, 1); Console.WriteLine($"returnedOffset: {readOffset}, consumer record id: {readConsumerRecords.ToString()}"); }
public static void DoExperiment1() { var file = MemoryMappedFile.CreateOrOpen("testFile-headers", HeaderSize); ulong offset = 34534; var MaxWriteOffsetStream = file.CreateViewStream(0, HeaderSize); var offsetBytes = BitConverter.GetBytes(offset); MaxWriteOffsetStream.Write(offsetBytes, 0, offsetBytes.Length); var accessor = file.CreateViewAccessor(0, HeaderSize); accessor.Write(0, offset); var consumerRecords = new List <ConsumerRecord>() { new ConsumerRecord() { id = 12, lastConsumedIndex = 24 }, new ConsumerRecord() { id = 32532, lastConsumedIndex = 36 } }; accessor.WriteArray <ConsumerRecord>(MaxWriteOffsetHeaderSize, consumerRecords.ToArray(), 0, consumerRecords.Count); ulong readOffset = 0; accessor.Read <ulong>(0, out readOffset); var x = 3; ConsumerRecord[] readConsumerRecords = new ConsumerRecord[x]; accessor.ReadArray <ConsumerRecord>(MaxWriteOffsetHeaderSize, readConsumerRecords, 0, 1); Console.WriteLine($"returnedOffset: {readOffset}, consumer record id: {readConsumerRecords.ToString()}"); }