private PropertyBlock Property(long key, Value value)
        {
            PropertyBlock block = new PropertyBlock();

            _store.encodeValue(block, ( int )key, value);
            return(block);
        }
Exemplo n.º 2
0
 public override RecordGenerators_Generator <PropertyRecord> Property()
 {
     return((recordSize, format, recordId) =>
     {
         PropertyRecord record = new PropertyRecord(recordId);
         int maxProperties = _random.intBetween(1, 4);
         StandaloneDynamicRecordAllocator stringAllocator = new StandaloneDynamicRecordAllocator();
         StandaloneDynamicRecordAllocator arrayAllocator = new StandaloneDynamicRecordAllocator();
         record.InUse = true;
         int blocksOccupied = 0;
         for (int i = 0; i < maxProperties && blocksOccupied < 4;)
         {
             PropertyBlock block = new PropertyBlock();
             // Dynamic records will not be written and read by the property record format,
             // that happens in the store where it delegates to a "sub" store.
             PropertyStore.EncodeValue(block, _random.Next(_tokenBits), _random.nextValue(), stringAllocator, arrayAllocator, true);
             int tentativeBlocksWithThisOne = blocksOccupied + block.ValueBlocks.length;
             if (tentativeBlocksWithThisOne <= 4)
             {
                 record.addPropertyBlock(block);
                 blocksOccupied = tentativeBlocksWithThisOne;
             }
         }
         record.PrevProp = RandomLongOrOccasionallyNull(_propertyBits);
         record.NextProp = RandomLongOrOccasionallyNull(_propertyBits);
         return record;
     });
 }
Exemplo n.º 3
0
        public override int ApplyAsInt(Value[] values)
        {
            _stringRecordIds.reset();
            _arrayRecordIds.reset();

            int propertyRecordsUsed       = 0;
            int freeBlocksInCurrentRecord = 0;

            foreach (Value value in values)
            {
                PropertyBlock block = new PropertyBlock();
                PropertyStore.EncodeValue(block, 0, value, _stringRecordCounter, _arrayRecordCounter, true);
                if (block.ValueBlocks.Length > freeBlocksInCurrentRecord)
                {
                    propertyRecordsUsed++;
                    freeBlocksInCurrentRecord = PropertyType.PayloadSizeLongs;
                }
                freeBlocksInCurrentRecord -= block.ValueBlocks.Length;
            }

            int size = propertyRecordsUsed * _propertyRecordSize;

            size += toIntExact(_stringRecordIds.peek()) * _stringRecordSize;
            size += toIntExact(_arrayRecordIds.peek()) * _arrayRecordSize;
            return(size);
        }
Exemplo n.º 4
0
        private void AssertCanEncodeAndDecodeToSameValue(object value, int payloadSize)
        {
            PropertyBlock target  = new PropertyBlock();
            bool          encoded = ShortArray.encode(0, value, target, payloadSize);

            assertTrue(encoded);
            assertEquals(Values.of(value), ShortArray.decode(target));
        }
Exemplo n.º 5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldReportDuplicatePropertyIndexesAcrossRecordsInPropertyChainForNode()
        internal virtual void ShouldReportDuplicatePropertyIndexesAcrossRecordsInPropertyChainForNode()
        {
            // given
            ChainCheck check = new ChainCheck();

            RecordAccessStub records = new RecordAccessStub();

            RelationshipRecord master = records.Add(inUse(new RelationshipRecord(1, 2, 3, 4)));

            master.NextProp = 1;

            PropertyRecord firstRecord = inUse(new PropertyRecord(1));

            firstRecord.NextProp = 12;

            PropertyBlock firstBlock = new PropertyBlock();

            firstBlock.SingleBlock = 1;
            firstBlock.KeyIndexId  = 1;

            PropertyBlock secondBlock = new PropertyBlock();

            secondBlock.SingleBlock = 1;
            secondBlock.KeyIndexId  = 2;

            PropertyRecord secondRecord = inUse(new PropertyRecord(12));

            secondRecord.PrevProp = 1;

            PropertyBlock thirdBlock = new PropertyBlock();

            thirdBlock.SingleBlock = 1;
            thirdBlock.KeyIndexId  = 4;

            PropertyBlock fourthBlock = new PropertyBlock();

            fourthBlock.SingleBlock = 1;
            fourthBlock.KeyIndexId  = 1;

            firstRecord.AddPropertyBlock(firstBlock);
            firstRecord.AddPropertyBlock(secondBlock);
            secondRecord.AddPropertyBlock(thirdBlock);
            secondRecord.AddPropertyBlock(fourthBlock);

            records.Add(firstRecord);
            records.Add(secondRecord);

            // when
            Org.Neo4j.Consistency.report.ConsistencyReport_RelationshipConsistencyReport report = mock(typeof(Org.Neo4j.Consistency.report.ConsistencyReport_RelationshipConsistencyReport));
            CheckerEngine <RelationshipRecord, Org.Neo4j.Consistency.report.ConsistencyReport_RelationshipConsistencyReport> checkEngine = records.Engine(master, report);

            check.checkReference(master, firstRecord, checkEngine, records);
            records.CheckDeferred();

            // then
            verify(report).propertyKeyNotUniqueInChain();
        }
Exemplo n.º 6
0
        private TextValue ReadLongString()
        {
            long reference = PropertyBlock.fetchLong(CurrentBlock());

            if (_stringPage == null)
            {
                _stringPage = _stringPage(reference);
            }
            return(String(this, reference, _stringPage));
        }
Exemplo n.º 7
0
        private ArrayValue ReadLongArray()
        {
            long reference = PropertyBlock.fetchLong(CurrentBlock());

            if (_arrayPage == null)
            {
                _arrayPage = _arrayPage(reference);
            }
            return(Array(this, reference, _arrayPage));
        }
Exemplo n.º 8
0
 private void ExistingRecord(PropertyRecord record, ExpectedRecord initialRecord)
 {
     foreach (ExpectedProperty initialProperty in initialRecord.Properties)
     {
         PropertyBlock block = new PropertyBlock();
         _propertyStore.encodeValue(block, initialProperty.Key, initialProperty.Value);
         record.AddPropertyBlock(block);
     }
     assertTrue(record.Size() <= PropertyType.PayloadSize);
 }
Exemplo n.º 9
0
 private LongValue ReadLong()
 {
     if (PropertyBlock.valueIsInlined(CurrentBlock()))
     {
         return(Values.longValue(( long )(( ulong )PropertyBlock.fetchLong(CurrentBlock()) >> 1)));
     }
     else
     {
         return(Values.longValue(Blocks[_block + 1]));
     }
 }
Exemplo n.º 10
0
        private PropertyBlock PropertyBlockWith(DynamicRecord dynamicRecord)
        {
            PropertyBlock propertyBlock = new PropertyBlock();

            PropertyKeyTokenRecord key = new PropertyKeyTokenRecord(10);

            propertyBlock.SingleBlock = key.Id | ((( long )PropertyType.String.intValue()) << 24) | (dynamicRecord.Id << 28);
            propertyBlock.AddValueRecord(dynamicRecord);

            return(propertyBlock);
        }
Exemplo n.º 11
0
        private void Encode(string @string)
        {
            PropertyBlock block         = new PropertyBlock();
            TextValue     expectedValue = Values.stringValue(@string);

            _propertyStore.encodeValue(block, KEY_ID, expectedValue);
            assertEquals(0, block.ValueRecords.Count);
            Value readValue = block.Type.value(block, _propertyStore);

            assertEquals(expectedValue, readValue);
        }
Exemplo n.º 12
0
        private void ExpectInvalidPropertyValue(PropertyRecord property, long[] longs)
        {
            PropertyBlock block = new PropertyBlock();

            block.ValueBlocks = longs;
            property.AddPropertyBlock(block);

            // when
            Org.Neo4j.Consistency.report.ConsistencyReport_PropertyConsistencyReport report = Check(property);

            // then
            verify(report).invalidPropertyValue(block);
            verifyNoMoreInteractions(report);
        }
Exemplo n.º 13
0
        private void CreateRecordIn <RECORD>(RecordStore <RECORD> store) where RECORD : Org.Neo4j.Kernel.impl.store.record.AbstractBaseRecord
        {
            RECORD record = store.NewRecord();

            record.Id    = store.nextId();
            record.InUse = true;
            if (record is PropertyRecord)
            {
                // Special hack for property store, since it's not enough to simply set a record as in use there
                PropertyBlock block = new PropertyBlock();
                (( PropertyStore )store).encodeValue(block, 0, Values.of(10));
                (( PropertyRecord )record).addPropertyBlock(block);
            }
            store.UpdateRecord(record);
        }
Exemplo n.º 14
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldReportPropertyKeyNotInUse()
        internal virtual void ShouldReportPropertyKeyNotInUse()
        {
            // given
            PropertyRecord         property = InUse(new PropertyRecord(42));
            PropertyKeyTokenRecord key      = Add(NotInUse(new PropertyKeyTokenRecord(0)));
            PropertyBlock          block    = PropertyBlock(key, PropertyType.INT, 0);

            property.AddPropertyBlock(block);

            // when
            Org.Neo4j.Consistency.report.ConsistencyReport_PropertyConsistencyReport report = Check(property);

            // then
            verify(report).keyNotInUse(block, key);
            verifyNoMoreInteractions(report);
        }
Exemplo n.º 15
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldReportStringRecordNotInUse()
        internal virtual void ShouldReportStringRecordNotInUse()
        {
            // given
            PropertyRecord         property = InUse(new PropertyRecord(42));
            PropertyKeyTokenRecord key      = Add(InUse(new PropertyKeyTokenRecord(6)));
            DynamicRecord          value    = Add(NotInUse(String(new DynamicRecord(1001))));
            PropertyBlock          block    = PropertyBlock(key, value);

            property.AddPropertyBlock(block);

            // when
            Org.Neo4j.Consistency.report.ConsistencyReport_PropertyConsistencyReport report = Check(property);
            // then
            verify(report).stringNotInUse(block, value);
            verifyNoMoreInteractions(report);
        }
Exemplo n.º 16
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldWriteOutTheDynamicChainBeforeUpdatingThePropertyRecord()
        public virtual void ShouldWriteOutTheDynamicChainBeforeUpdatingThePropertyRecord()
        {
            // given
            PageCache pageCache = PageCacheRule.getPageCache(_fileSystemAbstraction);
            Config    config    = Config.defaults(GraphDatabaseSettings.rebuild_idgenerators_fast, "true");

            DynamicStringStore stringPropertyStore = mock(typeof(DynamicStringStore));

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final PropertyStore store = new PropertyStore(storeFile, idFile, config, new org.neo4j.kernel.impl.core.JumpingIdGeneratorFactory(1), pageCache, org.neo4j.logging.NullLogProvider.getInstance(), stringPropertyStore, mock(PropertyKeyTokenStore.class), mock(DynamicArrayStore.class), org.neo4j.kernel.impl.store.format.RecordFormatSelector.defaultFormat());
            PropertyStore store = new PropertyStore(_storeFile, _idFile, config, new JumpingIdGeneratorFactory(1), pageCache, NullLogProvider.Instance, stringPropertyStore, mock(typeof(PropertyKeyTokenStore)), mock(typeof(DynamicArrayStore)), RecordFormatSelector.defaultFormat());

            store.Initialise(true);

            try
            {
                store.MakeStoreOk();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final long propertyRecordId = store.nextId();
                long propertyRecordId = store.NextId();

                PropertyRecord record = new PropertyRecord(propertyRecordId);
                record.InUse = true;

                DynamicRecord dynamicRecord = dynamicRecord();
                PropertyBlock propertyBlock = PropertyBlockWith(dynamicRecord);
                record.PropertyBlock = propertyBlock;

                doAnswer(invocation =>
                {
                    PropertyRecord recordBeforeWrite = store.GetRecord(propertyRecordId, store.NewRecord(), FORCE);
                    assertFalse(recordBeforeWrite.inUse());
                    return(null);
                }).when(stringPropertyStore).updateRecord(dynamicRecord);

                // when
                store.UpdateRecord(record);

                // then verify that our mocked method above, with the assert, was actually called
                verify(stringPropertyStore).updateRecord(dynamicRecord);
            }
            finally
            {
                store.Close();
            }
        }
Exemplo n.º 17
0
 private void AssertRecord(PropertyRecord record, ExpectedRecord expectedRecord)
 {
     assertEquals(expectedRecord.Properties.Length, record.NumberOfProperties());
     foreach (ExpectedProperty expectedProperty in expectedRecord.Properties)
     {
         PropertyBlock block = record.GetPropertyBlock(expectedProperty.Key);
         assertNotNull(block);
         assertEquals(expectedProperty.Value, block.Type.value(block, _propertyStore));
         if (expectedProperty.AssertHasDynamicRecords != null)
         {
             if (expectedProperty.AssertHasDynamicRecords.Value)
             {
                 assertThat(block.ValueRecords.Count, Matchers.greaterThan(0));
             }
             else
             {
                 assertEquals(0, block.ValueRecords.Count);
             }
         }
     }
 }
Exemplo n.º 18
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldReportDuplicatePropertyIndexesInPropertyRecordForNode()
        internal virtual void ShouldReportDuplicatePropertyIndexesInPropertyRecordForNode()
        {
            // given
            ChainCheck check = new ChainCheck();

            RecordAccessStub records = new RecordAccessStub();

            NodeRecord master = records.Add(inUse(new NodeRecord(1, false, -1, 1)));

            PropertyRecord propertyRecord = inUse(new PropertyRecord(1));
            PropertyBlock  firstBlock     = new PropertyBlock();

            firstBlock.SingleBlock = 1;
            firstBlock.KeyIndexId  = 1;

            PropertyBlock secondBlock = new PropertyBlock();

            secondBlock.SingleBlock = 1;
            secondBlock.KeyIndexId  = 2;

            PropertyBlock thirdBlock = new PropertyBlock();

            thirdBlock.SingleBlock = 1;
            thirdBlock.KeyIndexId  = 1;

            propertyRecord.AddPropertyBlock(firstBlock);
            propertyRecord.AddPropertyBlock(secondBlock);
            propertyRecord.AddPropertyBlock(thirdBlock);

            records.Add(propertyRecord);

            // when
            Org.Neo4j.Consistency.report.ConsistencyReport_NodeConsistencyReport report = mock(typeof(Org.Neo4j.Consistency.report.ConsistencyReport_NodeConsistencyReport));
            CheckerEngine <NodeRecord, Org.Neo4j.Consistency.report.ConsistencyReport_NodeConsistencyReport> checkEngine = records.Engine(master, report);

            check.checkReference(master, propertyRecord, checkEngine, records);

            // then
            verify(report).propertyKeyNotUniqueInChain();
        }
Exemplo n.º 19
0
 public abstract Org.Neo4j.Values.Storable.Value value(Org.Neo4j.Kernel.impl.store.record.PropertyBlock block, PropertyStore store);
Exemplo n.º 20
0
 public override int PropertyKey()
 {
     return(PropertyBlock.keyIndexId(CurrentBlock()));
 }
Exemplo n.º 21
0
 private TextValue ReadChar()
 {
     return(Values.charValue(( char )PropertyBlock.fetchShort(CurrentBlock())));
 }
Exemplo n.º 22
0
 private ByteValue ReadByte()
 {
     return(Values.byteValue(PropertyBlock.fetchByte(CurrentBlock())));
 }
Exemplo n.º 23
0
 private ShortValue ReadShort()
 {
     return(Values.shortValue(PropertyBlock.fetchShort(CurrentBlock())));
 }
Exemplo n.º 24
0
 private IntValue ReadInt()
 {
     return(Values.intValue(PropertyBlock.fetchInt(CurrentBlock())));
 }
Exemplo n.º 25
0
 private BooleanValue ReadBoolean()
 {
     return(Values.booleanValue(PropertyBlock.fetchByte(CurrentBlock()) == 1));
 }
Exemplo n.º 26
0
 private FloatValue ReadFloat()
 {
     return(Values.floatValue(Float.intBitsToFloat(PropertyBlock.fetchInt(CurrentBlock()))));
 }