Package apoc.util
Class Util
java.lang.Object
apoc.util.Util
- Since:
- 24.04.16
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanclassExists(String className) static Stringstatic voidclose(AutoCloseable closeable) static voidclose(AutoCloseable closeable, Consumer<Exception> onError) static booleanconstraintIsUnique(org.neo4j.graphdb.schema.ConstraintType type) static booleancontainsValueEquals(Collection<Object> collection, Object value) static <T> TcreateInstanceOrNull(String className) static StringencodeUrlComponent(String value) static StringencodeUserColonPassToBase64(String userPass) extractCredentialsIfNeeded(String url, boolean failOnError) flattenMap(Map<String, Object> map, String prefix) static <T> Tstatic voidgetAllQueryProcs(org.neo4j.graphdb.ExecutionPlanDescription executionPlanDescription, Set<String> procs) static Util.ConstraintCategorygetConstraintCategory(org.neo4j.graphdb.schema.ConstraintType type) static Util.ConstraintCategorygetConstraintCategory(org.neo4j.internal.schema.ConstraintDescriptor descriptor) static DateTimeFormatterstatic <T> Tstatic <T> TgetFutureOrCancel(Future<T> f, Map<String, Long> errorMessages, AtomicInteger errors, T errorValue) static Iterable<org.neo4j.graphdb.schema.IndexDefinition>getIndexes(org.neo4j.graphdb.Transaction transaction) static Iterable<org.neo4j.graphdb.schema.IndexDefinition>getIndexes(org.neo4j.graphdb.Transaction transaction, org.neo4j.graphdb.Label label) static Iterable<org.neo4j.graphdb.schema.IndexDefinition>getIndexes(org.neo4j.graphdb.Transaction transaction, org.neo4j.graphdb.RelationshipType relType) getLoadUrlByConfigFile(String loadType, String key, String suffix) static StringgetNodeElementId(org.neo4j.kernel.impl.coreapi.InternalTransaction tx, long id) static longstatic longgetRelationshipId(org.neo4j.kernel.impl.coreapi.InternalTransaction tx, String elementId) getRequestParameter(String parameters) static StreamConnectionstatic ObjectgetStringOrCompressedData(StringWriter writer, ExportConfig config) static intstatic <T> Future<T>static <T> Set<T>intersection(Collection<T> a, Collection<T> b) static <T> Tstatic <T> TinTx(org.neo4j.graphdb.GraphDatabaseService db, Pools pools, Function<org.neo4j.graphdb.Transaction, T> function) static <T> Future<T>inTxFuture(ExecutorService pool, org.neo4j.graphdb.GraphDatabaseService db, Function<org.neo4j.graphdb.Transaction, T> function) static <T> Future<T>inTxFuture(org.neo4j.logging.Log log, ExecutorService pool, org.neo4j.graphdb.GraphDatabaseService db, Function<org.neo4j.graphdb.Transaction, T> function, long maxRetries, Consumer<Long> callbackForRetry, Consumer<Void> callbackAction) static booleanisNodeCategory(org.neo4j.graphdb.schema.ConstraintType type) static booleanisNodeCategory(org.neo4j.internal.schema.ConstraintDescriptor descriptor) static booleanstatic booleanstatic booleanstatic booleanisRelationshipCategory(org.neo4j.graphdb.schema.ConstraintType type) static booleanisRelationshipCategory(org.neo4j.internal.schema.ConstraintDescriptor descriptor) static booleanisSelfRel(org.neo4j.graphdb.Relationship rel) static booleanstatic booleanisWriteableInstance(org.neo4j.kernel.internal.GraphDatabaseAPI db) static booleanisWriteableInstance(org.neo4j.kernel.internal.GraphDatabaseAPI db, org.neo4j.graphdb.Transaction systemTx) static StringjoinLabels(Iterable<org.neo4j.graphdb.Label> labels, String s) static org.neo4j.graphdb.Label[]static StringlabelString(List<String> labelNames) static StringlabelString(org.neo4j.graphdb.Node n) labelStrings(org.neo4j.graphdb.Node n) static voidstatic <T,R> List<R> map(Collection<T> collection, Function<T, R> mapper) static <T,R> List<R> map(T... values) mapFromLists(List<String> keys, List<Object> values) mapFromPairs(List<List<Object>> pairs) static org.neo4j.graphdb.NodemergeNode(org.neo4j.graphdb.Transaction tx, org.neo4j.graphdb.Label primaryLabel, org.neo4j.graphdb.Label addtionalLabel, org.apache.commons.lang3.tuple.Pair<String, Object>... pairs) static ThreadnewDaemonThread(Runnable target) all new threads being created within apoc should be daemon threads to allow graceful termination, so use this whenever you need a threadstatic org.neo4j.graphdb.Nodestatic longnodeCount(org.neo4j.graphdb.Transaction tx) static Stream<org.neo4j.graphdb.Node>nodeStream(org.neo4j.graphdb.Transaction tx, Object ids) static CountingInputStreamstatic URLConnectionopenUrlConnection(URL src, Map<String, Object> headers) static Stringstatic charparseCharFromConfig(Map<String, Object> config, String key, char defaultValue) partitionSubList(List<Object> data, int partitions) partitionSubList(List<Object> data, int partitions, List<Object> tombstone) static Stringstatic StreamConnectionreadHttpInputStream(String urlAddress, Map<String, Object> headers, String payload, int redirectLimit) static StringreadResourceFile(String name) static <T extends org.neo4j.graphdb.Entity>
List<T>static org.neo4j.graphdb.Noderebind(org.neo4j.graphdb.Transaction tx, org.neo4j.graphdb.Node node) static org.neo4j.graphdb.Relationshiprebind(org.neo4j.graphdb.Transaction tx, org.neo4j.graphdb.Relationship rel) static <T extends org.neo4j.graphdb.Entity>
Trebind(org.neo4j.graphdb.Transaction tx, T e) static org.neo4j.graphdb.Relationshiprelationship(org.neo4j.graphdb.Transaction tx, Object id) static longrelCount(org.neo4j.graphdb.Transaction tx) static Stream<org.neo4j.graphdb.Relationship>relsStream(org.neo4j.graphdb.Transaction tx, Object ids) static voidremoveFinished(List<Future> futures) static <T> TretryInTx(org.neo4j.logging.Log log, org.neo4j.graphdb.GraphDatabaseService db, Function<org.neo4j.graphdb.Transaction, T> function, long retry, long maxRetries, Consumer<Long> callbackForRetry) static LongrunNumericQuery(org.neo4j.graphdb.Transaction tx, String query, Map<String, Object> params) static StringSanitizes the given input to be used as a valid schema namestatic StringSanitizes the given input to be used as a valid schema namestatic voidsleep(int millis) static <T> List<T>static <T> List<org.neo4j.values.AnyValue>toAnyValues(List<T> list) static booleanstatic Doublestatic Integerstatic Stringstatic Longstatic org.neo4j.values.storable.PointValuestatic Stringstatic booleantransactionIsTerminated(org.neo4j.procedure.TerminationGuard db) Given a context related to the procedure invocation this method checks if the transaction is terminated in some waystatic voidvalidateQuery(org.neo4j.graphdb.GraphDatabaseService db, String statement, Set<org.neo4j.procedure.Mode> supportedModes, org.neo4j.graphdb.QueryExecutionType.QueryType... supportedQueryTypes) static voidvalidateQuery(org.neo4j.graphdb.GraphDatabaseService db, String statement, org.neo4j.graphdb.QueryExecutionType.QueryType... supportedQueryTypes) static <T> booleanvalueEquals(T one, T other) static voidwaitForFutures(List<Future> futures) static Stringstatic <T extends org.neo4j.graphdb.Entity>
TwithTransactionAndRebind(org.neo4j.graphdb.GraphDatabaseService db, org.neo4j.graphdb.Transaction transaction, Function<org.neo4j.graphdb.Transaction, T> action)
-
Field Details
-
NO_LABELS
public static final org.neo4j.graphdb.Label[] NO_LABELS -
NODE_COUNT
- See Also:
-
REL_COUNT
- See Also:
-
ERROR_BYTES_OR_STRING
- See Also:
-
REDIRECT_LIMIT
public static final int REDIRECT_LIMIT- See Also:
-
INVALID_QUERY_MODE_ERROR
-
-
Constructor Details
-
Util
public Util()
-
-
Method Details
-
labelString
-
labelString
-
joinLabels
-
labelStrings
-
labels
-
stream
-
nodeStream
-
node
-
relsStream
-
relationship
public static org.neo4j.graphdb.Relationship relationship(org.neo4j.graphdb.Transaction tx, Object id) -
retryInTx
-
inTxFuture
-
inTxFuture
public static <T> Future<T> inTxFuture(ExecutorService pool, org.neo4j.graphdb.GraphDatabaseService db, Function<org.neo4j.graphdb.Transaction, T> function) -
inTx
-
inThread
-
inFuture
-
toDouble
-
subMap
-
toLong
-
toInteger
-
openUrlConnection
public static URLConnection openUrlConnection(URL src, Map<String, Object> headers) throws IOException- Throws:
IOException
-
isRedirect
- Throws:
IOException
-
openInputStream
public static CountingInputStream openInputStream(Object input, Map<String, Object> headers, String payload, String compressionAlgo) throws IOException- Throws:
IOException
-
getStreamConnection
public static StreamConnection getStreamConnection(String urlAddress, Map<String, Object> headers, String payload) throws IOException- Throws:
IOException
-
readHttpInputStream
public static StreamConnection readHttpInputStream(String urlAddress, Map<String, Object> headers, String payload, int redirectLimit) throws IOException- Throws:
IOException
-
toBoolean
-
toString
-
encodeUrlComponent
-
toJson
-
fromJson
-
partitionSubList
-
partitionSubList
-
runNumericQuery
-
nodeCount
public static long nodeCount(org.neo4j.graphdb.Transaction tx) -
relCount
public static long relCount(org.neo4j.graphdb.Transaction tx) -
readResourceFile
-
readMap
-
take
-
merge
-
map
-
map
-
map
-
map
-
mapFromLists
-
mapFromPairs
-
cleanUrl
-
getFuture
public static <T> T getFuture(Future<T> f, Map<String, Long> errorMessages, AtomicInteger errors, T errorValue) -
getFutureOrCancel
public static <T> T getFutureOrCancel(Future<T> f, Map<String, Long> errorMessages, AtomicInteger errors, T errorValue) -
logErrors
-
sleep
public static void sleep(int millis) -
quote
-
sanitize
Sanitizes the given input to be used as a valid schema name- Parameters:
value- The value to sanitize- Returns:
- A value that is safe to be used in string concatenation, an empty optional indicates a value that cannot be safely quoted
-
sanitize
Sanitizes the given input to be used as a valid schema name- Parameters:
value- The value to sanitizeaddQuotes- If quotation should be added- Returns:
- A value that is safe to be used in string concatenation, an empty optional indicates a value that cannot be safely quoted
-
param
-
withMapping
-
isWriteableInstance
public static boolean isWriteableInstance(org.neo4j.kernel.internal.GraphDatabaseAPI db, org.neo4j.graphdb.Transaction systemTx) -
isWriteableInstance
public static boolean isWriteableInstance(org.neo4j.kernel.internal.GraphDatabaseAPI db) -
transactionIsTerminated
public static boolean transactionIsTerminated(org.neo4j.procedure.TerminationGuard db) Given a context related to the procedure invocation this method checks if the transaction is terminated in some way- Parameters:
db-- Returns:
-
waitForFutures
-
removeFinished
-
close
-
close
-
isNotNullOrEmpty
-
isNullOrEmpty
-
getRequestParameter
-
classExists
-
createInstanceOrNull
-
getLoadUrlByConfigFile
-
getFormat
-
parseCharFromConfig
-
flattenMap
-
rebind
public static org.neo4j.graphdb.Node rebind(org.neo4j.graphdb.Transaction tx, org.neo4j.graphdb.Node node) -
rebind
public static org.neo4j.graphdb.Relationship rebind(org.neo4j.graphdb.Transaction tx, org.neo4j.graphdb.Relationship rel) -
rebind
public static <T extends org.neo4j.graphdb.Entity> T rebind(org.neo4j.graphdb.Transaction tx, T e) -
rebind
-
mergeNode
-
intersection
-
validateQuery
public static void validateQuery(org.neo4j.graphdb.GraphDatabaseService db, String statement, org.neo4j.graphdb.QueryExecutionType.QueryType... supportedQueryTypes) -
validateQuery
-
getAllQueryProcs
-
newDaemonThread
all new threads being created within apoc should be daemon threads to allow graceful termination, so use this whenever you need a thread- Parameters:
target-- Returns:
-
encodeUserColonPassToBase64
-
extractCredentialsIfNeeded
-
isSelfRel
public static boolean isSelfRel(org.neo4j.graphdb.Relationship rel) -
toPoint
-
getStringOrCompressedData
-
withTransactionAndRebind
public static <T extends org.neo4j.graphdb.Entity> T withTransactionAndRebind(org.neo4j.graphdb.GraphDatabaseService db, org.neo4j.graphdb.Transaction transaction, Function<org.neo4j.graphdb.Transaction, T> action) -
getConstraintCategory
public static Util.ConstraintCategory getConstraintCategory(org.neo4j.graphdb.schema.ConstraintType type) -
getConstraintCategory
public static Util.ConstraintCategory getConstraintCategory(org.neo4j.internal.schema.ConstraintDescriptor descriptor) -
constraintIsUnique
public static boolean constraintIsUnique(org.neo4j.graphdb.schema.ConstraintType type) -
isNodeCategory
public static boolean isNodeCategory(org.neo4j.graphdb.schema.ConstraintType type) -
isRelationshipCategory
public static boolean isRelationshipCategory(org.neo4j.graphdb.schema.ConstraintType type) -
isNodeCategory
public static boolean isNodeCategory(org.neo4j.internal.schema.ConstraintDescriptor descriptor) -
isRelationshipCategory
public static boolean isRelationshipCategory(org.neo4j.internal.schema.ConstraintDescriptor descriptor) -
getNodeId
public static long getNodeId(org.neo4j.kernel.impl.coreapi.InternalTransaction tx, String elementId) -
getRelationshipId
public static long getRelationshipId(org.neo4j.kernel.impl.coreapi.InternalTransaction tx, String elementId) -
getNodeElementId
public static String getNodeElementId(org.neo4j.kernel.impl.coreapi.InternalTransaction tx, long id) -
isWindows
public static boolean isWindows() -
valueEquals
public static <T> boolean valueEquals(T one, T other) -
containsValueEquals
-
toAnyValues
-
indexOf
-
getIndexes
public static Iterable<org.neo4j.graphdb.schema.IndexDefinition> getIndexes(org.neo4j.graphdb.Transaction transaction) -
getIndexes
public static Iterable<org.neo4j.graphdb.schema.IndexDefinition> getIndexes(org.neo4j.graphdb.Transaction transaction, org.neo4j.graphdb.Label label) -
getIndexes
public static Iterable<org.neo4j.graphdb.schema.IndexDefinition> getIndexes(org.neo4j.graphdb.Transaction transaction, org.neo4j.graphdb.RelationshipType relType)
-