当前位置: 首页>>代码示例>>C#>>正文


C# TFPos类代码示例

本文整理汇总了C#中TFPos的典型用法代码示例。如果您正苦于以下问题:C# TFPos类的具体用法?C# TFPos怎么用?C# TFPos使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TFPos类属于命名空间,在下文中一共展示了TFPos类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: read_all_backward_from_beginning_of_second_chunk_returns_no_records

 public void read_all_backward_from_beginning_of_second_chunk_returns_no_records()
 {
     var pos = new TFPos(10000, 10000);
     var events = ReadIndex.ReadAllEventsBackward(pos, 100).Records.Select(r => r.Event).ToArray();
     Assert.AreEqual(1, events.Length);
     Assert.AreEqual(_event1, events[0]);
 }
开发者ID:base31,项目名称:geteventstore_EventStore,代码行数:7,代码来源:when_deleting_single_stream_spanning_through_2_chunks_in_db_with_3_chunks.cs

示例2: ResolvedEvent

        public ResolvedEvent(
            string positionStreamId, int positionSequenceNumber, string eventStreamId, int eventSequenceNumber,
            bool resolvedLinkTo, TFPos position, TFPos originalPosition, Guid eventId, string eventType, bool isJson, byte[] data,
            byte[] metadata, byte[] positionMetadata, DateTime timestamp)
        {
            if (Guid.Empty == eventId)
                throw new ArgumentException("Empty eventId provided.");
            if (string.IsNullOrEmpty(eventType))
                throw new ArgumentException("Empty eventType provided.");

            _positionStreamId = positionStreamId;
            _positionSequenceNumber = positionSequenceNumber;
            _eventStreamId = eventStreamId;
            _eventSequenceNumber = eventSequenceNumber;
            _resolvedLinkTo = resolvedLinkTo;
            _position = position;
            _originalPosition = originalPosition;
            EventId = eventId;
            EventType = eventType;
            IsJson = isJson;
            Timestamp = timestamp;

            //TODO: handle utf-8 conversion exception
            Data = Helper.UTF8NoBom.GetString(data);
            Metadata = Helper.UTF8NoBom.GetString(metadata);
            PositionMetadata = positionMetadata != null ? Helper.UTF8NoBom.GetString(positionMetadata) : null;
        }
开发者ID:nchistyakov,项目名称:EventStore-1,代码行数:27,代码来源:ResolvedEvent.cs

示例3: ResolvedEvent

        public ResolvedEvent(
            string positionStreamId, int positionSequenceNumber, string eventStreamId, int eventSequenceNumber,
            bool resolvedLinkTo, TFPos position, Guid eventId, string eventType, bool isJson, string data,
            string metadata, string positionMetadata = null, string streamMetadata = null)
        {
            DateTime timestamp = default(DateTime);
            if (Guid.Empty == eventId)
                throw new ArgumentException("Empty eventId provided.");
            if (string.IsNullOrEmpty(eventType))
                throw new ArgumentException("Empty eventType provided.");

            _positionStreamId = positionStreamId;
            _positionSequenceNumber = positionSequenceNumber;
            _eventStreamId = eventStreamId;
            _eventSequenceNumber = eventSequenceNumber;
            _resolvedLinkTo = resolvedLinkTo;
            _position = position;
            EventId = eventId;
            EventType = eventType;
            IsJson = isJson;
            Timestamp = timestamp;

            Data = data;
            Metadata = metadata;
            PositionMetadata = positionMetadata;
            StreamMetadata = streamMetadata;
        }
开发者ID:msbahrul,项目名称:EventStore,代码行数:27,代码来源:ResolvedEvent.cs

示例4: read_all_events_backward_returns_all_events_in_correct_order

        public void read_all_events_backward_returns_all_events_in_correct_order()
        {
            var pos = new TFPos(Db.Config.WriterCheckpoint.Read(), Db.Config.WriterCheckpoint.Read());
            var records = ReadIndex.ReadAllEventsBackward(pos, 10, false).Records;

            Assert.AreEqual(2, records.Count);
            Assert.AreEqual(_id1, records[1].Event.EventId);
            Assert.AreEqual(_id2, records[0].Event.EventId);
        }
开发者ID:soto,项目名称:EventStore,代码行数:9,代码来源:when_building_an_index_off_tfile_with_two_events_in_stream.cs

示例5: IndexReadAllResult

        public IndexReadAllResult(List<CommitEventRecord> records, TFPos currentPos, TFPos nextPos, TFPos prevPos)
        {
            Ensure.NotNull(records, "records");

            Records = records;
            CurrentPos = currentPos;
            NextPos = nextPos;
            PrevPos = prevPos;
        }
开发者ID:thinkbeforecoding,项目名称:EventStore,代码行数:9,代码来源:IndexReadAllResult.cs

示例6: SubscribeAwake

 public SubscribeAwake(
     IEnvelope envelope, Guid correlationId, string streamId, TFPos @from, Message replyWithMessage)
 {
     StreamId = streamId;
     From = @from;
     ReplyWithMessage = replyWithMessage;
     Envelope = envelope;
     CorrelationId = correlationId;
 }
开发者ID:kijanawoodard,项目名称:EventStore,代码行数:9,代码来源:AwakeReaderServiceMessage.cs

示例7: ReadAllResult

        public ReadAllResult(ResolvedEventRecord[] records, int maxCount, TFPos currentPos, TFPos nextPos, TFPos prevPos, long tfEofPosition)
        {
            Ensure.NotNull(records, "records");

            Records = records;
            MaxCount = maxCount;
            CurrentPos = currentPos;
            NextPos = nextPos;
            PrevPos = prevPos;
            TfEofPosition = tfEofPosition;
        }
开发者ID:robashton,项目名称:EventStore,代码行数:11,代码来源:ReadAllResult.cs

示例8: ReadAllResult

        public ReadAllResult(ResolvedEvent[] events, int maxCount, TFPos currentPos, TFPos nextPos, TFPos prevPos, long tfEofPosition)
        {
            Ensure.NotNull(events, "events");

            Events = events;
            MaxCount = maxCount;
            CurrentPos = currentPos;
            NextPos = nextPos;
            PrevPos = prevPos;
            TfEofPosition = tfEofPosition;
        }
开发者ID:base31,项目名称:geteventstore_EventStore,代码行数:11,代码来源:ReadAllResult.cs

示例9: GetAllBefore

 public void GetAllBefore(HttpEntity entity, TFPos position, int count)
 {
     var envelope = new SendToHttpEnvelope(entity,
                                           Format.Atom.ReadAllEventsBackwardCompleted,
                                           Configure.ReadAllEventsBackwardCompleted);
     Publish(new ClientMessage.ReadAllEventsBackward(Guid.NewGuid(),
                                                     envelope,
                                                     position.CommitPosition,
                                                     position.PreparePosition,
                                                     count,
                                                     true));
 }
开发者ID:robashton,项目名称:EventStore,代码行数:12,代码来源:AtomControllerDefinitions.cs

示例10: all_records_can_be_read_sequentially_page_by_page_in_backward_pass

        public void all_records_can_be_read_sequentially_page_by_page_in_backward_pass()
        {
            var recs = new[] { _p5, _p3, _p1, _p4, _p2 }; // in reverse committed order

            int count = 0;
            var pos = new TFPos(Db.Config.WriterCheckpoint.Read(), Db.Config.WriterCheckpoint.Read());
            ReadAllResult result;
            while ((result = ReadIndex.ReadAllEventsBackward(pos, 1, false)).Records.Count != 0)
            {
                Assert.AreEqual(1, result.Records.Count);
                Assert.AreEqual(recs[count], result.Records[0].Event);
                pos = result.NextPos;
                count += 1;
            }
            Assert.AreEqual(recs.Length, count);
        }
开发者ID:soto,项目名称:EventStore,代码行数:16,代码来源:when_having_two_intermingled_transactions_and_some_uncommited_prepares_in_the_end_read_index_should.cs

示例11: all_records_can_be_read_sequentially_page_by_page_in_forward_pass

        public void all_records_can_be_read_sequentially_page_by_page_in_forward_pass()
        {
            var recs = new[] {_p2, _p4, _p1, _p3, _p5}; // in committed order

            int count = 0;
            var pos = new TFPos(0, 0);
            ReadAllResult result;
            while ((result = ReadIndex.ReadAllEventsForward(pos, 1, false)).Records.Count != 0)
            {
                Assert.AreEqual(1, result.Records.Count);
                Assert.AreEqual(recs[count], result.Records[0].Event);
                pos = result.NextPos;
                count += 1;
            }
            Assert.AreEqual(recs.Length, count);
        }
开发者ID:soto,项目名称:EventStore,代码行数:16,代码来源:when_having_two_intermingled_transactions_and_some_uncommited_prepares_in_the_end_read_index_should.cs

示例12: IndexReadAllResult

        public IndexReadAllResult(List<CommitEventRecord> records, 
                                  int maxCount, 
                                  TFPos currentPos, 
                                  TFPos nextPos, 
                                  TFPos prevPos, 
                                  long tfEofPosition)
        {
            Ensure.NotNull(records, "records");

            Records = records;
            MaxCount = maxCount;
            CurrentPos = currentPos;
            NextPos = nextPos;
            PrevPos = prevPos;
            TfEofPosition = tfEofPosition;
        }
开发者ID:robashton,项目名称:EventStore,代码行数:16,代码来源:IndexReadAllResult.cs

示例13: Given

            //private TFPos _tfPos2;
            //private TFPos _tfPos3;

            protected override void Given()
            {
                base.Given();
                _tfPos1 = ExistingEvent("test-stream", "type1", "{}", "{Data: 1}");
                //_tfPos2 = ExistingEvent("test-stream", "type1", "{}", "{Data: 2}");
                //_tfPos3 = ExistingEvent("test-stream", "type2", "{}", "{Data: 3}");

                ExistingEvent("$et-type1", "$>", TFPosToMetadata(_tfPos1), "[email protected]");
                NoStream("$et-type2");
                NoStream("$et");
                //NOTE: the following events should be late written
                //ExistingEvent("$et-type2", "$>", "", "[email protected]");
                //ExistingEvent("$et-type1", "$>", "", "[email protected]");

                _querySourcesDefinition = new QuerySourcesDefinition
                    {
                        AllStreams = true,
                        Events = new[] {"type1", "type2"},
                        Options = new QuerySourcesDefinitionOptions {}
                    };
                _fromPosition = CheckpointTag.FromEventTypeIndexPositions(new TFPos(0, -1), new Dictionary<string, int>{{"type1", -1}, {"type2", -1}});
                _maxEvents = 1; // reading the first event
            }
开发者ID:jjvdangelo,项目名称:EventStore,代码行数:26,代码来源:feed_reader_by_event_indexes.cs

示例14: position_returned_for_prev_page_when_traversing_backward_allow_to_traverse_forward_correctly

        public void position_returned_for_prev_page_when_traversing_backward_allow_to_traverse_forward_correctly()
        {
            var recs = new[] { _p5, _p3, _p1, _p4, _p2 }; // in reverse committed order

            int count = 0;
            var pos = new TFPos(Db.Config.WriterCheckpoint.Read(), Db.Config.WriterCheckpoint.Read());
            ReadAllResult result;
            while ((result = ReadIndex.ReadAllEventsBackward(pos, 1, false)).Records.Count != 0)
            {
                Assert.AreEqual(1, result.Records.Count);
                Assert.AreEqual(recs[count], result.Records[0].Event);

                var localPos = result.PrevPos;
                int localCount = 0;
                ReadAllResult localResult;
                while ((localResult = ReadIndex.ReadAllEventsForward(localPos, 1, false)).Records.Count != 0)
                {
                    Assert.AreEqual(1, localResult.Records.Count);
                    Assert.AreEqual(recs[count - 1 - localCount], localResult.Records[0].Event);
                    localPos = localResult.NextPos;
                    localCount += 1;
                }

                pos = result.NextPos;
                count += 1;
            }
            Assert.AreEqual(recs.Length, count);
        }
开发者ID:soto,项目名称:EventStore,代码行数:28,代码来源:when_having_two_intermingled_transactions_and_some_uncommited_prepares_in_the_end_read_index_should.cs

示例15: TFPos

        /// <summary>
        /// Returns event records in the sequence they were committed into TF.
        /// Positions is specified as pre-positions (pointer at the beginning of the record).
        /// </summary>
        IndexReadAllResult IReadIndex.ReadAllEventsForward(TFPos pos, int maxCount)
        {
            var lastCommitPosition = Interlocked.Read(ref _lastCommitPosition);

            var records = new List<CommitEventRecord>();
            var nextPos = pos;
            // in case we are at position after which there is no commit at all, in that case we have to force 
            // PreparePosition to int.MaxValue, so if you decide to read backwards from PrevPos, 
            // you will receive all prepares.
            var prevPos = new TFPos(pos.CommitPosition, int.MaxValue);
            var count = 0;
            bool firstCommit = true;
            ITransactionFileSequentialReader seqReader = GetSeqReader();
            try
            {
                long nextCommitPos = pos.CommitPosition;
                while (count < maxCount)
                {
                    seqReader.Reposition(nextCommitPos);

                    SeqReadResult result;
                    do
                    {
                        result = seqReader.TryReadNext();
                    }
                    while (result.Success && result.LogRecord.RecordType != LogRecordType.Commit); // skip until commit

                    if (!result.Success) // no more records in TF
                        break;

                    nextCommitPos = result.RecordPostPosition;

                    var commit = (CommitLogRecord)result.LogRecord;
                    if (firstCommit)
                    {
                        firstCommit = false;
                        // for backward pass we want to allow read the same commit and skip read prepares, 
                        // so we put post-position of commit and post-position of prepare as TFPos for backward pass
                        prevPos = new TFPos(result.RecordPostPosition, pos.PreparePosition);
                    }

                    seqReader.Reposition(commit.TransactionPosition);
                    while (count < maxCount)
                    {
                        result = seqReader.TryReadNext();
                        if (!result.Success) // no more records in TF
                            break;
                        // prepare with TransactionEnd could be scavenged already
                        // so we could reach the same commit record. In that case have to stop
                        if (result.LogRecord.Position >= commit.Position) 
                            break;
                        if (result.LogRecord.RecordType != LogRecordType.Prepare) 
                            continue;

                        var prepare = (PrepareLogRecord)result.LogRecord;
                        if (prepare.TransactionPosition != commit.TransactionPosition) // wrong prepare
                            continue;

                        // prepare with useful data or delete tombstone
                        if ((prepare.Flags & (PrepareFlags.Data | PrepareFlags.StreamDelete)) != 0) 
                        {
                            if (new TFPos(commit.Position, prepare.LogPosition) >= pos)
                            {
                                var eventRecord = new EventRecord(commit.FirstEventNumber + prepare.TransactionOffset, prepare);
                                records.Add(new CommitEventRecord(eventRecord, commit.Position));
                                count++;

                                // for forward pass position is inclusive, 
                                // so we put pre-position of commit and post-position of prepare
                                nextPos = new TFPos(commit.LogPosition, result.RecordPostPosition); 
                            }
                        }

                        if ((prepare.Flags & PrepareFlags.TransactionEnd) != 0)
                            break;
                    }
                }
            }
            finally
            {
                ReturnSeqReader(seqReader);
            }
            return new IndexReadAllResult(records, maxCount, pos, nextPos, prevPos, lastCommitPosition);
        }
开发者ID:base31,项目名称:geteventstore_EventStore,代码行数:88,代码来源:ReadIndex.cs


注:本文中的TFPos类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。