//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldReportUnreferencedConstraintIndex() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldReportUnreferencedConstraintIndex() { // given int ruleId = 0; DynamicRecord record = InUse(DynamicRecord(ruleId)); IndexProviderDescriptor providerDescriptor = new IndexProviderDescriptor("in-memory", "1.0"); StoreIndexDescriptor rule = constraintIndexRule(ruleId, _labelId, _propertyKeyId, providerDescriptor, ( long )ruleId); when(Checker().ruleAccess.loadSingleSchemaRule(ruleId)).thenReturn(rule); Add(InUse(new LabelTokenRecord(_labelId))); Add(InUse(new PropertyKeyTokenRecord(_propertyKeyId))); // when Check(record); SchemaRecordCheck obligationChecker = Checker().forObligationChecking(); Org.Neo4j.Consistency.report.ConsistencyReport_SchemaConsistencyReport report = Check(obligationChecker, record); // then verify(report).missingObligation(Org.Neo4j.Storageengine.Api.schema.SchemaRule_Kind.UniquenessConstraint); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldNotReportConstraintIndexRuleWithoutBackReference() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldNotReportConstraintIndexRuleWithoutBackReference() { // given int ruleId = 1; DynamicRecord record = InUse(DynamicRecord(ruleId)); IndexProviderDescriptor providerDescriptor = new IndexProviderDescriptor("in-memory", "1.0"); StoreIndexDescriptor rule = constraintIndexRule(ruleId, _labelId, _propertyKeyId, providerDescriptor); when(Checker().ruleAccess.loadSingleSchemaRule(ruleId)).thenReturn(rule); Add(InUse(new LabelTokenRecord(_labelId))); Add(InUse(new PropertyKeyTokenRecord(_propertyKeyId))); // when Check(record); SchemaRecordCheck obligationChecker = Checker().forObligationChecking(); Org.Neo4j.Consistency.report.ConsistencyReport_SchemaConsistencyReport report = Check(obligationChecker, record); // then verifyZeroInteractions(report); }
//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); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void detectUniqueIndexWithoutOwningConstraint() public virtual void DetectUniqueIndexWithoutOwningConstraint() { IndexDescriptor descriptor = UniqueForLabel(LABEL_ID, PROPERTY_ID_1); StoreIndexDescriptor indexRule = descriptor.WithId(RULE_ID); assertTrue(indexRule.IndexWithoutOwningConstraint); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void dropShouldDeleteEntireIndexFolder() public virtual void DropShouldDeleteEntireIndexFolder() { // given File root = Storage.directory().directory("root"); IndexDirectoryStructure directoryStructure = IndexDirectoryStructure.directoriesByProvider(root).forProvider(GenericNativeIndexProvider.Descriptor); long indexId = 8; File indexDirectory = directoryStructure.DirectoryForIndex(indexId); StoreIndexDescriptor descriptor = IndexDescriptorFactory.forSchema(SchemaDescriptorFactory.forLabel(1, 1)).withId(indexId); IndexSpecificSpaceFillingCurveSettingsCache spatialSettings = mock(typeof(IndexSpecificSpaceFillingCurveSettingsCache)); PageCache pageCache = Storage.pageCache(); FileSystemAbstraction fs = Storage.fileSystem(); File indexFile = new File(indexDirectory, "my-index"); GenericLayout layout = new GenericLayout(1, spatialSettings); RecoveryCleanupWorkCollector immediate = immediate(); IndexDropAction dropAction = new FileSystemIndexDropAction(fs, directoryStructure); GenericNativeIndexPopulator populator = new GenericNativeIndexPopulator(pageCache, fs, indexFile, layout, EMPTY, descriptor, spatialSettings, directoryStructure, mock(typeof(SpaceFillingCurveConfiguration)), dropAction, false); populator.Create(); // when assertTrue(fs.ListFiles(indexDirectory).Length > 0); populator.Drop(); // then assertFalse(fs.FileExists(indexDirectory)); }
//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) { SchemaIndex luceneIndex = LuceneSchemaIndexBuilder.Create(descriptor, _config).withOperationalMode(_operationalMode).withSamplingConfig(samplingConfig).withIndexStorage(GetIndexStorage(descriptor.Id)).build(); luceneIndex.open(); return(new LuceneIndexAccessor(luceneIndex, descriptor)); }
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected: //ORIGINAL LINE: IndexProxy createPopulatingIndexProxy(final org.neo4j.storageengine.api.schema.StoreIndexDescriptor descriptor, final boolean flipToTentative, final IndexingService.Monitor monitor, final IndexPopulationJob populationJob) internal virtual IndexProxy CreatePopulatingIndexProxy(StoreIndexDescriptor descriptor, bool flipToTentative, IndexingService.Monitor monitor, IndexPopulationJob populationJob) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final FlippableIndexProxy flipper = new FlippableIndexProxy(); FlippableIndexProxy flipper = new FlippableIndexProxy(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final String indexUserDescription = indexUserDescription(descriptor); string indexUserDescription = indexUserDescription(descriptor); IndexPopulator populator = PopulatorFromProvider(descriptor, _samplingConfig, populationJob.BufferFactory()); CapableIndexDescriptor capableIndexDescriptor = _providerMap.withCapabilities(descriptor); FailedIndexProxyFactory failureDelegateFactory = new FailedPopulatingIndexProxyFactory(capableIndexDescriptor, populator, indexUserDescription, new IndexCountsRemover(_storeView, descriptor.Id), _logProvider); MultipleIndexPopulator.IndexPopulation indexPopulation = populationJob.AddPopulator(populator, capableIndexDescriptor, indexUserDescription, flipper, failureDelegateFactory); PopulatingIndexProxy populatingIndex = new PopulatingIndexProxy(capableIndexDescriptor, populationJob, indexPopulation); flipper.FlipTo(populatingIndex); // Prepare for flipping to online mode flipper.FlipTarget = () => { monitor.PopulationCompleteOn(descriptor); IndexAccessor accessor = OnlineAccessorFromProvider(descriptor, _samplingConfig); OnlineIndexProxy onlineProxy = new OnlineIndexProxy(capableIndexDescriptor, accessor, _storeView, true); if (flipToTentative) { return(new TentativeConstraintIndexProxy(flipper, onlineProxy)); } return(onlineProxy); }; return(new ContractCheckingIndexProxy(flipper, false)); }
public IndexEntryProcessor(ConsistencyReporter reporter, IndexCheck indexCheck, StoreIndexDescriptor indexDescriptor, TokenNameLookup tokenNameLookup) { this._reporter = reporter; this._indexCheck = indexCheck; this._indexDescriptor = indexDescriptor; this._tokenNameLookup = tokenNameLookup; }
internal virtual IndexProxy CreateRecoveringIndexProxy(StoreIndexDescriptor descriptor) { CapableIndexDescriptor capableIndexDescriptor = _providerMap.withCapabilities(descriptor); IndexProxy proxy = new RecoveringIndexProxy(capableIndexDescriptor); return(new ContractCheckingIndexProxy(proxy, true)); }
/// <summary> /// Serialize the provided IndexRule onto the target buffer /// </summary> /// <param name="indexDescriptor"> the StoreIndexDescriptor to serialize </param> /// <exception cref="IllegalStateException"> if the StoreIndexDescriptor is of type unique, but the owning constrain has not been set </exception> public static sbyte[] Serialize(StoreIndexDescriptor indexDescriptor) { ByteBuffer target = ByteBuffer.allocate(LengthOf(indexDescriptor)); target.putInt(LEGACY_LABEL_OR_REL_TYPE_ID); target.put(INDEX_RULE); IndexProviderDescriptor providerDescriptor = indexDescriptor.ProviderDescriptor(); UTF8.putEncodedStringInto(providerDescriptor.Key, target); UTF8.putEncodedStringInto(providerDescriptor.Version, target); switch (indexDescriptor.Type()) { case GENERAL: target.put(GENERAL_INDEX); break; case UNIQUE: target.put(UNIQUE_INDEX); // The owning constraint can be null. See IndexRule.getOwningConstraint() long?owningConstraint = indexDescriptor.OwningConstraint; target.putLong(owningConstraint == null ? NO_OWNING_CONSTRAINT_YET : owningConstraint); break; default: throw new System.NotSupportedException(format("Got unknown index descriptor type '%s'.", indexDescriptor.Type())); } indexDescriptor.Schema().processWith(new SchemaDescriptorSerializer(target)); UTF8.putEncodedStringInto(indexDescriptor.Name, target); return(target.array()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldReportTwoIndexRulesWithDuplicateContent() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldReportTwoIndexRulesWithDuplicateContent() { // given int ruleId1 = 0; int ruleId2 = 1; DynamicRecord record1 = InUse(DynamicRecord(ruleId1)); DynamicRecord record2 = InUse(DynamicRecord(ruleId2)); IndexProviderDescriptor providerDescriptor = new IndexProviderDescriptor("in-memory", "1.0"); StoreIndexDescriptor rule1 = constraintIndexRule(ruleId1, _labelId, _propertyKeyId, providerDescriptor, ( long )ruleId1); StoreIndexDescriptor rule2 = constraintIndexRule(ruleId2, _labelId, _propertyKeyId, providerDescriptor, ( long )ruleId2); when(Checker().ruleAccess.loadSingleSchemaRule(ruleId1)).thenReturn(rule1); when(Checker().ruleAccess.loadSingleSchemaRule(ruleId2)).thenReturn(rule2); Add(InUse(new LabelTokenRecord(_labelId))); Add(InUse(new PropertyKeyTokenRecord(_propertyKeyId))); // when Check(record1); Org.Neo4j.Consistency.report.ConsistencyReport_SchemaConsistencyReport report = Check(record2); // then verify(report).duplicateRuleContent(record1); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldReportConstraintIndexNotReferencingBack() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldReportConstraintIndexNotReferencingBack() { // given int ruleId1 = 0; int ruleId2 = 1; DynamicRecord record1 = InUse(DynamicRecord(ruleId1)); DynamicRecord record2 = InUse(DynamicRecord(ruleId2)); IndexProviderDescriptor providerDescriptor = new IndexProviderDescriptor("in-memory", "1.0"); StoreIndexDescriptor rule1 = constraintIndexRule(ruleId1, _labelId, _propertyKeyId, providerDescriptor, ( long )ruleId1); ConstraintRule rule2 = uniquenessConstraintRule(ruleId2, _labelId, _propertyKeyId, ruleId1); when(Checker().ruleAccess.loadSingleSchemaRule(ruleId1)).thenReturn(rule1); when(Checker().ruleAccess.loadSingleSchemaRule(ruleId2)).thenReturn(rule2); Add(InUse(new LabelTokenRecord(_labelId))); Add(InUse(new PropertyKeyTokenRecord(_propertyKeyId))); // when Check(record1); Check(record2); SchemaRecordCheck obligationChecker = Checker().forObligationChecking(); Org.Neo4j.Consistency.report.ConsistencyReport_SchemaConsistencyReport report = Check(obligationChecker, record1); Check(obligationChecker, record2); // then verify(report).constraintIndexRuleNotReferencingBack(record2); }
private void AssertCorrectLength(StoreIndexDescriptor indexRule) { // GIVEN ByteBuffer buffer = ByteBuffer.wrap(SchemaRuleSerialization.Serialize(indexRule)); // THEN assertThat(SchemaRuleSerialization.LengthOf(indexRule), equalTo(buffer.capacity())); }
private void AssertEqualityByDescriptor(IndexDescriptor descriptor) { StoreIndexDescriptor rule1 = descriptor.WithId(RULE_ID); StoreIndexDescriptor rule2 = descriptor.WithId(RULE_ID_2); StoreIndexDescriptor rule3 = (descriptor.Type() == IndexDescriptor.Type.GENERAL ? forSchema(descriptor.Schema()) : uniqueForSchema(descriptor.Schema())).withId(RULE_ID); AssertEquality(rule1, rule2); AssertEquality(rule1, rule3); }
// HELPERS //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void assertSerializeAndDeserializeIndexRule(org.neo4j.storageengine.api.schema.StoreIndexDescriptor indexRule) throws org.neo4j.internal.kernel.api.exceptions.schema.MalformedSchemaRuleException private void AssertSerializeAndDeserializeIndexRule(StoreIndexDescriptor indexRule) { StoreIndexDescriptor deserialized = AssertIndexRule(SerialiseAndDeserialise(indexRule)); assertThat(deserialized.Id, equalTo(indexRule.Id)); assertThat(deserialized, equalTo(indexRule)); assertThat(deserialized.Schema(), equalTo(indexRule.Schema())); assertThat(deserialized.ProviderDescriptor(), equalTo(indexRule.ProviderDescriptor())); }
//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); }
internal virtual IndexProxy CreateFailedIndexProxy(StoreIndexDescriptor descriptor, IndexPopulationFailure populationFailure) { // Note about the buffer factory instantiation here. Question is why an index populator is instantiated for a failed index proxy to begin with. // The byte buffer factory should not be used here anyway so the buffer size doesn't actually matter. IndexPopulator indexPopulator = PopulatorFromProvider(descriptor, _samplingConfig, heapBufferFactory(1024)); CapableIndexDescriptor capableIndexDescriptor = _providerMap.withCapabilities(descriptor); string indexUserDescription = indexUserDescription(descriptor); IndexProxy proxy; proxy = new FailedIndexProxy(capableIndexDescriptor, indexUserDescription, indexPopulator, populationFailure, new IndexCountsRemover(_storeView, descriptor.Id), _logProvider); proxy = new ContractCheckingIndexProxy(proxy, true); return(proxy); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCreateGeneralIndex() public virtual void ShouldCreateGeneralIndex() { // GIVEN IndexDescriptor descriptor = ForLabel(LABEL_ID, PROPERTY_ID_1); StoreIndexDescriptor indexRule = descriptor.WithId(RULE_ID); // THEN assertThat(indexRule.Id, equalTo(RULE_ID)); assertFalse(indexRule.CanSupportUniqueConstraint()); assertThat(indexRule.Schema(), equalTo(descriptor.Schema())); assertThat(indexRule, equalTo(descriptor)); assertThat(indexRule.ProviderDescriptor(), equalTo(ProviderDescriptor)); assertException(indexRule.getOwningConstraint, typeof(System.InvalidOperationException)); assertException(() => indexRule.WithOwningConstraint(RULE_ID_2), typeof(System.InvalidOperationException)); }
internal override NumberLayout Layout(StoreIndexDescriptor descriptor, File storeFile) { // split like this due to legacy reasons, there are old stores out there with these different identifiers switch (descriptor.Type()) { case GENERAL: return(new NumberLayoutNonUnique()); case UNIQUE: return(new NumberLayoutUnique()); default: throw new System.ArgumentException("Unknown index type " + descriptor.Type()); } }
public override IndexPopulator GetPopulator(StoreIndexDescriptor descriptor, IndexSamplingConfig samplingConfig, ByteBufferFactory bufferFactory) { SchemaIndex luceneIndex = LuceneSchemaIndexBuilder.Create(descriptor, _config).withFileSystem(_fileSystem).withOperationalMode(_operationalMode).withSamplingConfig(samplingConfig).withIndexStorage(GetIndexStorage(descriptor.Id)).withWriterConfig(IndexWriterConfigs.population).build(); if (luceneIndex.ReadOnly) { throw new System.NotSupportedException("Can't create populator for read only index"); } if (descriptor.Type() == UNIQUE) { return(new UniqueLuceneIndexPopulator(luceneIndex, descriptor)); } else { return(new NonUniqueLuceneIndexPopulator(luceneIndex, samplingConfig)); } }
internal virtual IndexProxy CreateOnlineIndexProxy(StoreIndexDescriptor descriptor) { try { IndexAccessor onlineAccessor = OnlineAccessorFromProvider(descriptor, _samplingConfig); CapableIndexDescriptor capableIndexDescriptor = _providerMap.withCapabilities(descriptor); IndexProxy proxy; proxy = new OnlineIndexProxy(capableIndexDescriptor, onlineAccessor, _storeView, false); proxy = new ContractCheckingIndexProxy(proxy, true); return(proxy); } catch (IOException e) { _logProvider.getLog(this.GetType()).error("Failed to open index: " + descriptor.Id + " (" + descriptor.UserDescription(_tokenNameLookup) + "), requesting re-population.", e); return(CreateRecoveringIndexProxy(descriptor)); } }
public override InternalIndexState GetInitialState(StoreIndexDescriptor descriptor) { PartitionedIndexStorage indexStorage = GetIndexStorage(descriptor.Id); string failure = indexStorage.StoredIndexFailure; if (!string.ReferenceEquals(failure, null)) { return(InternalIndexState.FAILED); } try { return(IndexIsOnline(indexStorage, descriptor) ? InternalIndexState.ONLINE : InternalIndexState.POPULATING); } catch (IOException e) { _monitor.failedToOpenIndex(descriptor, "Requesting re-population.", e); return(InternalIndexState.POPULATING); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCreateUniqueIndex() public virtual void ShouldCreateUniqueIndex() { // GIVEN IndexDescriptor descriptor = UniqueForLabel(LABEL_ID, PROPERTY_ID_1); StoreIndexDescriptor indexRule = descriptor.WithId(RULE_ID); // THEN assertThat(indexRule.Id, equalTo(RULE_ID)); assertTrue(indexRule.CanSupportUniqueConstraint()); assertThat(indexRule.Schema(), equalTo(descriptor.Schema())); assertThat(indexRule, equalTo(descriptor)); assertThat(indexRule.ProviderDescriptor(), equalTo(ProviderDescriptor)); assertThat(indexRule.OwningConstraint, equalTo(null)); StoreIndexDescriptor withConstraint = indexRule.WithOwningConstraint(RULE_ID_2); assertThat(withConstraint.OwningConstraint, equalTo(RULE_ID_2)); assertThat(indexRule.OwningConstraint, equalTo(null)); // this is unchanged }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldReportInvalidPropertyReferenceFromIndexRule() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldReportInvalidPropertyReferenceFromIndexRule() { // given int schemaRuleId = 0; DynamicRecord record = InUse(DynamicRecord(schemaRuleId)); IndexProviderDescriptor providerDescriptor = new IndexProviderDescriptor("in-memory", "1.0"); StoreIndexDescriptor rule = indexRule(schemaRuleId, _labelId, _propertyKeyId, providerDescriptor); when(Checker().ruleAccess.loadSingleSchemaRule(schemaRuleId)).thenReturn(rule); Add(InUse(new LabelTokenRecord(_labelId))); PropertyKeyTokenRecord propertyKeyToken = Add(NotInUse(new PropertyKeyTokenRecord(_propertyKeyId))); // when Org.Neo4j.Consistency.report.ConsistencyReport_SchemaConsistencyReport report = Check(record); // then verify(report).propertyKeyNotInUse(propertyKeyToken); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void assertParseIndexRule(String serialized, String name) throws Exception private void AssertParseIndexRule(string serialized, string name) { // GIVEN long ruleId = 24; IndexDescriptor index = ForLabel(512, 4); IndexProviderDescriptor indexProvider = new IndexProviderDescriptor("index-provider", "25.0"); sbyte[] bytes = DecodeBase64(serialized); // WHEN StoreIndexDescriptor deserialized = AssertIndexRule(SchemaRuleSerialization.Deserialize(ruleId, ByteBuffer.wrap(bytes))); // THEN assertThat(deserialized.Id, equalTo(ruleId)); assertThat(deserialized, equalTo(index)); assertThat(deserialized.Schema(), equalTo(index.Schema())); assertThat(deserialized.ProviderDescriptor(), equalTo(indexProvider)); assertThat(deserialized.Name, @is(name)); assertException(deserialized.getOwningConstraint, typeof(System.InvalidOperationException)); }
/// <summary> /// Compute the byte size needed to serialize the provided IndexRule using serialize. </summary> /// <param name="indexDescriptor"> the StoreIndexDescriptor </param> /// <returns> the byte size of StoreIndexDescriptor </returns> internal static int LengthOf(StoreIndexDescriptor indexDescriptor) { int length = 4; // legacy label or relType id length += 1; // schema rule type IndexProviderDescriptor providerDescriptor = indexDescriptor.ProviderDescriptor(); length += UTF8.computeRequiredByteBufferSize(providerDescriptor.Key); length += UTF8.computeRequiredByteBufferSize(providerDescriptor.Version); length += 1; // index type if (indexDescriptor.Type() == IndexDescriptor.Type.UNIQUE) { length += 8; // owning constraint id } length += indexDescriptor.Schema().computeWith(schemaSizeComputer); length += UTF8.computeRequiredByteBufferSize(indexDescriptor.Name); return(length); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void assertParseUniqueIndexRule(String serialized, String name) throws org.neo4j.internal.kernel.api.exceptions.schema.MalformedSchemaRuleException private void AssertParseUniqueIndexRule(string serialized, string name) { // GIVEN long ruleId = 33; long constraintId = 11; IndexDescriptor index = TestIndexDescriptorFactory.uniqueForLabel(61, 988); IndexProviderDescriptor indexProvider = new IndexProviderDescriptor("index-provider", "25.0"); sbyte[] bytes = DecodeBase64(serialized); // WHEN StoreIndexDescriptor deserialized = AssertIndexRule(SchemaRuleSerialization.Deserialize(ruleId, ByteBuffer.wrap(bytes))); // THEN assertThat(deserialized.Id, equalTo(ruleId)); assertThat(deserialized, equalTo(index)); assertThat(deserialized.Schema(), equalTo(index.Schema())); assertThat(deserialized.ProviderDescriptor(), equalTo(indexProvider)); assertThat(deserialized.OwningConstraint, equalTo(constraintId)); assertThat(deserialized.Name, @is(name)); }
internal IndexCheck(StoreIndexDescriptor indexRule) { this._indexRule = indexRule; SchemaDescriptor schema = indexRule.Schema(); int[] entityTokenIntIds = Schema.EntityTokenIds; long[] entityTokenLongIds = new long[entityTokenIntIds.Length]; for (int i = 0; i < entityTokenIntIds.Length; i++) { entityTokenLongIds[i] = entityTokenIntIds[i]; } [email protected]_PropertySchemaType propertySchemaType = Schema.propertySchemaType(); _entityType = Schema.entityType(); if (_entityType == EntityType.NODE) { _nodeChecker = new NodeInUseWithCorrectLabelsCheck <IndexEntry, Org.Neo4j.Consistency.report.ConsistencyReport_IndexConsistencyReport>(entityTokenLongIds, propertySchemaType, false); } if (_entityType == EntityType.RELATIONSHIP) { _relationshipChecker = new RelationshipInUseWithCorrectRelationshipTypeCheck <IndexEntry, Org.Neo4j.Consistency.report.ConsistencyReport_IndexConsistencyReport>(entityTokenLongIds); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private org.neo4j.kernel.api.index.IndexAccessor onlineAccessorFromProvider(org.neo4j.storageengine.api.schema.StoreIndexDescriptor descriptor, org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig samplingConfig) throws java.io.IOException private IndexAccessor OnlineAccessorFromProvider(StoreIndexDescriptor descriptor, IndexSamplingConfig samplingConfig) { IndexProvider indexProvider = _providerMap.lookup(descriptor.ProviderDescriptor()); return(indexProvider.GetOnlineAccessor(descriptor, samplingConfig)); }
private IndexPopulator PopulatorFromProvider(StoreIndexDescriptor descriptor, IndexSamplingConfig samplingConfig, ByteBufferFactory bufferFactory) { IndexProvider indexProvider = _providerMap.lookup(descriptor.ProviderDescriptor()); return(indexProvider.GetPopulator(descriptor, samplingConfig, bufferFactory)); }