diff --git a/enterprise/kernel/src/main/java/org/neo4j/kernel/impl/store/format/highlimit/NodeRecordFormat.java b/enterprise/kernel/src/main/java/org/neo4j/kernel/impl/store/format/highlimit/NodeRecordFormat.java index 13bb827f9ee40..967900d345171 100644 --- a/enterprise/kernel/src/main/java/org/neo4j/kernel/impl/store/format/highlimit/NodeRecordFormat.java +++ b/enterprise/kernel/src/main/java/org/neo4j/kernel/impl/store/format/highlimit/NodeRecordFormat.java @@ -129,8 +129,8 @@ protected byte headerBits( NodeRecord record ) protected boolean canUseFixedReferences( NodeRecord record, int recordSize ) { return (isRecordBigEnoughForFixedReferences( recordSize ) && - ((record.getNextProp() != NULL) && ((record.getNextProp() & HIGH_DWORD_LOWER_NIBBLE_MASK) == 0)) && - ((record.getNextRel() != NULL) && ((record.getNextRel() & HIGH_DWORD_LOWER_NIBBLE_MASK) == 0))); + ((record.getNextProp() == NULL) || ((record.getNextProp() & HIGH_DWORD_LOWER_NIBBLE_MASK) == 0)) && + ((record.getNextRel() == NULL) || ((record.getNextRel() & HIGH_DWORD_LOWER_NIBBLE_MASK) == 0))); } private boolean isRecordBigEnoughForFixedReferences( int recordSize ) diff --git a/enterprise/kernel/src/main/java/org/neo4j/kernel/impl/store/format/highlimit/PropertyRecordFormat.java b/enterprise/kernel/src/main/java/org/neo4j/kernel/impl/store/format/highlimit/PropertyRecordFormat.java index 6965ecadac6eb..e55fdab1812d6 100644 --- a/enterprise/kernel/src/main/java/org/neo4j/kernel/impl/store/format/highlimit/PropertyRecordFormat.java +++ b/enterprise/kernel/src/main/java/org/neo4j/kernel/impl/store/format/highlimit/PropertyRecordFormat.java @@ -184,8 +184,8 @@ public long getNextRecordReference( PropertyRecord record ) private boolean canUseFixedReferences( PropertyRecord record, int recordSize ) { return ( isRecordBigEnoughForFixedReferences( recordSize ) && - ((record.getNextProp() != NULL) && ((record.getNextProp() & HIGH_DWORD_LOWER_WORD_CHECK_MASK) == 0)) && - ((record.getPrevProp() != NULL) && ((record.getPrevProp() & HIGH_DWORD_LOWER_WORD_CHECK_MASK) == 0))); + ((record.getNextProp() == NULL) || ((record.getNextProp() & HIGH_DWORD_LOWER_WORD_CHECK_MASK) == 0)) && + ((record.getPrevProp() == NULL) || ((record.getPrevProp() & HIGH_DWORD_LOWER_WORD_CHECK_MASK) == 0))); } private boolean isRecordBigEnoughForFixedReferences( int recordSize ) diff --git a/enterprise/kernel/src/main/java/org/neo4j/kernel/impl/store/format/highlimit/RelationshipGroupRecordFormat.java b/enterprise/kernel/src/main/java/org/neo4j/kernel/impl/store/format/highlimit/RelationshipGroupRecordFormat.java index 840ccc3f1175a..456efad5ef5dd 100644 --- a/enterprise/kernel/src/main/java/org/neo4j/kernel/impl/store/format/highlimit/RelationshipGroupRecordFormat.java +++ b/enterprise/kernel/src/main/java/org/neo4j/kernel/impl/store/format/highlimit/RelationshipGroupRecordFormat.java @@ -160,11 +160,11 @@ protected void doWriteInternal( RelationshipGroupRecord record, PageCursor curso protected boolean canUseFixedReferences( RelationshipGroupRecord record, int recordSize ) { return (isRecordBigEnoughForFixedReferences( recordSize ) && - (record.getNext() != NULL) && ((record.getNext() & ONE_BIT_OVERFLOW_BIT_MASK) == 0) && - (record.getFirstOut() != NULL) && ((record.getFirstOut() & ONE_BIT_OVERFLOW_BIT_MASK) == 0) && - (record.getFirstIn() != NULL) && ((record.getFirstIn() & ONE_BIT_OVERFLOW_BIT_MASK) == 0) && - (record.getFirstLoop() != NULL) && ((record.getFirstLoop() & ONE_BIT_OVERFLOW_BIT_MASK) == 0) && - (record.getOwningNode() != NULL) && ((record.getOwningNode() & ONE_BIT_OVERFLOW_BIT_MASK) == 0)); + ((record.getNext() == NULL) || ((record.getNext() & ONE_BIT_OVERFLOW_BIT_MASK) == 0)) && + ((record.getFirstOut() == NULL) || ((record.getFirstOut() & ONE_BIT_OVERFLOW_BIT_MASK) == 0)) && + ((record.getFirstIn() == NULL) || ((record.getFirstIn() & ONE_BIT_OVERFLOW_BIT_MASK) == 0)) && + ((record.getFirstLoop() == NULL) || ((record.getFirstLoop() & ONE_BIT_OVERFLOW_BIT_MASK) == 0)) && + ((record.getOwningNode() == NULL) || ((record.getOwningNode() & ONE_BIT_OVERFLOW_BIT_MASK) == 0))); } private boolean isRecordBigEnoughForFixedReferences( int recordSize ) diff --git a/enterprise/kernel/src/main/java/org/neo4j/kernel/impl/store/format/highlimit/RelationshipRecordFormat.java b/enterprise/kernel/src/main/java/org/neo4j/kernel/impl/store/format/highlimit/RelationshipRecordFormat.java index e7e637dd7d5d8..edc800a14effe 100644 --- a/enterprise/kernel/src/main/java/org/neo4j/kernel/impl/store/format/highlimit/RelationshipRecordFormat.java +++ b/enterprise/kernel/src/main/java/org/neo4j/kernel/impl/store/format/highlimit/RelationshipRecordFormat.java @@ -196,11 +196,11 @@ protected boolean canUseFixedReferences( RelationshipRecord record, int recordSi return (isRecordBigEnoughForFixedReferences( recordSize ) && (record.getFirstNode() & ONE_BIT_OVERFLOW_BIT_MASK) == 0) && ((record.getSecondNode() & ONE_BIT_OVERFLOW_BIT_MASK) == 0) && - ((record.getFirstPrevRel() != NULL) && ((record.getFirstPrevRel() & ONE_BIT_OVERFLOW_BIT_MASK) == 0)) && - ((record.getFirstNextRel() != NULL) && ((record.getFirstNextRel() & ONE_BIT_OVERFLOW_BIT_MASK) == 0)) && - ((record.getSecondPrevRel() != NULL) && ((record.getSecondPrevRel() & ONE_BIT_OVERFLOW_BIT_MASK) == 0)) && - ((record.getSecondNextRel() != NULL) && ((record.getSecondNextRel() & ONE_BIT_OVERFLOW_BIT_MASK) == 0)) && - ((record.getNextProp() != NULL) && ((record.getNextProp() & THREE_BITS_OVERFLOW_BIT_MASK) == 0)); + ((record.getFirstPrevRel() == NULL) || ((record.getFirstPrevRel() & ONE_BIT_OVERFLOW_BIT_MASK) == 0)) && + ((record.getFirstNextRel() == NULL) || ((record.getFirstNextRel() & ONE_BIT_OVERFLOW_BIT_MASK) == 0)) && + ((record.getSecondPrevRel() == NULL) || ((record.getSecondPrevRel() & ONE_BIT_OVERFLOW_BIT_MASK) == 0)) && + ((record.getSecondNextRel() == NULL) || ((record.getSecondNextRel() & ONE_BIT_OVERFLOW_BIT_MASK) == 0)) && + ((record.getNextProp() == NULL) || ((record.getNextProp() & THREE_BITS_OVERFLOW_BIT_MASK) == 0)); } private boolean isRecordBigEnoughForFixedReferences( int recordSize ) diff --git a/enterprise/kernel/src/test/java/org/neo4j/kernel/impl/store/format/highlimit/NodeRecordFormatTest.java b/enterprise/kernel/src/test/java/org/neo4j/kernel/impl/store/format/highlimit/NodeRecordFormatTest.java index 34105964b4d20..ab85e2c93eac3 100644 --- a/enterprise/kernel/src/test/java/org/neo4j/kernel/impl/store/format/highlimit/NodeRecordFormatTest.java +++ b/enterprise/kernel/src/test/java/org/neo4j/kernel/impl/store/format/highlimit/NodeRecordFormatTest.java @@ -72,7 +72,7 @@ public void readWriteFixedReferencesRecord() throws Exception } @Test - public void useVariableLengthFormatWhenRelationshipIsMissing() throws IOException + public void useFixedReferencesFormatWhenRelationshipIsMissing() throws IOException { NodeRecord source = new NodeRecord( 1 ); NodeRecord target = new NodeRecord( 1 ); @@ -80,12 +80,12 @@ public void useVariableLengthFormatWhenRelationshipIsMissing() throws IOExceptio writeReadRecord( source, target ); - assertFalse( "Record should use variable length reference format.", target.isUseFixedReferences() ); + assertTrue( "Record should use fixed reference format.", target.isUseFixedReferences() ); verifySameReferences( source, target ); } @Test - public void useVariableLengthFormatWhenPropertyIsMissing() throws IOException + public void useFixedReferencesFormatWhenPropertyIsMissing() throws IOException { NodeRecord source = new NodeRecord( 1 ); NodeRecord target = new NodeRecord( 1 ); @@ -93,7 +93,7 @@ public void useVariableLengthFormatWhenPropertyIsMissing() throws IOException writeReadRecord( source, target ); - assertFalse( "Record should use variable length reference format.", target.isUseFixedReferences() ); + assertTrue( "Record should use fixed reference format.", target.isUseFixedReferences() ); verifySameReferences( source, target ); } diff --git a/enterprise/kernel/src/test/java/org/neo4j/kernel/impl/store/format/highlimit/PropertyRecordFormatTest.java b/enterprise/kernel/src/test/java/org/neo4j/kernel/impl/store/format/highlimit/PropertyRecordFormatTest.java index 1de814d6120a7..1601f3b8e46c6 100644 --- a/enterprise/kernel/src/test/java/org/neo4j/kernel/impl/store/format/highlimit/PropertyRecordFormatTest.java +++ b/enterprise/kernel/src/test/java/org/neo4j/kernel/impl/store/format/highlimit/PropertyRecordFormatTest.java @@ -104,7 +104,7 @@ public void readWriteFixedReferencesRecord() throws Exception } @Test - public void useVariableLengthFormatWhenNextPropertyIsMissing() throws IOException + public void useFixedReferenceFormatWhenNextPropertyIsMissing() throws IOException { PropertyRecord source = new PropertyRecord( 1 ); PropertyRecord target = new PropertyRecord( 1 ); @@ -112,12 +112,12 @@ public void useVariableLengthFormatWhenNextPropertyIsMissing() throws IOExceptio writeReadRecord( source, target ); - assertFalse( "Record should use variable length reference format.", target.isUseFixedReferences() ); + assertTrue( "Record should use fixed reference format.", target.isUseFixedReferences() ); verifySameReferences( source, target ); } @Test - public void useVariableLengthFormatWhenPreviousPropertyIsMissing() throws IOException + public void useFixedReferenceFormatWhenPreviousPropertyIsMissing() throws IOException { PropertyRecord source = new PropertyRecord( 1 ); PropertyRecord target = new PropertyRecord( 1 ); @@ -125,7 +125,7 @@ public void useVariableLengthFormatWhenPreviousPropertyIsMissing() throws IOExce writeReadRecord( source, target ); - assertFalse( "Record should use variable length reference format.", target.isUseFixedReferences() ); + assertTrue( "Record should use fixed reference format.", target.isUseFixedReferences() ); verifySameReferences( source, target ); } diff --git a/enterprise/kernel/src/test/java/org/neo4j/kernel/impl/store/format/highlimit/RelationshipGroupRecordFormatTest.java b/enterprise/kernel/src/test/java/org/neo4j/kernel/impl/store/format/highlimit/RelationshipGroupRecordFormatTest.java index 77a45734ae886..ba2aad0ae046f 100644 --- a/enterprise/kernel/src/test/java/org/neo4j/kernel/impl/store/format/highlimit/RelationshipGroupRecordFormatTest.java +++ b/enterprise/kernel/src/test/java/org/neo4j/kernel/impl/store/format/highlimit/RelationshipGroupRecordFormatTest.java @@ -76,7 +76,7 @@ public void readWriteFixedReferencesRecord() throws Exception } @Test - public void useVariableLengthFormatWhenOneOfTheReferencesIsMissing() throws IOException + public void useFixedReferenceFormatWhenOneOfTheReferencesIsMissing() throws IOException { RelationshipGroupRecord source = new RelationshipGroupRecord( 1 ); RelationshipGroupRecord target = new RelationshipGroupRecord( 1 ); @@ -167,6 +167,7 @@ private void writeRecordWithOldFormat( RelationshipGroupRecord oldFormatRecord ) private void verifyRecordsWithPoisonedReference( RelationshipGroupRecord source, RelationshipGroupRecord target, long poisonedReference ) throws IOException { + boolean nullPoisoned = poisonedReference == BaseHighLimitRecordFormat.NULL; int differentReferences = 5; List references = buildReferenceList( differentReferences, poisonedReference ); for ( int i = 0; i < differentReferences; i++ ) @@ -179,7 +180,14 @@ private void verifyRecordsWithPoisonedReference( RelationshipGroupRecord source, writeReadRecord( source, target ); - assertFalse( "Record should use variable length reference format.", target.isUseFixedReferences() ); + if ( nullPoisoned ) + { + assertTrue( "Record should use fixed reference format.", target.isUseFixedReferences() ); + } + else + { + assertFalse( "Record should use variable length reference format.", target.isUseFixedReferences() ); + } verifySameReferences( source, target ); Collections.rotate( references, 1 ); } diff --git a/enterprise/kernel/src/test/java/org/neo4j/kernel/impl/store/format/highlimit/RelationshipRecordFormatTest.java b/enterprise/kernel/src/test/java/org/neo4j/kernel/impl/store/format/highlimit/RelationshipRecordFormatTest.java index 8ebf104217555..f49714a19f3d5 100644 --- a/enterprise/kernel/src/test/java/org/neo4j/kernel/impl/store/format/highlimit/RelationshipRecordFormatTest.java +++ b/enterprise/kernel/src/test/java/org/neo4j/kernel/impl/store/format/highlimit/RelationshipRecordFormatTest.java @@ -129,7 +129,7 @@ public void readWriteFixedReferencesRecord() throws Exception } @Test - public void useVariableLengthFormatWhenAtLeastOneOfTheReferencesIsMissing() throws IOException + public void useFixedRecordFormatWhenAtLeastOneOfTheReferencesIsMissing() throws IOException { RelationshipRecord source = new RelationshipRecord( 1 ); RelationshipRecord target = new RelationshipRecord( 1 ); @@ -238,7 +238,14 @@ private void verifyRecordsWithPoisonedReference( RelationshipRecord source, Rela writeReadRecord( source, target ); - assertFalse( "Record should use variable length reference format.", target.isUseFixedReferences() ); + if ( nullPoison ) + { + assertTrue( "Record should use fixed reference format.", target.isUseFixedReferences() ); + } + else + { + assertFalse( "Record should use variable length reference format.", target.isUseFixedReferences() ); + } verifySameReferences( source, target ); Collections.rotate( references, 1 ); }