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);
        }
Example #2
0
//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);
        }
Example #3
0
        public override IndexCapability GetCapability(StoreIndexDescriptor descriptor)
        {
            FulltextIndexDescriptor fulltextIndexDescriptor;

            if (descriptor is FulltextIndexDescriptor)
            {
                // We got our own index descriptor type, so we can ask it directly.
                fulltextIndexDescriptor = ( FulltextIndexDescriptor )descriptor;
                return(new FulltextIndexCapability(fulltextIndexDescriptor.EventuallyConsistent));
            }
            SchemaDescriptor schema = descriptor.Schema();

            if (schema is FulltextSchemaDescriptor)
            {
                // The fulltext schema descriptor is readily available with our settings.
                // This could be the situation where the index creation is about to be committed.
                // In that case, the schema descriptor is our own legit type, but the StoreIndexDescriptor is generic.
                FulltextSchemaDescriptor fulltextSchemaDescriptor = ( FulltextSchemaDescriptor )schema;
                return(new FulltextIndexCapability(fulltextSchemaDescriptor.EventuallyConsistent));
            }
            // The schema descriptor is probably a generic multi-token descriptor.
            // This happens if it was loaded from the schema store instead of created by our provider.
            // This would be the case when the IndexingService is starting up, and if so, we probably have an online accessor that we can ask instead.
            FulltextIndexAccessor accessor = GetOpenOnlineAccessor(descriptor);

            if (accessor != null)
            {
                fulltextIndexDescriptor = accessor.Descriptor;
                return(new FulltextIndexCapability(fulltextIndexDescriptor.EventuallyConsistent));
            }
            // All of the above has failed, so we need to load the settings in from the storage directory of the index.
            // This situation happens during recovery.
            PartitionedIndexStorage indexStorage = GetIndexStorage(descriptor.Id);

            fulltextIndexDescriptor = readOrInitialiseDescriptor(descriptor, _defaultAnalyzerName, _tokenHolders.propertyKeyTokens(), indexStorage.IndexFolder, _fileSystem);
            return(new FulltextIndexCapability(fulltextIndexDescriptor.EventuallyConsistent));
        }
Example #4
0
 internal FulltextIndexUpdater(FulltextIndexAccessor outerInstance, bool idempotent, bool refresh) : base(outerInstance, idempotent, refresh)
 {
     this._outerInstance = outerInstance;
 }