Skip to content

Commit 7c67310

Browse files
authored
[NOID] Procedure argument descriptions (#664)
1 parent 69f2ce5 commit 7c67310

File tree

89 files changed

+12531
-799
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+12531
-799
lines changed

common/src/main/java/apoc/cypher/CypherUtils.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import static java.lang.String.join;
2323
import static java.util.stream.Collectors.toList;
2424

25-
import apoc.result.MapResult;
25+
import apoc.result.CypherStatementMapResult;
2626
import java.util.Collection;
2727
import java.util.Collections;
2828
import java.util.Map;
@@ -31,11 +31,11 @@
3131
import org.neo4j.procedure.Name;
3232

3333
public class CypherUtils {
34-
public static Stream<MapResult> runCypherQuery(
34+
public static Stream<CypherStatementMapResult> runCypherQuery(
3535
Transaction tx, @Name("cypher") String statement, @Name("params") Map<String, Object> params) {
3636
if (params == null) params = Collections.emptyMap();
3737
return tx.execute(withParamMapping(statement, params.keySet()), params).stream()
38-
.map(MapResult::new);
38+
.map(CypherStatementMapResult::new);
3939
}
4040

4141
public static String withParamMapping(String fragment, Collection<String> keys) {

common/src/main/java/apoc/export/util/ExportUtils.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
package apoc.export.util;
2020

2121
import apoc.export.cypher.ExportFileManager;
22-
import apoc.result.ProgressInfo;
22+
import apoc.result.ExportProgressInfo;
2323
import apoc.util.QueueBasedSpliterator;
2424
import apoc.util.QueueUtil;
2525
import apoc.util.Util;
@@ -34,7 +34,7 @@
3434
public class ExportUtils {
3535
private ExportUtils() {}
3636

37-
public static Stream<ProgressInfo> getProgressInfoStream(
37+
public static Stream<ExportProgressInfo> getProgressInfoStream(
3838
GraphDatabaseService db,
3939
ExecutorService executorService,
4040
TerminationGuard terminationGuard,
@@ -44,12 +44,13 @@ public static Stream<ProgressInfo> getProgressInfoStream(
4444
ExportFileManager cypherFileManager,
4545
Consumer<ProgressReporter> dump) {
4646
long timeout = exportConfig.getTimeoutSeconds();
47-
final ArrayBlockingQueue<ProgressInfo> queue = new ArrayBlockingQueue<>(1000);
47+
final ArrayBlockingQueue<ExportProgressInfo> queue = new ArrayBlockingQueue<>(1000);
4848
ProgressReporter reporterWithConsumer = reporter.withConsumer((pi) -> QueueUtil.put(
4949
queue,
50-
pi == ProgressInfo.EMPTY
51-
? ProgressInfo.EMPTY
52-
: new ProgressInfo(pi).drain(cypherFileManager.getStringWriter(format), exportConfig),
50+
pi == ExportProgressInfo.EMPTY
51+
? ExportProgressInfo.EMPTY
52+
: new ExportProgressInfo((ExportProgressInfo) pi)
53+
.drain(cypherFileManager.getStringWriter(format), exportConfig),
5354
timeout));
5455
Util.inTxFuture(
5556
null,
@@ -61,9 +62,9 @@ public static Stream<ProgressInfo> getProgressInfoStream(
6162
},
6263
0,
6364
_ignored -> {},
64-
_ignored -> QueueUtil.put(queue, ProgressInfo.EMPTY, timeout));
65-
QueueBasedSpliterator<ProgressInfo> spliterator =
66-
new QueueBasedSpliterator<>(queue, ProgressInfo.EMPTY, terminationGuard, (int) timeout);
65+
_ignored -> QueueUtil.put(queue, ExportProgressInfo.EMPTY, timeout));
66+
QueueBasedSpliterator<ExportProgressInfo> spliterator =
67+
new QueueBasedSpliterator<>(queue, ExportProgressInfo.EMPTY, terminationGuard, (int) timeout);
6768
return StreamSupport.stream(spliterator, false);
6869
}
6970
}

common/src/main/java/apoc/export/util/ProgressReporter.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@
2323
import java.util.function.Consumer;
2424
import java.util.stream.Stream;
2525

26-
/**
27-
* @author mh
28-
* @since 22.05.16
29-
*/
3026
public class ProgressReporter implements Reporter {
3127
private final SizeCounter sizeCounter;
3228
private final PrintWriter out;
@@ -44,7 +40,7 @@ public ProgressReporter(SizeCounter sizeCounter, PrintWriter out, ProgressInfo p
4440
this.out = out;
4541
this.time = start;
4642
this.progressInfo = progressInfo;
47-
this.batchSize = progressInfo.batchSize;
43+
this.batchSize = progressInfo.getBatchSize();
4844
}
4945

5046
public ProgressReporter withConsumer(Consumer<ProgressInfo> consumer) {
@@ -92,8 +88,8 @@ public void acceptBatch() {
9288

9389
public void updateRunningBatch(ProgressInfo progressInfo) {
9490
lastBatch = Math.max(totalEntities / batchSize, lastBatch);
95-
progressInfo.batches = lastBatch;
96-
this.progressInfo.rows = totalEntities;
91+
progressInfo.setBatches(lastBatch);
92+
this.progressInfo.setRows(totalEntities);
9793
this.progressInfo.updateTime(start);
9894
}
9995

common/src/main/java/apoc/get/Get.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@
1818
*/
1919
package apoc.get;
2020

21+
import apoc.result.CreatedNodeResult;
2122
import apoc.result.NodeResult;
2223
import apoc.result.RelationshipResult;
24+
import apoc.result.UpdatedNodeResult;
25+
import apoc.result.UpdatedRelationshipResult;
2326
import apoc.util.Util;
2427
import java.util.stream.Stream;
2528
import org.neo4j.kernel.impl.coreapi.InternalTransaction;
@@ -37,7 +40,19 @@ public Stream<NodeResult> nodes(@Name("nodes") Object ids) {
3740
return Util.nodeStream(tx, ids).map(NodeResult::new);
3841
}
3942

43+
public Stream<UpdatedNodeResult> updatedNodes(@Name("nodes") Object ids) {
44+
return Util.nodeStream(tx, ids).map(UpdatedNodeResult::new);
45+
}
46+
47+
public Stream<CreatedNodeResult> createdNodes(@Name("nodes") Object ids) {
48+
return Util.nodeStream(tx, ids).map(CreatedNodeResult::new);
49+
}
50+
4051
public Stream<RelationshipResult> rels(@Name("rels") Object ids) {
4152
return Util.relsStream(tx, ids).map(RelationshipResult::new);
4253
}
54+
55+
public Stream<UpdatedRelationshipResult> updatesRels(@Name("rels") Object ids) {
56+
return Util.relsStream(tx, ids).map(UpdatedRelationshipResult::new);
57+
}
4358
}

common/src/main/java/apoc/load/LoadJsonUtils.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919
package apoc.load;
2020

21-
import apoc.result.MapResult;
21+
import apoc.result.LoadDataMapResult;
2222
import apoc.util.JsonUtil;
2323
import apoc.util.Util;
2424
import java.util.Collections;
@@ -31,7 +31,7 @@
3131
import org.neo4j.procedure.TerminationGuard;
3232

3333
public class LoadJsonUtils {
34-
public static Stream<MapResult> loadJsonStream(
34+
public static Stream<LoadDataMapResult> loadJsonStream(
3535
@Name("urlOrKeyOrBinary") Object urlOrKeyOrBinary,
3636
@Name("headers") Map<String, Object> headers,
3737
@Name("payload") String payload,
@@ -52,7 +52,7 @@ public static Stream<MapResult> loadJsonStream(
5252
terminationGuard.check();
5353
}
5454
if (value instanceof Map) {
55-
return Stream.of(new MapResult((Map) value));
55+
return Stream.of(new LoadDataMapResult((Map) value));
5656
}
5757
if (value instanceof List) {
5858
if (((List) value).isEmpty()) return Stream.empty();
@@ -61,13 +61,13 @@ public static Stream<MapResult> loadJsonStream(
6161
if (terminationGuard != null) {
6262
terminationGuard.check();
6363
}
64-
return new MapResult((Map) v);
64+
return new LoadDataMapResult((Map) v);
6565
});
66-
return Stream.of(new MapResult(Collections.singletonMap("result", value)));
66+
return Stream.of(new LoadDataMapResult(Collections.singletonMap("result", value)));
6767
}
6868
if (!failOnError)
6969
throw new RuntimeException("Incompatible Type " + (value == null ? "null" : value.getClass()));
70-
else return Stream.of(new MapResult(Collections.emptyMap()));
70+
else return Stream.of(new LoadDataMapResult(Collections.emptyMap()));
7171
});
7272
}
7373
}

common/src/main/java/apoc/meta/Tables4LabelsProfile.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import java.util.stream.Stream;
2727
import java.util.stream.StreamSupport;
2828
import org.neo4j.graphdb.*;
29+
import org.neo4j.procedure.Description;
2930

3031
public class Tables4LabelsProfile {
3132
Map<OrderedLabels, PropertyContainerProfile> labelMap;
@@ -37,12 +38,25 @@ public class Tables4LabelsProfile {
3738
* DAO class that the stored procedure returns
3839
*/
3940
public class NodeTypePropertiesEntry {
41+
@Description("The type of the node.")
4042
public String nodeType;
43+
44+
@Description("The labels on the node.")
4145
public List<String> nodeLabels;
46+
47+
@Description("The name of the property.")
4248
public String propertyName;
49+
50+
@Description("The types this property has.")
4351
public List<String> propertyTypes;
52+
53+
@Description("Whether or not this property exists on all nodes of the given type.")
4454
public boolean mandatory;
55+
56+
@Description("The number of times this property was observed.")
4557
public long propertyObservations;
58+
59+
@Description("The number of times the label was seen.")
4660
public long totalObservations;
4761

4862
public NodeTypePropertiesEntry(
@@ -64,13 +78,28 @@ public NodeTypePropertiesEntry(
6478
}
6579

6680
public class RelTypePropertiesEntry {
81+
@Description("The type of the relationship.")
6782
public String relType;
83+
84+
@Description("The labels belonging to the start node.")
6885
public List<String> sourceNodeLabels;
86+
87+
@Description("The labels belonging to the end node.")
6988
public List<String> targetNodeLabels;
89+
90+
@Description("The name of the property.")
7091
public String propertyName;
92+
93+
@Description("The types this property has.")
7194
public List<String> propertyTypes;
95+
96+
@Description("Whether or not this property exists on all nodes of the given type.")
7297
public boolean mandatory;
98+
99+
@Description("The number of times this property was observed.")
73100
public long propertyObservations;
101+
102+
@Description("The number of times the label was seen.")
74103
public long totalObservations;
75104

76105
public RelTypePropertiesEntry(

common/src/main/java/apoc/periodic/BatchAndTotalResult.java

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,74 @@
2121
import apoc.util.Util;
2222
import java.util.List;
2323
import java.util.Map;
24+
import org.neo4j.procedure.Description;
2425

2526
public class BatchAndTotalResult {
27+
@Description("The total number of batches.")
2628
public final long batches;
29+
30+
@Description("The number of processed input rows.")
2731
public final long total;
32+
33+
@Description("The duration taken in seconds.")
2834
public final long timeTaken;
35+
36+
@Description("The number of successful inner queries (actions).")
2937
public final long committedOperations;
38+
39+
@Description("The number of failed inner queries (actions).")
3040
public final long failedOperations;
41+
42+
@Description("The number of failed batches.")
3143
public final long failedBatches;
44+
45+
@Description("The number of retries.")
3246
public final long retries;
47+
48+
@Description("A map of batch error messages paired with their corresponding error counts.")
3349
public final Map<String, Long> errorMessages;
50+
51+
@Description(
52+
"""
53+
{
54+
total :: INTEGER,
55+
failed :: INTEGER,
56+
committed :: INTEGER,
57+
errors :: MAP
58+
}
59+
""")
3460
public final Map<String, Object> batch;
61+
62+
@Description(
63+
"""
64+
{
65+
total :: INTEGER,
66+
failed :: INTEGER,
67+
committed :: INTEGER,
68+
errors :: MAP
69+
}
70+
""")
3571
public final Map<String, Object> operations;
72+
73+
@Description("If the transaction was terminated before completion.")
3674
public final boolean wasTerminated;
75+
76+
@Description(
77+
"Parameters of failed batches. The key is the batch number as a STRING and the value is a list of batch parameters.")
3778
public final Map<String, List<Map<String, Object>>> failedParams;
79+
80+
@Description(
81+
"""
82+
{
83+
nodesCreated :: INTEGER,
84+
nodesDeleted :: INTEGER,
85+
relationshipsCreated :: INTEGER,
86+
relationshipsDeleted :: INTEGER,
87+
propertiesSet :: INTEGER,
88+
labelsAdded :: INTEGER,
89+
labelsRemoved :: INTEGER
90+
}
91+
""")
3892
public final Map<String, Long> updateStatistics;
3993

4094
public BatchAndTotalResult(

common/src/main/java/apoc/periodic/PeriodicUtils.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,27 @@
4545
import org.neo4j.graphdb.Result;
4646
import org.neo4j.graphdb.Transaction;
4747
import org.neo4j.logging.Log;
48+
import org.neo4j.procedure.Description;
4849
import org.neo4j.procedure.TerminationGuard;
4950

5051
public class PeriodicUtils {
5152

5253
private PeriodicUtils() {}
5354

5455
public static class JobInfo {
56+
@Description("The name of the job.")
5557
public final String name;
58+
59+
@Description("The delay on the job.")
5660
public long delay;
61+
62+
@Description("The rate of the job.")
5763
public long rate;
64+
65+
@Description("If the job has completed.")
5866
public boolean done;
67+
68+
@Description("If the job has been cancelled.")
5969
public boolean cancelled;
6070

6171
public JobInfo(String name) {

common/src/main/java/apoc/result/AssertSchemaResult.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,22 @@
2020

2121
import java.util.Arrays;
2222
import java.util.List;
23+
import org.neo4j.procedure.Description;
2324

2425
public class AssertSchemaResult {
26+
@Description("The label associated with the constraint or index.")
2527
public final Object label;
28+
29+
@Description("The property key associated with the constraint or index.")
2630
public final String key;
31+
32+
@Description("The property keys associated with the constraint or index.")
2733
public final List<String> keys;
34+
35+
@Description("Whether or not this is a uniqueness constraint.")
2836
public boolean unique = false;
37+
38+
@Description("The action applied to this constraint or index; can be [\"KEPT\", \"CREATED\", \"DROPPED\"]")
2939
public String action = "KEPT";
3040

3141
public AssertSchemaResult(Object label, List<String> keys) {

common/src/main/java/apoc/result/ByteArrayResult.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@
1818
*/
1919
package apoc.result;
2020

21+
import org.neo4j.procedure.Description;
22+
2123
public class ByteArrayResult {
2224
public static final ByteArrayResult NULL = new ByteArrayResult(null);
2325

26+
@Description("The data as a bytearray.")
2427
public final byte[] value;
2528

2629
public ByteArrayResult(byte[] value) {

0 commit comments

Comments
 (0)