//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldPersistFulltextIndexSettings() throws java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldPersistFulltextIndexSettings() { // Given File indexFolder = Directory.directory("indexFolder"); string analyzerName = "simple"; string eventuallyConsistency = "true"; string defaultAnalyzer = "defaultAnalyzer"; int[] propertyIds = new int[] { 1, 2, 3 }; MultiTokenSchemaDescriptor schema = SchemaDescriptorFactory.multiToken(new int[] { 1, 2 }, EntityType.NODE, propertyIds); // A fulltext index descriptor with configurations Properties properties = properties(analyzerName, eventuallyConsistency); FulltextSchemaDescriptor fulltextSchemaDescriptor = new FulltextSchemaDescriptor(schema, properties); StoreIndexDescriptor storeIndexDescriptor = StoreIndexDescriptorFromSchema(fulltextSchemaDescriptor); TokenRegistry tokenRegistry = SimpleTokenHolder.CreatePopulatedTokenRegistry(Org.Neo4j.Kernel.impl.core.TokenHolder_Fields.TYPE_PROPERTY_KEY, propertyIds); SimpleTokenHolder tokenHolder = new SimpleTokenHolder(tokenRegistry); FulltextIndexDescriptor fulltextIndexDescriptor = readOrInitialiseDescriptor(storeIndexDescriptor, defaultAnalyzer, tokenHolder, indexFolder, Fs); assertEquals(analyzerName, fulltextIndexDescriptor.AnalyzerName()); assertEquals(bool.Parse(eventuallyConsistency), fulltextIndexDescriptor.EventuallyConsistent); // When persisting it FulltextIndexSettings.SaveFulltextIndexSettings(fulltextIndexDescriptor, indexFolder, Fs); // Then we should be able to load it back with settings being the same StoreIndexDescriptor loadingIndexDescriptor = StoreIndexDescriptorFromSchema(schema); FulltextIndexDescriptor loadedDescriptor = readOrInitialiseDescriptor(loadingIndexDescriptor, defaultAnalyzer, tokenHolder, indexFolder, Fs); assertEquals(fulltextIndexDescriptor.AnalyzerName(), loadedDescriptor.AnalyzerName()); assertEquals(fulltextIndexDescriptor.EventuallyConsistent, loadedDescriptor.EventuallyConsistent); }
public override IndexPopulator GetPopulator(StoreIndexDescriptor descriptor, IndexSamplingConfig samplingConfig, ByteBufferFactory bufferFactory) { PartitionedIndexStorage indexStorage = GetIndexStorage(descriptor.Id); FulltextIndexDescriptor fulltextIndexDescriptor = readOrInitialiseDescriptor(descriptor, _defaultAnalyzerName, _tokenHolders.propertyKeyTokens(), indexStorage.IndexFolder, _fileSystem); DatabaseIndex <FulltextIndexReader> fulltextIndex = FulltextIndexBuilder.Create(fulltextIndexDescriptor, _config, _tokenHolders.propertyKeyTokens()).withFileSystem(_fileSystem).withOperationalMode(_operationalMode).withIndexStorage(indexStorage).withPopulatingMode(true).build(); if (fulltextIndex.ReadOnly) { throw new System.NotSupportedException("Can't create populator for read only index"); } _log.debug("Creating populator for fulltext schema index: %s", descriptor); return(new FulltextIndexPopulator(fulltextIndexDescriptor, fulltextIndex, () => FulltextIndexSettings.saveFulltextIndexSettings(fulltextIndexDescriptor, indexStorage.IndexFolder, _fileSystem))); }
internal FulltextIndexTransactionState(FulltextIndexProvider provider, Log log, IndexReference indexReference) { FulltextIndexAccessor accessor = provider.GetOpenOnlineAccessor(( StoreIndexDescriptor )indexReference); log.Debug("Acquired online fulltext schema index accessor, as base accessor for transaction state: %s", accessor); _descriptor = accessor.Descriptor; SchemaDescriptor schema = _descriptor.schema(); _toCloseLater = new List <AutoCloseable>(); _writer = accessor.TransactionStateIndexWriter; _modifiedEntityIdsInThisTransaction = new LongHashSet(); _visitingNodes = Schema.entityType() == EntityType.NODE; _txStateVisitor = new FulltextIndexTransactionStateVisitor(_descriptor, _modifiedEntityIdsInThisTransaction, _writer); }
internal FulltextIndexTransactionStateVisitor(FulltextIndexDescriptor descriptor, MutableLongSet modifiedEntityIdsInThisTransaction, TransactionStateLuceneIndexWriter writer) { this._descriptor = descriptor; this._schema = descriptor.Schema(); this._modifiedEntityIdsInThisTransaction = modifiedEntityIdsInThisTransaction; this._writer = writer; this._visitingNodes = _schema.entityType() == EntityType.NODE; _entityTokenIds = _schema.EntityTokenIds; int[] propertyIds = _schema.PropertyIds; _propertyValues = new Value[propertyIds.Length]; _propKeyToIndex = new IntIntHashMap(); for (int i = 0; i < propertyIds.Length; i++) { _propKeyToIndex.put(propertyIds[i], i); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: static void saveFulltextIndexSettings(FulltextIndexDescriptor descriptor, java.io.File indexFolder, org.neo4j.io.fs.FileSystemAbstraction fs) throws java.io.IOException internal static void SaveFulltextIndexSettings(FulltextIndexDescriptor descriptor, File indexFolder, FileSystemAbstraction fs) { File indexConfigFile = new File(indexFolder, INDEX_CONFIG_FILE); Properties settings = new Properties(); settings.setProperty(INDEX_CONFIG_EVENTUALLY_CONSISTENT, Convert.ToString(descriptor.EventuallyConsistent)); settings.setProperty(INDEX_CONFIG_ANALYZER, descriptor.AnalyzerName()); //JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter: settings.setProperty(INDEX_CONFIG_PROPERTY_NAMES, descriptor.PropertyNames().collect(Collectors.joining(", ", "[", "]"))); settings.setProperty("_propertyIds", Arrays.ToString(descriptor.Properties())); settings.setProperty("_name", descriptor.Name()); settings.setProperty("_schema_entityType", descriptor.Schema().entityType().name()); settings.setProperty("_schema_entityTokenIds", Arrays.ToString(descriptor.Schema().EntityTokenIds)); using (StoreChannel channel = fs.Create(indexConfigFile), Writer writer = fs.OpenAsWriter(indexConfigFile, StandardCharsets.UTF_8, false)) { settings.store(writer, "Auto-generated file. Do not modify!"); writer.flush(); channel.Force(true); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public org.neo4j.kernel.api.index.IndexAccessor getOnlineAccessor(org.neo4j.storageengine.api.schema.StoreIndexDescriptor descriptor, org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig samplingConfig) throws java.io.IOException public override IndexAccessor GetOnlineAccessor(StoreIndexDescriptor descriptor, IndexSamplingConfig samplingConfig) { PartitionedIndexStorage indexStorage = GetIndexStorage(descriptor.Id); FulltextIndexDescriptor fulltextIndexDescriptor = readOrInitialiseDescriptor(descriptor, _defaultAnalyzerName, _tokenHolders.propertyKeyTokens(), indexStorage.IndexFolder, _fileSystem); FulltextIndexBuilder fulltextIndexBuilder = FulltextIndexBuilder.Create(fulltextIndexDescriptor, _config, _tokenHolders.propertyKeyTokens()).withFileSystem(_fileSystem).withOperationalMode(_operationalMode).withIndexStorage(indexStorage).withPopulatingMode(false); if (fulltextIndexDescriptor.EventuallyConsistent) { fulltextIndexBuilder = fulltextIndexBuilder.WithIndexUpdateSink(_indexUpdateSink); } DatabaseFulltextIndex fulltextIndex = fulltextIndexBuilder.Build(); fulltextIndex.open(); ThreadStart onClose = () => _openOnlineAccessors.remove(descriptor); FulltextIndexAccessor accessor = new FulltextIndexAccessor(_indexUpdateSink, fulltextIndex, fulltextIndexDescriptor, onClose); _openOnlineAccessors.put(descriptor, accessor); _log.debug("Created online accessor for fulltext schema index %s: %s", descriptor, accessor); return(accessor); }
/// <summary> /// Create new lucene fulltext index builder. /// </summary> /// <param name="descriptor"> The descriptor for this index </param> /// <param name="propertyKeyTokenHolder"> A token holder used to look up property key token names by id. </param> /// <returns> new FulltextIndexBuilder </returns> public static FulltextIndexBuilder Create(FulltextIndexDescriptor descriptor, Config config, TokenHolder propertyKeyTokenHolder) { return(new FulltextIndexBuilder(descriptor, config, propertyKeyTokenHolder)); }
private FulltextIndexBuilder(FulltextIndexDescriptor descriptor, Config config, TokenHolder propertyKeyTokenHolder) : base(config) { this._descriptor = descriptor; this._propertyKeyTokenHolder = propertyKeyTokenHolder; }
internal LuceneFulltextIndex(PartitionedIndexStorage storage, IndexPartitionFactory partitionFactory, FulltextIndexDescriptor descriptor, TokenHolder propertyKeyTokenHolder) : base(storage, partitionFactory, descriptor) { this._analyzer = descriptor.Analyzer(); this._identifier = descriptor.Name; this._type = descriptor.Schema().entityType(); this._properties = descriptor.PropertyNames(); this._propertyKeyTokenHolder = propertyKeyTokenHolder; File indexFolder = storage.IndexFolder; _transactionsFolder = new File(indexFolder.Parent, indexFolder.Name + ".tx"); }
public FulltextIndexAccessor(IndexUpdateSink indexUpdateSink, DatabaseFulltextIndex luceneIndex, FulltextIndexDescriptor descriptor, ThreadStart onClose) : base(luceneIndex, descriptor) { this._indexUpdateSink = indexUpdateSink; this._descriptor = descriptor; this._onClose = onClose; }
public FulltextIndexPopulator(FulltextIndexDescriptor descriptor, DatabaseIndex <FulltextIndexReader> luceneFulltext, ThrowingAction <IOException> descriptorCreateAction) : base(luceneFulltext) { this._descriptor = descriptor; this._descriptorCreateAction = descriptorCreateAction; }