Lucene.Net  3.0.3
Lucene.Net is a .NET port of the Java Lucene Indexing Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties
IndexFileNames.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 using Lucene.Net.Support;
20 
21 namespace Lucene.Net.Index
22 {
23 
25  public sealed class IndexFileNames
26  {
27 
29  public /*internal*/ const System.String SEGMENTS = "segments";
30 
32  public /*internal*/ const System.String SEGMENTS_GEN = "segments.gen";
33 
37  public /*internal*/ const System.String DELETABLE = "deletable";
38 
40  public /*internal*/ const System.String NORMS_EXTENSION = "nrm";
41 
43  public /*internal*/ const System.String FREQ_EXTENSION = "frq";
44 
46  public /*internal*/ const System.String PROX_EXTENSION = "prx";
47 
49  public /*internal*/ const System.String TERMS_EXTENSION = "tis";
50 
52  public /*internal*/ const System.String TERMS_INDEX_EXTENSION = "tii";
53 
55  public /*internal*/ const System.String FIELDS_INDEX_EXTENSION = "fdx";
56 
58  public /*internal*/ const System.String FIELDS_EXTENSION = "fdt";
59 
61  public /*internal*/ const System.String VECTORS_FIELDS_EXTENSION = "tvf";
62 
64  public /*internal*/ const System.String VECTORS_DOCUMENTS_EXTENSION = "tvd";
65 
67  public /*internal*/ const System.String VECTORS_INDEX_EXTENSION = "tvx";
68 
70  public /*internal*/ const System.String COMPOUND_FILE_EXTENSION = "cfs";
71 
73  public /*internal*/ const System.String COMPOUND_FILE_STORE_EXTENSION = "cfx";
74 
76  internal const System.String DELETES_EXTENSION = "del";
77 
79  public /*internal*/ const System.String FIELD_INFOS_EXTENSION = "fnm";
80 
82  public /*internal*/ const System.String PLAIN_NORMS_EXTENSION = "f";
83 
85  public /*internal*/ const System.String SEPARATE_NORMS_EXTENSION = "s";
86 
88  public /*internal*/ const System.String GEN_EXTENSION = "gen";
89 
97  public /*internal*/ static readonly System.String[] INDEX_EXTENSIONS = new System.String[]{COMPOUND_FILE_EXTENSION, FIELD_INFOS_EXTENSION, FIELDS_INDEX_EXTENSION, FIELDS_EXTENSION, TERMS_INDEX_EXTENSION, TERMS_EXTENSION, FREQ_EXTENSION, PROX_EXTENSION, DELETES_EXTENSION, VECTORS_INDEX_EXTENSION, VECTORS_DOCUMENTS_EXTENSION, VECTORS_FIELDS_EXTENSION, GEN_EXTENSION, NORMS_EXTENSION, COMPOUND_FILE_STORE_EXTENSION};
98 
102  public /*internal*/ static readonly System.String[] INDEX_EXTENSIONS_IN_COMPOUND_FILE = new System.String[]{FIELD_INFOS_EXTENSION, FIELDS_INDEX_EXTENSION, FIELDS_EXTENSION, TERMS_INDEX_EXTENSION, TERMS_EXTENSION, FREQ_EXTENSION, PROX_EXTENSION, VECTORS_INDEX_EXTENSION, VECTORS_DOCUMENTS_EXTENSION, VECTORS_FIELDS_EXTENSION, NORMS_EXTENSION};
103 
104  public /*internal*/ static readonly System.String[] STORE_INDEX_EXTENSIONS = new System.String[]{VECTORS_INDEX_EXTENSION, VECTORS_FIELDS_EXTENSION, VECTORS_DOCUMENTS_EXTENSION, FIELDS_INDEX_EXTENSION, FIELDS_EXTENSION};
105 
106  public /*internal*/ static readonly System.String[] NON_STORE_INDEX_EXTENSIONS = new System.String[]{FIELD_INFOS_EXTENSION, FREQ_EXTENSION, PROX_EXTENSION, TERMS_EXTENSION, TERMS_INDEX_EXTENSION, NORMS_EXTENSION};
107 
109  public /*internal*/ static readonly System.String[] COMPOUND_EXTENSIONS = new System.String[]{FIELD_INFOS_EXTENSION, FREQ_EXTENSION, PROX_EXTENSION, FIELDS_INDEX_EXTENSION, FIELDS_EXTENSION, TERMS_INDEX_EXTENSION, TERMS_EXTENSION};
110 
112  public /*internal*/ static readonly System.String[] VECTOR_EXTENSIONS = new System.String[]{VECTORS_INDEX_EXTENSION, VECTORS_DOCUMENTS_EXTENSION, VECTORS_FIELDS_EXTENSION};
113 
126  public /*internal*/ static System.String FileNameFromGeneration(System.String base_Renamed, System.String extension, long gen)
127  {
128  if (gen == SegmentInfo.NO)
129  {
130  return null;
131  }
132  else if (gen == SegmentInfo.WITHOUT_GEN)
133  {
134  return base_Renamed + extension;
135  }
136  else
137  {
138 #if !PRE_LUCENE_NET_2_0_0_COMPATIBLE
139  return base_Renamed + "_" + Number.ToString(gen) + extension;
140 #else
141  return base_Renamed + "_" + System.Convert.ToString(gen, 16) + extension;
142 #endif
143  }
144  }
145 
150  internal static bool IsDocStoreFile(System.String fileName)
151  {
152  if (fileName.EndsWith(COMPOUND_FILE_STORE_EXTENSION))
153  return true;
154  for (int i = 0; i < STORE_INDEX_EXTENSIONS.Length; i++)
155  if (fileName.EndsWith(STORE_INDEX_EXTENSIONS[i]))
156  return true;
157  return false;
158  }
159 
160  internal static System.String SegmentFileName(System.String segmentName, System.String ext)
161  {
162  return segmentName + "." + ext;
163  }
164  }
165 }