Пример #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void before()
        public virtual void Before()
        {
            _config = Config.defaults();
            DefaultIdGeneratorFactory idGeneratorFactory = new DefaultIdGeneratorFactory(_fs.get());

            _storeFactory = new StoreFactory(_testDirectory.databaseLayout(), _config, idGeneratorFactory, PageCacheRule.getPageCache(_fs.get()), _fs.get(), NullLogProvider.Instance, EmptyVersionContextSupplier.EMPTY);
            _neoStores    = _storeFactory.openAllNeoStores(true);
            _store        = _neoStores.SchemaStore;
        }
Пример #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public org.neo4j.storageengine.api.schema.SchemaRule loadSingleSchemaRule(long ruleId) throws org.neo4j.internal.kernel.api.exceptions.schema.MalformedSchemaRuleException
        public override SchemaRule LoadSingleSchemaRule(long ruleId)
        {
            ICollection <DynamicRecord> records;

            try
            {
                records = _schemaStore.getRecords(ruleId, RecordLoad.NORMAL);
            }
            catch (Exception e)
            {
                throw new MalformedSchemaRuleException(e.Message, e);
            }
            return(SchemaStore.ReadSchemaRule(ruleId, records, NewRecordBuffer()));
        }
Пример #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @BeforeClass public static void initStorage() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public static void InitStorage()
        {
            using (Transaction transaction = Db.beginTx())
            {
                TokenWrite tokenWrite = Transaction.tokenWrite();
                tokenWrite.PropertyKeyGetOrCreateForName(PROP1);
                tokenWrite.PropertyKeyGetOrCreateForName(PROP2);
                tokenWrite.LabelGetOrCreateForName(LABEL1);
                tokenWrite.LabelGetOrCreateForName(LABEL2);
                tokenWrite.RelationshipTypeGetOrCreateForName(TYPE1);
                transaction.Success();
            }
            SchemaStore schemaStore = ResolveDependency(typeof(RecordStorageEngine)).testAccessNeoStores().SchemaStore;

            _storage = new SchemaStorage(schemaStore);
        }
Пример #4
0
            protected internal override ReturnType fetchNextOrNull()
            {
                while (currentId <= highestId)
                {
                    long id = currentId++;
                    _outerInstance.schemaStore.getRecord(id, record, RecordLoad.FORCE);
                    if (record.inUse() && record.StartRecord)
                    {
                        // It may be that concurrently to our reading there's a transaction dropping the schema rule
                        // that we're reading and that rule may have spanned multiple dynamic records.
                        try
                        {
                            ICollection <DynamicRecord> records;
                            try
                            {
                                records = _outerInstance.schemaStore.getRecords(id, RecordLoad.NORMAL);
                            }
                            catch (InvalidRecordException)
                            {
                                // This may have been due to a concurrent drop of this rule.
                                continue;
                            }

                            SchemaRule schemaRule = SchemaStore.ReadSchemaRule(id, records, scratchData);
                            if (_returnType.IsInstanceOfType(schemaRule))
                            {
                                ReturnType returnRule = _returnType.cast(schemaRule);
                                if (_predicate(returnRule))
                                {
                                    return(returnRule);
                                }
                            }
                        }
                        catch (MalformedSchemaRuleException e)
                        {
                            if (!_ignoreMalformed)
                            {
                                throw new Exception(e);
                            }
                        }
                    }
                }
                return(null);
            }
Пример #5
0
 public Loaders(RecordStore <NodeRecord> nodeStore, PropertyStore propertyStore, RecordStore <RelationshipRecord> relationshipStore, RecordStore <RelationshipGroupRecord> relationshipGroupStore, RecordStore <PropertyKeyTokenRecord> propertyKeyTokenStore, RecordStore <RelationshipTypeTokenRecord> relationshipTypeTokenStore, RecordStore <LabelTokenRecord> labelTokenStore, SchemaStore schemaStore)
 {
     _nodeLoader                  = _nodeLoader(nodeStore);
     _propertyLoader              = _propertyLoader(propertyStore);
     _relationshipLoader          = _relationshipLoader(relationshipStore);
     _relationshipGroupLoader     = _relationshipGroupLoader(relationshipGroupStore);
     _schemaRuleLoader            = _schemaRuleLoader(schemaStore);
     _propertyKeyTokenLoader      = _propertyKeyTokenLoader(propertyKeyTokenStore);
     _labelTokenLoader            = _labelTokenLoader(labelTokenStore);
     _relationshipTypeTokenLoader = _relationshipTypeTokenLoader(relationshipTypeTokenStore);
 }
Пример #6
0
 public RecordAccess_LoaderAnonymousInnerClass5(SchemaStore store)
 {
     this._store = store;
 }
Пример #7
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
//ORIGINAL LINE: public static org.neo4j.kernel.impl.transaction.state.RecordAccess_Loader<org.neo4j.kernel.impl.store.record.SchemaRecord,org.neo4j.storageengine.api.schema.SchemaRule> schemaRuleLoader(final org.neo4j.kernel.impl.store.SchemaStore store)
        public static RecordAccess_Loader <SchemaRecord, SchemaRule> SchemaRuleLoader(SchemaStore store)
        {
            return(new RecordAccess_LoaderAnonymousInnerClass5(store));
        }
Пример #8
0
        public override bool VisitSchemaRuleCommand(Command.SchemaRuleCommand command)
        {
            SchemaStore schemaStore = _neoStores.SchemaStore;

            if (_version == CommandVersion.BEFORE)
            {
                // We are doing reverse-recovery. There is no need for updating the cache, since the indexing service be told what it needs to know when we do
                // forward-recovery later.
                bool create = command.Mode == Command.Mode.Create;
                foreach (DynamicRecord record in command.RecordsBefore)
                {
                    if (create)
                    {
                        // Schema create commands do not properly store their before images, so we need to correct them.
                        // That is, if the schema was created by this command, then obviously the before image of those records were not in use.
                        record.InUse = false;
                    }
                    schemaStore.UpdateRecord(record);
                }
                return(false);
            }

            // schema rules. Execute these after generating the property updates so. If executed
            // before and we've got a transaction that sets properties/labels as well as creating an index
            // we might end up with this corner-case:
            // 1) index rule created and index population job started
            // 2) index population job processes some nodes, but doesn't complete
            // 3) we gather up property updates and send those to the indexes. The newly created population
            //    job might get those as updates
            // 4) the population job will apply those updates as added properties, and might end up with duplicate
            //    entries for the same property
            foreach (DynamicRecord record in command.RecordsAfter)
            {
                schemaStore.UpdateRecord(record);
            }

            if (command.SchemaRule is ConstraintRule)
            {
                switch (command.Mode)
                {
                case UPDATE:
                case CREATE:
                    _neoStores.MetaDataStore.LatestConstraintIntroducingTx = _transactionId;
                    break;

                case DELETE:
                    break;

                default:
                    throw new System.InvalidOperationException(command.Mode.name());
                }
            }

            switch (command.Mode)
            {
            case DELETE:
                _cacheAccess.removeSchemaRuleFromCache(command.Key);
                break;

            default:
                _cacheAccess.addSchemaRule(command.SchemaRule);
                break;
            }
            return(false);
        }
Пример #9
0
        public DirectRecordAccessSet(RecordStore <NodeRecord> nodeStore, PropertyStore propertyStore, RecordStore <RelationshipRecord> relationshipStore, RecordStore <RelationshipGroupRecord> relationshipGroupStore, RecordStore <PropertyKeyTokenRecord> propertyKeyTokenStore, RecordStore <RelationshipTypeTokenRecord> relationshipTypeTokenStore, RecordStore <LabelTokenRecord> labelTokenStore, SchemaStore schemaStore)
        {
            Loaders loaders = new Loaders(nodeStore, propertyStore, relationshipStore, relationshipGroupStore, propertyKeyTokenStore, relationshipTypeTokenStore, labelTokenStore, schemaStore);

            _nodeRecords                  = new DirectRecordAccess <NodeRecord, Void>(nodeStore, loaders.NodeLoader());
            _propertyRecords              = new DirectRecordAccess <PropertyRecord, PrimitiveRecord>(propertyStore, loaders.PropertyLoader());
            _relationshipRecords          = new DirectRecordAccess <RelationshipRecord, Void>(relationshipStore, loaders.RelationshipLoader());
            _relationshipGroupRecords     = new DirectRecordAccess <RelationshipGroupRecord, int>(relationshipGroupStore, loaders.RelationshipGroupLoader());
            _propertyKeyTokenRecords      = new DirectRecordAccess <PropertyKeyTokenRecord, Void>(propertyKeyTokenStore, loaders.PropertyKeyTokenLoader());
            _relationshipTypeTokenRecords = new DirectRecordAccess <RelationshipTypeTokenRecord, Void>(relationshipTypeTokenStore, loaders.RelationshipTypeTokenLoader());
            _labelTokenRecords            = new DirectRecordAccess <LabelTokenRecord, Void>(labelTokenStore, loaders.LabelTokenLoader());
            _all = new DirectRecordAccess[] { _nodeRecords, _propertyRecords, _relationshipRecords, _relationshipGroupRecords, _propertyKeyTokenRecords, _relationshipTypeTokenRecords, _labelTokenRecords };
        }