Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hooks in call to RecordFormat.prepare
as to properly make the decision about the secondary record unit before writing commands to the log
- Loading branch information
Showing
9 changed files
with
302 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
191 changes: 191 additions & 0 deletions
191
...l/src/test/java/org/neo4j/kernel/impl/transaction/state/PrepareTrackingRecordFormats.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,191 @@ | ||
/* | ||
* Copyright (c) 2002-2016 "Neo Technology," | ||
* Network Engine for Objects in Lund AB [http://neotechnology.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Neo4j is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.neo4j.kernel.impl.transaction.state; | ||
|
||
import java.io.IOException; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
import org.neo4j.io.pagecache.PageCursor; | ||
import org.neo4j.io.pagecache.PagedFile; | ||
import org.neo4j.kernel.impl.store.StoreHeader; | ||
import org.neo4j.kernel.impl.store.format.RecordFormat; | ||
import org.neo4j.kernel.impl.store.format.RecordFormats; | ||
import org.neo4j.kernel.impl.store.id.IdSequence; | ||
import org.neo4j.kernel.impl.store.record.AbstractBaseRecord; | ||
import org.neo4j.kernel.impl.store.record.DynamicRecord; | ||
import org.neo4j.kernel.impl.store.record.LabelTokenRecord; | ||
import org.neo4j.kernel.impl.store.record.NodeRecord; | ||
import org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord; | ||
import org.neo4j.kernel.impl.store.record.PropertyRecord; | ||
import org.neo4j.kernel.impl.store.record.RecordLoad; | ||
import org.neo4j.kernel.impl.store.record.RelationshipGroupRecord; | ||
import org.neo4j.kernel.impl.store.record.RelationshipRecord; | ||
import org.neo4j.kernel.impl.store.record.RelationshipTypeTokenRecord; | ||
|
||
public class PrepareTrackingRecordFormats implements RecordFormats | ||
{ | ||
private final RecordFormats actual; | ||
private final Set<NodeRecord> nodePrepare = new HashSet<>(); | ||
private final Set<RelationshipRecord> relationshipPrepare = new HashSet<>(); | ||
private final Set<RelationshipGroupRecord> relationshipGroupPrepare = new HashSet<>(); | ||
private final Set<PropertyRecord> propertyPrepare = new HashSet<>(); | ||
private final Set<DynamicRecord> dynamicPrepare = new HashSet<>(); | ||
private final Set<PropertyKeyTokenRecord> propertyKeyTokenPrepare = new HashSet<>(); | ||
private final Set<LabelTokenRecord> labelTokenPrepare = new HashSet<>(); | ||
private final Set<RelationshipTypeTokenRecord> relationshipTypeTokenPrepare = new HashSet<>(); | ||
|
||
public PrepareTrackingRecordFormats( RecordFormats actual ) | ||
{ | ||
this.actual = actual; | ||
} | ||
|
||
@Override | ||
public String storeVersion() | ||
{ | ||
return actual.storeVersion(); | ||
} | ||
|
||
@Override | ||
public PrepareTrackingRecordFormat<NodeRecord> node() | ||
{ | ||
return new PrepareTrackingRecordFormat<>( actual.node(), nodePrepare ); | ||
} | ||
|
||
@Override | ||
public PrepareTrackingRecordFormat<RelationshipGroupRecord> relationshipGroup() | ||
{ | ||
return new PrepareTrackingRecordFormat<>( actual.relationshipGroup(), relationshipGroupPrepare ); | ||
} | ||
|
||
@Override | ||
public PrepareTrackingRecordFormat<RelationshipRecord> relationship() | ||
{ | ||
return new PrepareTrackingRecordFormat<>( actual.relationship(), relationshipPrepare ); | ||
} | ||
|
||
@Override | ||
public PrepareTrackingRecordFormat<PropertyRecord> property() | ||
{ | ||
return new PrepareTrackingRecordFormat<>( actual.property(), propertyPrepare ); | ||
} | ||
|
||
@Override | ||
public PrepareTrackingRecordFormat<LabelTokenRecord> labelToken() | ||
{ | ||
return new PrepareTrackingRecordFormat<>( actual.labelToken(), labelTokenPrepare ); | ||
} | ||
|
||
@Override | ||
public PrepareTrackingRecordFormat<PropertyKeyTokenRecord> propertyKeyToken() | ||
{ | ||
return new PrepareTrackingRecordFormat<>( actual.propertyKeyToken(), propertyKeyTokenPrepare ); | ||
} | ||
|
||
@Override | ||
public PrepareTrackingRecordFormat<RelationshipTypeTokenRecord> relationshipTypeToken() | ||
{ | ||
return new PrepareTrackingRecordFormat<>( actual.relationshipTypeToken(), relationshipTypeTokenPrepare ); | ||
} | ||
|
||
@Override | ||
public PrepareTrackingRecordFormat<DynamicRecord> dynamic() | ||
{ | ||
return new PrepareTrackingRecordFormat<>( actual.dynamic(), dynamicPrepare ); | ||
} | ||
|
||
public class PrepareTrackingRecordFormat<RECORD extends AbstractBaseRecord> implements RecordFormat<RECORD> | ||
{ | ||
private final RecordFormat<RECORD> actual; | ||
private final Set<RECORD> prepare; | ||
|
||
PrepareTrackingRecordFormat( RecordFormat<RECORD> actual, Set<RECORD> prepare ) | ||
{ | ||
this.actual = actual; | ||
this.prepare = prepare; | ||
} | ||
|
||
@Override | ||
public RECORD newRecord() | ||
{ | ||
return actual.newRecord(); | ||
} | ||
|
||
@Override | ||
public int getRecordSize( StoreHeader storeHeader ) | ||
{ | ||
return actual.getRecordSize( storeHeader ); | ||
} | ||
|
||
@Override | ||
public int getRecordHeaderSize() | ||
{ | ||
return actual.getRecordHeaderSize(); | ||
} | ||
|
||
@Override | ||
public boolean isInUse( PageCursor cursor ) | ||
{ | ||
return actual.isInUse( cursor ); | ||
} | ||
|
||
@Override | ||
public void read( RECORD record, PageCursor cursor, RecordLoad mode, int recordSize, PagedFile storeFile ) | ||
throws IOException | ||
{ | ||
actual.read( record, cursor, mode, recordSize, storeFile ); | ||
} | ||
|
||
@Override | ||
public void prepare( RECORD record, int recordSize, IdSequence idSequence ) | ||
{ | ||
prepare.add( record ); | ||
actual.prepare( record, recordSize, idSequence ); | ||
} | ||
|
||
@Override | ||
public void write( RECORD record, PageCursor cursor, int recordSize, PagedFile storeFile ) throws IOException | ||
{ | ||
actual.write( record, cursor, recordSize, storeFile ); | ||
} | ||
|
||
@Override | ||
public long getNextRecordReference( RECORD record ) | ||
{ | ||
return actual.getNextRecordReference( record ); | ||
} | ||
|
||
@Override | ||
public boolean equals( Object otherFormat ) | ||
{ | ||
return actual.equals( otherFormat ); | ||
} | ||
|
||
@Override | ||
public int hashCode() | ||
{ | ||
return actual.hashCode(); | ||
} | ||
|
||
public boolean prepared( RECORD record ) | ||
{ | ||
return prepare.contains( record ); | ||
} | ||
} | ||
} |
Oops, something went wrong.