Esempio n. 1
0
		private static void EnsureIndexVersionMatches(Lucene.Net.Store.Directory directory, IndexDefinition indexDefinition)
		{
			var versionToCheck = IndexVersion;
			if (indexDefinition.IsMapReduce)
			{
				versionToCheck = MapReduceIndexVersion;
			}
			var indexVersion = IndexVersionFileName(indexDefinition);
			if (directory.FileExists(indexVersion) == false)
			{
				throw new InvalidOperationException("Could not find " + indexVersion + " " + indexDefinition.IndexId + ", resetting index");
			}
			using (var indexInput = directory.OpenInput(indexVersion))
			{
				var versionFromDisk = indexInput.ReadString();
				if (versionFromDisk != versionToCheck)
					throw new InvalidOperationException("Index " + indexDefinition.IndexId + " is of version " + versionFromDisk +
														" which is not compatible with " + versionToCheck + ", resetting index");
			}
		}
Esempio n. 2
0
		private static void EnsureIndexVersionMatches(string indexName, Lucene.Net.Store.Directory directory)
		{
			if (directory.FileExists("index.version") == false)
			{
				throw new InvalidOperationException("Could not find index.version " + indexName + ", resetting index");
			}
			using(var indexInput = directory.OpenInput("index.version"))
			{
				var versionFromDisk = indexInput.ReadString();
				if (versionFromDisk != IndexVersion)
					throw new InvalidOperationException("Index " + indexName + " is of version " + versionFromDisk +
														" which is not compatible with " + IndexVersion + ", resetting index");
			}
		}