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)); }
//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()); }
private void VerifyNodeCorrectlyIndexedUniquely(long nodeId, Value[] propertyValues, CheckerEngine <NodeRecord, Org.Neo4j.Consistency.report.ConsistencyReport_NodeConsistencyReport> engine, StoreIndexDescriptor indexRule, IndexReader reader) { IndexQuery[] query = Seek(indexRule.Schema(), propertyValues); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.eclipse.collections.api.iterator.LongIterator indexedNodeIds = queryIndexOrEmpty(reader, query); LongIterator indexedNodeIds = QueryIndexOrEmpty(reader, query); long count = 0; while (indexedNodeIds.hasNext()) { long indexedNodeId = indexedNodeIds.next(); if (nodeId == indexedNodeId) { count++; } else { engine.Report().uniqueIndexNotUnique(indexRule, Values.asObjects(propertyValues), indexedNodeId); } } ReportIncorrectIndexCount(propertyValues, engine, indexRule, count); }
/* getOnlineAccessor */ //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotCheckConflictsWhenApplyingUpdatesInOnlineAccessor() throws java.io.IOException, org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldNotCheckConflictsWhenApplyingUpdatesInOnlineAccessor() { // given _provider = NewProvider(); // when StoreIndexDescriptor descriptor = DescriptorUnique(); using (IndexAccessor accessor = _provider.getOnlineAccessor(descriptor, SamplingConfig()), IndexUpdater indexUpdater = accessor.NewUpdater(IndexUpdateMode.ONLINE)) { Value value = SomeValue(); indexUpdater.Process(IndexEntryUpdate.add(1, descriptor.Schema(), value)); // then // ... expect no failure on duplicate value indexUpdater.Process(IndexEntryUpdate.add(2, descriptor.Schema(), value)); } }
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); }
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); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void storeAndLoad_Big_CompositeMultiTokenSchemaRule() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void StoreAndLoadBigCompositeMultiTokenSchemaRule() { // GIVEN StoreIndexDescriptor indexRule = forSchema(multiToken(IntStream.range(1, 200).toArray(), EntityType.RELATIONSHIP, IntStream.range(1, 200).toArray()), PROVIDER_DESCRIPTOR).withId(_store.nextId()); // WHEN StoreIndexDescriptor readIndexRule = ( StoreIndexDescriptor )SchemaRuleSerialization.deserialize(indexRule.Id, wrap(SchemaRuleSerialization.serialize(indexRule))); // THEN assertEquals(indexRule.Id, readIndexRule.Id); assertEquals(indexRule.Schema(), readIndexRule.Schema()); assertEquals(indexRule, readIndexRule); assertEquals(indexRule.ProviderDescriptor(), readIndexRule.ProviderDescriptor()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void storeAndLoadSchemaRule() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void StoreAndLoadSchemaRule() { // GIVEN StoreIndexDescriptor indexRule = forSchema(forLabel(1, 4), PROVIDER_DESCRIPTOR).withId(_store.nextId()); // WHEN StoreIndexDescriptor readIndexRule = ( StoreIndexDescriptor )SchemaRuleSerialization.deserialize(indexRule.Id, wrap(SchemaRuleSerialization.serialize(indexRule))); // THEN assertEquals(indexRule.Id, readIndexRule.Id); assertEquals(indexRule.Schema(), readIndexRule.Schema()); assertEquals(indexRule, readIndexRule); assertEquals(indexRule.ProviderDescriptor(), readIndexRule.ProviderDescriptor()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void storeAndLoadCompositeSchemaRule() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void StoreAndLoadCompositeSchemaRule() { // GIVEN int[] propertyIds = new int[] { 4, 5, 6, 7 }; StoreIndexDescriptor indexRule = forSchema(forLabel(2, propertyIds), PROVIDER_DESCRIPTOR).withId(_store.nextId()); // WHEN StoreIndexDescriptor readIndexRule = ( StoreIndexDescriptor )SchemaRuleSerialization.deserialize(indexRule.Id, wrap(SchemaRuleSerialization.serialize(indexRule))); // THEN assertEquals(indexRule.Id, readIndexRule.Id); assertEquals(indexRule.Schema(), readIndexRule.Schema()); assertEquals(indexRule, readIndexRule); assertEquals(indexRule.ProviderDescriptor(), readIndexRule.ProviderDescriptor()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void storeAndLoadAnyTokenMultiTokenSchemaRule() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void StoreAndLoadAnyTokenMultiTokenSchemaRule() { // GIVEN int[] propertyIds = new int[] { 4, 5, 6, 7 }; int[] entityTokens = new int[] {}; StoreIndexDescriptor indexRule = forSchema(multiToken(entityTokens, EntityType.NODE, propertyIds), PROVIDER_DESCRIPTOR).withId(_store.nextId()); // WHEN StoreIndexDescriptor readIndexRule = ( StoreIndexDescriptor )SchemaRuleSerialization.deserialize(indexRule.Id, wrap(SchemaRuleSerialization.serialize(indexRule))); // THEN assertEquals(indexRule.Id, readIndexRule.Id); assertEquals(indexRule.Schema(), readIndexRule.Schema()); assertEquals(indexRule, readIndexRule); assertEquals(indexRule.ProviderDescriptor(), readIndexRule.ProviderDescriptor()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldDifferentiateNodesAndRelationships() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldDifferentiateNodesAndRelationships() { OnlineIndexUpdates onlineIndexUpdates = new OnlineIndexUpdates(_nodeStore, _relationshipStore, _indexingService, _propertyPhysicalToLogicalConverter); int nodeId = 0; NodeRecord inUseNode = GetNode(nodeId, true); Value nodePropertyValue = Values.of("hej"); long nodePropertyId = CreateNodeProperty(inUseNode, nodePropertyValue, 1); NodeRecord notInUseNode = GetNode(nodeId, false); _nodeStore.updateRecord(inUseNode); Command.NodeCommand nodeCommand = new Command.NodeCommand(inUseNode, notInUseNode); PropertyRecord nodePropertyBlocks = new PropertyRecord(nodePropertyId); nodePropertyBlocks.NodeId = nodeId; Command.PropertyCommand nodePropertyCommand = new Command.PropertyCommand(_recordAccess.getIfLoaded(nodePropertyId).forReadingData(), nodePropertyBlocks); StoreIndexDescriptor nodeIndexDescriptor = forSchema(multiToken(_entityTokens, NODE, 1, 4, 6), EMPTY.ProviderDescriptor).withId(0); _indexingService.createIndexes(nodeIndexDescriptor); _indexingService.getIndexProxy(nodeIndexDescriptor.Schema()).awaitStoreScanCompleted(0, MILLISECONDS); long relId = 0; RelationshipRecord inUse = GetRelationship(relId, true, ENTITY_TOKEN); Value relationshipPropertyValue = Values.of("da"); long propertyId = CreateRelationshipProperty(inUse, relationshipPropertyValue, 1); RelationshipRecord notInUse = GetRelationship(relId, false, ENTITY_TOKEN); _relationshipStore.updateRecord(inUse); Command.RelationshipCommand relationshipCommand = new Command.RelationshipCommand(inUse, notInUse); PropertyRecord relationshipPropertyBlocks = new PropertyRecord(propertyId); relationshipPropertyBlocks.RelId = relId; Command.PropertyCommand relationshipPropertyCommand = new Command.PropertyCommand(_recordAccess.getIfLoaded(propertyId).forReadingData(), relationshipPropertyBlocks); StoreIndexDescriptor relationshipIndexDescriptor = forSchema(multiToken(_entityTokens, RELATIONSHIP, 1, 4, 6), EMPTY.ProviderDescriptor).withId(1); _indexingService.createIndexes(relationshipIndexDescriptor); _indexingService.getIndexProxy(relationshipIndexDescriptor.Schema()).awaitStoreScanCompleted(0, MILLISECONDS); onlineIndexUpdates.Feed(NodeGroup(nodeCommand, nodePropertyCommand), RelationshipGroup(relationshipCommand, relationshipPropertyCommand)); assertTrue(onlineIndexUpdates.HasUpdates()); assertThat(onlineIndexUpdates, containsInAnyOrder(IndexEntryUpdate.remove(relId, relationshipIndexDescriptor, relationshipPropertyValue, null, null), IndexEntryUpdate.remove(nodeId, nodeIndexDescriptor, nodePropertyValue, null, null))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldUpdateCorrectIndexes() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldUpdateCorrectIndexes() { OnlineIndexUpdates onlineIndexUpdates = new OnlineIndexUpdates(_nodeStore, _relationshipStore, _indexingService, _propertyPhysicalToLogicalConverter); long relId = 0; RelationshipRecord inUse = GetRelationship(relId, true, ENTITY_TOKEN); Value propertyValue = Values.of("hej"); Value propertyValue2 = Values.of("da"); long propertyId = CreateRelationshipProperty(inUse, propertyValue, 1); long propertyId2 = CreateRelationshipProperty(inUse, propertyValue2, 4); 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); PropertyRecord propertyBlocks2 = new PropertyRecord(propertyId2); propertyBlocks2.RelId = relId; Command.PropertyCommand propertyCommand2 = new Command.PropertyCommand(_recordAccess.getIfLoaded(propertyId2).forReadingData(), propertyBlocks2); StoreIndexDescriptor indexDescriptor0 = forSchema(multiToken(_entityTokens, RELATIONSHIP, 1, 4, 6), EMPTY.ProviderDescriptor).withId(0); StoreIndexDescriptor indexDescriptor1 = forSchema(multiToken(_entityTokens, RELATIONSHIP, 2, 4, 6), EMPTY.ProviderDescriptor).withId(1); StoreIndexDescriptor indexDescriptor2 = forSchema(multiToken(new int[] { ENTITY_TOKEN, OTHER_ENTITY_TOKEN }, RELATIONSHIP, 1), EMPTY.ProviderDescriptor).withId(2); StoreIndexDescriptor indexDescriptor3 = forSchema(multiToken(new int[] { OTHER_ENTITY_TOKEN }, RELATIONSHIP, 1), EMPTY.ProviderDescriptor).withId(3); _indexingService.createIndexes(indexDescriptor0, indexDescriptor1, indexDescriptor2); _indexingService.getIndexProxy(indexDescriptor0.Schema()).awaitStoreScanCompleted(0, MILLISECONDS); _indexingService.getIndexProxy(indexDescriptor1.Schema()).awaitStoreScanCompleted(0, MILLISECONDS); _indexingService.getIndexProxy(indexDescriptor2.Schema()).awaitStoreScanCompleted(0, MILLISECONDS); onlineIndexUpdates.Feed(NodeGroup(null), RelationshipGroup(relationshipCommand, propertyCommand, propertyCommand2)); assertTrue(onlineIndexUpdates.HasUpdates()); assertThat(onlineIndexUpdates, containsInAnyOrder(IndexEntryUpdate.remove(relId, indexDescriptor0, propertyValue, propertyValue2, null), IndexEntryUpdate.remove(relId, indexDescriptor1, null, propertyValue2, null), IndexEntryUpdate.remove(relId, indexDescriptor2, propertyValue))); assertThat(onlineIndexUpdates, not(containsInAnyOrder(indexDescriptor3))); // This index is only for a different relationship type. }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private static void verifyConstraintOn(org.eclipse.collections.impl.list.mutable.primitive.LongArrayList nodeIds, org.neo4j.storageengine.api.NodePropertyAccessor nodePropertyAccessor, org.neo4j.storageengine.api.schema.StoreIndexDescriptor descriptor) throws org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException private static void VerifyConstraintOn(LongArrayList nodeIds, NodePropertyAccessor nodePropertyAccessor, StoreIndexDescriptor descriptor) { MutableMap <Value, long> points = Maps.mutable.empty(); MutableLongIterator iter = nodeIds.longIterator(); try { while (iter.hasNext()) { long id = iter.next(); Value value = nodePropertyAccessor.GetNodePropertyValue(id, descriptor.Schema().PropertyId); long? other = points.getIfAbsentPut(value, id); if (other.Value != id) { throw new IndexEntryConflictException(other.Value, id, value); } } } catch (EntityNotFoundException e) { throw new Exception("Failed to validate uniqueness constraint", e); } }
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)); }