Lucene.Net  3.0.3
Lucene.Net is a port of the Lucene search engine library, written in C# and targeted at .NET runtime users.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Pages
NIOFSDirectory.cs
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 using System;
19 namespace Lucene.Net.Store
20 {
21  /// <summary>
22  /// Not implemented. Waiting for volunteers.
23  /// </summary>
24  public class NIOFSDirectory : Lucene.Net.Store.FSDirectory
25  {
26  public NIOFSDirectory(System.IO.DirectoryInfo dir, LockFactory lockFactory)
27  : base(dir, lockFactory)
28  {
29  throw new System.NotImplementedException("Waiting for volunteers to implement this class");
30  }
31 
32  /// <summary>
33  /// Not implemented. Waiting for volunteers.
34  /// </summary>
35  public class NIOFSIndexInput
36  {
37  public NIOFSIndexInput()
38  {
39  throw new System.NotImplementedException("Waiting for volunteers to implement this class");
40  }
41  }
42 
43  public override IndexOutput CreateOutput(string name)
44  {
45  throw new System.NotImplementedException("Waiting for volunteers to implement this class");
46  }
47  }
48 }
49 
50 
51 //namespace Lucene.Net.Store
52 //{
53 
54 // /// <summary> An <see cref="FSDirectory" /> implementation that uses
55 // /// java.nio's FileChannel's positional read, which allows
56 // /// multiple threads to read from the same file without
57 // /// synchronizing.
58 // ///
59 // /// <p/>This class only uses FileChannel when reading; writing
60 // /// is achieved with <see cref="SimpleFSDirectory.SimpleFSIndexOutput" />.
61 // ///
62 // /// <p/><b>NOTE</b>: NIOFSDirectory is not recommended on Windows because of a bug
63 // /// in how FileChannel.read is implemented in Sun's JRE.
64 // /// Inside of the implementation the position is apparently
65 // /// synchronized. See <a
66 // /// href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6265734">here</a>
67 // /// for details.
68 // /// </summary>
69 // public class NIOFSDirectory:FSDirectory
70 // {
71 
72 // /// <summary>Create a new NIOFSDirectory for the named location.
73 // ///
74 // /// </summary>
75 // /// <param name="path">the path of the directory
76 // /// </param>
77 // /// <param name="lockFactory">the lock factory to use, or null for the default.
78 // /// </param>
79 // /// <throws> IOException </throws>
80 // [System.Obsolete("Use the constructor that takes a DirectoryInfo, this will be removed in the 3.0 release")]
81 // public NIOFSDirectory(System.IO.FileInfo path, LockFactory lockFactory):base(new System.IO.DirectoryInfo(path.FullName), lockFactory)
82 // {
83 // }
84 
85 // /// <summary>Create a new NIOFSDirectory for the named location.
86 // ///
87 // /// </summary>
88 // /// <param name="path">the path of the directory
89 // /// </param>
90 // /// <param name="lockFactory">the lock factory to use, or null for the default.
91 // /// </param>
92 // /// <throws> IOException </throws>
93 // public NIOFSDirectory(System.IO.DirectoryInfo path, LockFactory lockFactory) : base(path, lockFactory)
94 // {
95 // }
96 
97 // /// <summary>Create a new NIOFSDirectory for the named location and the default lock factory.
98 // ///
99 // /// </summary>
100 // /// <param name="path">the path of the directory
101 // /// </param>
102 // /// <throws> IOException </throws>
103 // [System.Obsolete("Use the constructor that takes a DirectoryInfo, this will be removed in the 3.0 release")]
104 // public NIOFSDirectory(System.IO.FileInfo path):base(new System.IO.DirectoryInfo(path.FullName), null)
105 // {
106 // }
107 
108 // /// <summary>Create a new NIOFSDirectory for the named location and the default lock factory.
109 // ///
110 // /// </summary>
111 // /// <param name="path">the path of the directory
112 // /// </param>
113 // /// <throws> IOException </throws>
114 // public NIOFSDirectory(System.IO.DirectoryInfo path) : base(path, null)
115 // {
116 // }
117 
118 // // back compatibility so FSDirectory can instantiate via reflection
119 // /// <deprecated>
120 // /// </deprecated>
121 // [Obsolete]
122 // internal NIOFSDirectory()
123 // {
124 // }
125 
126 // /// <summary>Creates an IndexInput for the file with the given name. </summary>
127 // public override IndexInput OpenInput(System.String name, int bufferSize)
128 // {
129 // EnsureOpen();
130 // return new NIOFSIndexInput(new System.IO.FileInfo(System.IO.Path.Combine(GetFile().FullName, name)), bufferSize, GetReadChunkSize());
131 // }
132 
133 // /// <summary>Creates an IndexOutput for the file with the given name. </summary>
134 // public override IndexOutput CreateOutput(System.String name)
135 // {
136 // InitOutput(name);
137 // return new SimpleFSDirectory.SimpleFSIndexOutput(new System.IO.FileInfo(System.IO.Path.Combine(directory.FullName, name)));
138 // }
139 
140 // public /*protected internal*/ class NIOFSIndexInput:SimpleFSDirectory.SimpleFSIndexInput
141 // {
142 
143 // private System.IO.MemoryStream byteBuf; // wraps the buffer for NIO
144 
145 // private byte[] otherBuffer;
146 // private System.IO.MemoryStream otherByteBuf;
147 
148 // internal System.IO.BinaryReader channel;
149 
150 // /// <deprecated> Please use ctor taking chunkSize
151 // /// </deprecated>
152 // [Obsolete("Please use ctor taking chunkSize")]
153 // public NIOFSIndexInput(System.IO.FileInfo path, int bufferSize):this(path, bufferSize, FSDirectory.DEFAULT_READ_CHUNK_SIZE)
154 // {
155 // }
156 
157 // public NIOFSIndexInput(System.IO.FileInfo path, int bufferSize, int chunkSize):base(path, bufferSize, chunkSize)
158 // {
159 // channel = (System.IO.BinaryReader) file;
160 // }
161 
162 // protected internal override void NewBuffer(byte[] newBuffer)
163 // {
164 // base.NewBuffer(newBuffer);
165 // // {{Aroush-2.9}} byteBuf = ByteBuffer.wrap(newBuffer);
166 // System.Diagnostics.Debug.Fail("Port issue:", "byteBuf = ByteBuffer.wrap(newBuffer)"); // {{Aroush-2.9}}
167 // }
168 
169 // public override void Close()
170 // {
171 // if (!isClone && file.isOpen)
172 // {
173 // // Close the channel & file
174 // try
175 // {
176 // channel.Close();
177 // }
178 // finally
179 // {
180 // file.Close();
181 // }
182 // }
183 // }
184 
185 // public override void ReadInternal(byte[] b, int offset, int len)
186 // {
187 
188 // System.IO.MemoryStream bb;
189 
190 // // Determine the ByteBuffer we should use
191 // if (b == buffer && 0 == offset)
192 // {
193 // // Use our own pre-wrapped byteBuf:
194 // System.Diagnostics.Debug.Assert(byteBuf != null);
195 // byteBuf.Position = 0;
196 // byteBuf.Capacity = len;
197 // bb = byteBuf;
198 // }
199 // else
200 // {
201 // if (offset == 0)
202 // {
203 // if (otherBuffer != b)
204 // {
205 // // Now wrap this other buffer; with compound
206 // // file, we are repeatedly called with its
207 // // buffer, so we wrap it once and then re-use it
208 // // on subsequent calls
209 // otherBuffer = b;
210 // // otherByteBuf = ByteBuffer.wrap(b); {{Aroush-2.9}}
211 // System.Diagnostics.Debug.Fail("Port issue:", "otherByteBuf = ByteBuffer.wrap(b)"); // {{Aroush-2.9}}
212 // }
213 // else
214 // otherByteBuf.Position = 0;
215 // otherByteBuf.Capacity = len;
216 // bb = otherByteBuf;
217 // }
218 // else
219 // {
220 // // Always wrap when offset != 0
221 // bb = null; // bb = ByteBuffer.wrap(b, offset, len); {{Aroush-2.9}}
222 // System.Diagnostics.Debug.Fail("Port issue:", "bb = ByteBuffer.wrap(b, offset, len)"); // {{Aroush-2.9}}
223 // }
224 // }
225 
226 // int readOffset = (int) bb.Position;
227 // int readLength = bb.Capacity - readOffset;
228 // System.Diagnostics.Debug.Assert(readLength == len);
229 
230 // long pos = GetFilePointer();
231 
232 // try
233 // {
234 // while (readLength > 0)
235 // {
236 // int limit;
237 // if (readLength > chunkSize)
238 // {
239 // // LUCENE-1566 - work around JVM Bug by breaking
240 // // very large reads into chunks
241 // limit = readOffset + chunkSize;
242 // }
243 // else
244 // {
245 // limit = readOffset + readLength;
246 // }
247 // bb.Capacity = limit;
248 // int i = -1; // int i = channel.Read(bb, pos, limit); // {{Aroush-2.9}} must read from 'channel' into 'bb'
249 // System.Diagnostics.Debug.Fail("Port issue:", "channel.Read(bb, pos, limit)"); // {{Aroush-2.9}}
250 // if (i == - 1)
251 // {
252 // throw new System.IO.IOException("read past EOF");
253 // }
254 // pos += i;
255 // readOffset += i;
256 // readLength -= i;
257 // }
258 // }
259 // catch (System.OutOfMemoryException e)
260 // {
261 // // propagate OOM up and add a hint for 32bit VM Users hitting the bug
262 // // with a large chunk size in the fast path.
263 // System.OutOfMemoryException outOfMemoryError = new System.OutOfMemoryException("OutOfMemoryError likely caused by the Sun VM Bug described in " + "https://issues.apache.org/jira/browse/LUCENE-1566; try calling FSDirectory.setReadChunkSize " + "with a a value smaller than the current chunk size (" + chunkSize + ")", e);
264 // throw outOfMemoryError;
265 // }
266 // }
267 // }
268 // }
269 //}