Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor version updates and code polishes #395

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
74bf0a6
Add missing @Override annotations and remove unneeded else clauses
seabamirum Feb 27, 2024
c13d290
More code cleanup, mostly removing else clause and adding overrides
seabamirum Feb 28, 2024
4bc4dda
Match neo4j, java, and package versions of remote
seabamirum Feb 28, 2024
89f36d0
Merge remote-tracking branch 'refs/remotes/origin/master' into fork/s…
Andy2003 May 29, 2024
d889795
Merge remote-tracking branch 'refs/remotes/origin/master' into fork/s…
Andy2003 May 29, 2024
ba6b5ea
fix review comments
Andy2003 May 29, 2024
7d8c46f
neo4j 5.19, polishes
seabamirum May 29, 2024
65553b4
Merge remote-tracking branch 'refs/remotes/origin/master' into neo4j-…
Andy2003 May 30, 2024
b3134b7
Merge pull request #1 from neo4j-contrib/master
seabamirum May 30, 2024
c64dde2
Merge branch 'neo4j-latest-java21' of
seabamirum May 30, 2024
2cfb14b
Delete .factorypath
seabamirum May 30, 2024
f369c98
Added back newline at end of file
seabamirum May 30, 2024
5eefe69
Removed private unused methods, variables and unthrown exceptions
seabamirum May 30, 2024
aafc1cd
Added back line breaks at end of files
seabamirum May 31, 2024
ff475ad
Merge branch 'neo4j-contrib:master' into neo4j-latest-java21
seabamirum Jun 8, 2024
229e727
Merge branch 'neo4j-contrib:master' into neo4j-latest-java21
seabamirum Jun 23, 2024
f2b3f02
Merge pull request #2 from neo4j-contrib/master
seabamirum Nov 4, 2024
f77248a
Fix spatial procedures call to be compatible with 5.23+
seabamirum Nov 4, 2024
c979207
Fix compile errors with 5.26.0
seabamirum Jan 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,4 @@ public ReferencedEnvelope getBounds() {
return bbox;
}

}
}
Andy2003 marked this conversation as resolved.
Show resolved Hide resolved
16 changes: 0 additions & 16 deletions src/main/java/org/geotools/data/neo4j/Neo4jSpatialDataStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -229,20 +229,4 @@ public Style getStyle(String typeName) {
}
return result;
}

private EditableLayer getEditableLayer(String typeName) throws IOException {
try (Transaction tx = database.beginTx()) {
Layer layer = spatialDatabase.getLayer(tx, typeName);
if (layer == null) {
throw new IOException("Layer not found: " + typeName);
}

if (!(layer instanceof EditableLayer)) {
throw new IOException("Cannot create a FeatureWriter on a read-only layer: " + layer);
}
tx.commit();

return (EditableLayer) layer;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,4 @@ public Param[] getParametersInfo() {
return new Param[]{DBTYPE, DIRECTORY};
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -477,4 +477,4 @@ public static void main(String[] args) {
databases.shutdown();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,4 @@ public String getSignature() {
// Attributes

protected Layer layer;
}
}
7 changes: 0 additions & 7 deletions src/main/java/org/neo4j/gis/spatial/DynamicLayerConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
package org.neo4j.gis.spatial;

import java.io.File;
import java.io.PrintStream;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -169,12 +168,6 @@ public String[] getNames() {
public int getNodeCount() {
return nodeCount;
}

public void describeUsage(PrintStream out) {
for (String name : names.keySet()) {
out.println(name + "\t" + names.get(name));
}
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public void refreshGeomNode(Transaction tx) {
* @deprecated This method is of questionable value, since it is better to
* query the geometry object directly, outside the result
*/
@Deprecated
public int getType() {
//TODO: Get the type from the geometryEncoder
return SpatialDatabaseService.convertJtsClassToGeometryType(getGeometry().getClass());
Expand Down
12 changes: 0 additions & 12 deletions src/main/java/org/neo4j/gis/spatial/SpatialDatabaseService.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
import org.neo4j.graphdb.Direction;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Relationship;
import org.neo4j.graphdb.RelationshipType;
import org.neo4j.graphdb.Transaction;

/**
Expand Down Expand Up @@ -283,17 +282,6 @@ public Layer findLayerContainingGeometryNode(Transaction tx, Node geometryNode)
return null;
}

private Layer getLayerFromChild(Transaction tx, Node child, RelationshipType relType) {
Relationship indexRel = child.getSingleRelationship(relType, Direction.INCOMING);
if (indexRel != null) {
Node layerNode = indexRel.getStartNode();
if (layerNode.hasProperty(PROP_LAYER)) {
return LayerUtilities.makeLayerFromNode(tx, indexManager, layerNode);
}
}
return null;
}

public boolean containsLayer(Transaction tx, String name) {
return getLayer(tx, name) != null;
}
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/neo4j/gis/spatial/WKBGeometryEncoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@
import org.locationtech.jts.io.WKBReader;
import org.locationtech.jts.io.WKBWriter;
import org.neo4j.gis.spatial.encoders.AbstractSinglePropertyEncoder;
import org.neo4j.gis.spatial.encoders.Configurable;
import org.neo4j.graphdb.Entity;
import org.neo4j.graphdb.Transaction;

public class WKBGeometryEncoder extends AbstractSinglePropertyEncoder implements Configurable {
public class WKBGeometryEncoder extends AbstractSinglePropertyEncoder {

@Override
public Geometry decodeGeometry(Entity container) {
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/neo4j/gis/spatial/WKTGeometryEncoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@
import org.locationtech.jts.io.WKTReader;
import org.locationtech.jts.io.WKTWriter;
import org.neo4j.gis.spatial.encoders.AbstractSinglePropertyEncoder;
import org.neo4j.gis.spatial.encoders.Configurable;
import org.neo4j.graphdb.Entity;
import org.neo4j.graphdb.Transaction;

public class WKTGeometryEncoder extends AbstractSinglePropertyEncoder implements Configurable {
public class WKTGeometryEncoder extends AbstractSinglePropertyEncoder {

@Override
public Geometry decodeGeometry(Entity container) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public boolean equals(Object obj) {
return false;
}

protected void save(Transaction tx, Node node) {
protected void save(Node node) {
node.setProperty("from", this.from);
node.setProperty("to", this.to);
node.setProperty("type", this.type);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private void save(Transaction tx) {
}
for (PropertyMapper mapper : toSave) {
Node node = tx.createNode();
mapper.save(tx, node);
mapper.save(node);
layer.getLayerNode(tx).createRelationshipTo(node, SpatialRelationshipTypes.PROPERTY_MAPPING);
}
}
Expand All @@ -89,14 +89,6 @@ private void addPropertyMapper(Transaction tx, PropertyMapper mapper) {
save(tx);
}

private PropertyMapper removePropertyMapper(Transaction tx, String to) {
PropertyMapper mapper = getPropertyMappers(tx).remove(to);
if (mapper != null) {
save(tx);
}
return mapper;
}

public PropertyMapper getPropertyMapper(Transaction tx, String to) {
return getPropertyMappers(tx).get(to);
}
Expand All @@ -105,4 +97,4 @@ public void addPropertyMapper(Transaction tx, String from, String to, String typ
addPropertyMapper(tx, PropertyMapper.fromParams(from, to, type, params));
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,4 @@ public String getSignature() {
return "NativePointEncoder(geometry='" + locationProperty + "', bbox='" + bboxProperty + "', crs="
+ crs.getCode() + ")";
}
}
}
3 changes: 0 additions & 3 deletions src/main/java/org/neo4j/gis/spatial/filter/SearchCQL.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,19 @@
*/
public class SearchCQL implements SearchFilter {

private final Transaction tx;
private final Neo4jFeatureBuilder featureBuilder;
private final Layer layer;
private final org.geotools.api.filter.Filter filter;
private final Envelope filterEnvelope;

public SearchCQL(Transaction tx, Layer layer, org.geotools.api.filter.Filter filter) {
this.tx = tx;
this.layer = layer;
this.featureBuilder = Neo4jFeatureBuilder.fromLayer(tx, layer);
this.filter = filter;
this.filterEnvelope = Utilities.extractEnvelopeFromFilter(filter);
}

public SearchCQL(Transaction tx, Layer layer, String cql) {
this.tx = tx;
this.layer = layer;
this.featureBuilder = Neo4jFeatureBuilder.fromLayer(tx, layer);
try {
Expand Down
5 changes: 1 addition & 4 deletions src/main/java/org/neo4j/gis/spatial/index/IndexManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,9 @@ private String description() {
private class IndexRemover implements Runnable {

private final IndexDefinition index;
private Exception e;

private IndexRemover(IndexDefinition index) {
this.index = index;
this.e = null;
}

@Override
Expand All @@ -266,8 +264,7 @@ public void run() {
}
tx.commit();
}
} catch (Exception e) {
this.e = e;
} catch (Exception ignored) {
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/neo4j/gis/spatial/osm/OSMImporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ void logNodesFound(long currentTime) {
LogCounter found = nodeFindStats.get(type);
double rate = 0.0f;
if (found.totalTime > 0) {
rate = (1000.0 * (float) found.count / (float) found.totalTime);
rate = (1000.0 * found.count / found.totalTime);
}
System.out.println("\t" + type + ": \t" + found.count
+ "/" + (found.totalTime / 1000)
Expand Down Expand Up @@ -532,7 +532,7 @@ void logNodeAddition(LinkedHashMap<String, Object> tags,
if (currentTime - logTime > 1432) {
System.out.println(
new Date(currentTime) + ": Saving " + type + " " + count + " \t(" + (1000.0 * (float) count
/ (float) (currentTime - firstLogTime)) + " " + type + "/second)");
/ (currentTime - firstLogTime)) + " " + type + "/second)");
logTime = currentTime;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ protected boolean validate(GeoPipeFlow flow) {
final Object leftObject = flow.getProperties().get(key);
return comparison.compare(leftObject, value);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ public class IdentityPipe<S> extends AbstractPipe<S, S> {
protected S processNextStart() {
return this.starts.next();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ public void reset() {
// to achieve in a generic way without a full-stack code change.
RelationshipTraversal.exhaustIterator(source);
}
}
}
11 changes: 4 additions & 7 deletions src/main/java/org/neo4j/gis/spatial/rtree/RTreeIndex.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import javax.annotation.Nonnull;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
Expand Down Expand Up @@ -225,7 +226,7 @@ public void add(Transaction tx, List<Node> geomNodes) {
}
nodesToAdd.addAll(geomNodes);
detachGeometryNodes(tx, false, getIndexRoot(tx), new NullListener());
deleteTreeBelow(tx, getIndexRoot(tx));
deleteTreeBelow(getIndexRoot(tx));
buildRtreeFromScratch(tx, getIndexRoot(tx), decodeGeometryNodeEnvelopes(nodesToAdd), 0.7);
countSaved = false;
totalGeometryCount = nodesToAdd.size();
Expand Down Expand Up @@ -1042,13 +1043,9 @@ private static Node chooseIndexNodeWithSmallestArea(List<Node> indexNodes) {
}

private static int countChildren(Node indexNode, RelationshipType relationshipType) {
int counter = 0;
try (var relationships = indexNode.getRelationships(Direction.OUTGOING, relationshipType)) {
for (Relationship ignored : relationships) {
counter++;
}
return (int) StreamSupport.stream(relationships.spliterator(), false).count();
}
return counter;
}

/**
Expand Down Expand Up @@ -1383,7 +1380,7 @@ private static double getArea(Envelope e) {
return e.getArea();
}

private static void deleteTreeBelow(Transaction ignored, Node rootNode) {
private static void deleteTreeBelow(Node rootNode) {
try (var relationships = rootNode.getRelationships(Direction.OUTGOING, RTreeRelationshipTypes.RTREE_CHILD)) {
for (Relationship relationship : relationships) {
deleteRecursivelySubtree(relationship.getEndNode(), relationship);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ public static void exhaustIterator(Iterator<?> source) {
source.next();
}
}
}
}
Loading