internal FulltextIndexDescriptor(StoreIndexDescriptor descriptor, IList <string> propertyNames, Analyzer analyzer, string analyzerName, bool eventuallyConsistent) : base(descriptor)
 {
     this._propertyNames        = propertyNames;
     this._analyzer             = analyzer;
     this._analyzerName         = analyzerName;
     this._eventuallyConsistent = eventuallyConsistent;
 }
Beispiel #2
0
 public override void PopulationCompleteOn(StoreIndexDescriptor descriptor)
 {
     if (Barrier != null)
     {
         Barrier.release();
     }
 }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldContainFedRelationshipUpdate() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldContainFedRelationshipUpdate()
        {
            OnlineIndexUpdates onlineIndexUpdates = new OnlineIndexUpdates(_nodeStore, _relationshipStore, _indexingService, _propertyPhysicalToLogicalConverter);

            long relId = 0;
            RelationshipRecord inUse    = GetRelationship(relId, true, ENTITY_TOKEN);
            Value propertyValue         = Values.of("hej");
            long  propertyId            = CreateRelationshipProperty(inUse, propertyValue, 1);
            RelationshipRecord notInUse = GetRelationship(relId, false, ENTITY_TOKEN);

            _relationshipStore.updateRecord(inUse);

            Command.RelationshipCommand relationshipCommand = new Command.RelationshipCommand(inUse, notInUse);
            PropertyRecord propertyBlocks = new PropertyRecord(propertyId);

            propertyBlocks.RelId = relId;
            Command.PropertyCommand propertyCommand = new Command.PropertyCommand(_recordAccess.getIfLoaded(propertyId).forReadingData(), propertyBlocks);

            StoreIndexDescriptor indexDescriptor = forSchema(multiToken(_entityTokens, RELATIONSHIP, 1, 4, 6), EMPTY.ProviderDescriptor).withId(0);

            _indexingService.createIndexes(indexDescriptor);
            _indexingService.getIndexProxy(indexDescriptor.Schema()).awaitStoreScanCompleted(0, MILLISECONDS);

            onlineIndexUpdates.Feed(NodeGroup(null), RelationshipGroup(relationshipCommand, propertyCommand));
            assertTrue(onlineIndexUpdates.HasUpdates());
            IEnumerator <IndexEntryUpdate <SchemaDescriptor> > iterator = onlineIndexUpdates.GetEnumerator();

//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertEquals(iterator.next(), IndexEntryUpdate.remove(relId, indexDescriptor, propertyValue, null, null));
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertFalse(iterator.hasNext());
        }
Beispiel #4
0
        internal static FulltextIndexDescriptor ReadOrInitialiseDescriptor(StoreIndexDescriptor descriptor, string defaultAnalyzerName, TokenHolder propertyKeyTokenHolder, File indexFolder, FileSystemAbstraction fileSystem)
        {
            Properties indexConfiguration = new Properties();

            if (descriptor.Schema() is FulltextSchemaDescriptor)
            {
                FulltextSchemaDescriptor schema = ( FulltextSchemaDescriptor )descriptor.Schema();
                indexConfiguration.putAll(Schema.IndexConfiguration);
            }
            LoadPersistedSettings(indexConfiguration, indexFolder, fileSystem);
            bool           eventuallyConsistent = bool.Parse(indexConfiguration.getProperty(INDEX_CONFIG_EVENTUALLY_CONSISTENT));
            string         analyzerName         = indexConfiguration.getProperty(INDEX_CONFIG_ANALYZER, defaultAnalyzerName);
            Analyzer       analyzer             = CreateAnalyzer(analyzerName);
            IList <string> names = new List <string>();

            foreach (int propertyKeyId in descriptor.Schema().PropertyIds)
            {
                try
                {
                    names.Add(propertyKeyTokenHolder.GetTokenById(propertyKeyId).name());
                }
                catch (TokenNotFoundException e)
                {
                    throw new System.InvalidOperationException("Property key id not found.", new PropertyKeyIdNotFoundKernelException(propertyKeyId, e));
                }
            }
            IList <string> propertyNames = Collections.unmodifiableList(names);

            return(new FulltextIndexDescriptor(descriptor, propertyNames, analyzer, analyzerName, eventuallyConsistent));
        }
Beispiel #5
0
 public override void CheckIndexRule(StoreIndexDescriptor rule, DynamicRecord record, RecordAccess records, CheckerEngine <DynamicRecord, Org.Neo4j.Consistency.report.ConsistencyReport_SchemaConsistencyReport> engine)
 {
     if (rule.CanSupportUniqueConstraint())
     {
         DynamicRecord obligation = outerInstance.indexObligations[rule.Id];
         if (obligation == null)                                // no pointer to here
         {
             if (rule.OwningConstraint != null)                 // we only expect a pointer if we have an owner
             {
                 engine.Report().missingObligation(Org.Neo4j.Storageengine.Api.schema.SchemaRule_Kind.UniquenessConstraint);
             }
         }
         else
         {
             // if someone points to here, it must be our owner
             if (obligation.Id != rule.OwningConstraint.Value)
             {
                 engine.Report().constraintIndexRuleNotReferencingBack(obligation);
             }
         }
     }
     if (outerInstance.indexAccessors.NotOnlineRules().Contains(rule))
     {
         engine.Report().schemaRuleNotOnline(rule);
     }
 }
            public override void Run()
            {
                Org.Neo4j.Kernel.api.schema.LabelSchemaDescriptor descriptor = SchemaDescriptorFactory.forLabel(LabelIdToDropIndexFor, outerInstance.propertyId);
                StoreIndexDescriptor rule = FindRuleForLabel(descriptor);

                outerInstance.indexService.DropIndex(rule);
            }
Beispiel #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldDropIndexGivenDropSchemaRuleCommand() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldDropIndexGivenDropSchemaRuleCommand()
        {
            // Given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.storageengine.api.schema.StoreIndexDescriptor indexRule = indexRule(1, 42, 42, INDEX_DESCRIPTOR);
            StoreIndexDescriptor indexRule = indexRule(1, 42, 42, _indexDescriptor);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final IndexBatchTransactionApplier applier = newIndexTransactionApplier();
            IndexBatchTransactionApplier applier = NewIndexTransactionApplier();

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final Command.SchemaRuleCommand command = new Command.SchemaRuleCommand(singleton(createdDynamicRecord(1)), singleton(dynamicRecord(1, false)), indexRule);
            Command.SchemaRuleCommand command = new Command.SchemaRuleCommand(singleton(CreatedDynamicRecord(1)), singleton(dynamicRecord(1, false)), indexRule);

            // When
            bool result;

            using (TransactionApplier txApplier = applier.StartTx(_transactionToApply))
            {
                result = txApplier.VisitSchemaRuleCommand(command);
            }

            // Then
            assertFalse(result);
            verify(_indexingService).dropIndex(indexRule);
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void createEmptyIndex(org.neo4j.storageengine.api.schema.StoreIndexDescriptor schemaIndexDescriptor, SpatialIndexProvider provider) throws java.io.IOException
        private void CreateEmptyIndex(StoreIndexDescriptor schemaIndexDescriptor, SpatialIndexProvider provider)
        {
            IndexPopulator populator = provider.GetPopulator(schemaIndexDescriptor, SamplingConfig(), heapBufferFactory(1024));

            populator.Create();
            populator.Close(true);
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void createEmptyIndex(org.neo4j.storageengine.api.schema.StoreIndexDescriptor schemaIndexDescriptor, org.neo4j.kernel.impl.index.schema.config.ConfiguredSpaceFillingCurveSettingsCache configuredSettings) throws java.io.IOException
        private void CreateEmptyIndex(StoreIndexDescriptor schemaIndexDescriptor, ConfiguredSpaceFillingCurveSettingsCache configuredSettings)
        {
            SpatialIndexFiles.SpatialFileLayout fileLayout = MakeIndexFile(schemaIndexDescriptor.Id, configuredSettings).LayoutForNewIndex;
            SpatialIndexPopulator.PartPopulator populator  = new SpatialIndexPopulator.PartPopulator(_pageCache, Fs, fileLayout, _monitor, schemaIndexDescriptor, new StandardConfiguration());
            populator.Create();
            populator.Close(true);
        }
        public override InternalIndexState GetInitialState(StoreIndexDescriptor descriptor)
        {
            TemporalIndexFiles temporalIndexFiles = new TemporalIndexFiles(DirectoryStructure(), descriptor, _fs);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final Iterable<TemporalIndexFiles.FileLayout> existing = temporalIndexFiles.existing();
            IEnumerable <TemporalIndexFiles.FileLayout> existing = temporalIndexFiles.Existing();
            InternalIndexState state = InternalIndexState.ONLINE;

            foreach (TemporalIndexFiles.FileLayout subIndex in existing)
            {
                try
                {
                    switch (NativeIndexes.ReadState(_pageCache, subIndex.indexFile))
                    {
                    case FAILED:
                        return(InternalIndexState.FAILED);

                    case POPULATING:
                        state = InternalIndexState.POPULATING;
                        goto default;

                    default:                              // continue
                        break;
                    }
                }
                catch (Exception e) when(e is MetadataMismatchException || e is IOException)
                {
                    _monitor.failedToOpenIndex(descriptor, "Requesting re-population.", e);
                    return(InternalIndexState.POPULATING);
                }
            }
            return(state);
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void visitAddedNodeKeyConstraint(org.neo4j.kernel.api.schema.constraints.NodeKeyConstraintDescriptor uniqueConstraint, long constraintId) throws org.neo4j.internal.kernel.api.exceptions.schema.CreateConstraintFailureException
        private void VisitAddedNodeKeyConstraint(NodeKeyConstraintDescriptor uniqueConstraint, long constraintId)
        {
            StoreIndexDescriptor indexRule = _schemaStorage.indexGetForSchema(uniqueConstraint.OwnedIndexDescriptor());

            _recordState.createSchemaRule(_constraintSemantics.createNodeKeyConstraintRule(constraintId, uniqueConstraint, indexRule.Id));
            _recordState.setConstraintIndexOwner(indexRule, constraintId);
        }
Beispiel #12
0
 internal PartFactory(PageCache pageCache, FileSystemAbstraction fs, TemporalIndexFiles temporalIndexFiles, StoreIndexDescriptor descriptor, IndexSamplingConfig samplingConfig, IndexProvider.Monitor monitor)
 {
     this.PageCache          = pageCache;
     this.Fs                 = fs;
     this.TemporalIndexFiles = temporalIndexFiles;
     this.Descriptor         = descriptor;
     this.SamplingConfig     = samplingConfig;
     this.Monitor            = monitor;
 }
 internal PartFactory(PageCache pageCache, FileSystemAbstraction fs, SpatialIndexFiles spatialIndexFiles, StoreIndexDescriptor descriptor, IndexProvider.Monitor monitor, SpaceFillingCurveConfiguration configuration)
 {
     this.PageCache         = pageCache;
     this.Fs                = fs;
     this.SpatialIndexFiles = spatialIndexFiles;
     this.Descriptor        = descriptor;
     this.Monitor           = monitor;
     this.Configuration     = configuration;
 }
Beispiel #14
0
		 private void SetOwnerNull( SchemaStore schemaStore, StoreIndexDescriptor rule )
		 {
			  rule = rule.WithOwningConstraint( null );
			  IList<DynamicRecord> dynamicRecords = schemaStore.AllocateFrom( rule );
			  foreach ( DynamicRecord record in dynamicRecords )
			  {
					schemaStore.UpdateRecord( record );
			  }
		 }
Beispiel #15
0
 internal PartAccessor(PageCache pageCache, FileSystemAbstraction fs, SpatialIndexFiles.SpatialFileLayout fileLayout, RecoveryCleanupWorkCollector recoveryCleanupWorkCollector, IndexProvider.Monitor monitor, StoreIndexDescriptor descriptor, SpaceFillingCurveConfiguration searchConfiguration, bool readOnly) : base(pageCache, fs, fileLayout.IndexFile, fileLayout.Layout, monitor, descriptor, NO_HEADER_WRITER, readOnly)
 {
     this.Layout              = fileLayout.Layout;
     this.Descriptor          = descriptor;
     this.SearchConfiguration = searchConfiguration;
     this.Crs      = fileLayout.SpatialFile.crs;
     this.Settings = fileLayout.Settings;
     instantiateTree(recoveryCleanupWorkCollector, HeaderWriter);
 }
        public override IndexPopulator GetPopulator(StoreIndexDescriptor descriptor, IndexSamplingConfig samplingConfig, ByteBufferFactory bufferFactory)
        {
            if (_readOnly)
            {
                throw new System.NotSupportedException("Can't create populator for read only index");
            }
            TemporalIndexFiles files = new TemporalIndexFiles(DirectoryStructure(), descriptor, _fs);

            return(new TemporalIndexPopulator(descriptor, samplingConfig, files, _pageCache, _fs, _monitor));
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public String getPopulationFailure(org.neo4j.storageengine.api.schema.StoreIndexDescriptor descriptor) throws IllegalStateException
        public override string GetPopulationFailure(StoreIndexDescriptor descriptor)
        {
            string failure = GetIndexStorage(descriptor.Id).StoredIndexFailure;

            if (string.ReferenceEquals(failure, null))
            {
                throw new System.InvalidOperationException("Index " + descriptor.Id + " isn't failed");
            }
            return(failure);
        }
Beispiel #18
0
 internal NativeIndex(PageCache pageCache, FileSystemAbstraction fs, File storeFile, IndexLayout <KEY, VALUE> layout, IndexProvider.Monitor monitor, StoreIndexDescriptor descriptor, bool readOnly)
 {
     this.PageCache  = pageCache;
     this.StoreFile  = storeFile;
     this.Layout     = layout;
     this.FileSystem = fs;
     this.Descriptor = descriptor;
     this._monitor   = monitor;
     this._readOnly  = readOnly;
 }
Beispiel #19
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setup() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void Setup()
        {
            ValueCreatorUtil        = CreateValueCreatorUtil();
            IndexDescriptor         = ValueCreatorUtil.indexDescriptor();
            Layout                  = CreateLayout();
            IndexDirectoryStructure = directoriesByProvider(_directory.directory("root")).forProvider(IndexDescriptor.providerDescriptor());
            _indexFile              = IndexDirectoryStructure.directoryForIndex(IndexDescriptor.Id);
            Fs.mkdirs(_indexFile.ParentFile);
            PageCache = _pageCacheRule.getPageCache(Fs);
        }
Beispiel #20
0
        public void PutIndexProxy(IndexProxy indexProxy)
        {
            StoreIndexDescriptor descriptor = indexProxy.Descriptor;
            SchemaDescriptor     schema     = descriptor.Schema();

            _indexesById.put(descriptor.Id, indexProxy);
            _indexesByDescriptor[schema] = indexProxy;
            _indexIdsByDescriptor.put(schema, descriptor.Id);
            AddDescriptorToLookups(schema);
        }
Beispiel #21
0
            public bool test(StoreIndexDescriptor descriptor)
            {
                bool result = _outerInstance.storeView.indexSample(descriptor.Id, register).readSecond() == 0;

                if (result)
                {
                    log.debug("Recovering index sampling for index %s", descriptor.Schema().userDescription(_tokenNameLookup));
                }
                return(result);
            }
Beispiel #22
0
 internal PartFactory(PageCache pageCache, FileSystemAbstraction fs, RecoveryCleanupWorkCollector recoveryCleanupWorkCollector, IndexProvider.Monitor monitor, StoreIndexDescriptor descriptor, SpatialIndexFiles spatialIndexFiles, SpaceFillingCurveConfiguration searchConfiguration, bool readOnly)
 {
     this.PageCache = pageCache;
     this.Fs        = fs;
     this.RecoveryCleanupWorkCollector = recoveryCleanupWorkCollector;
     this.Monitor             = monitor;
     this.Descriptor          = descriptor;
     this.SpatialIndexFiles   = spatialIndexFiles;
     this.SearchConfiguration = searchConfiguration;
     this.ReadOnly            = readOnly;
 }
Beispiel #23
0
        public override IndexPopulator GetPopulator(StoreIndexDescriptor descriptor, IndexSamplingConfig samplingConfig, ByteBufferFactory bufferFactory)
        {
            if (ReadOnly)
            {
                throw new System.NotSupportedException("Can't create populator for read only index");
            }

            File storeFile = NativeIndexFileFromIndexId(descriptor.Id);

            return(NewIndexPopulator(storeFile, Layout(descriptor, null), descriptor, bufferFactory));
        }
Beispiel #24
0
        private SchemaStorage CreateSchemaStorage()
        {
            SchemaStorage               schemaStorage = mock(typeof(SchemaStorage));
            StoreIndexDescriptor        rule          = _descriptor.withId(INDEX_ID);
            List <StoreIndexDescriptor> rules         = new List <StoreIndexDescriptor>();

            rules.Add(rule);

            when(schemaStorage.IndexesGetAll()).thenReturn(rules.GetEnumerator());
            return(schemaStorage);
        }
Beispiel #25
0
 internal PartFactory(PageCache pageCache, FileSystemAbstraction fs, RecoveryCleanupWorkCollector recoveryCleanupWorkCollector, IndexProvider.Monitor monitor, StoreIndexDescriptor descriptor, IndexSamplingConfig samplingConfig, TemporalIndexFiles temporalIndexFiles, bool readOnly)
 {
     this.PageCache = pageCache;
     this.Fs        = fs;
     this.RecoveryCleanupWorkCollector = recoveryCleanupWorkCollector;
     this.Monitor            = monitor;
     this.Descriptor         = descriptor;
     this.SamplingConfig     = samplingConfig;
     this.TemporalIndexFiles = temporalIndexFiles;
     this.ReadOnly           = readOnly;
 }
Beispiel #26
0
        public virtual void Remove(StoreIndexDescriptor descriptor)
        {
            IndexAccessor remove = _accessors.remove(descriptor.Id);

            if (remove != null)
            {
                remove.Dispose();
            }
            _onlineIndexRules.Remove(descriptor);
            _notOnlineIndexRules.Remove(descriptor);
        }
Beispiel #27
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReturnNullIfIndexRuleForLabelAndPropertyDoesNotExist()
        public virtual void ShouldReturnNullIfIndexRuleForLabelAndPropertyDoesNotExist()
        {
            // Given
            CreateSchema(Index(LABEL1, PROP1));

            // When
            StoreIndexDescriptor rule = _storage.indexGetForSchema(IndexDescriptor(LABEL1, PROP2));

            // Then
            assertNull(rule);
        }
Beispiel #28
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldListIndexRulesForLabelPropertyAndKind()
        public virtual void ShouldListIndexRulesForLabelPropertyAndKind()
        {
            // Given
            CreateSchema(UniquenessConstraint(LABEL1, PROP1), Index(LABEL1, PROP2));

            // When
            StoreIndexDescriptor rule = _storage.indexGetForSchema(UniqueIndexDescriptor(LABEL1, PROP1));

            // Then
            assertNotNull(rule);
            AssertRule(rule, LABEL1, PROP1, IndexDescriptor.Type.UNIQUE);
        }
Beispiel #29
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReturnIndexRuleForLabelAndProperty()
        public virtual void ShouldReturnIndexRuleForLabelAndProperty()
        {
            // Given
            CreateSchema(Index(LABEL1, PROP1), Index(LABEL1, PROP2), Index(LABEL2, PROP1));

            // When
            StoreIndexDescriptor rule = _storage.indexGetForSchema(IndexDescriptor(LABEL1, PROP2));

            // Then
            assertNotNull(rule);
            AssertRule(rule, LABEL1, PROP2, IndexDescriptor.Type.GENERAL);
        }
        // === INDEX RULES ===

        private static StoreIndexDescriptor ReadIndexRule(long id, bool constraintIndex, int label, ByteBuffer serialized)
        {
            IndexProviderDescriptor providerDescriptor = ReadIndexProviderDescriptor(serialized);

            int[] propertyKeyIds                       = ReadIndexPropertyKeys(serialized);
            LabelSchemaDescriptor schema               = SchemaDescriptorFactory.forLabel(label, propertyKeyIds);
            Optional <string>     name                 = null;
            IndexDescriptor       descriptor           = constraintIndex ? IndexDescriptorFactory.uniqueForSchema(schema, name, providerDescriptor) : IndexDescriptorFactory.forSchema(schema, name, providerDescriptor);
            StoreIndexDescriptor  storeIndexDescriptor = constraintIndex ? descriptor.WithIds(id, ReadOwningConstraint(serialized)) : descriptor.WithId(id);

            return(storeIndexDescriptor);
        }