Skip to content

Commit

Permalink
Support for checking nodes from tx state
Browse files Browse the repository at this point in the history
  • Loading branch information
pontusmelke committed Dec 4, 2017
1 parent 54a71c6 commit 024a388
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 2 deletions.
Expand Up @@ -58,7 +58,7 @@ public void shouldSeeNodeInTransaction() throws Exception
}

@Test
public void shouldSeeNewLabelledNodeInTransaction() throws Exception
public void shouldSeeNewLabeledNodeInTransaction() throws Exception
{
long nodeId;
int labelId;
Expand Down
Expand Up @@ -24,6 +24,7 @@
import org.neo4j.internal.kernel.api.RelationshipGroupCursor;
import org.neo4j.internal.kernel.api.RelationshipTraversalCursor;
import org.neo4j.io.pagecache.PageCursor;
import org.neo4j.kernel.api.txstate.TransactionState;
import org.neo4j.kernel.impl.store.NodeLabelsField;
import org.neo4j.kernel.impl.store.RecordCursor;
import org.neo4j.kernel.impl.store.record.DynamicRecord;
Expand Down Expand Up @@ -139,18 +140,37 @@ public boolean next()
reset();
return false;
}
// Check tx state

boolean hasChanges = read.hasTxStateWithChanges();
TransactionState txs = hasChanges ? read.txState() : null;
do
{
read.node( this, next++, pageCursor );
if ( hasChanges && txs.nodeIsAddedInThisTx( next ) )
{
setId( next++ );
setInUse( true );
}
else if ( hasChanges && txs.nodeIsDeletedInThisTx( next ) )
{
next++;
setInUse( false );
}
else
{
read.node( this, next++, pageCursor );
}
if ( next > highMark )
{
if ( highMark == NO_ID )
{
//we are using single
next = NO_ID;
return inUse();
}
else
{
//Check if there is a new high mark
highMark = read.nodeHighMark();
if ( next > highMark )
{
Expand Down
@@ -0,0 +1,31 @@
/*
* Copyright (c) 2002-2017 "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.newapi;

import org.neo4j.internal.kernel.api.TransactionStateTestBase;

public class TransactionStateTest extends TransactionStateTestBase<WriteTestSupport>
{
@Override
public WriteTestSupport newTestSupport()
{
return new WriteTestSupport();
}
}

0 comments on commit 024a388

Please sign in to comment.