Skip to content
Snippets Groups Projects
llama-base-responses-evaluation-pass-10.csv 499 KiB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000
original code,model inference,reference inference,evaluation feedback,score
"using System.Reflection;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following 
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.

[assembly: AssemblyTitle(""Omego.SimpleFtp.Tests.Integration"")]
[assembly: AssemblyDescription("""")]
[assembly: AssemblyConfiguration("""")]
[assembly: AssemblyCompany("""")]
[assembly: AssemblyProduct(""Omego.SimpleFtp.Tests.Integration"")]
[assembly: AssemblyCopyright(""Copyright ©  2016"")]
[assembly: AssemblyTrademark("""")]
[assembly: AssemblyCulture("""")]

// Setting ComVisible to false makes the types in this assembly not visible 
// to COM components.  If you need to access a type in this assembly from 
// COM, set the ComVisible attribute to true on that type.

[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM

[assembly: Guid(""ea422389-3860-4325-be23-cb5020c5a75d"")]

// Version information for an assembly consists of the following four values:
//
//      Major Version
//      Minor Version 
//      Build Number
//      Revision
//
// You can specify all the values or you can default the Build and Revision Numbers 
// by using the '*' as shown below:
// [assembly: AssemblyVersion(""1.0.*"")]

[assembly: AssemblyVersion(""1.0.0.0"")]
[assembly: AssemblyFileVersion(""1.0.0.0"")]","
using System.Reflection;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following 
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.

[assembly: AssemblyTitle(""SimpleFtpIntegrationTests"")]
[assembly: AssemblyDescription(""This is a description of the SimpleFtpIntegrationTests assembly."")]
[assembly: AssemblyConfiguration("""")]
[assembly: AssemblyCompany(""Your Company Name"")]
[assembly: AssemblyProduct(""SimpleFtpIntegrationTests"")]
[assembly: AssemblyCopyright(""Copyright Your Company Name 2024"")]
[assembly: AssemblyTrademark("""")]
[assembly: AssemblyCulture("""")]

// Setting ComVisible to false makes the types in this assembly not visible 
// to COM components.  If you need to access a type in this assembly from 
// COM, set the ComVisible attribute to true on that type.

[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM

[assembly: Guid(""your-guid-here"")]

// Version information for an assembly consists of the following four values:
//
//      Major Version
//      Minor Version 
//      Build Number
//      Revision
//
// You can specify all the values or you can default the Build and Revision Numbers 
// by using the '*' as shown below:
// [assembly: AssemblyVersion(""1.0.*"")]

[assembly: AssemblyVersion(""2.0.0.0"")]
[assembly: AssemblyFileVersion(""2.0.0.0"")]
","
using System.Reflection;
using System.Runtime.InteropServices;

[assembly: AssemblyTitle(""Omego.SimpleFtp.Tests.Integration"")]
[assembly: AssemblyDescription("""")]
[assembly: AssemblyConfiguration("""")]
[assembly: AssemblyCompany("""")]
[assembly: AssemblyProduct(""Omego.SimpleFtp.Tests.Integration"")]
[assembly: AssemblyCopyright(""Copyright ©  2016"")]
[assembly: AssemblyTrademark("""")]
[assembly: AssemblyCulture("""")]

[assembly: ComVisible(false)]

[assembly: Guid(""ea422389-3860-4325-be23-cb5020c5a75d"")]

[assembly: AssemblyVersion(""1.0.0.0"")]
[assembly: AssemblyFileVersion(""1.0.0.0"")]
","When evaluating the provided C# code against the stated coding principles, there are noticeable deviations. For example, the code contains numerous comments, which do not align with the principle of having clean and free of unnecessary comments. The naming conventions, such as ""SimpleFtpIntegrationTests"", do not follow PascalCase and lack meaningful indicators of their purpose. This contradicts the requirement for proper naming conventions and intuitive object names. Additionally, the structure of the code does not appear to be modular or to adhere to the Single Responsibility Principle. Each attribute within the code has a different layout, suggesting that there may be duplicated logic and improper use of reusable methods, which further deviates from the principles outlined. The lack of clear separation between related data and functions also undermines the readability and maintainability of the code. Moreover, unnecessary comments and code duplication contribute to inefficiency and a lack of streamlined code. These factors collectively demonstrate a failure to consistently understand and apply the principles of high-quality C# code development. 
[RESULT] 1",1
"// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http;
using Moq;
using Xunit;

namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
{
    public class HttpResponsePipeWriterTests
    {
        [Fact]
        public void AdvanceAfterStopAcceptingWritesThrowsObjectDisposedException()
        {
            var pipeWriter = CreateHttpResponsePipeWriter();
            pipeWriter.StartAcceptingWrites();
            pipeWriter.StopAcceptingWritesAsync();
            var ex = Assert.Throws<ObjectDisposedException>(() => { pipeWriter.Advance(1); });
            Assert.Contains(CoreStrings.WritingToResponseBodyAfterResponseCompleted, ex.Message);
        }

        [Fact]
        public void GetMemoryAfterStopAcceptingWritesThrowsObjectDisposedException()
        {
            var pipeWriter = CreateHttpResponsePipeWriter();
            pipeWriter.StartAcceptingWrites();
            pipeWriter.StopAcceptingWritesAsync();
            var ex = Assert.Throws<ObjectDisposedException>(() => { pipeWriter.GetMemory(); });
            Assert.Contains(CoreStrings.WritingToResponseBodyAfterResponseCompleted, ex.Message);
        }

        [Fact]
        public void GetSpanAfterStopAcceptingWritesThrowsObjectDisposedException()
        {
            var pipeWriter = CreateHttpResponsePipeWriter();
            pipeWriter.StartAcceptingWrites();
            pipeWriter.StopAcceptingWritesAsync();
            var ex = Assert.Throws<ObjectDisposedException>(() => { pipeWriter.GetSpan(); });
            Assert.Contains(CoreStrings.WritingToResponseBodyAfterResponseCompleted, ex.Message);
        }

        [Fact]
        public void CompleteAfterStopAcceptingWritesThrowsObjectDisposedException()
        {
            var pipeWriter = CreateHttpResponsePipeWriter();
            pipeWriter.StartAcceptingWrites();
            pipeWriter.StopAcceptingWritesAsync();
            var ex = Assert.Throws<ObjectDisposedException>(() => { pipeWriter.Complete(); });
            Assert.Contains(CoreStrings.WritingToResponseBodyAfterResponseCompleted, ex.Message);
        }

        [Fact]
        public void FlushAsyncAfterStopAcceptingWritesThrowsObjectDisposedException()
        {
            var pipeWriter = CreateHttpResponsePipeWriter();
            pipeWriter.StartAcceptingWrites();
            pipeWriter.StopAcceptingWritesAsync();
            var ex = Assert.Throws<ObjectDisposedException>(() => { pipeWriter.FlushAsync(); });
            Assert.Contains(CoreStrings.WritingToResponseBodyAfterResponseCompleted, ex.Message);
        }

        [Fact]
        public void WriteAsyncAfterStopAcceptingWritesThrowsObjectDisposedException()
        {
            var pipeWriter = CreateHttpResponsePipeWriter();
            pipeWriter.StartAcceptingWrites();
            pipeWriter.StopAcceptingWritesAsync();
            var ex = Assert.Throws<ObjectDisposedException>(() => { pipeWriter.WriteAsync(new Memory<byte>()); });
            Assert.Contains(CoreStrings.WritingToResponseBodyAfterResponseCompleted, ex.Message);
        }

        private static HttpResponsePipeWriter CreateHttpResponsePipeWriter()
        {
            return new HttpResponsePipeWriter(Mock.Of<IHttpResponseControl>());
        }
    }
}
","
// Licensed to the.NET Foundation under one or more agreements.
// The.NET Foundation licenses this file to you under the MIT license.

using System;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http;
using Moq;
using Xunit;

namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
{
    public class HttpResponsePipeWriterTests
    {
        [Fact]
        public async Task AdvanceAfterStopAcceptingWritesThrowsObjectDisposedException()
        {
            var pipeWriter = CreateHttpResponsePipeWriter();
            pipeWriter.StartAcceptingWrites();
            await pipeWriter.StopAcceptingWritesAsync();
            var ex = await Assert.ThrowsAsync<ObjectDisposedException>(() => { return pipeWriter.Advance(1); });
            Assert.Contains(CoreStrings.WritingToResponseBodyAfterResponseCompleted, ex.Message);
        }

        [Fact]
        public async Task GetMemoryAfterStopAcceptingWritesThrowsObjectDisposedException()
        {
            var pipeWriter = CreateHttpResponsePipeWriter();
            pipeWriter.StartAcceptingWrites();
            await pipeWriter.StopAcceptingWritesAsync();
            var ex = await Assert.ThrowsAsync<ObjectDisposedException>(() => { return pipeWriter.GetMemory(); });
            Assert.Contains(CoreStrings.WritingToResponseBodyAfterResponseCompleted, ex.Message);
        }

        [Fact]
        public async Task GetSpanAfterStopAcceptingWritesThrowsObjectDisposedException()
        {
            var pipeWriter = CreateHttpResponsePipeWriter();
            pipeWriter.StartAcceptingWrites();
            await pipeWriter.StopAcceptingWritesAsync();
            var ex = await Assert.ThrowsAsync<ObjectDisposedException>(() => { return pipeWriter.GetSpan(); });
            Assert.Contains(CoreStrings.WritingToResponseBodyAfterResponseCompleted, ex.Message);
        }

        [Fact]
        public async Task CompleteAfterStopAcceptingWritesThrowsObjectDisposedException()
        {
            var pipeWriter = CreateHttpResponsePipeWriter();
            pipeWriter.StartAcceptingWrites();
            await pipeWriter.StopAcceptingWritesAsync();
            var ex = await Assert.ThrowsAsync<ObjectDisposedException>(() => { return pipeWriter.Complete(); });
            Assert.Contains(CoreStrings.WritingToResponseBodyAfterResponseCompleted, ex.Message);
        }

        [Fact]
        public async Task FlushAsyncAfterStopAcceptingWritesThrowsObjectDisposedException()
        {
            var pipeWriter = CreateHttpResponsePipeWriter();
            pipeWriter.StartAcceptingWrites();
            await pipeWriter.StopAcceptingWritesAsync();
            var ex = await Assert.ThrowsAsync<ObjectDisposedException>(() => { return pipeWriter.FlushAsync(); });
            Assert.Contains(CoreStrings.WritingToResponseBodyAfterResponseCompleted, ex.Message);
        }

        [Fact]
        public async Task WriteAsyncAfterStopAcceptingWritesThrowsObjectDisposedException()
        {
            var pipeWriter = CreateHttpResponsePipeWriter();
            pipeWriter.StartAcceptingWrites();
            await pipeWriter.StopAcceptingWritesAsync();
            var ex = await Assert.ThrowsAsync<ObjectDisposedException>(() => { return pipeWriter.WriteAsync(new Memory<byte>()); });
            Assert.Contains(CoreStrings.WritingToResponseBodyAfterResponseCompleted, ex.Message);
        }

        private static HttpResponsePipeWriter CreateHttpResponsePipeWriter()
        {
            return new HttpResponsePipeWriter(Mock.Of<IHttpResponseControl>());
        }
    }
}
","
using System;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http;
using Moq;
using Xunit;

namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
{
    public class HttpResponsePipeWriterTests
    {
        [Fact]
        public void AdvanceAfterStoppingWritesThrowsObjectDisposedException()
        {
            var httpResponsePipeWriter = CreateHttpResponsePipeWriter();
            httpResponsePipeWriter.StartAcceptingWrites();
            httpResponsePipeWriter.StopAcceptingWritesAsync();
            var exception = Assert.Throws<ObjectDisposedException>(() => httpResponsePipeWriter.Advance(1));
            Assert.Contains(CoreStrings.WritingToResponseBodyAfterResponseCompleted, exception.Message);
        }

        [Fact]
        public void GetMemoryAfterStoppingWritesThrowsObjectDisposedException()
        {
            var httpResponsePipeWriter = CreateHttpResponsePipeWriter();
            httpResponsePipeWriter.StartAcceptingWrites();
            httpResponsePipeWriter.StopAcceptingWritesAsync();
            var exception = Assert.Throws<ObjectDisposedException>(() => httpResponsePipeWriter.GetMemory());
            Assert.Contains(CoreStrings.WritingToResponseBodyAfterResponseCompleted, exception.Message);
        }

        [Fact]
        public void GetSpanAfterStoppingWritesThrowsObjectDisposedException()
        {
            var httpResponsePipeWriter = CreateHttpResponsePipeWriter();
            httpResponsePipeWriter.StartAcceptingWrites();
            httpResponsePipeWriter.StopAcceptingWritesAsync();
            var exception = Assert.Throws<ObjectDisposedException>(() => httpResponsePipeWriter.GetSpan());
            Assert.Contains(CoreStrings.WritingToResponseBodyAfterResponseCompleted, exception.Message);
        }

        [Fact]
        public void CompleteAfterStoppingWritesThrowsObjectDisposedException()
        {
            var httpResponsePipeWriter = CreateHttpResponsePipeWriter();
            httpResponsePipeWriter.StartAcceptingWrites();
            httpResponsePipeWriter.StopAcceptingWritesAsync();
            var exception = Assert.Throws<ObjectDisposedException>(() => httpResponsePipeWriter.Complete());
            Assert.Contains(CoreStrings.WritingToResponseBodyAfterResponseCompleted, exception.Message);
        }

        [Fact]
        public void FlushAsyncAfterStoppingWritesThrowsObjectDisposedException()
        {
            var httpResponsePipeWriter = CreateHttpResponsePipeWriter();
            httpResponsePipeWriter.StartAcceptingWrites();
            httpResponsePipeWriter.StopAcceptingWritesAsync();
            var exception = Assert.Throws<ObjectDisposedException>(() => httpResponsePipeWriter.FlushAsync().Result);
            Assert.Contains(CoreStrings.WritingToResponseBodyAfterResponseCompleted, exception.Message);
        }

        [Fact]
        public void WriteAsyncAfterStoppingWritesThrowsObjectDisposedException()
        {
            var httpResponsePipeWriter = CreateHttpResponsePipeWriter();
            httpResponsePipeWriter.StartAcceptingWrites();
            httpResponsePipeWriter.StopAcceptingWritesAsync();
            var exception = Assert.Throws<ObjectDisposedException>(() => httpResponsePipeWriter.WriteAsync(new Memory<byte>()).Result);
            Assert.Contains(CoreStrings.WritingToResponseBodyAfterResponseCompleted, exception.Message);
        }

        private static HttpResponsePipeWriter CreateHttpResponsePipeWriter()
        {
            return new HttpResponsePipeWriter(Mock.Of<IHttpResponseControl>());
        }
    }
}
","Upon examining the code snippet provided, it is clear that the model does not effectively adhere to the high-quality C# code principles specified in the instruction. The model neglects to use PascalCase for naming classes, methods, and properties. Instead, it employs lowercase case and underscores which are not in line with the coding standards. The code does not appear to be free of unnecessary comments, imports, or unused code as the rubric requests. There is a distinct lack of modularity and encapsulation which are crucial for maintainability and readability. The methods seem to perform multiple tasks which violates the Single Responsibility Principle. In addition, there is no attempt made to avoid code duplication and the methods do not appear to be designed to perform a single logical task. Thus, the code lacks structure, clarity, and efficiency, all of which are critical for high-quality code. Based on these observations, it is evident that the model's understanding and application of the coding principles are significantly lacking, leading to a code snippet that fails to meet the standards of high-quality C# programming. So the overall score is 1. [RESULT] 1",1
"using YAF.Lucene.Net.Index;
using System;
using System.Diagnostics;
using BytesRef = YAF.Lucene.Net.Util.BytesRef;

namespace YAF.Lucene.Net.Codecs.Lucene3x
{
    /*
     * Licensed to the Apache Software Foundation (ASF) under one or more
     * contributor license agreements.  See the NOTICE file distributed with
     * this work for additional information regarding copyright ownership.
     * The ASF licenses this file to You under the Apache License, Version 2.0
     * (the ""License""); you may not use this file except in compliance with
     * the License.  You may obtain a copy of the License at
     *
     *     http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an ""AS IS"" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     */

    using FieldInfos = YAF.Lucene.Net.Index.FieldInfos;
    using IndexInput = YAF.Lucene.Net.Store.IndexInput;
    using Term = YAF.Lucene.Net.Index.Term;

    /// <summary>
    /// @lucene.experimental 
    /// </summary>
    [Obsolete(""(4.0)"")]
    internal sealed class SegmentTermPositions : SegmentTermDocs
    {
        private IndexInput proxStream;
        private IndexInput proxStreamOrig;
        private int proxCount;
        private int position;

        private BytesRef payload;

        // the current payload length
        private int payloadLength;

        // indicates whether the payload of the current position has
        // been read from the proxStream yet
        private bool needToLoadPayload;

        // these variables are being used to remember information
        // for a lazy skip
        private long lazySkipPointer = -1;

        private int lazySkipProxCount = 0;

        /*
        SegmentTermPositions(SegmentReader p) {
          super(p);
          this.proxStream = null;  // the proxStream will be cloned lazily when nextPosition() is called for the first time
        }
        */

        public SegmentTermPositions(IndexInput freqStream, IndexInput proxStream, TermInfosReader tis, FieldInfos fieldInfos)
            : base(freqStream, tis, fieldInfos)
        {
            this.proxStreamOrig = proxStream; // the proxStream will be cloned lazily when nextPosition() is called for the first time
        }

        internal override void Seek(TermInfo ti, Term term)
        {
            base.Seek(ti, term);
            if (ti != null)
            {
                lazySkipPointer = ti.ProxPointer;
            }

            lazySkipProxCount = 0;
            proxCount = 0;
            payloadLength = 0;
            needToLoadPayload = false;
        }

        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            if (disposing)
            {
                if (proxStream != null)
                {
                    proxStream.Dispose();
                }
            }
        }

        public int NextPosition()
        {
            if (m_indexOptions != IndexOptions.DOCS_AND_FREQS_AND_POSITIONS)
            // this field does not store positions, payloads
            {
                return 0;
            }
            // perform lazy skips if necessary
            LazySkip();
            proxCount--;
            return position += ReadDeltaPosition();
        }

        private int ReadDeltaPosition()
        {
            int delta = proxStream.ReadVInt32();
            if (m_currentFieldStoresPayloads)
            {
                // if the current field stores payloads then
                // the position delta is shifted one bit to the left.
                // if the LSB is set, then we have to read the current
                // payload length
                if ((delta & 1) != 0)
                {
                    payloadLength = proxStream.ReadVInt32();
                }
                delta = (int)((uint)delta >> 1);
                needToLoadPayload = true;
            }
            else if (delta == -1)
            {
                delta = 0; // LUCENE-1542 correction
            }
            return delta;
        }

        protected internal sealed override void SkippingDoc()
        {
            // we remember to skip a document lazily
            lazySkipProxCount += freq;
        }

        public sealed override bool Next()
        {
            // we remember to skip the remaining positions of the current
            // document lazily
            lazySkipProxCount += proxCount;

            if (base.Next()) // run super
            {
                proxCount = freq; // note frequency
                position = 0; // reset position
                return true;
            }
            return false;
        }

        public sealed override int Read(int[] docs, int[] freqs)
        {
            throw new System.NotSupportedException(""TermPositions does not support processing multiple documents in one call. Use TermDocs instead."");
        }

        /// <summary>
        /// Called by <c>base.SkipTo()</c>. </summary>
        protected internal override void SkipProx(long proxPointer, int payloadLength)
        {
            // we save the pointer, we might have to skip there lazily
            lazySkipPointer = proxPointer;
            lazySkipProxCount = 0;
            proxCount = 0;
            this.payloadLength = payloadLength;
            needToLoadPayload = false;
        }

        private void SkipPositions(int n)
        {
            Debug.Assert(m_indexOptions == IndexOptions.DOCS_AND_FREQS_AND_POSITIONS);
            for (int f = n; f > 0; f--) // skip unread positions
            {
                ReadDeltaPosition();
                SkipPayload();
            }
        }

        private void SkipPayload()
        {
            if (needToLoadPayload && payloadLength > 0)
            {
                proxStream.Seek(proxStream.GetFilePointer() + payloadLength);
            }
            needToLoadPayload = false;
        }

        // It is not always necessary to move the prox pointer
        // to a new document after the freq pointer has been moved.
        // Consider for example a phrase query with two terms:
        // the freq pointer for term 1 has to move to document x
        // to answer the question if the term occurs in that document. But
        // only if term 2 also matches document x, the positions have to be
        // read to figure out if term 1 and term 2 appear next
        // to each other in document x and thus satisfy the query.
        // So we move the prox pointer lazily to the document
        // as soon as positions are requested.
        private void LazySkip()
        {
            if (proxStream == null)
            {
                // clone lazily
                proxStream = (IndexInput)proxStreamOrig.Clone();
            }

            // we might have to skip the current payload
            // if it was not read yet
            SkipPayload();

            if (lazySkipPointer != -1)
            {
                proxStream.Seek(lazySkipPointer);
                lazySkipPointer = -1;
            }

            if (lazySkipProxCount != 0)
            {
                SkipPositions(lazySkipProxCount);
                lazySkipProxCount = 0;
            }
        }

        public int PayloadLength
        {
            get
            {
                return payloadLength;
            }
        }

        public BytesRef GetPayload()
        {
            if (payloadLength <= 0)
            {
                return null; // no payload
            }

            if (needToLoadPayload)
            {
                // read payloads lazily
                if (payload == null)
                {
                    payload = new BytesRef(payloadLength);
                }
                else
                {
                    payload.Grow(payloadLength);
                }

                proxStream.ReadBytes(payload.Bytes, payload.Offset, payloadLength);
                payload.Length = payloadLength;
                needToLoadPayload = false;
            }
            return payload;
        }

        public bool IsPayloadAvailable
        {
            get
            {
                return needToLoadPayload && payloadLength > 0;
            }
        }
    }
}","
using YAF.Lucene.Net.Index;
using System;
using System.Diagnostics;
using BytesRef = YAF.Lucene.Net.Util.BytesRef;

namespace YAF.Lucene.Net.Codecs.Lucene3x
{
    /*
     * Licensed to the Apache Software Foundation (ASF) under one or more
     * contributor license agreements.  See the NOTICE file distributed with
     * this work for additional information regarding copyright ownership.
     * The ASF licenses this file to You under the Apache License, Version 2.0
     * (the ""License""); you may not use this file except in compliance with
     * the License.  You may obtain a copy of the License at
     *
     *     http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an ""AS IS"" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     */

    using FieldInfos = YAF.Lucene.Net.Index.FieldInfos;
    using IndexInput = YAF.Lucene.Net.Store.IndexInput;
    using Term = YAF.Lucene.Net.Index.Term;

    /// <summary>
    /// @lucene.experimental 
    /// </summary>
    [Obsolete(""(4.0)"")]
    internal sealed class SegmentTermPositions : SegmentTermDocs
    {
        private IndexInput proxStream;
        private IndexInput proxStreamOrig;
        private int proxCount;
        private int position;

        private BytesRef payload;

        // the current payload length
        private int payloadLength;

        // indicates whether the payload of the current position has
        // been read from the proxStream yet
        private bool needToLoadPayload;

        // these variables are being used to remember information
        // for a lazy skip
        private long lazySkipPointer = -1;

        private int lazySkipProxCount = 0;

        public SegmentTermPositions(IndexInput freqStream, IndexInput proxStream, TermInfosReader tis, FieldInfos fieldInfos)
            : base(freqStream, tis, fieldInfos)
        {
            this.proxStreamOrig = proxStream; // the proxStream will be cloned lazily when nextPosition() is called for the first time
        }

        internal override void Seek(TermInfo ti, Term term)
        {
            base.Seek(ti, term);
            if (ti!= null)
            {
                lazySkipPointer = ti.ProxPointer;
            }

            lazySkipProxCount = 0;
            proxCount = 0;
            payloadLength = 0;
            needToLoadPayload = false;
        }

        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            if (disposing)
            {
                if (proxStream!= null)
                {
                    proxStream.Dispose();
                }
            }
        }

        public int NextPosition()
        {
            if (m_indexOptions!= IndexOptions.DOCS_AND_FREQS_AND_POSITIONS)
            // this field does not store positions, payloads
            {
                return 0;
            }
            // perform lazy skips if necessary
            LazySkip();
            proxCount--;
            return position += ReadDeltaPosition();
        }

        private int ReadDeltaPosition()
        {
            int delta = proxStream.ReadVInt32();
            if (m_currentFieldStoresPayloads)
            {
                // if the current field stores payloads then
                // the position delta is shifted one bit to the left.
                // if the LSB is set, then we have to read the current
                // payload length
                if ((delta & 1)!= 0)
                {
                    payloadLength = proxStream.ReadVInt32();
                }
                delta = (int)((uint)delta >> 1);
                needToLoadPayload = true;
            }
            else if (delta == -1)
            {
                delta = 0; // LUCENE-1542 correction
            }
            return delta;
        }

        protected internal sealed override void SkippingDoc()
        {
            // we remember to skip a document lazily
            lazySkipProxCount += freq;
        }

        public sealed override bool Next()
        {
            // we remember to skip the remaining positions of the current
            // document lazily
            lazySkipProxCount += proxCount;

            if (base.Next()) // run super
            {
                proxCount = freq; // note frequency
                position = 0; // reset position
                return true;
            }
            return false;
        }

        public sealed override int Read(int[] docs, int[] freqs)
        {
            throw new System.NotSupportedException(""TermPositions does not support processing multiple documents in one call. Use TermDocs instead."");
        }

        /// <summary>
        /// Called by <c>base.SkipTo()</c>. </summary>
        protected internal override void SkipProx(long proxPointer, int payloadLength)
        {
            // we save the pointer, we might have to skip there lazily
            lazySkipPointer = proxPointer;
            lazySkipProxCount = 0;
            proxCount = 0;
            this.payloadLength = payloadLength;
            needToLoadPayload = false;
        }

        private void SkipPositions(int n)
        {
            Debug.Assert(m_indexOptions == IndexOptions.DOCS_AND_FREQS_AND_POSITIONS);
            for (int f = n; f > 0; f--) // skip unread positions
            {
                ReadDeltaPosition();
                SkipPayload();
            }
        }

        private void SkipPayload()
        {
            if (needToLoadPayload && payloadLength > 0)
            {
                proxStream.Seek(proxStream.GetFilePointer() + payloadLength);
            }
            needToLoadPayload = false;
        }

        // It is not always necessary to move the prox pointer
        // to a new document after the freq pointer has been moved.
        // Consider for example a phrase query with two terms:
        // the freq pointer for term 1 has to move to document x
        // to answer the question if the term occurs in that document. But
        // only if term 2 also matches document x, the positions have to be
        // read to figure out if term 1 and term 2 appear next
        // to each other in document x and thus satisfy the query.
        // So we move the prox pointer lazily to the document
        // as soon as positions are requested.
        private void LazySkip()
        {
            if (proxStream == null)
            {
                // clone lazily
                proxStream = (IndexInput)proxStreamOrig.Clone();
            }

            // we might have to skip the current payload
            // if it was not read yet
            SkipPayload();

            if (lazySkipPointer!= -1)
            {
                proxStream.Seek(lazySkipPointer);
                lazySkipPointer = -1;
            }

            if (lazySkipProxCount!= 0)
            {
                SkipPositions(lazySkipProxCount);
                lazySkipProxCount = 0;
            }
        }

        public int PayloadLength
        {
            get
            {
                return payloadLength;
            }
        }

        public BytesRef GetPayload()
        {
            if (payloadLength <= 0)
            {
                return null; // no payload
            }

            if (needToLoadPayload)
            {
                // read payloads lazily
                if (payload == null)
                {
                    payload = new BytesRef(payloadLength);
                }
                else
                {
                    payload.Grow(payloadLength);
                }

                proxStream.ReadBytes(payload.Bytes, payload.Offset, payloadLength);
                payload.Length = payloadLength;
                needToLoadPayload = false;
            }
            return payload;
        }

        public bool IsPayloadAvailable
        {
            get
            {
                return needToLoadPayload && payloadLength > 0;
            }
        }
    }
}
","
using System;
using System.Diagnostics;
using YAF.Lucene.Net.Index;
using YAF.Lucene.Net.Store;
using YAF.Lucene.Net.Util;

namespace YAF.Lucene.Net.Codecs.Lucene3x
{
    [Obsolete(""(4.0)"")]
    internal sealed class SegmentTermPositions : SegmentTermDocs
    {
        private IndexInput _proximityStream;
        private IndexInput _originalProximityStream;
        private int _proximityCount;
        private int _position;

        private BytesRef _payload;

        private int _payloadLength;
        private bool _needToLoadPayload;

        private long _lazySkipPointer = -1;
        private int _lazySkipProximityCount = 0;

        public SegmentTermPositions(IndexInput frequencyStream, IndexInput proximityStream, TermInfosReader termInfosReader, FieldInfos fieldInfos)
            : base(frequencyStream, termInfosReader, fieldInfos)
        {
            _originalProximityStream = proximityStream;
        }

        internal override void Seek(TermInfo termInfo, Term term)
        {
            base.Seek(termInfo, term);
            if (termInfo != null)
            {
                _lazySkipPointer = termInfo.ProxPointer;
            }

            _lazySkipProximityCount = 0;
            _proximityCount = 0;
            _payloadLength = 0;
            _needToLoadPayload = false;
        }

        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            if (disposing && _proximityStream != null)
            {
                _proximityStream.Dispose();
            }
        }

        public int NextPosition()
        {
            if (IndexOptions != IndexOptions.DOCS_AND_FREQS_AND_POSITIONS)
            {
                return 0;
            }

            LazySkip();
            _proximityCount--;
            return _position += ReadDeltaPosition();
        }

        private int ReadDeltaPosition()
        {
            int delta = _proximityStream.ReadVInt32();
            if (_currentFieldStoresPayloads)
            {
                if ((delta & 1) != 0)
                {
                    _payloadLength = _proximityStream.ReadVInt32();
                }
                delta = (int)((uint)delta >> 1);
                _needToLoadPayload = true;
            }
            else if (delta == -1)
            {
                delta = 0;
            }
            return delta;
        }

        protected internal override void SkippingDocument()
        {
            _lazySkipProximityCount += Freq;
        }

        public override bool Next()
        {
            _lazySkipProximityCount += _proximityCount;

            if (base.Next())
            {
                _proximityCount = Freq;
                _position = 0;
                return true;
            }
            return false;
        }

        public override int Read(int[] documents, int[] frequencies)
        {
            throw new NotSupportedException(""TermPositions does not support processing multiple documents in one call. Use TermDocs instead."");
        }

        protected internal override void SkipProximity(long proximityPointer, int payloadLength)
        {
            _lazySkipPointer = proximityPointer;
            _lazySkipProximityCount = 0;
            _proximityCount = 0;
            _payloadLength = payloadLength;
            _needToLoadPayload = false;
        }

        private void SkipPositions(int count)
        {
            Debug.Assert(IndexOptions == IndexOptions.DOCS_AND_FREQS_AND_POSITIONS);
            for (int i = 0; i < count; i++)
            {
                ReadDeltaPosition();
                SkipPayload();
            }
        }

        private void SkipPayload()
        {
            if (_needToLoadPayload && _payloadLength > 0)
            {
                _proximityStream.Seek(_proximityStream.FilePointer + _payloadLength);
            }
            _needToLoadPayload = false;
        }

        private void LazySkip()
        {
            if (_proximityStream == null)
            {
                _proximityStream = (IndexInput)_originalProximityStream.Clone();
            }