Exemplo n.º 1
0
        public virtual void TestSimpleIntBlocks()
        {
            Directory dir = NewDirectory();

            Int32StreamFactory f = (new MockFixedInt32BlockPostingsFormat(128)).GetInt32Factory();

            Int32IndexOutput @out = f.CreateOutput(dir, "test", NewIOContext(Random));

            for (int i = 0; i < 11777; i++)
            {
                @out.Write(i);
            }
            @out.Dispose();

            Int32IndexInput @in = f.OpenInput(dir, "test", NewIOContext(Random));

            Int32IndexInput.Reader r = @in.GetReader();

            for (int i = 0; i < 11777; i++)
            {
                assertEquals(i, r.Next());
            }
            @in.Dispose();

            dir.Dispose();
        }
Exemplo n.º 2
0
            public override Int32IndexOutput CreateOutput(Directory dir, string fileName, IOContext context)
            {
                Int32StreamFactory f = delegates[(Math.Abs(salt ^ GetExtension(fileName).GetHashCode())) % delegates.Count];

                if (LuceneTestCase.Verbose)
                {
                    Console.WriteLine("MockRandomCodec: write using int factory " + f + " to fileName=" + fileName);
                }
                return(f.CreateOutput(dir, fileName, context));
            }
Exemplo n.º 3
0
            public override Int32IndexInput OpenInput(Directory dir, string fileName, IOContext context)
            {
                // Must only use extension, because IW.addIndexes can
                // rename segment!
                Int32StreamFactory f = delegates[(Math.Abs(salt ^ GetExtension(fileName).GetHashCode())) % delegates.Count];

                if (LuceneTestCase.Verbose)
                {
                    Console.WriteLine("MockRandomCodec: read using int factory " + f + " from fileName=" + fileName);
                }
                return(f.OpenInput(dir, fileName, context));
            }
Exemplo n.º 4
0
        public virtual void TestEmptySimpleIntBlocks()
        {
            Directory dir = NewDirectory();

            Int32StreamFactory f    = (new MockFixedInt32BlockPostingsFormat(128)).GetInt32Factory();
            Int32IndexOutput   @out = f.CreateOutput(dir, "test", NewIOContext(Random));

            // write no ints
            @out.Dispose();

            Int32IndexInput @in = f.OpenInput(dir, "test", NewIOContext(Random));

            @in.GetReader();
            // read no ints
            @in.Dispose();
            dir.Dispose();
        }