private static IStreamable <Empty, int> CreateSequentialStreamable(int length, MemoryPool <Empty, int> pool) { // Construct event batches from input. var batches = new List <StreamMessage <Empty, int> >(); var batch = StreamMessageManager.GetStreamMessage(pool); for (int i = 0; i < length; i++) { batch.Add(0, DateTimeOffset.MaxValue.UtcTicks, Empty.Default, i); if (batch.Count == Config.DataBatchSize) { batches.Add(batch); batch = StreamMessageManager.GetStreamMessage(pool); } } if (batch.Count > 0) { batches.Add(batch); } // Add last CTI of infinity. // TODO: inline this punctuation // batches.Add(new StreamMessage<Empty, int>(StreamMessageKind.Punctuation, DateTimeOffset.MaxValue.UtcTicks)); // Convert to IStreamable. return(batches.ToObservable().CreateStreamable()); }
public bool Get(out StreamMessage <TKey, TPayload> result) { if (!this.batchQueue.TryDequeue(out result)) { result = this.IsColumnar ? StreamMessageManager.GetStreamMessage(this.memoryPool) : new StreamMessage <TKey, TPayload>(this.memoryPool); Interlocked.Increment(ref this.createdObjects); } return(true); }
private static IStreamable <Empty, int> CloneInputToStreamable(List <StreamMessage <Empty, int> > inputSequence) { // Clone each batch in the input sequence var batches = new List <StreamMessage <Empty, int> >(); foreach (var inputBatch in inputSequence) { var batch = StreamMessageManager.GetStreamMessage(inputBatch.memPool); batch.CloneFrom(inputBatch); batches.Add(batch); } // Convert the batches to IStreamable. return(batches.ToObservable().CreateStreamable()); }
private static List <StreamMessage <Empty, int> > CreateInputData(int length, MemoryPool <Empty, int> pool) { // Construct event batches from input. var batches = new List <StreamMessage <Empty, int> >(); var batch = StreamMessageManager.GetStreamMessage(pool); batch.Allocate(); for (int i = 0; i < length; i++) { batch.Add(0, StreamEvent.InfinitySyncTime, Empty.Default, i); if (batch.Count == Config.DataBatchSize) { batches.Add(batch); batch = StreamMessageManager.GetStreamMessage(pool); batch.Allocate(); } } // Add last CTI of infinity. batch.AddPunctuation(StreamEvent.InfinitySyncTime); batches.Add(batch); return(batches); }