OpenInput() публичный Метод

Returns a stream reading an existing file.
public OpenInput ( System name ) : IndexInput
name System
Результат IndexInput
Пример #1
0
        public override IndexInput OpenInput(string name, IOContext context)
        {
            UninterruptableMonitor.Enter(this);
            try
            {
                if (VERBOSE)
                {
                    Console.WriteLine("nrtdir.openInput name=" + name);
                }
#pragma warning disable 612, 618
                if (cache.FileExists(name))
#pragma warning restore 612, 618
                {
                    if (VERBOSE)
                    {
                        Console.WriteLine("  from cache");
                    }
                    return(cache.OpenInput(name, context));
                }
                else
                {
                    return(@delegate.OpenInput(name, context));
                }
            }
            finally
            {
                UninterruptableMonitor.Exit(this);
            }
        }
Пример #2
0
 public override IndexInput OpenInput(string name, IOContext context)
 {
     lock (this)
     {
         if (VERBOSE)
         {
             Console.WriteLine("nrtdir.openInput name=" + name);
         }
         if (Cache.FileExists(name))
         {
             if (VERBOSE)
             {
                 Console.WriteLine("  from cache");
             }
             return(Cache.OpenInput(name, context));
         }
         else
         {
             return(@delegate.OpenInput(name, context));
         }
     }
 }
Пример #3
0
        public virtual void  TestIllegalEOF()
        {
            RAMDirectory dir = new RAMDirectory();
            IndexOutput  o   = dir.CreateOutput("out");

            byte[] b = new byte[1024];
            o.WriteBytes(b, 0, 1024);
            o.Close();
            IndexInput i = dir.OpenInput("out");

            i.Seek(1024);
            i.Close();
            dir.Close();
        }
Пример #4
0
        public virtual void TestIllegalEOF()
        {
            RAMDirectory dir = new RAMDirectory();
            IndexOutput  o   = dir.CreateOutput("out", NewIOContext(Random));
            var          b   = new byte[1024];

            o.WriteBytes(b, 0, 1024);
            o.Dispose();
            IndexInput i = dir.OpenInput("out", NewIOContext(Random));

            i.Seek(1024);
            i.Dispose();
            dir.Dispose();
        }
Пример #5
0
        public virtual void TestSeekToEOFThenBack()
        {
            RAMDirectory dir = new RAMDirectory();

            IndexOutput o     = dir.CreateOutput("out", NewIOContext(Random));
            var         bytes = new byte[3 * RAMInputStream.BUFFER_SIZE];

            o.WriteBytes(bytes, 0, bytes.Length);
            o.Dispose();

            IndexInput i = dir.OpenInput("out", NewIOContext(Random));

            i.Seek(2 * RAMInputStream.BUFFER_SIZE - 1);
            i.Seek(3 * RAMInputStream.BUFFER_SIZE);
            i.Seek(RAMInputStream.BUFFER_SIZE);
            i.ReadBytes(bytes, 0, 2 * RAMInputStream.BUFFER_SIZE);
            i.Dispose();
            dir.Dispose();
        }
Пример #6
0
		public virtual void  TestIllegalEOF()
		{
			RAMDirectory dir = new RAMDirectory();
			IndexOutput o = dir.CreateOutput("out");
			byte[] b = new byte[1024];
			o.WriteBytes(b, 0, 1024);
			o.Close();
			IndexInput i = dir.OpenInput("out");
			i.Seek(1024);
			i.Close();
			dir.Close();
		}
Пример #7
0
        public virtual void TestSeekToEOFThenBack()
        {
            RAMDirectory dir = new RAMDirectory();

            IndexOutput o = dir.CreateOutput("out", NewIOContext(Random()));
            var bytes = new byte[3 * RAMInputStream.BUFFER_SIZE];
            o.WriteBytes(bytes, 0, bytes.Length);
            o.Dispose();

            IndexInput i = dir.OpenInput("out", NewIOContext(Random()));
            i.Seek(2 * RAMInputStream.BUFFER_SIZE - 1);
            i.Seek(3 * RAMInputStream.BUFFER_SIZE);
            i.Seek(RAMInputStream.BUFFER_SIZE);
            i.ReadBytes(bytes, 0, 2 * RAMInputStream.BUFFER_SIZE);
            i.Dispose();
            dir.Dispose();
        }
Пример #8
0
 public virtual void TestIllegalEOF()
 {
     RAMDirectory dir = new RAMDirectory();
     IndexOutput o = dir.CreateOutput("out", NewIOContext(Random()));
     var b = new byte[1024];
     o.WriteBytes(b, 0, 1024);
     o.Dispose();
     IndexInput i = dir.OpenInput("out", NewIOContext(Random()));
     i.Seek(1024);
     i.Dispose();
     dir.Dispose();
 }