OpenInput() public méthode

Returns a stream reading an existing file.
public OpenInput ( System name ) : IndexInput
name System
Résultat IndexInput
        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);
            }
        }
 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));
         }
     }
 }
Exemple #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();
        }
        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();
        }
        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();
        }
		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();
		}
        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();
        }
 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();
 }