Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move AnyValues.of out of values module
- Loading branch information
1 parent
dd4994a
commit 4e591a6
Showing
77 changed files
with
752 additions
and
660 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
111 changes: 111 additions & 0 deletions
111
...cypher/src/main/java/org/neo4j/cypher/internal/javacompat/NodeProxyWrappingNodeValue.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,111 @@ | |||
/* | |||
* 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.cypher.internal.javacompat; | |||
|
|||
import java.util.ArrayList; | |||
|
|||
import org.neo4j.graphdb.Label; | |||
import org.neo4j.graphdb.Node; | |||
import org.neo4j.graphdb.NotFoundException; | |||
import org.neo4j.values.AnyValueWriter; | |||
import org.neo4j.values.storable.TextArray; | |||
import org.neo4j.values.storable.Values; | |||
import org.neo4j.values.virtual.MapValue; | |||
import org.neo4j.values.virtual.NodeValue; | |||
import org.neo4j.values.virtual.VirtualValues; | |||
|
|||
public class NodeProxyWrappingNodeValue extends NodeValue | |||
{ | |||
private final Node node; | |||
private volatile TextArray labels; | |||
private volatile MapValue properties; | |||
|
|||
NodeProxyWrappingNodeValue( Node node ) | |||
{ | |||
super( node.getId() ); | |||
this.node = node; | |||
} | |||
|
|||
public Node nodeProxy() | |||
{ | |||
return node; | |||
} | |||
|
|||
@Override | |||
public <E extends Exception> void writeTo( AnyValueWriter<E> writer ) throws E | |||
{ | |||
TextArray l; | |||
MapValue p; | |||
try | |||
{ | |||
l = labels(); | |||
p = properties(); | |||
} | |||
catch ( NotFoundException e ) | |||
{ | |||
l = Values.stringArray(); | |||
p = VirtualValues.EMPTY_MAP; | |||
|
|||
} | |||
writer.writeNode( node.getId(), l, p ); | |||
} | |||
|
|||
@Override | |||
public TextArray labels() | |||
{ | |||
TextArray l = labels; | |||
if ( l == null ) | |||
{ | |||
synchronized ( this ) | |||
{ | |||
l = labels; | |||
if ( l == null ) | |||
{ | |||
ArrayList<String> ls = new ArrayList<>(); | |||
for ( Label label : node.getLabels() ) | |||
{ | |||
ls.add( label.name() ); | |||
} | |||
l = labels = Values.stringArray( ls.toArray( new String[ls.size()] ) ); | |||
|
|||
} | |||
} | |||
} | |||
return l; | |||
} | |||
|
|||
@Override | |||
public MapValue properties() | |||
{ | |||
MapValue m = properties; | |||
if ( m == null ) | |||
{ | |||
synchronized ( this ) | |||
{ | |||
m = properties; | |||
if ( m == null ) | |||
{ | |||
m = properties = ValueUtils.asMapValue( node.getAllProperties() ); | |||
} | |||
} | |||
} | |||
return m; | |||
} | |||
} |
139 changes: 139 additions & 0 deletions
139
...rc/main/java/org/neo4j/cypher/internal/javacompat/RelationshipProxyWrappingEdgeValue.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,139 @@ | |||
/* | |||
* 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.cypher.internal.javacompat; | |||
|
|||
import org.neo4j.graphdb.NotFoundException; | |||
import org.neo4j.graphdb.Relationship; | |||
import org.neo4j.values.AnyValueWriter; | |||
import org.neo4j.values.storable.TextValue; | |||
import org.neo4j.values.storable.Values; | |||
import org.neo4j.values.virtual.EdgeValue; | |||
import org.neo4j.values.virtual.MapValue; | |||
import org.neo4j.values.virtual.NodeValue; | |||
import org.neo4j.values.virtual.VirtualValues; | |||
|
|||
public class RelationshipProxyWrappingEdgeValue extends EdgeValue | |||
{ | |||
private final Relationship relationship; | |||
private volatile TextValue type; | |||
private volatile MapValue properties; | |||
private volatile NodeValue startNode; | |||
private volatile NodeValue endNode; | |||
|
|||
RelationshipProxyWrappingEdgeValue( Relationship relationship ) | |||
{ | |||
super( relationship.getId() ); | |||
this.relationship = relationship; | |||
} | |||
|
|||
public Relationship relationshipProxy() | |||
{ | |||
return relationship; | |||
} | |||
|
|||
@Override | |||
public <E extends Exception> void writeTo( AnyValueWriter<E> writer ) throws E | |||
{ | |||
MapValue p; | |||
try | |||
{ | |||
p = properties(); | |||
} | |||
catch ( NotFoundException e ) | |||
{ | |||
p = VirtualValues.EMPTY_MAP; | |||
|
|||
} | |||
writer.writeEdge( id(), startNode().id(), endNode().id(), type(), p ); | |||
} | |||
|
|||
@Override | |||
public NodeValue startNode() | |||
{ | |||
NodeValue start = startNode; | |||
if ( start == null ) | |||
{ | |||
synchronized ( this ) | |||
{ | |||
start = startNode; | |||
if ( start == null ) | |||
{ | |||
start = startNode = ValueUtils.fromNodeProxy( relationship.getStartNode() ); | |||
} | |||
} | |||
} | |||
return start; | |||
} | |||
|
|||
@Override | |||
public NodeValue endNode() | |||
{ | |||
NodeValue end = endNode; | |||
if ( end == null ) | |||
{ | |||
synchronized ( this ) | |||
{ | |||
end = endNode; | |||
if ( end == null ) | |||
{ | |||
end = endNode = ValueUtils.fromNodeProxy( relationship.getEndNode() ); | |||
} | |||
} | |||
} | |||
return end; | |||
} | |||
|
|||
@Override | |||
public TextValue type() | |||
{ | |||
TextValue t = type; | |||
if ( t == null ) | |||
{ | |||
synchronized ( this ) | |||
{ | |||
t = type; | |||
if ( t == null ) | |||
{ | |||
t = type = Values.stringValue( relationship.getType().name() ); | |||
} | |||
} | |||
} | |||
return t; | |||
} | |||
|
|||
@Override | |||
public MapValue properties() | |||
{ | |||
MapValue m = properties; | |||
if ( m == null ) | |||
{ | |||
synchronized ( this ) | |||
{ | |||
m = properties; | |||
if ( m == null ) | |||
{ | |||
m = properties = ValueUtils.asMapValue( relationship.getAllProperties() ); | |||
} | |||
} | |||
} | |||
return m; | |||
} | |||
} | |||
|
Oops, something went wrong.