private void WriteReadRecord(PropertyRecord source, PropertyRecord target, int recordSize) { _recordFormat.prepare(source, recordSize, _idSequence); _recordFormat.write(source, _pageCursor, recordSize); _pageCursor.Offset = 0; _recordFormat.read(target, _pageCursor, RecordLoad.NORMAL, recordSize); }
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; }); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void writeAndReadRecordWithRelativeReferences() public virtual void WriteAndReadRecordWithRelativeReferences() { int recordSize = _recordFormat.getRecordSize(new IntStoreHeader(DATA_SIZE)); long recordId = 0xF1F1F1F1F1F1L; int recordOffset = _pageCursor.Offset; PropertyRecord record = CreateRecord(_recordFormat, recordId); _recordFormat.write(record, _pageCursor, recordSize); PropertyRecord recordFromStore = _recordFormat.newRecord(); recordFromStore.Id = recordId; ResetCursor(_pageCursor, recordOffset); _recordFormat.read(recordFromStore, _pageCursor, RecordLoad.NORMAL, recordSize); // records should be the same assertEquals(record.NextProp, recordFromStore.NextProp); assertEquals(record.PrevProp, recordFromStore.PrevProp); // now lets try to read same data into a record with different id - we should get different absolute references ResetCursor(_pageCursor, recordOffset); PropertyRecord recordWithOtherId = _recordFormat.newRecord(); recordWithOtherId.Id = 1L; _recordFormat.read(recordWithOtherId, _pageCursor, RecordLoad.NORMAL, recordSize); VerifyDifferentReferences(record, recordWithOtherId); }
private void ExistingChain(params ExpectedRecord[] initialRecords) { PropertyRecord prev = null; foreach (ExpectedRecord initialRecord in initialRecords) { PropertyRecord record = this._records.create(_propertyStore.nextId(), _primitive.record).forChangingData(); record.InUse = true; ExistingRecord(record, initialRecord); if (prev == null) { // This is the first one, update primitive to point to this _primitive.record.NextProp = record.Id; } else { // link property records together record.PrevProp = prev.Id; prev.NextProp = record.Id; } prev = record; } }
//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(); }
private void WriteRecordWithOldFormat(PropertyRecord oldFormatRecord) { int oldRecordSize = PropertyRecordFormatV3_0_0.RECORD_SIZE; PropertyRecordFormatV3_0_0 recordFormatV30 = new PropertyRecordFormatV3_0_0(); recordFormatV30.prepare(oldFormatRecord, oldRecordSize, _idSequence); recordFormatV30.Write(oldFormatRecord, _pageCursor, oldRecordSize); _pageCursor.Offset = 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); }
private PropertyRecord CreateRecord(PropertyRecordFormat format, long recordId) { PropertyRecord record = format.NewRecord(); record.InUse = true; record.Id = recordId; record.NextProp = 1L; record.PrevProp = (int.MaxValue + 1L) << (sizeof(sbyte) * 8) * 3; return(record); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldConvertDynamicAddedProperty() public virtual void ShouldConvertDynamicAddedProperty() { // GIVEN int key = 10; PropertyRecord before = PropertyRecord(); PropertyRecord after = PropertyRecord(Property(key, _longString)); // THEN assertThat(Convert(_none, _none, Change(before, after)), equalTo(EntityUpdates.ForEntity(0, false).added(key, _longString).build())); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldIgnoreInlinedUnchangedProperty() public virtual void ShouldIgnoreInlinedUnchangedProperty() { // GIVEN int key = 10; Value value = Values.of(12341); PropertyRecord before = PropertyRecord(Property(key, value)); PropertyRecord after = PropertyRecord(Property(key, value)); // WHEN assertThat(Convert(_none, _none, Change(before, after)), equalTo(EntityUpdates.ForEntity(0, false).build())); }
public static int[] Keys(PropertyRecord property) { int[] toStartWith = new int[MAX_BLOCK_PER_RECORD_COUNT]; int index = 0; foreach (PropertyBlock propertyBlock in property) { toStartWith[index++] = propertyBlock.KeyIndexId; } return(Arrays.copyOf(toStartWith, index)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void useFixedReferenceFormatWhenPreviousPropertyIsMissing() public virtual void UseFixedReferenceFormatWhenPreviousPropertyIsMissing() { PropertyRecord source = new PropertyRecord(1); PropertyRecord target = new PropertyRecord(1); source.Initialize(true, Record.NULL_REFERENCE.intValue(), RandomFixedReference()); WriteReadRecord(source, target); assertTrue("Record should use fixed reference format.", target.UseFixedReferences); VerifySameReferences(source, target); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void useVariableLengthFormatWhenNextPropertyReferenceTooBig() public virtual void UseVariableLengthFormatWhenNextPropertyReferenceTooBig() { PropertyRecord source = new PropertyRecord(1); PropertyRecord target = new PropertyRecord(1); source.Initialize(true, RandomFixedReference(), _tooBigReference); WriteReadRecord(source, target); assertFalse("Record should use variable length reference format.", target.UseFixedReferences); VerifySameReferences(source, target); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void useVariableLengthFormatWhenRecordSizeIsTooSmall() public virtual void UseVariableLengthFormatWhenRecordSizeIsTooSmall() { PropertyRecord source = new PropertyRecord(1); PropertyRecord target = new PropertyRecord(1); source.Initialize(true, RandomFixedReference(), RandomFixedReference()); WriteReadRecord(source, target, PropertyRecordFormat.FixedFormatRecordSize - 1); assertFalse("Record should use variable length reference if format record is too small.", target.UseFixedReferences); VerifySameReferences(source, target); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void useFixedReferenceFormatWhenRecordCanFitInRecordSizeRecord() public virtual void UseFixedReferenceFormatWhenRecordCanFitInRecordSizeRecord() { PropertyRecord source = new PropertyRecord(1); PropertyRecord target = new PropertyRecord(1); source.Initialize(true, RandomFixedReference(), RandomFixedReference()); WriteReadRecord(source, target, PropertyRecordFormat.FixedFormatRecordSize); assertTrue("Record should use fixed reference if can fit in format record.", target.UseFixedReferences); VerifySameReferences(source, target); }
private void AssertChain(params ExpectedRecord[] expectedRecords) { long nextProp = _primitive.forReadingLinkage().NextProp; int expectedRecordCursor = 0; while (!Record.NO_NEXT_PROPERTY.@is(nextProp)) { PropertyRecord record = _records.getIfLoaded(nextProp).forReadingData(); AssertRecord(record, expectedRecords[expectedRecordCursor++]); nextProp = record.NextProp; } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void readWriteFixedReferencesRecord() public virtual void ReadWriteFixedReferencesRecord() { PropertyRecord source = new PropertyRecord(1); PropertyRecord target = new PropertyRecord(1); source.Initialize(true, RandomFixedReference(), RandomFixedReference()); WriteReadRecord(source, target); assertTrue("Record should use fixed reference format.", target.UseFixedReferences); VerifySameReferences(source, target); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void inUseRecordEquality() public virtual void InUseRecordEquality() { PropertyRecord record1 = new PropertyRecord(1); record1.Initialize(true, 1, 2); record1.SecondaryUnitId = 42; PropertyRecord record2 = record1.Clone(); PropertyCheckType check = new PropertyCheckType(); assertTrue(check.Equal(record1, record2)); }
public override void CheckReference(RECORD record, PropertyRecord property, CheckerEngine <RECORD, REPORT> engine, RecordAccess records) { foreach (int key in Keys(property)) { if (!_keys.add(key)) { engine.Report().propertyKeyNotUniqueInChain(); } } if (!Record.NO_NEXT_PROPERTY.@is(property.NextProp)) { engine.ComparativeCheck(records.Property(property.NextProp), this); } }
public void CheckReference(Org.Neo4j.Kernel.impl.store.record.PropertyRecord record, Org.Neo4j.Kernel.impl.store.record.PropertyRecord property, CheckerEngine <Org.Neo4j.Kernel.impl.store.record.PropertyRecord, Org.Neo4j.Consistency.report.ConsistencyReport_PropertyConsistencyReport> engine, Org.Neo4j.Consistency.store.RecordAccess records) { if (record.Id != property.Id) { if (!property.InUse() || Record.NO_NEXT_PROPERTY.@is(property.NextProp)) { WrongOwner(engine.Report()); } else if (property.NextProp != record.Id) { engine.ComparativeCheck(property(records, property.NextProp), this); } } }
public void checkReference(Org.Neo4j.Kernel.impl.store.record.PropertyRecord record, Org.Neo4j.Kernel.impl.store.record.PropertyRecord referred, CheckerEngine <Org.Neo4j.Kernel.impl.store.record.PropertyRecord, Org.Neo4j.Consistency.report.ConsistencyReport_PropertyConsistencyReport> engine, Org.Neo4j.Consistency.store.RecordAccess records) { if (!referred.inUse()) { notInUse(engine.report(), referred); } else { if (otherReference(referred) != record.getId()) { noBackReference(engine.report(), referred); } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldConvertDynamicInlinedRemovedProperty() public virtual void ShouldConvertDynamicInlinedRemovedProperty() { // GIVEN int key = 10; PropertyRecord before = PropertyRecord(Property(key, _longString)); PropertyRecord after = PropertyRecord(); // WHEN EntityUpdates update = Convert(_none, _none, Change(before, after)); // THEN EntityUpdates expected = EntityUpdates.ForEntity(0, false).removed(key, _longString).build(); assertEquals(expected, update); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void readSingleUnitRecordStoredNotInFixedReferenceFormat() public virtual void ReadSingleUnitRecordStoredNotInFixedReferenceFormat() { PropertyRecord oldFormatRecord = new PropertyRecord(1); PropertyRecord newFormatRecord = new PropertyRecord(1); oldFormatRecord.Initialize(true, RandomFixedReference(), RandomFixedReference()); WriteRecordWithOldFormat(oldFormatRecord); assertFalse("This should be single unit record.", oldFormatRecord.HasSecondaryUnitId()); assertFalse("Old format is not aware about fixed references.", oldFormatRecord.UseFixedReferences); _recordFormat.read(newFormatRecord, _pageCursor, RecordLoad.NORMAL, PropertyRecordFormat.RECORD_SIZE); VerifySameReferences(oldFormatRecord, newFormatRecord); }
private static PropertyRecord PropertyRecord(params PropertyBlock[] propertyBlocks) { PropertyRecord record = new PropertyRecord(0); if (propertyBlocks != null) { record.InUse = true; foreach (PropertyBlock propertyBlock in propertyBlocks) { record.AddPropertyBlock(propertyBlock); } } record.NodeId = 0; return(record); }
public override void Run(StoreAccess store, PrintStream @out) { long propId = FirstPropId(store); RecordStore <PropertyRecord> propertyStore = store.PropertyStore; PropertyRecord record = propertyStore.NewRecord(); while (propId != Record.NO_NEXT_PROPERTY.intValue()) { propertyStore.GetRecord(propId, record, NORMAL); // We rely on this method having the side-effect of loading the property blocks: record.NumberOfProperties(); @out.println(record); propId = record.NextProp; } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void notInUseRecordEquality() public virtual void NotInUseRecordEquality() { PropertyRecord record1 = new PropertyRecord(1); record1.Initialize(false, 1, 2); record1.SecondaryUnitId = 42; PropertyRecord record2 = new PropertyRecord(1); record2.Initialize(false, 11, 22); record2.SecondaryUnitId = 24; PropertyCheckType check = new PropertyCheckType(); assertTrue(check.Equal(record1, record2)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldConvertInlinedRemovedProperty() public virtual void ShouldConvertInlinedRemovedProperty() { // GIVEN int key = 10; Value value = Values.of(12341); PropertyRecord before = PropertyRecord(Property(key, value)); PropertyRecord after = PropertyRecord(); // WHEN EntityUpdates update = Convert(_none, _none, Change(before, after)); // THEN EntityUpdates expected = EntityUpdates.ForEntity(0, false).removed(key, value).build(); assertEquals(expected, update); }
//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(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldDetectAndAbortPropertyChainLoadingOnCircularReference() throws java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldDetectAndAbortPropertyChainLoadingOnCircularReference() { // given NeoStores neoStores = StoresRule.builder().build(); // Create property chain 1 --> 2 --> 3 --> 4 // ↑ │ // └───────────┘ PropertyStore propertyStore = neoStores.PropertyStore; PropertyRecord record = propertyStore.NewRecord(); // 1 record.Id = 1; record.Initialize(true, -1, 2); propertyStore.UpdateRecord(record); // 2 record.Id = 2; record.Initialize(true, 1, 3); propertyStore.UpdateRecord(record); // 3 record.Id = 3; record.Initialize(true, 2, 4); propertyStore.UpdateRecord(record); // 4 record.Id = 4; record.Initialize(true, 3, 2); // <-- completing the circle propertyStore.UpdateRecord(record); // when PropertyReader reader = new PropertyReader(new StoreAccess(neoStores)); try { reader.GetPropertyRecordChain(1); fail("Should have detected circular reference"); } catch (PropertyReader.CircularPropertyRecordChainException e) { // then good assertEquals(4, e.PropertyRecordClosingTheCircle().Id); } }
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); } } } }