19 using System.Collections.Generic;
20 using Lucene.Net.Documents;
23 using Lucene.Net.Store;
26 namespace Lucene.Net.Index
65 public abstract class IndexReader : System.ICloneable, System.IDisposable
67 private class AnonymousClassFindSegmentsFile :
SegmentInfos.FindSegmentsFile
69 private void InitBlock(Lucene.Net.Store.Directory directory2)
71 this.directory2 = directory2;
73 private Lucene.Net.Store.Directory directory2;
74 internal AnonymousClassFindSegmentsFile(Lucene.Net.Store.Directory directory2, Lucene.Net.Store.Directory Param1):base(Param1)
76 InitBlock(directory2);
78 public override System.Object DoBody(System.String segmentFileName)
80 return (
long) directory2.FileModified(segmentFileName);
89 private readonly System.String option;
97 public override System.String ToString()
126 protected internal bool hasChanges;
128 private int refCount;
130 protected internal static int DEFAULT_TERMS_INDEX_DIVISOR = 1;
133 public virtual int RefCount
158 public virtual void IncRef()
162 System.Diagnostics.Debug.Assert(refCount > 0);
179 public virtual void DecRef()
183 System.Diagnostics.Debug.Assert(refCount > 0);
200 protected internal void EnsureOpen()
220 return Open(directory, null, null, readOnly, DEFAULT_TERMS_INDEX_DIVISOR);
237 return Open(commit.
Directory, null, commit, readOnly, DEFAULT_TERMS_INDEX_DIVISOR);
259 return Open(directory, deletionPolicy, null, readOnly, DEFAULT_TERMS_INDEX_DIVISOR);
293 return Open(directory, deletionPolicy, null, readOnly, termInfosIndexDivisor);
317 return Open(commit.
Directory, deletionPolicy, commit, readOnly, DEFAULT_TERMS_INDEX_DIVISOR);
353 return Open(commit.
Directory, deletionPolicy, commit, readOnly, termInfosIndexDivisor);
358 return DirectoryReader.Open(directory, deletionPolicy, commit, readOnly, termInfosIndexDivisor);
409 throw new NotSupportedException(
"This reader does not support reopen().");
423 throw new NotSupportedException(
"This reader does not support reopen().");
438 throw new NotSupportedException(
"This reader does not support reopen(IndexCommit).");
460 public virtual System.Object Clone()
462 throw new System.NotSupportedException(
"This reader does not implement clone()");
474 throw new System.NotSupportedException(
"This reader does not implement clone()");
487 throw new NotSupportedException(
"This reader does not support this method.");
498 return (
long) ((System.Int64)
new AnonymousClassFindSegmentsFile(directory2, directory2).Run());
512 public static long GetCurrentVersion(
Directory directory)
533 public static System.Collections.Generic.IDictionary<string,
string> GetCommitUserData(
Directory directory)
566 get {
throw new System.NotSupportedException(
"This reader does not support this method."); }
577 public virtual IDictionary<string, string> CommitUserData
579 get {
throw new System.NotSupportedException(
"This reader does not support this method."); }
612 public virtual bool IsCurrent()
614 throw new NotSupportedException(
"This reader does not support this method.");
622 public virtual bool IsOptimized()
624 throw new NotSupportedException(
"This reader does not support this method.");
664 abstract public ITermFreqVector GetTermFreqVector(
int docNumber, String field);
678 abstract public void GetTermFreqVector(
int docNumber, String field,
TermVectorMapper mapper);
686 abstract public void GetTermFreqVector(
int docNumber,
TermVectorMapper mapper);
702 [System.Diagnostics.CodeAnalysis.SuppressMessage(
"Microsoft.Design",
"CA1024:UsePropertiesWhereAppropriate")]
703 public abstract int NumDocs();
709 public abstract int MaxDoc {
get; }
712 public virtual int NumDeletedDocs
714 get {
return MaxDoc - NumDocs(); }
792 public abstract bool IsDeleted(
int n);
795 public abstract bool HasDeletions {
get; }
798 public virtual bool HasNorms(System.String field)
803 return Norms(field) != null;
811 public abstract byte[] Norms(System.String field);
818 public abstract void Norms(System.String field, byte[] bytes,
int offset);
842 public virtual void SetNorm(
int doc, String field, byte value)
849 DoSetNorm(doc, field, value);
854 protected internal abstract void DoSetNorm(
int doc, System.String field, byte value_Renamed);
873 public virtual void SetNorm(
int doc, System.String field,
float value)
876 SetNorm(doc, field,
Similarity.EncodeNorm(value));
904 public abstract int DocFreq(
Term t);
952 termPositions.
Seek(term);
953 return termPositions;
978 public virtual void DeleteDocument(
int docNum)
993 protected internal abstract void DoDelete(
int docNum);
1014 public virtual int DeleteDocuments(
Term term)
1025 DeleteDocument(docs.
Doc);
1047 public virtual void UndeleteAll()
1059 protected internal abstract void DoUndeleteAll();
1065 protected internal virtual void AcquireWriteLock()
1089 public void Flush(IDictionary<string, string> commitUserData)
1094 Commit(commitUserData);
1106 public void Commit()
1122 public void Commit(IDictionary<string, string> commitUserData)
1128 DoCommit(commitUserData);
1135 protected internal abstract void DoCommit(IDictionary<string, string> commitUserData);
1137 [Obsolete(
"Use Dispose() instead")]
1148 public void Dispose()
1153 protected virtual void Dispose(
bool disposing)
1169 protected internal abstract void DoClose();
1181 public abstract ICollection<string> GetFieldNames(
FieldOption fldOption);
1193 get {
throw new NotSupportedException(
"This reader does not support this method."); }
1204 public static void Main(String[] args)
1206 System.String filename = null;
1207 bool extract =
false;
1209 foreach (
string t
in args)
1211 if (t.Equals(
"-extract"))
1215 else if (filename == null)
1221 if (filename == null)
1223 System.Console.Out.WriteLine(
"Usage: Lucene.Net.Index.IndexReader [-extract] <cfsfile>");
1232 var file =
new System.IO.FileInfo(filename);
1233 System.String dirname =
new System.IO.FileInfo(file.FullName).DirectoryName;
1234 filename = file.
Name;
1238 System.String[] files = cfr.
ListAll();
1239 System.Array.Sort(files);
1241 foreach (
string t
in files)
1247 System.Console.Out.WriteLine(
"extract " + t +
" with " + len +
" bytes to local directory...");
1250 var f =
new System.IO.FileStream(t, System.IO.FileMode.Create);
1253 var buffer =
new byte[1024];
1254 int chunk = buffer.
Length;
1257 var bufLen = (int) System.Math.Min(chunk, len);
1259 f.Write(buffer, 0, bufLen);
1267 System.Console.Out.WriteLine(t +
": " + len +
" bytes");
1270 catch (System.IO.IOException ioe)
1272 System.Console.Error.WriteLine(ioe.StackTrace);
1283 catch (System.IO.IOException ioe)
1285 System.Console.Error.WriteLine(ioe.StackTrace);
1330 public virtual object FieldCacheKey
1332 get {
return this; }
1339 public virtual object DeletesCacheKey
1341 get {
return this; }
1358 public virtual long UniqueTermCount
1360 get {
throw new System.NotSupportedException(
"this reader does not implement getUniqueTermCount()"); }
1369 public virtual int TermInfosIndexDivisor
1371 get {
throw new NotSupportedException(
"This reader does not support this method."); }