Пример #1
0
        public virtual IList <DynamicRecord> AllocateFrom(SchemaRule rule)
        {
            IList <DynamicRecord>  records         = new List <DynamicRecord>();
            DynamicRecord          record          = GetRecord(rule.Id, NextRecord(), CHECK);
            DynamicRecordAllocator recordAllocator = new ReusableRecordsCompositeAllocator(singleton(record), this);

            AllocateRecordsFromBytes(records, SchemaRuleSerialization.serialize(rule), recordAllocator);
            return(records);
        }
Пример #2
0
        public static SchemaRuleCommand CreateIndexRule(IndexProviderDescriptor provider, long id, LabelSchemaDescriptor descriptor)
        {
            SchemaRule    rule   = IndexDescriptorFactory.forSchema(descriptor, provider).withId(id);
            DynamicRecord record = new DynamicRecord(id);

            record.InUse = true;
            record.SetCreated();
            record.Data = SchemaRuleSerialization.serialize(rule);
            return(new SchemaRuleCommand(Collections.emptyList(), singletonList(record), rule));
        }
Пример #3
0
//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());
        }
Пример #4
0
//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());
        }
Пример #5
0
//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());
        }
Пример #6
0
//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());
        }
        private SchemaRule ReadSchemaRule(ICollection <DynamicRecord> recordsBefore)
        {
            // TODO: Why was this assertion here?
            //            assert first(recordsBefore).inUse() : "Asked to deserialize schema records that were not in
            // use.";
            SchemaRule rule;
            ByteBuffer deserialized = AbstractDynamicStore.concatData(recordsBefore, new sbyte[100]);

            try
            {
                rule = SchemaRuleSerialization.deserialize(Iterables.first(recordsBefore).Id, deserialized);
            }
            catch (MalformedSchemaRuleException)
            {
                return(null);
            }
            return(rule);
        }
Пример #8
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: static org.neo4j.storageengine.api.schema.SchemaRule readSchemaRule(long id, java.util.Collection<org.neo4j.kernel.impl.store.record.DynamicRecord> records, byte[] buffer) throws org.neo4j.internal.kernel.api.exceptions.schema.MalformedSchemaRuleException
        internal static SchemaRule ReadSchemaRule(long id, ICollection <DynamicRecord> records, sbyte[] buffer)
        {
            ByteBuffer scratchBuffer = ConcatData(records, buffer);

            return(SchemaRuleSerialization.deserialize(id, scratchBuffer));
        }