-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
AbstractIteratorRelationshipCursor.java
86 lines (74 loc) · 2.78 KB
/
AbstractIteratorRelationshipCursor.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
* 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.api.store;
import org.neo4j.collection.primitive.PrimitiveLongIterator;
import org.neo4j.kernel.impl.locking.LockService;
import org.neo4j.kernel.impl.store.RelationshipStore;
import org.neo4j.storageengine.api.txstate.ReadableTransactionState;
import static org.neo4j.kernel.api.StatementConstants.NO_SUCH_NODE;
import static org.neo4j.kernel.api.StatementConstants.NO_SUCH_RELATIONSHIP;
import static org.neo4j.kernel.api.StatementConstants.NO_SUCH_RELATIONSHIP_TYPE;
public abstract class AbstractIteratorRelationshipCursor extends AbstractRelationshipCursor
{
private ReadableTransactionState state;
private PrimitiveLongIterator addedRelationshipIterator;
private boolean fromStore;
AbstractIteratorRelationshipCursor( RelationshipStore relationshipStore, LockService lockService )
{
super( relationshipStore, lockService );
}
void internalInitTxState( ReadableTransactionState state, PrimitiveLongIterator addedRelationshipIterator )
{
this.state = state;
this.addedRelationshipIterator = addedRelationshipIterator;
this.fromStore = true;
}
@Override
protected final boolean fetchNext()
{
if ( fromStore )
{
while ( doFetchNext() )
{
if ( state.relationshipIsDeletedInThisTx( id() ) )
{
continue;
}
return true;
}
fromStore = false;
}
if ( addedRelationshipIterator != null && addedRelationshipIterator.hasNext() )
{
state.getRelationshipState( addedRelationshipIterator.next() ).accept( this );
return true;
}
visit( NO_SUCH_RELATIONSHIP, NO_SUCH_RELATIONSHIP_TYPE, NO_SUCH_NODE, NO_SUCH_NODE );
return false;
}
protected abstract boolean doFetchNext();
@Override
public void close()
{
super.close();
state = null;
addedRelationshipIterator = null;
}
}