file_name stringlengths 6 86 | file_path stringlengths 45 249 | content stringlengths 47 6.26M | file_size int64 47 6.26M | language stringclasses 1 value | extension stringclasses 1 value | repo_name stringclasses 767 values | repo_stars int64 8 14.4k | repo_forks int64 0 1.17k | repo_open_issues int64 0 788 | repo_created_at stringclasses 767 values | repo_pushed_at stringclasses 767 values |
|---|---|---|---|---|---|---|---|---|---|---|---|
ChronoGraphMigration.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/internal/api/migration/ChronoGraphMigration.java | package org.chronos.chronograph.internal.api.migration;
import org.chronos.chronodb.api.key.ChronoIdentifier;
import org.chronos.chronodb.internal.impl.dump.entry.ChronoDBDumpBinaryEntry;
import org.chronos.chronodb.internal.impl.dump.entry.ChronoDBDumpEntry;
import org.chronos.chronodb.internal.impl.dump.entry.ChronoDBDumpPlainEntry;
import org.chronos.chronodb.internal.impl.dump.meta.ChronoDBDumpMetadata;
import org.chronos.chronograph.internal.api.structure.ChronoGraphInternal;
import org.chronos.common.serialization.KryoManager;
import org.chronos.common.version.ChronosVersion;
public interface ChronoGraphMigration {
public static final Object ENTRY_UNCHANGED = new Object();
public static final Object DROP_ENTRY = new Object();
public ChronosVersion getFromVersion();
public ChronosVersion getToVersion();
public void execute(ChronoGraphInternal graph);
public void execute(ChronoDBDumpMetadata dumpMetadata);
public Object execute(ChronoIdentifier chronoIdentifier, Object value);
public default <T> ChronoDBDumpEntry<T> execute(ChronoDBDumpEntry<T> dumpEntry) {
if (dumpEntry instanceof ChronoDBDumpPlainEntry) {
ChronoDBDumpPlainEntry plainEntry = (ChronoDBDumpPlainEntry) dumpEntry;
ChronoIdentifier chronoIdentifier = plainEntry.getChronoIdentifier();
Object value = plainEntry.getValue();
Object newValue = this.execute(chronoIdentifier, value);
if (newValue == ENTRY_UNCHANGED) {
return dumpEntry;
} else if (newValue == DROP_ENTRY) {
return null;
} else {
plainEntry.setValue(newValue);
return dumpEntry;
}
} else if (dumpEntry instanceof ChronoDBDumpBinaryEntry) {
ChronoDBDumpBinaryEntry binaryEntry = (ChronoDBDumpBinaryEntry) dumpEntry;
ChronoIdentifier chronoIdentifier = binaryEntry.getChronoIdentifier();
byte[] binaryValue = binaryEntry.getValue();
Object value;
if (binaryValue == null || binaryValue.length <= 0) {
value = null;
} else {
value = KryoManager.deserialize(binaryValue);
}
Object newValue = this.execute(chronoIdentifier, value);
if (newValue == ENTRY_UNCHANGED) {
return dumpEntry;
} else if (newValue == DROP_ENTRY) {
return null;
} else {
binaryEntry.setValue(KryoManager.serialize(newValue));
return dumpEntry;
}
} else {
throw new IllegalArgumentException("Encountered unknown subclass of " + ChronoDBDumpEntry.class.getName() + ": " + dumpEntry.getClass().getName());
}
}
}
| 2,815 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
ChronoElementInternal.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/internal/api/structure/ChronoElementInternal.java | package org.chronos.chronograph.internal.api.structure;
import org.chronos.chronograph.api.structure.ChronoElement;
import org.chronos.chronograph.internal.impl.structure.graph.ChronoProperty;
public interface ChronoElementInternal extends ChronoElement {
public void notifyPropertyChanged(ChronoProperty<?> chronoProperty);
/**
* Validates the graph invariant on this element.
* <p>
* The graph invariant states the following conditions:
* <ul>
* If a vertex has an IN edge, then that edge must reference the vertex as in-vertex
* If a vertex has an OUT edge, then that edge must reference the vertex as out-vertex
* For any edge, the IN vertex must reference the edge as incoming, and the OUT vertex must reference the edge as outgoing
* If a vertex is being deleted, all adjacent edges must be deleted.
* If an edge is being deleted, it must no longer appear as adjacent edge in the two neighboring vertices.
* </ul>
* <p>
* If any of these conditions are violated,
*/
public void validateGraphInvariant();
}
| 1,094 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
ChronoGraphInternal.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/internal/api/structure/ChronoGraphInternal.java | package org.chronos.chronograph.internal.api.structure;
import org.chronos.chronodb.api.ChronoDB;
import org.chronos.chronograph.api.structure.ChronoGraph;
import org.chronos.chronograph.internal.impl.transaction.trigger.ChronoGraphTriggerManagerInternal;
import org.chronos.common.autolock.AutoLock;
import org.chronos.common.version.ChronosVersion;
import java.util.Optional;
public interface ChronoGraphInternal extends ChronoGraph {
/**
* Returns the {@link ChronoDB} instance that acts as the backing store for this {@link ChronoGraph}.
*
* @return The backing ChronoDB instance. Never <code>null</code>.
*/
public ChronoDB getBackingDB();
/**
* Returns the trigger manager for this graph instance.
*
* @return The trigger manager. Never <code>null</code>.
*/
public ChronoGraphTriggerManagerInternal getTriggerManager();
/**
* Returns the version of ChronoGraph currently stored in the database.
*
* @return The version. Never <code>null</code>.
*/
public Optional<ChronosVersion> getStoredChronoGraphVersion();
/**
* Sets the ChronoGraph version to store in the database.
*
* @param version The new version. Must not be <code>null</code>. Must be
* greater than or equal to the currently stored version.
*/
public void setStoredChronoGraphVersion(ChronosVersion version);
/**
* Acquires the commit lock.
*
* <p>
* Use this in conjunction with <code>try-with-resources</code> statements for easy locking.
*
* @return The auto-closable commit lock. Never <code>null</code>.
*/
public AutoLock commitLock();
}
| 1,698 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
ChronoGraphConfiguration.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/internal/api/configuration/ChronoGraphConfiguration.java | package org.chronos.chronograph.internal.api.configuration;
import org.apache.tinkerpop.gremlin.process.traversal.step.map.PropertiesStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.map.PropertyMapStep;
import org.apache.tinkerpop.gremlin.structure.Element;
import org.chronos.chronograph.api.structure.ChronoGraph;
import org.chronos.chronograph.api.transaction.AllEdgesIterationHandler;
import org.chronos.chronograph.api.transaction.AllVerticesIterationHandler;
import org.chronos.common.configuration.ChronosConfiguration;
/**
* This class represents the configuration of a single {@link ChronoGraph} instance.
*
* @author martin.haeusler@uibk.ac.at -- Initial Contribution and API
*/
public interface ChronoGraphConfiguration extends ChronosConfiguration {
// =====================================================================================================================
// STATIC KEY NAMES
// =====================================================================================================================
public static final String NAMESPACE = "org.chronos.chronograph";
public static final String NS_DOT = NAMESPACE + '.';
public static final String TRANSACTION_CHECK_ID_EXISTENCE_ON_ADD = NS_DOT + "transaction.checkIdExistenceOnAdd";
public static final String TRANSACTION_AUTO_OPEN = NS_DOT + "transaction.autoOpen";
public static final String TRANSACTION_CHECK_GRAPH_INVARIANT = NS_DOT + "transaction.checkGraphInvariant";
public static final String GRAPH_MODIFICATION_LOG_LEVEL = NS_DOT + "transaction.graphModificationLogLevel";
public static final String ALL_VERTICES_ITERATION_HANDLER_CLASS_NAME = NS_DOT + "transaction.allVerticesQueryHandlerClassName";
public static final String ALL_EDGES_ITERATION_HANDLER_CLASS_NAME = NS_DOT + "transaction.allEdgesQueryHandlerClassName";
public static final String USE_STATIC_GROOVY_COMPILATION_CACHE = NS_DOT + "groovy.cache.useStatic";
/**
* Enables or disables utilization of secondary indices for the Gremlin {@link PropertyMapStep valueMap()} step.
*
* Please note that this has some side effects:
* <ul>
* <li>The values will be reported as a set, i.e. they will not contain duplicates, and they will be reported in no particular order.</li>
* <li>Even if your original property value was a single value (e.g. a single string), it will be reported as a set (of size 1).</li>
* <li>If there is a secondary index available, property values that do not match the type of the index will NOT be returned.</li>
* </ul>
*
* <p>
* Use this setting only if all property values match the type of the index. If that isn't the case, index queries will produce wrong results
* without warning.
* </p>
*
* <p>
* The setting can be declared globally in the graph configuration (default: <code>false</code>), or overwritten on a per-traversal basis by calling:
* </p>
*
* <pre>
* graph.traversal()
* .with(ChronoGraphConfiguration.USE_SECONDARY_INDEX_FOR_VALUE_MAP_STEP, false) // true to enable, false to disable
* .V()
* ...
* </pre>
*
* @param useSecondaryIndexForGremlinValueMapStep Use <code>true</code> if secondary indices should be used for {@link PropertyMapStep valueMap()} steps.
* Please see the consequences listed above.
* @return <code>this</code>, for method chaining.
*/
public static final String USE_SECONDARY_INDEX_FOR_VALUE_MAP_STEP = NS_DOT + "gremlin.useSecondaryIndexForValueMapStep";
/**
* Enables or disables utilization of secondary indices for the Gremlin {@link PropertiesStep values()} step.
*
* Please note that this has some side effects:
* <ul>
* <li>The values will be reported as a set, i.e. they will not contain duplicates, and they will be reported in no particular order.</li>
* <li>If a property contains multiple values, those values will be flattened.</li>
* <li>If there is a secondary index available, property values that do not match the type of the index will NOT be returned.</li>
* </ul>
*
* Use this setting only if all property values match the type of the index. If that isn't the case, index queries will produce wrong results
* without warning.
*
* The setting can be declared globally in the graph configuration (default: <code>false</code>), or overwritten on a per-traversal basis by calling:
*
* <pre>
* graph.traversal()
* .with(ChronoGraphConfiguration.USE_SECONDARY_INDEX_FOR_VALUES_STEP, false) // true to enable, false to disable
* .V()
* ...
* </pre>
*
* @param useSecondaryIndexForGremlinValuesStep Use <code>true</code> if secondary indices should be used for {@link PropertiesStep values()} steps.
* Please see the consequences listed above.
* @return <code>this</code>, for method chaining.
*/
public static final String USE_SECONDARY_INDEX_FOR_VALUES_STEP = NS_DOT + "gremlin.useSecondaryIndexForValuesStep";
// =================================================================================================================
// GENERAL CONFIGURATION
// =================================================================================================================
/**
* Checks if graph {@link Element} IDs provided by the user should be checked in the backend for duplicates or not.
* <p>
* <p>
* This property has the following implications:
* <ul>
* <li><b>When it is <code>true</code>:</b><br>
* This is the "trusted" mode. The user of the API will be responsible for providing unique identifiers for the
* graph elements. No additional checking will be performed before the ID is being used to instantiate a graph
* element. This mode allows for faster graph element creation, but inconsistencies may be introduced if the user
* provides duplicate IDs.
* <li><b>When it is <code>false</code>:</b><br>
* This is the "untrusted" mode. Before using a user-provided ID for a new graph element, a check will be performed
* in the underlying persistence if an element with that ID already exists. If such an element already exists, an
* exception will be thrown and the ID will not be used. This mode is slower when creating new graph elements due to
* the additional check, but it is also safer in that it warns the user early that a duplicate ID exists.
* </ul>
* <p>
* Regardless whether this setting is on or off, when the user provides no custom ID for a graph element, a new
* UUID-based identifier will be generated automatically.
*
* @return <code>true</code> if a check for duplicated IDs should be performed, or <code>false</code> if that check
* should be skipped.
*/
public boolean isCheckIdExistenceOnAddEnabled();
/**
* Checks if auto-opening of graph transactions is enabled or not.
*
* @return <code>true</code> if auto-opening of graph transactions is enabled, otherwise <code>false</code>.
*/
public boolean isTransactionAutoOpenEnabled();
/**
* Whether or not to perform a check on graph integrity on the change set before committing.
*
* @return <code>true</code> if the integrity check should be performed, otherwise <code>false</code>.
*/
public boolean isGraphInvariantCheckActive();
/**
* Returns the handler which should be invoked when a query requires iteration over all vertices.
*
* @return The all-vertices-iteration handler. May be <code>null</code>.
*/
public AllVerticesIterationHandler getAllVerticesIterationHandler();
/**
* Returns the handler which should be invoked when a query requires iteration over all edges.
*
* @return The all-edges-iteration handler. May be <code>null</code>.
*/
public AllEdgesIterationHandler getAllEdgesIterationHandler();
/**
* Returns <code>true</code> if the static groovy compilation cache should be used.
*
* If <code>false</code> is returned, each ChronoGraph instance should use a cache local to that instance.
*
* @return <code>true</code> if the static cache should be used, <code>false</code> if a local cache should be used.
*/
public boolean isUseStaticGroovyCompilationCache();
/**
* Whether to use secondary indices for evaluating a Gremlin {@link PropertyMapStep valueMap} step.
*
* @return <code>true</code> if secondary indices should be used for the <code>valueMap</code> step, otherwise <code>false</code>.
*/
public boolean isUseSecondaryIndexForGremlinValueMapStep();
/**
* Whether to use secondary indices for evaluating a Gremlin {@link PropertiesStep values} step.
*
* @return <code>true</code> if secondary indices should be used for the <code>values</code> step, otherwise <code>false</code>.
*/
public boolean isUseSecondaryIndexForGremlinValuesStep();
}
| 9,220 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
IChronoGraphVertexIndex.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/internal/api/index/IChronoGraphVertexIndex.java | package org.chronos.chronograph.internal.api.index;
/**
* A common interface for all vertex indices.
*
* @author martin.haeusler@uibk.ac.at -- Initial Contribution and API
*/
public interface IChronoGraphVertexIndex extends ChronoGraphIndexInternal {
}
| 259 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
ChronoGraphIndexInternal.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/internal/api/index/ChronoGraphIndexInternal.java | package org.chronos.chronograph.internal.api.index;
import org.chronos.chronodb.api.ChronoDB;
import org.chronos.chronodb.internal.impl.index.IndexingOption;
import org.chronos.chronograph.api.index.ChronoGraphIndex;
import java.util.Set;
/**
* This class is the internal representation of {@link ChronoGraphIndex}, offering additional methods to be used by internal API only.
*
* @author martin.haeusler@uibk.ac.at -- Initial Contribution and API
*/
public interface ChronoGraphIndexInternal extends ChronoGraphIndex {
/**
* Returns the index key used in the backing {@link ChronoDB} index.
*
* @return The backend index key. Never <code>null</code>.
*/
public String getBackendIndexKey();
/**
* Returns the indexing options applied to the backing {@link ChronoDB} index.
*
* @return The backend indexing options. May be empty, but never <code>null</code>.
*/
public Set<IndexingOption> getIndexingOptions();
}
| 978 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
ChronoGraphIndexManagerInternal.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/internal/api/index/ChronoGraphIndexManagerInternal.java | package org.chronos.chronograph.internal.api.index;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Element;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.chronos.chronodb.internal.api.Period;
import org.chronos.chronodb.internal.api.query.searchspec.SearchSpecification;
import org.chronos.chronodb.internal.impl.index.IndexingOption;
import org.chronos.chronograph.api.index.ChronoGraphIndex;
import org.chronos.chronograph.api.index.ChronoGraphIndexManager;
import org.chronos.chronograph.api.transaction.ChronoGraphTransaction;
import org.chronos.chronograph.internal.impl.index.IndexType;
import java.util.Iterator;
import java.util.Set;
import java.util.concurrent.Callable;
/**
* The internal representation of the {@link ChronoGraphIndexManager} with additional methods for internal use.
*
* @author martin.haeusler@uibk.ac.at -- Initial Contribution and API
*/
public interface ChronoGraphIndexManagerInternal extends ChronoGraphIndexManager {
// =====================================================================================================================
// INDEX MANIPULATION
// =====================================================================================================================
/**
* Adds an index on the given property.
*
* @param elementType The type of element ({@link Vertex} or {@link Edge}) to add the index on.
* @param indexType The type of value to index.
* @param propertyName The name of the gremlin property to index.
* @param startTimestamp The timestamp at which the index should start (inclusive). Must be less than or equal to the "now" timestamp on the branch.
* @param endTimestamp The timestamp at which the index should end (exclusive). Must be greater than <code>startTimestamp</code>.
* @param options The indexing options to apply.
*/
public ChronoGraphIndex addIndex(Class<? extends Element> elementType, IndexType indexType, String propertyName, long startTimestamp, long endTimestamp, Set<IndexingOption> options);
// =====================================================================================================================
// INDEX QUERYING
// =====================================================================================================================
/**
* Performs an index search for the vertices that meet <b>all</b> of the given search specifications.
*
* @param tx The graph transaction to operate on. Must not be <code>null</code>, must be open.
* @param searchSpecifications The search specifications to find the matching vertices for. Must not be <code>null</code>.
* @return An iterator over the IDs of all vertices that fulfill all given search specifications. May be empty, but
* never <code>null</code>.
*/
public Iterator<String> findVertexIdsByIndexedProperties(final ChronoGraphTransaction tx, final Set<SearchSpecification<?, ?>> searchSpecifications);
/**
* Performs an index search for the edges that meet <b>all</b> of the given search specifications.
*
* @param tx The graph transaction to operate on. Must not be <code>null</code>, must be open.
* @param searchSpecifications The search specifications to find the matching edges for. Must not be <code>null</code>.
* @return An iterator over the IDs of all edges that fulfill all given search specifications. May be empty, but
* never <code>null</code>.
*/
public Iterator<String> findEdgeIdsByIndexedProperties(final ChronoGraphTransaction tx, final Set<SearchSpecification<?, ?>> searchSpecifications);
// =================================================================================================================
// LOCKING
// =================================================================================================================
public <T> T withIndexReadLock(Callable<T> action);
public void withIndexReadLock(Runnable action);
public <T> T withIndexWriteLock(Callable<T> action);
public void withIndexWriteLock(Runnable action);
}
| 4,233 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
IChronoGraphEdgeIndex.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/internal/api/index/IChronoGraphEdgeIndex.java | package org.chronos.chronograph.internal.api.index;
/**
* A common interface for all edge indices.
*
* @author martin.haeusler@uibk.ac.at -- Initial Contribution and API
*/
public interface IChronoGraphEdgeIndex extends ChronoGraphIndexInternal {
}
| 255 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
ChronoGraphTransactionInternal.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/internal/api/transaction/ChronoGraphTransactionInternal.java | package org.chronos.chronograph.internal.api.transaction;
import org.chronos.chronograph.api.structure.ChronoEdge;
import org.chronos.chronograph.api.structure.ChronoGraph;
import org.chronos.chronograph.api.structure.record.IEdgeRecord;
import org.chronos.chronograph.api.structure.record.IEdgeTargetRecord;
import org.chronos.chronograph.api.structure.record.IVertexRecord;
import org.chronos.chronograph.api.transaction.ChronoGraphTransaction;
import org.chronos.chronograph.internal.impl.structure.graph.ChronoVertexImpl;
import org.chronos.chronograph.internal.impl.transaction.threaded.ChronoThreadedTransactionGraph;
public interface ChronoGraphTransactionInternal extends ChronoGraphTransaction {
public ChronoEdge loadIncomingEdgeFromEdgeTargetRecord(ChronoVertexImpl targetVertex, String label,
IEdgeTargetRecord record);
public ChronoEdge loadOutgoingEdgeFromEdgeTargetRecord(ChronoVertexImpl sourceVertex, String label,
IEdgeTargetRecord record);
public IVertexRecord loadVertexRecord(String recordId);
public IEdgeRecord loadEdgeRecord(final String recordId);
public default void assertIsOpen() {
if (this.isOpen()) {
return;
}
// the TX has been closed. Try to find out if the graph itself was closed.
Boolean graphClosed;
try {
ChronoGraph graph = this.getGraph();
// threaded transaction graphs are bound to their transaction. If the transaction
// is closed, the graph is closed. For this case, we're interested in the status
// of the *original* graph on which the transaction graph operates.
if (graph instanceof ChronoThreadedTransactionGraph) {
graphClosed = ((ChronoThreadedTransactionGraph) graph).isOriginalGraphClosed();
} else {
graphClosed = graph.isClosed();
}
} catch (Exception e) {
// we were unable to detect if the owning graph has been closed or not...
graphClosed = null;
}
String graphDetailMessage;
if (graphClosed == null) {
graphDetailMessage = "";
} else if (graphClosed == true) {
graphDetailMessage = " The ChronoGraph instance has also been closed.";
} else {
graphDetailMessage = " The ChronoGraph instance is still open.";
}
throw new IllegalStateException(
"This operation is bound to a Threaded Transaction, which was already closed. "
+ "Cannot continue to operate on this element." + graphDetailMessage);
}
}
| 2,728 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
GraphTransactionContextInternal.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/internal/api/transaction/GraphTransactionContextInternal.java | package org.chronos.chronograph.internal.api.transaction;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Property;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.chronos.chronodb.internal.api.query.searchspec.SearchSpecification;
import org.chronos.chronograph.api.transaction.GraphTransactionContext;
import org.chronos.chronograph.internal.impl.structure.graph.ChronoEdgeImpl;
import org.chronos.chronograph.internal.impl.structure.graph.ChronoProperty;
import org.chronos.chronograph.internal.impl.structure.graph.ChronoVertexImpl;
import org.chronos.chronograph.internal.impl.structure.graph.proxy.ChronoEdgeProxy;
import org.chronos.chronograph.internal.impl.structure.graph.proxy.ChronoVertexProxy;
import java.util.Collection;
import java.util.Set;
import java.util.stream.Collectors;
public interface GraphTransactionContextInternal extends GraphTransactionContext {
Set<String> getLoadedVertexIds();
public ChronoVertexImpl getLoadedVertexForId(String id);
public void registerLoadedVertex(ChronoVertexImpl vertex);
Set<String> getLoadedEdgeIds();
public ChronoEdgeImpl getLoadedEdgeForId(String id);
public void registerLoadedEdge(ChronoEdgeImpl edge);
public void registerVertexProxyInCache(ChronoVertexProxy proxy);
public void registerEdgeProxyInCache(ChronoEdgeProxy proxy);
public ChronoVertexProxy getOrCreateVertexProxy(Vertex vertex);
public ChronoEdgeProxy getOrCreateEdgeProxy(Edge edge);
public void markVertexAsModified(ChronoVertexImpl vertex);
public void markEdgeAsModified(ChronoEdgeImpl edge);
public void markPropertyAsModified(ChronoProperty<?> property);
public void markPropertyAsDeleted(ChronoProperty<?> property);
public void removeVariable(String keyspace, String variableName);
public void setVariableValue(String keyspace, String variableName, Object value);
public Set<Vertex> getVerticesWithModificationsOnProperty(String property);
public Set<Edge> getEdgesWithModificationsOnProperty(String property);
public default Set<Vertex> getVerticesWithModificationsOnProperties(Set<String> properties){
return properties.stream().flatMap(p -> this.getVerticesWithModificationsOnProperty(p).stream()).collect(Collectors.toSet());
}
public default Set<Edge> getEdgesWithModificationsOnProperties(Set<String> properties){
return properties.stream().flatMap(p -> this.getEdgesWithModificationsOnProperty(p).stream()).collect(Collectors.toSet());
}
}
| 2,576 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
ChronoGraphFactory.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/ChronoGraphFactory.java | package org.chronos.chronograph.api;
import org.chronos.chronograph.api.builder.graph.ChronoGraphBaseBuilder;
import org.chronos.chronograph.api.structure.ChronoGraph;
import org.chronos.chronograph.internal.impl.factory.ChronoGraphFactoryImpl;
/**
* The graph factory is responsible for creating new {@link ChronoGraph} instances.
*
* <p>
* You can use the {@link #INSTANCE} constant directly, or alternatively use {@link ChronoGraph#FACTORY} to get access to the singleton instance of this class.
*
* @author martin.haeusler@uibk.ac.at -- Initial Contribution and API
*/
public interface ChronoGraphFactory {
/** The singleton instance of the graph factory interface. */
public static final ChronoGraphFactory INSTANCE = new ChronoGraphFactoryImpl();
/**
* Entry point to the fluent API for creating new {@link ChronoGraph} instances.
*
* @return The fluent builder for method chaining. Never <code>null</code>.
*/
public ChronoGraphBaseBuilder create();
}
| 983 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
GraphTriggerScriptException.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/exceptions/GraphTriggerScriptException.java | package org.chronos.chronograph.api.exceptions;
public class GraphTriggerScriptException extends GraphTriggerException {
public GraphTriggerScriptException() {
}
protected GraphTriggerScriptException(final String message, final Throwable cause, final boolean enableSuppression, final boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
public GraphTriggerScriptException(final String message, final Throwable cause) {
super(message, cause);
}
public GraphTriggerScriptException(final String message) {
super(message);
}
public GraphTriggerScriptException(final Throwable cause) {
super(cause);
}
}
| 719 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
ChronoGraphException.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/exceptions/ChronoGraphException.java | package org.chronos.chronograph.api.exceptions;
import org.chronos.common.exceptions.ChronosException;
public class ChronoGraphException extends ChronosException {
public ChronoGraphException() {
super();
}
protected ChronoGraphException(final String message, final Throwable cause, final boolean enableSuppression,
final boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
public ChronoGraphException(final String message, final Throwable cause) {
super(message, cause);
}
public ChronoGraphException(final String message) {
super(message);
}
public ChronoGraphException(final Throwable cause) {
super(cause);
}
}
| 688 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
GraphTriggerScriptCompilationException.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/exceptions/GraphTriggerScriptCompilationException.java | package org.chronos.chronograph.api.exceptions;
public class GraphTriggerScriptCompilationException extends GraphTriggerScriptException {
public GraphTriggerScriptCompilationException() {
}
protected GraphTriggerScriptCompilationException(final String message, final Throwable cause, final boolean enableSuppression, final boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
public GraphTriggerScriptCompilationException(final String message, final Throwable cause) {
super(message, cause);
}
public GraphTriggerScriptCompilationException(final String message) {
super(message);
}
public GraphTriggerScriptCompilationException(final Throwable cause) {
super(cause);
}
}
| 791 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
TriggerAlreadyExistsException.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/exceptions/TriggerAlreadyExistsException.java | package org.chronos.chronograph.api.exceptions;
public class TriggerAlreadyExistsException extends ChronoGraphException {
public TriggerAlreadyExistsException() {
}
protected TriggerAlreadyExistsException(final String message, final Throwable cause, final boolean enableSuppression, final boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
public TriggerAlreadyExistsException(final String message, final Throwable cause) {
super(message, cause);
}
public TriggerAlreadyExistsException(final String message) {
super(message);
}
public TriggerAlreadyExistsException(final Throwable cause) {
super(cause);
}
}
| 730 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
ChronoGraphSchemaViolationException.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/exceptions/ChronoGraphSchemaViolationException.java | package org.chronos.chronograph.api.exceptions;
public class ChronoGraphSchemaViolationException extends ChronoGraphException {
public ChronoGraphSchemaViolationException() {
}
protected ChronoGraphSchemaViolationException(final String message, final Throwable cause, final boolean enableSuppression, final boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
public ChronoGraphSchemaViolationException(final String message, final Throwable cause) {
super(message, cause);
}
public ChronoGraphSchemaViolationException(final String message) {
super(message);
}
public ChronoGraphSchemaViolationException(final Throwable cause) {
super(cause);
}
}
| 765 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
InvalidChronoIdentifierException.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/exceptions/InvalidChronoIdentifierException.java | package org.chronos.chronograph.api.exceptions;
public class InvalidChronoIdentifierException extends ChronoGraphException {
public InvalidChronoIdentifierException() {
super();
}
protected InvalidChronoIdentifierException(final String message, final Throwable cause,
final boolean enableSuppression, final boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
public InvalidChronoIdentifierException(final String message, final Throwable cause) {
super(message, cause);
}
public InvalidChronoIdentifierException(final String message) {
super(message);
}
public InvalidChronoIdentifierException(final Throwable cause) {
super(cause);
}
}
| 708 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
PropertyIsAlreadyIndexedException.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/exceptions/PropertyIsAlreadyIndexedException.java | package org.chronos.chronograph.api.exceptions;
public class PropertyIsAlreadyIndexedException extends ChronoGraphIndexingException {
public PropertyIsAlreadyIndexedException() {
super();
}
protected PropertyIsAlreadyIndexedException(final String message, final Throwable cause,
final boolean enableSuppression, final boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
public PropertyIsAlreadyIndexedException(final String message, final Throwable cause) {
super(message, cause);
}
public PropertyIsAlreadyIndexedException(final String message) {
super(message);
}
public PropertyIsAlreadyIndexedException(final Throwable cause) {
super(cause);
}
}
| 722 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
GraphTriggerClassNotFoundException.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/exceptions/GraphTriggerClassNotFoundException.java | package org.chronos.chronograph.api.exceptions;
public class GraphTriggerClassNotFoundException extends GraphTriggerException {
public GraphTriggerClassNotFoundException() {
}
protected GraphTriggerClassNotFoundException(final String message, final Throwable cause, final boolean enableSuppression, final boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
public GraphTriggerClassNotFoundException(final String message, final Throwable cause) {
super(message, cause);
}
public GraphTriggerClassNotFoundException(final String message) {
super(message);
}
public GraphTriggerClassNotFoundException(final Throwable cause) {
super(cause);
}
}
| 761 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
ChronoGraphCommitConflictException.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/exceptions/ChronoGraphCommitConflictException.java | package org.chronos.chronograph.api.exceptions;
public class ChronoGraphCommitConflictException extends ChronoGraphException {
public ChronoGraphCommitConflictException() {
super();
}
protected ChronoGraphCommitConflictException(final String message, final Throwable cause,
final boolean enableSuppression, final boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
public ChronoGraphCommitConflictException(final String message, final Throwable cause) {
super(message, cause);
}
public ChronoGraphCommitConflictException(final String message) {
super(message);
}
public ChronoGraphCommitConflictException(final Throwable cause) {
super(cause);
}
}
| 720 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
ChronoGraphIndexingException.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/exceptions/ChronoGraphIndexingException.java | package org.chronos.chronograph.api.exceptions;
public class ChronoGraphIndexingException extends ChronoGraphException {
public ChronoGraphIndexingException() {
super();
}
protected ChronoGraphIndexingException(final String message, final Throwable cause, final boolean enableSuppression,
final boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
public ChronoGraphIndexingException(final String message, final Throwable cause) {
super(message, cause);
}
public ChronoGraphIndexingException(final String message) {
super(message);
}
public ChronoGraphIndexingException(final Throwable cause) {
super(cause);
}
}
| 684 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
ChronoGraphConfigurationException.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/exceptions/ChronoGraphConfigurationException.java | package org.chronos.chronograph.api.exceptions;
public class ChronoGraphConfigurationException extends ChronoGraphException {
public ChronoGraphConfigurationException() {
super();
}
protected ChronoGraphConfigurationException(final String message, final Throwable cause,
final boolean enableSuppression, final boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
public ChronoGraphConfigurationException(final String message, final Throwable cause) {
super(message, cause);
}
public ChronoGraphConfigurationException(final String message) {
super(message);
}
public ChronoGraphConfigurationException(final Throwable cause) {
super(cause);
}
}
| 714 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
GraphInvariantViolationException.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/exceptions/GraphInvariantViolationException.java | package org.chronos.chronograph.api.exceptions;
public class GraphInvariantViolationException extends ChronoGraphException {
public GraphInvariantViolationException() {
}
protected GraphInvariantViolationException(final String message, final Throwable cause, final boolean enableSuppression, final boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
public GraphInvariantViolationException(final String message, final Throwable cause) {
super(message, cause);
}
public GraphInvariantViolationException(final String message) {
super(message);
}
public GraphInvariantViolationException(final Throwable cause) {
super(cause);
}
}
| 747 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
GraphTriggerException.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/exceptions/GraphTriggerException.java | package org.chronos.chronograph.api.exceptions;
public class GraphTriggerException extends ChronoGraphException {
public GraphTriggerException() {
}
protected GraphTriggerException(final String message, final Throwable cause, final boolean enableSuppression, final boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
public GraphTriggerException(final String message, final Throwable cause) {
super(message, cause);
}
public GraphTriggerException(final String message) {
super(message);
}
public GraphTriggerException(final Throwable cause) {
super(cause);
}
}
| 682 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
GraphTriggerScriptInstantiationException.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/exceptions/GraphTriggerScriptInstantiationException.java | package org.chronos.chronograph.api.exceptions;
public class GraphTriggerScriptInstantiationException extends GraphTriggerScriptException {
public GraphTriggerScriptInstantiationException() {
}
protected GraphTriggerScriptInstantiationException(final String message, final Throwable cause, final boolean enableSuppression, final boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
public GraphTriggerScriptInstantiationException(final String message, final Throwable cause) {
super(message, cause);
}
public GraphTriggerScriptInstantiationException(final String message) {
super(message);
}
public GraphTriggerScriptInstantiationException(final Throwable cause) {
super(cause);
}
}
| 803 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
ChronoGraphSchemaManager.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/schema/ChronoGraphSchemaManager.java | package org.chronos.chronograph.api.schema;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Property;
import org.chronos.chronograph.api.exceptions.ChronoGraphSchemaViolationException;
import org.chronos.chronograph.api.structure.ChronoEdge;
import org.chronos.chronograph.api.structure.ChronoElement;
import org.chronos.chronograph.api.structure.ChronoGraph;
import org.chronos.chronograph.api.structure.ChronoVertex;
import java.util.Set;
/**
* A manager for schema constraints on a {@link ChronoGraph} instance.
*
* <p>
* Validation constraints are expressed as groovy scripts.
* </p>
*
* <h1>Scripting API</h1>
*
* A validator script is a Groovy script, which is compiled with <b>static type checking</b>
* (i.e. dynamic features of Groovy are unavailable). The script has access to the
* following global variables:
*
* <ul>
* <li><b><code>element</code></b>: The graph element ({@link ChronoVertex} or {@link ChronoEdge} to validate. Never <code>null</code>. Navigation to neighboring elements is permitted, but be aware of performance implications in case of excessive querying.</li>
* <li><b><code>branch</code></b>: The name of the branch on which the validation occurs, as a string. Never <code>null</code>.</li>
* </ul>
*
* <h2>Validator Results</h2>
* In case that the validator script encounters a schema violation, it should throw a {@link ChronoGraphSchemaViolationException}. If
* the script exits without throwing any exception, the graph is assumed to conform to the schema. If an exception other than
* {@link ChronoGraphSchemaViolationException} is thrown, the validator itself is invalid. In this case, a warning will be printed
* to the console, and the assumption will be made that the graph violates the schema (since its structure caused a validator to fail).
*
* <h2>Assumptions about the Validator Scripts</h2>
* The following basic assumptions are made (but not enforced) about the validator script:
* <ul>
* <li><b>Idempotence</b>: Given the same input graph, it will always and consistently produce the same result.</li>
* <li><b>Independence</b>: The output solely depends on the input graph. No external API calls are made (including the network and the local file system).</li>
* <li><b>Purity</b>: The validator script does not modify any state, neither in-memory nor on disk or over network. Validator scripts are <b>not</b> allowed
* to perform any modifications on the graph. They will receive an unmodifiable version of the graph elements, and any attempt to modify them will result in an immediate exception.</li>
* </ul>
*
* <h2>Things to avoid when writing Validator Scripts</h2>
* <ul>
* <li><b>Do not perform excessive querying on the graph.</b> This will lead to poor performance. Checking the element and the immediate neighbors is fine.</li>
* <li><b>Be aware of {@link NullPointerException}s and absent {@link Property properties} and {@link Edge edges}.</b> Validator scripts should be safe in this regard.</li>
* <li><b>Be aware of unexpected {@link Property property} values.</b> Validators should not fail with {@link ClassCastException}s.</li>
* <li><b>Do not access the file system.</b></li>
* <li><b>Do not access the network.</b></li>
* <li><b>Do not declare any static members, or access any non-constant static members.</b></li>
* <li><b>Do not attempt to access any classes which are not part of ChronoGraph (i.e. do not access your own classes).</b> This will cause the validator to fail if it is invoked from outside your application (e.g. when a command-line interface is used).</li>
* <li><b>Do not attempt to use system classes.</b> Examples include {@link System}, {@link Thread} and {@link Runtime}. Validator execution is not sandboxed!</li>
* <li><b>Do not start threads or executor pools.</b></li>
* <li><b>Do not open any resources (JDBC connections, file handles, input/output streams...).</b></li>
* </ul>
*
* @author martin.haeusler@uibk.ac.at -- Initial Contribution and API
*/
@SuppressWarnings("unused")
public interface ChronoGraphSchemaManager {
/**
* Adds the given validator class and associates it with the given name.
*
* <p>
* In case that there is already a validator with the given name, the old validator will
* be replaced.
* </p>
*
* @param validatorName The unique name of the validator. Must not be <code>null</code> or empty.
* @param scriptContent The Groovy script which acts as the validator body. Please see the documentation of {@link ChronoGraphSchemaManager} for the scripting API details. The script content will be compiled immediately; in case that the compilation fails, an {@link IllegalArgumentException} will be thrown and the script will <b>not</b> be stored.
* @return <code>true</code> if a validator was overwritten, <code>false</code> if no validator was previously bound to the given name.
*/
public boolean addOrOverrideValidator(String validatorName, String scriptContent);
/**
* Adds the given validator class and associates it with the given name.
*
* <p>
* In case that there is already a validator with the given name, the old validator will
* be replaced.
* </p>
*
* @param validatorName The unique name of the validator. Must not be <code>null</code> or empty.
* @param scriptContent The Groovy script which acts as the validator body. Please see the documentation of {@link ChronoGraphSchemaManager} for the scripting API details. The script content will be compiled immediately; in case that the compilation fails, an {@link IllegalArgumentException} will be thrown and the script will <b>not</b> be stored.
* @param commitMetadata The metadata for the commit of adding or overriding a validator. May be <code>null</code>.
* @return <code>true</code> if a validator was overwritten, <code>false</code> if no validator was previously bound to the given name.
*/
public boolean addOrOverrideValidator(String validatorName, String scriptContent, Object commitMetadata);
/**
* Removes the validator with the given name.
*
* @param validatorName The name of the validator to remove.
* @return <code>true</code> if the validator was successfully removed, or <code>false</code> if no validator existed with the given name.
*/
public boolean removeValidator(String validatorName);
/**
* Removes the validator with the given name.
*
* @param validatorName The name of the validator to remove.
* @param commitMetadata The metadata for the commit of removing a validator. May be <code>null</code>.
* @return <code>true</code> if the validator was successfully removed, or <code>false</code> if no validator existed with the given name.
*/
public boolean removeValidator(String validatorName, Object commitMetadata);
/**
* Returns the script content of the validator with the given name.
*
* @param validatorName The name of the validator to get the script content for. Must not be <code>null</code>.
* @return The validator script, or <code>null</code> if there is no validator with the given name.
*/
public String getValidatorScript(String validatorName);
/**
* Returns an immutable set containing all validator names that are currently in use (i.e. bound to a validator script).
*
* @return The set of all validator names which are currently bound to a validator script. May be empty, but never <code>null</code>.
*/
public Set<String> getAllValidatorNames();
/**
* Validates the given element.
*
* @param branch The branch on which the validation occurs. Must not be <code>null</code>.
* @param elements The elements to validate. Must not be <code>null</code>.
* @return The schema validation result. Never <code>null</code>.
*/
public SchemaValidationResult validate(String branch, Iterable<? extends ChronoElement> elements);
}
| 8,054 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
SchemaValidationResult.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/schema/SchemaValidationResult.java | package org.chronos.chronograph.api.schema;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.tinkerpop.gremlin.structure.Element;
import org.chronos.chronograph.api.structure.ChronoElement;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* An immutable data object representing the result of a {@link ChronoGraphSchemaManager#validate(String, ChronoElement)} call.
*
* @author martin.haeusler@uibk.ac.at -- Initial Contribution and API
*/
public interface SchemaValidationResult {
/**
* Checks if this validation result represents a validation success (i.e. no violations have been reported).
*
* @return <code>true</code> if this result represents a success, otherwise <code>false</code>.
*/
public default boolean isSuccess() {
return this.getFailedValidators().isEmpty();
}
/**
* Checks if this validation result represents a validation failure (i.e. at least one violation has been reported).
*
* @return <code>true</code> if this result represents a failure, otherwise <code>false</code>.
*/
public default boolean isFailure() {
return !this.isSuccess();
}
/**
* Returns the total number of validation errors.
*
* @return The total number of validation errors. Never negative.
*/
public int getFailureCount();
/**
* Returns the set of validator names which reported a violation.
*
* @return An immutable set of validator names which reported a violation. Never <code>null</code>, will be empty in case of {@linkplain #isSuccess() success}.
*/
public Set<String> getFailedValidators();
/**
* Returns the set of all violations, grouped by validator.
*
* @return A map. The map key is the validator name, the value is a list of violations. Each violation is a pair containing the offending element,
* as well as the violation exception. The result map is never <code>null</code>. Validators which reported no violations will not be contained in the keyset.
*/
public Map<String, List<Pair<Element, Throwable>>> getViolationsByValidators();
/**
* Returns the set of validator names which reported a violation on the given {@link Element}.
*
* @return An immutable set of validator names which reported a violation on the given element. Never <code>null</code>, will be empty in case of {@linkplain #isSuccess() success}.
*/
public default Set<String> getFailedValidatorsForElement(Element element) {
return this.getFailedValidatorExceptionsForElement(element).keySet();
}
/**
* Returns a map from validator name to the encountered validation issue for the given {@link Element}.
*
* @return An immutable map from validator name to the error thrown by the validator. Never <code>null</code>, will be empty in case of {@linkplain #isSuccess() success}.
*/
public Map<String, Throwable> getFailedValidatorExceptionsForElement(Element element);
/**
* Compacts this validation result into an error message.
*
* @return The error message.
*/
public String generateErrorMessage();
}
| 3,194 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
ChronoGraphMaintenanceManager.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/maintenance/ChronoGraphMaintenanceManager.java | package org.chronos.chronograph.api.maintenance;
import org.chronos.chronodb.api.ChronoDBConstants;
import org.chronos.chronograph.internal.impl.structure.graph.features.ChronoGraphGraphFeatures;
import java.util.function.Predicate;
public interface ChronoGraphMaintenanceManager {
/**
* Performs a rollover on the branch with the given name.
*
* <p>
* Not all backends support this operation. Please use {@link ChronoGraphGraphFeatures#supportsRollover()} first to check if this operation is supported or not.
*
* @param branchName
* The branch name to roll over. Must not be <code>null</code>, must refer to an existing branch.
*
* @throws UnsupportedOperationException
* Thrown if this backend {@linkplain ChronoGraphGraphFeatures#supportsRollover() does not support rollovers}.
*/
public default void performRolloverOnBranch(String branchName) {
this.performRolloverOnBranch(branchName, true);
}
/**
* Performs a rollover on the branch with the given name.
*
* <p>
* Not all backends support this operation. Please use {@link ChronoGraphGraphFeatures#supportsRollover()} first to check if this operation is supported or not.
*
* @param branchName
* The branch name to roll over. Must not be <code>null</code>, must refer to an existing branch.
* @param updateIndex
* Use <code>true</code> to update all clean indices to match the data content at the new head revision. Using <code>false</code> will instead mark all indices as dirty.
* @throws UnsupportedOperationException
* Thrown if this backend {@linkplain ChronoGraphGraphFeatures#supportsRollover() does not support rollovers}.
*/
public void performRolloverOnBranch(String branchName, boolean updateIndex);
/**
* Performs a rollover on the {@link ChronoDBConstants#MASTER_BRANCH_IDENTIFIER master} branch.
*
* <p>
* Not all backends support this operation. Please use {@link ChronoGraphGraphFeatures#supportsRollover()} first to check if this operation is supported or not.
*
* @throws UnsupportedOperationException
* Thrown if this backend {@linkplain ChronoGraphGraphFeatures#supportsRollover() does not support rollovers}.
*/
public default void performRolloverOnMaster() {
this.performRolloverOnBranch(ChronoDBConstants.MASTER_BRANCH_IDENTIFIER);
}
/**
* Performs a rollover on the {@link ChronoDBConstants#MASTER_BRANCH_IDENTIFIER master} branch.
*
* <p>
* Not all backends support this operation. Please use {@link ChronoGraphGraphFeatures#supportsRollover()} first to check if this operation is supported or not.
*
* @param updateIndex
* Use <code>true</code> to update all clean indices to match the data content at the new head revision. Using <code>false</code> will instead mark all indices as dirty.
*
* @throws UnsupportedOperationException
* Thrown if this backend {@linkplain ChronoGraphGraphFeatures#supportsRollover() does not support rollovers}.
*/
public default void performRolloverOnMaster(boolean updateIndex){
this.performRolloverOnBranch(ChronoDBConstants.MASTER_BRANCH_IDENTIFIER, updateIndex);
}
/**
* Performs a rollover on all existing branches.
*
* <p>
* Not all backends support this operation. Please use {@link ChronoGraphGraphFeatures#supportsRollover()} first to check if this operation is supported or not.
*
* <p>
* <b>Important note:</b> This method is <b>not guaranteed to be ACID safe</b>. Rollovers will be executed one after the other. If an unexpected event (such as JVM crash, exceptions, power supply failure...) occurs, then some branches may have been rolled over while others have not.
*
* <p>
* This is a <b>very</b> expensive operation that can substantially increase the memory footprint of the database on disk. Use with care.
*
* @throws UnsupportedOperationException
* Thrown if this backend {@linkplain ChronoGraphGraphFeatures#supportsRollover() does not support rollovers}.
*/
public default void performRolloverOnAllBranches(){
this.performRolloverOnAllBranches(true);
}
/**
* Performs a rollover on all existing branches.
*
* <p>
* Not all backends support this operation. Please use {@link ChronoGraphGraphFeatures#supportsRollover()} first to check if this operation is supported or not.
*
* <p>
* <b>Important note:</b> This method is <b>not guaranteed to be ACID safe</b>. Rollovers will be executed one after the other. If an unexpected event (such as JVM crash, exceptions, power supply failure...) occurs, then some branches may have been rolled over while others have not.
*
* <p>
* This is a <b>very</b> expensive operation that can substantially increase the memory footprint of the database on disk. Use with care.
*
* @param updateIndex
* Use <code>true</code> to update all clean indices to match the data content at the new head revision. Using <code>false</code> will instead mark all indices as dirty.
*
* @throws UnsupportedOperationException
* Thrown if this backend {@linkplain ChronoGraphGraphFeatures#supportsRollover() does not support rollovers}.
*/
public void performRolloverOnAllBranches(boolean updateIndex);
/**
* Performs a rollover on all branches that match the given predicate.
*
* <p>
* Not all backends support this operation. Please use {@link ChronoGraphGraphFeatures#supportsRollover()} first to check if this operation is supported or not.
*
* <p>
* <b>Important note:</b> This method is <b>not guaranteed to be ACID safe</b>. Rollovers will be executed one after the other. If an unexpected event (such as JVM crash, exceptions, power supply failure...) occurs, then some branches may have been rolled over while others have not.
*
* <p>
* This is a potentially <b>very</b> expensive operation that can substantially increase the memory footprint of the database on disk. Use with care.
*
* @param branchPredicate
* The predicate that decides whether or not to roll over the branch in question. Must not be <code>null</code>.
*
* @throws UnsupportedOperationException
* Thrown if this backend {@linkplain ChronoGraphGraphFeatures#supportsRollover() does not support rollovers}.
*/
public default void performRolloverOnAllBranchesWhere(Predicate<String> branchPredicate){
this.performRolloverOnAllBranchesWhere(branchPredicate, true);
}
/**
* Performs a rollover on all branches that match the given predicate.
*
* <p>
* Not all backends support this operation. Please use {@link ChronoGraphGraphFeatures#supportsRollover()} first to check if this operation is supported or not.
*
* <p>
* <b>Important note:</b> This method is <b>not guaranteed to be ACID safe</b>. Rollovers will be executed one after the other. If an unexpected event (such as JVM crash, exceptions, power supply failure...) occurs, then some branches may have been rolled over while others have not.
*
* <p>
* This is a potentially <b>very</b> expensive operation that can substantially increase the memory footprint of the database on disk. Use with care.
*
* @param branchPredicate
* The predicate that decides whether or not to roll over the branch in question. Must not be <code>null</code>.
*
* @param updateIndex
* Use <code>true</code> to update all clean indices to match the data content at the new head revision. Using <code>false</code> will instead mark all indices as dirty.
*
* @throws UnsupportedOperationException
* Thrown if this backend {@linkplain ChronoGraphGraphFeatures#supportsRollover() does not support rollovers}.
*/
public void performRolloverOnAllBranchesWhere(Predicate<String> branchPredicate, boolean updateIndex);
}
| 8,246 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
ChronoGraphHistoryManager.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/history/ChronoGraphHistoryManager.java | package org.chronos.chronograph.api.history;
import java.util.Collections;
import java.util.Set;
import static com.google.common.base.Preconditions.*;
public interface ChronoGraphHistoryManager {
/**
* Restores the given edges and vertices back to their original state as of the given timestamp.
*
* <p>
* <b>This method requires an open graph transaction, and WILL modify its state!</b> No commit will be performed.
* </p>
*
* <p>
* During the restoration process, any state of the current element will be <b>overwritten</b> by the historical state!
* </p>
*
* @param timestamp The timestamp to revert back to. Must be less than or equal to the current transaction timestamp, and must not be negative.
* @param vertexIds The vertex IDs to restore from the given timestamp. May be <code>null</code> or empty (implying that no vertices should be restored). IDs which cannot be found will be treated as "did not exist in the restore timestamp state" and will be deleted in the current graph transaction. Please note that restoring a vertex will also restore its adjacent edges, if possible.
* @param edgeIds The edge IDs to restore from the given timestamp. May be <code>null</code> or empty (implying that no edges should be restored). IDs which cannot be found will be treated as "did not exist in the restore timestamp state" and will be deleted in the current graph transaction. Please note that restoring an edge does NOT restore its adjacent vertices, thus restoration of edges may fail.
* @return The restore result, containing further information about the outcome of this operation. Never <code>null</code>. As a side effect, the current graph transaction state will be modified by this operation.
*/
public RestoreResult restoreGraphElementsAsOf(long timestamp, Set<String> vertexIds, Set<String> edgeIds);
/**
* Restores the given vertices back to their original state as of the given timestamp.
*
* <p>
* <b>This method requires an open graph transaction, and WILL modify its state!</b> No commit will be performed.
* </p>
*
* <p>
* During the restoration process, any state of the current element will be <b>overwritten</b> by the historical state!
* </p>
*
* @param timestamp The timestamp to revert back to. Must be less than or equal to the current transaction timestamp, and must not be negative.
* @param vertexIds The vertex IDs to restore from the given timestamp. May be <code>null</code> or empty (implying that no vertices should be restored). IDs which cannot be found will be treated as "did not exist in the restore timestamp state" and will be deleted in the current graph transaction. Please note that restoring a vertex will also restore its adjacent edges, if possible.
* @return The restore result, containing further information about the outcome of this operation. Never <code>null</code>. As a side effect, the current graph transaction state will be modified by this operation.
*/
public default RestoreResult restoreVerticesAsOf(long timestamp, Set<String> vertexIds) {
checkNotNull(vertexIds, "Precondition violation - argument 'vertexIds' must not be NULL!");
return this.restoreGraphElementsAsOf(timestamp, vertexIds, Collections.emptySet());
}
/**
* Restores the given vertex back to its original state as of the given timestamp.
*
* <p>
* <b>This method requires an open graph transaction, and WILL modify its state!</b> No commit will be performed.
* </p>
*
* <p>
* During the restoration process, any state of the current element will be <b>overwritten</b> by the historical state!
* </p>
*
* @param timestamp The timestamp to revert back to. Must be less than or equal to the current transaction timestamp, and must not be negative.
* @param vertexId The vertex ID to restore from the given timestamp. Must not be <code>null</code>. IDs which cannot be found will be treated as "did not exist in the restore timestamp state" and will be deleted in the current graph transaction. Please note that restoring a vertex will also restore its adjacent edges, if possible.
* @return The restore result, containing further information about the outcome of this operation. Never <code>null</code>. As a side effect, the current graph transaction state will be modified by this operation.
*/
public default RestoreResult restoreVertexAsOf(long timestamp, String vertexId){
checkNotNull(vertexId, "Precondition violation - argument 'vertexId' must not be NULL!");
return this.restoreVerticesAsOf(timestamp, Collections.singleton(vertexId));
}
/**
* Restores the given edges back to their original state as of the given timestamp.
*
* <p>
* <b>This method requires an open graph transaction, and WILL modify its state!</b> No commit will be performed.
* </p>
*
* <p>
* During the restoration process, any state of the current element will be <b>overwritten</b> by the historical state!
* </p>
*
* @param timestamp The timestamp to revert back to. Must be less than or equal to the current transaction timestamp, and must not be negative.
* @param edgeIds The edge IDs to restore from the given timestamp. May be <code>null</code> or empty (implying that no edges should be restored). IDs which cannot be found will be treated as "did not exist in the restore timestamp state" and will be deleted in the current graph transaction. Please note that restoring an edge does NOT restore its adjacent vertices, thus restoration of edges may fail.
* @return The restore result, containing further information about the outcome of this operation. Never <code>null</code>. As a side effect, the current graph transaction state will be modified by this operation.
*/
public default RestoreResult restoreEdgesAsOf(long timestamp, Set<String> edgeIds) {
checkNotNull(edgeIds, "Precondition violation - argument 'edgeIds' must not be NULL!");
return this.restoreGraphElementsAsOf(timestamp, edgeIds, Collections.emptySet());
}
/**
* Restores the given edge back to its original state as of the given timestamp.
*
* <p>
* <b>This method requires an open graph transaction, and WILL modify its state!</b> No commit will be performed.
* </p>
*
* <p>
* During the restoration process, any state of the current element will be <b>overwritten</b> by the historical state!
* </p>
*
* @param timestamp The timestamp to revert back to. Must be less than or equal to the current transaction timestamp, and must not be negative.
* @param edgeId The edge ID to restore from the given timestamp. Must not be <code>null</code>. IDs which cannot be found will be treated as "did not exist in the restore timestamp state" and will be deleted in the current graph transaction. Please note that restoring an edge does NOT restore its adjacent vertices, thus restoration of edges may fail.
* @return The restore result, containing further information about the outcome of this operation. Never <code>null</code>. As a side effect, the current graph transaction state will be modified by this operation.
*/
public default RestoreResult restoreEdgeAsOf(long timestamp, String edgeId){
checkNotNull(edgeId, "Precondition violation - argument 'edgeId' must not be NULL!");
return this.restoreEdgesAsOf(timestamp, Collections.singleton(edgeId));
}
/**
* Restores the full graph state as it has been at the given timestamp.
*
* <p>
* <b>This method requires and open graph transaction, and WILL modify its state!</b> No commit will be performed. All changes done previously to this transaction will be lost!
* </p>
*
* @param timestamp The timestamp to revert back to. Must be less than or equal to the current transaction timestamp, and must not be negative.
* @return The restore result, containing further information about the outcome of this operation. Never <code>null</code>. As a side effect, the current graph transaction state will be modified by this operation.
*/
public RestoreResult restoreGraphStateAsOf(long timestamp);
}
| 8,374 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
RestoreResult.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/history/RestoreResult.java | package org.chronos.chronograph.api.history;
import java.util.Set;
public interface RestoreResult {
/**
* Returns the set of Vertex IDs that were restored successfully.
*
* <p>
* Please note that "restored" can also mean "deleted" if they did not exist at the restoration timestamp.
* </p>
*
* @return The set of Vertex IDs which were restored successfully. May be empty but never <code>null</code>.
*/
public Set<String> getSuccessfullyRestoredVertexIds();
/**
* Returns the set of Edge IDs that were restored successfully.
*
* <p>
* Please note that "restored" can also mean "deleted" if they did not exist at the restoration timestamp.
* </p>
*
* @return The set of Edge IDs which were restored successfully. May be empty but never <code>null</code>.
*/
public Set<String> getSuccessfullyRestoredEdgeIds();
/**
* Returns the set of Edge IDs that could not be restored.
*
* <p>
* This can happen for example if the edge was connected to
* a vertex which no longer exists.
* </p>
*
* @return The set of edge IDs which failed to be restored. May be empty but never <code>null</code>.
*/
public Set<String> getFailedEdgeIds();
}
| 1,283 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
ChronoGraphMBeanSupport.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/jmx/ChronoGraphMBeanSupport.java | package org.chronos.chronograph.api.jmx;
import org.chronos.chronograph.internal.impl.structure.graph.StandardChronoGraph;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import java.lang.management.ManagementFactory;
public class ChronoGraphMBeanSupport {
private static final Logger log = LoggerFactory.getLogger(ChronoGraphMBeanSupport.class);
public static void registerMBeans(final StandardChronoGraph standardChronoGraph){
try{
// wire up the cache MBean
ChronoGraphCacheStatistics.getInstance().setCache(standardChronoGraph.getBackingDB().getCache());
// wire up the MBeans with the server
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
// register the transaction statistics MBean
ObjectName objectNameTransactionStatistics = new ObjectName("org.chronos.chronograph:type=ChronoGraph.TransactionStatistics");
mbs.registerMBean(ChronoGraphTransactionStatistics.getInstance(), objectNameTransactionStatistics);
// register the cache statistics MBean
ObjectName objectNameCacheStatistics = new ObjectName("org.chronos.chronograph:type=ChronoGraph.CacheStatistics");
mbs.registerMBean(ChronoGraphCacheStatistics.getInstance(), objectNameCacheStatistics);
}catch(Exception e){
log.warn("Failed to register ChronoGraph MBeans. JMX functionality will not be available for this instance. Exception is: " + e);
}
}
}
| 1,586 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
ChronoGraphTransactionStatisticsMBean.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/jmx/ChronoGraphTransactionStatisticsMBean.java | package org.chronos.chronograph.api.jmx;
public interface ChronoGraphTransactionStatisticsMBean {
public long getNumberOfVertexRecordRefetches();
public void incrementNumberOfVertexRecordRefetches();
public void resetNumberOfVertexRecordRefetches();
}
| 269 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
ChronoGraphCacheStatisticsMBean.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/jmx/ChronoGraphCacheStatisticsMBean.java | package org.chronos.chronograph.api.jmx;
public interface ChronoGraphCacheStatisticsMBean {
public int getCacheSize();
public long getHitCount();
public long getMissCount();
public long getRequestCount();
public double getHitRate();
}
| 262 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
ChronoGraphCacheStatistics.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/jmx/ChronoGraphCacheStatistics.java | package org.chronos.chronograph.api.jmx;
import org.chronos.chronodb.internal.api.cache.ChronoDBCache;
public class ChronoGraphCacheStatistics implements ChronoGraphCacheStatisticsMBean {
private static final ChronoGraphCacheStatistics INSTANCE = new ChronoGraphCacheStatistics();
public static ChronoGraphCacheStatistics getInstance(){
return INSTANCE;
}
private ChronoDBCache cacheInstance;
public void setCache(ChronoDBCache cache){
this.cacheInstance = cache;
}
public int getCacheSize(){
ChronoDBCache cache = this.cacheInstance;
if(cache == null){
return 0;
}
return cache.size();
}
public long getHitCount(){
ChronoDBCache cache = this.cacheInstance;
if(cache == null){
return 0;
}
return cache.getStatistics().getCacheHitCount();
}
public long getMissCount(){
ChronoDBCache cache = this.cacheInstance;
if(cache == null){
return 0;
}
return cache.getStatistics().getCacheMissCount();
}
public long getRequestCount(){
ChronoDBCache cache = this.cacheInstance;
if(cache == null){
return 0;
}
return cache.getStatistics().getRequestCount();
}
public double getHitRate(){
ChronoDBCache cache = this.cacheInstance;
if(cache == null){
return 0;
}
return cache.getStatistics().getCacheHitRatio();
}
}
| 1,513 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
ChronoGraphTransactionStatistics.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/jmx/ChronoGraphTransactionStatistics.java | package org.chronos.chronograph.api.jmx;
import java.util.concurrent.atomic.AtomicLong;
public class ChronoGraphTransactionStatistics implements ChronoGraphTransactionStatisticsMBean {
private static final ChronoGraphTransactionStatisticsMBean INSTANCE = new ChronoGraphTransactionStatistics();
public static ChronoGraphTransactionStatisticsMBean getInstance(){
return INSTANCE;
}
private AtomicLong numberOfVertexRecordRefetches = new AtomicLong(0);
@Override
public long getNumberOfVertexRecordRefetches() {
return this.numberOfVertexRecordRefetches.get();
}
@Override
public void incrementNumberOfVertexRecordRefetches() {
this.numberOfVertexRecordRefetches.incrementAndGet();
}
@Override
public void resetNumberOfVertexRecordRefetches() {
this.numberOfVertexRecordRefetches.set(0);
}
}
| 883 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
ChronoGraph.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/structure/ChronoGraph.java | package org.chronos.chronograph.api.structure;
import com.google.common.collect.Iterators;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.Graph.*;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.util.GraphFactoryClass;
import org.chronos.chronodb.api.ChronoDBConstants;
import org.chronos.chronodb.api.DumpOption;
import org.chronos.chronodb.api.Order;
import org.chronos.chronograph.api.ChronoGraphFactory;
import org.chronos.chronograph.api.branch.ChronoGraphBranchManager;
import org.chronos.chronograph.api.branch.GraphBranch;
import org.chronos.chronograph.api.history.ChronoGraphHistoryManager;
import org.chronos.chronograph.api.index.ChronoGraphIndexManager;
import org.chronos.chronograph.api.iterators.ChronoGraphIterators;
import org.chronos.chronograph.api.iterators.ChronoGraphRootIteratorBuilder;
import org.chronos.chronograph.api.maintenance.ChronoGraphMaintenanceManager;
import org.chronos.chronograph.api.schema.ChronoGraphSchemaManager;
import org.chronos.chronograph.api.statistics.ChronoGraphStatisticsManager;
import org.chronos.chronograph.api.transaction.ChronoGraphTransactionManager;
import org.chronos.chronograph.api.transaction.trigger.ChronoGraphTriggerManager;
import org.chronos.chronograph.internal.api.configuration.ChronoGraphConfiguration;
import org.chronos.chronograph.internal.impl.factory.ChronoGraphFactoryImpl;
import java.io.File;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import static com.google.common.base.Preconditions.*;
import static org.apache.tinkerpop.gremlin.structure.Graph.*;
/**
* The main entry point into the ChronoGraph API. Represents the entire graph instance.
*
* <p>
* You can acquire an instance of this class through the static {@link ChronoGraph#FACTORY} field and by using the
* fluent graph builder API that it offers.
*
* @author martin.haeusler@uibk.ac.at -- Initial Contribution and API
*/
@OptIn(OptIn.SUITE_STRUCTURE_STANDARD)
@OptIn(OptIn.SUITE_PROCESS_STANDARD)
@OptOut(
test = "org.apache.tinkerpop.gremlin.structure.io.IoGraphTest",
method = "shouldReadWriteModernToFileWithHelpers",
specific = "graphml",
reason = "The Gremlin Test Suite has File I/O issues on Windows."
)
@OptOut(
test = "org.apache.tinkerpop.gremlin.structure.io.IoGraphTest",
method = "shouldReadWriteClassicToFileWithHelpers",
specific = "graphml",
reason = "The Gremlin Test Suite has File I/O issues on Windows."
)
@OptOut(
test = "org.apache.tinkerpop.gremlin.structure.io.IoGraphTest",
method = "shouldReadWriteModernToFileWithHelpers",
specific = "graphson",
reason = "The Gremlin Test Suite has File I/O issues on Windows."
)
@OptOut(
test = "org.apache.tinkerpop.gremlin.structure.io.IoGraphTest",
method = "shouldReadWriteClassicToFileWithHelpers",
specific = "graphson",
reason = "The Gremlin Test Suite has File I/O issues on Windows."
)
@OptOut(
test = "org.apache.tinkerpop.gremlin.structure.io.IoGraphTest",
method = "shouldReadWriteModernToFileWithHelpers",
specific = "gryo",
reason = "The Gremlin Test Suite has File I/O issues on Windows."
)
@OptOut(
test = "org.apache.tinkerpop.gremlin.structure.io.IoGraphTest",
method = "shouldReadWriteClassicToFileWithHelpers",
specific = "gryo",
reason = "The Gremlin Test Suite has File I/O issues on Windows."
)
@OptOut(
test = "org.apache.tinkerpop.gremlin.structure.io.IoTest$GraphMLTest",
method = "shouldProperlyEncodeWithGraphML",
reason = "The Gremlin Test Suite has File I/O issues on Windows."
)
@OptOut(
test = "org.apache.tinkerpop.gremlin.structure.GraphConstructionTest",
method = "shouldMaintainOriginalConfigurationObjectGivenToFactory",
reason = "ChronoGraph internally adds configuration properties, test checks only property count."
)
@OptOut(
test = "org.apache.tinkerpop.gremlin.structure.TransactionTest",
method = "shouldSupportMultipleThreadsOnTheSameTransaction",
reason = "ChronoGraph is full ACID. This test can only work by violating ACID."
)
@OptOut(
test = "org.apache.tinkerpop.gremlin.structure.TransactionTest",
method = "shouldNotReuseThreadedTransaction",
reason = "ChronoGraph is full ACID. This test can only work by violating ACID."
)
@OptOut(
test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.SubgraphTest$Traversals",
method = "g_V_withSideEffectXsgX_repeatXbothEXcreatedX_subgraphXsgX_outVX_timesX5X_name_dedup",
reason = "VertexProperty does not support user supplied identifiers in ChronoGraph, but this test requires that."
)
@OptOut(
test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.SubgraphTest$Traversals",
method = "g_V_withSideEffectXsgX_outEXknowsX_subgraphXsgX_name_capXsgX",
reason = "VertexProperty does not support user supplied identifiers in ChronoGraph, but this test requires that."
)
@OptOut(
test = "org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.EventStrategyProcessTest",
method = "shouldUseActualPropertyOfVertexPropertyWhenRemoved",
reason = "This test fetches a meta-property from a vertex-property, deletes it, and later" +
" asserts that the corresponding event has been fired correctly. To do so, it compares" +
" the contents of the event with the original property. As this property was removed," +
" the data for comparison is no longer there (Properties in ChronoGraph are mutable)." +
" Fixing this would require a major change that makes properties immutable."
)
@OptOut(
test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.AddVertexTest",
method = "g_V_hasLabelXpersonX_propertyXname_nullX",
reason = "This test requires management of property cardinalities in a schema, which ChronoGraph doesn't do." +
" Funnily enough, TinkerProp specifies that the cardinality extraction method is just a hint and need not" +
" be correct, but the test relies on that regardless."
)
@OptOut(
test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.MergeEdgeTest",
method = "g_mergeEXlabel_knows_out_marko_in_vadasX_optionXonCreate_created_YX_optionXonMatch_created_NX_exists_updated",
reason = "This test uses integers as Vertex IDs. We only support strings as custom Vertex IDs."
)
@OptOut(
test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.MergeEdgeTest",
method = "g_mergeEXlabel_knows_out_marko_in_vadasX_optionXonCreate_created_YX_optionXonMatch_created_NX",
reason = "This test uses integers as Vertex IDs. We only support strings as custom Vertex IDs."
)
@OptOut(
test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.MergeEdgeTest",
method = "g_mergeEXlabel_knows_out_marko_in_vadas_weight_05X_exists",
reason = "This test uses integers as Vertex IDs. We only support strings as custom Vertex IDs."
)
@OptOut(
test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.MergeEdgeTest",
method = "g_V_hasXperson_name_marko_X_mergeEXlabel_knowsX_optionXonCreate_created_YX_optionXonMatch_created_NX_exists_updated",
reason = "This test uses integers as Vertex IDs. We only support strings as custom Vertex IDs."
)
@OptOut(
test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.MergeEdgeTest",
method = "g_mergeEXlabel_knows_out_marko_in_vadasX",
reason = "This test uses integers as Vertex IDs. We only support strings as custom Vertex IDs."
)
@OptOut(
test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.MergeEdgeTest",
method = "g_mergeEXlabel_knows_out_marko_in_vadasX_optionXonCreate_created_YX_optionXonMatch_created_NX_exists",
reason = "This test uses integers as Vertex IDs. We only support strings as custom Vertex IDs."
)
@OptOut(
test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.MergeEdgeTest",
method = "g_injectXlabel_knows_out_marko_in_vadasX_mergeE",
reason = "This test uses integers as Vertex IDs. We only support strings as custom Vertex IDs."
)
@OptOut(
test = "org.apache.tinkerpop.gremlin.process.traversal.CoreTraversalTest",
method = "shouldAllowIdsOfMixedTypes",
reason = "We do not support traversal.V() with mixed types."
)
@OptOut(
test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.OrderTest",
method = "g_V_orXhasLabelXpersonX_hasXsoftware_name_lopXX_order_byXageX",
reason = "ChronoGraph has explicit sort positions for NULL/absent values. This test demands that NULL/absent values are discarded during sorting."
)
@OptOut(
test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.MergeEdgeTest",
method = "g_mergeE_with_outV_inV_options",
reason = "ChronoGraph does not support custom IDs of type integer."
)
@GraphFactoryClass(ChronoGraphFactoryImpl.class)
public interface ChronoGraph extends Graph {
/**
* The main {@link ChronoGraphFactory} instance to create new graphs with.
*/
public static final ChronoGraphFactory FACTORY = ChronoGraphFactory.INSTANCE;
// =================================================================================================================
// CONFIGURATION
// =================================================================================================================
/**
* Returns the {@link ChronoGraphConfiguration} associated with this graph instance.
*
* <p>
* This is similar to {@link #configuration()}, except that this method returns an object that provides handy
* accessor methods for the underlying data.
*
* @return The graph configuration.
*/
public ChronoGraphConfiguration getChronoGraphConfiguration();
// =====================================================================================================================
// GRAPH CLOSING
// =====================================================================================================================
/**
* Closes this graph instance.
*
* <p>
* After closing a graph, no further data can be retrieved from or stored in it. Calling this method on an already
* closed graph has no effect.
*/
@Override
public void close(); // note: redefined from Graph without 'throws Exception' declaration.
/**
* Checks if this graph instance is closed or not.
*
* <p>
* If this method returns <code>true</code>, data access methods on the graph will throw exceptions when attempting
* to execute them.
*
* @return <code>true</code> if closed, <code>false</code> if it is still open.
*/
public boolean isClosed();
// =====================================================================================================================
// TRANSACTION HANDLING
// =====================================================================================================================
/**
* Returns the "now" timestamp, i.e. the timestamp of the latest commit on the graph, on the master branch.
*
* <p>
* Requesting a transaction on this timestamp will always deliver a transaction on the "head" revision.
*
* @return The "now" timestamp. Will be zero if no commit has been taken place yet, otherwise a positive value.
*/
public long getNow();
/**
* Returns the "now" timestamp, i.e. the timestamp of the latest commit on the graph, on the given branch.
*
* <p>
* Requesting a transaction on this timestamp will always deliver a transaction on the "head" revision.
*
* @param branchName The name of the branch to retrieve the "now" timestamp for. Must refer to an existing branch. Must not
* be <code>null</code>.
* @return The "now" timestamp on the given branch. If no commits have occurred on the branch yet, this method
* returns zero (master branch) or the branching timestamp (non-master branch), otherwise a positive value.
*/
public long getNow(final String branchName);
/**
* Returns the {@linkplain ChronoGraphTransactionManager transaction manager} associated with this graph instance.
*
* @return The transaction manager. Never <code>null</code>.
*/
@Override
public ChronoGraphTransactionManager tx();
// =================================================================================================================
// TINKERPOP EXTENSION METHODS (CONVENIENCE METHODS)
// =================================================================================================================
/**
* Returns the single {@link Vertex} with the given ID, or <code>null</code> if there is no such vertex.
*
* <p>
* This is a convenience method which forwards to the standard TinkerPop {@link #vertices(Object...)} method.
* </p>
*
* @param id The ID of the vertex. Must not be <code>null</code>. Can be either a {@link String} containing the ID, or the {@link Vertex} itself.
* @return The vertex with the given ID, or <code>null</code>.
* @see #vertices(Object...)
*/
public default Vertex vertex(Object id) {
checkNotNull(id, "Precondition violation - argument 'id' must not be NULL!");
return Iterators.getOnlyElement(this.vertices(id), null);
}
/**
* Returns the single {@link Edge} with the given ID, or <code>null</code> if there is no such edge.
*
* <p>
* This is a convenience method which forwards to the standard TinkerPop {@link #edges(Object...)} method.
* </p>
*
* @param id The ID of the edge. Must not be <code>null</code>. Can be either a {@link String} containing the ID, or the {@link Edge} itself.
* @return The edge with the given ID, or <code>null</code>.
* @see #edges(Object...)
*/
public default Edge edge(Object id) {
checkNotNull(id, "Precondition violation - argument 'id' must not be NULL!");
return Iterators.getOnlyElement(this.edges(id), null);
}
// =====================================================================================================================
// TEMPORAL ACTIONS
// =====================================================================================================================
/**
* Returns the history of the vertex with the given id, in the form of timestamps.
*
* <p>
* Each returned timestamp reflects a point in time when a commit occurred that changed the vertex in question. The
* same commit may have simultaneously also changed other elements in the graph. Opening a transaction on this
* timestamp, and retrieving the vertex by id from it will produce the vertex in the state at that point in time.
*
* <p>
* <b>NOTE:</b> This method requires an open transaction! The returned history will always be the history up to and
* including (but not after) the transaction timestamp!
*
* @param vertexId The id of the vertex to fetch the history timestamps for. Must not be <code>null</code>.
* @return An iterator over the history timestamps. May be empty, but never <code>null</code>. The history will be in descending
* order (highest timestamp first).
*/
public default Iterator<Long> getVertexHistory(Object vertexId) {
this.tx().readWrite();
long timestamp = this.tx().getCurrentTransaction().getTimestamp();
return this.getVertexHistory(vertexId, 0, timestamp, Order.DESCENDING);
}
/**
* Returns the history of the vertex with the given id, in the form of timestamps.
*
* <p>
* Each returned timestamp reflects a point in time when a commit occurred that changed the vertex in question. The
* same commit may have simultaneously also changed other elements in the graph. Opening a transaction on this
* timestamp, and retrieving the vertex by id from it will produce the vertex in the state at that point in time.
*
* <p>
* <b>NOTE:</b> This method requires an open transaction! The returned history will always be the history up to and
* including (but not after) the transaction timestamp!
*
* @param vertexId The id of the vertex to fetch the history timestamps for. Must not be <code>null</code>.
* @param order The desired ordering of the history. Must not be <code>null</code>.
* @return An iterator over the history timestamps. May be empty, but never <code>null</code>. The history will be in descending
* order (highest timestamp first).
*/
public default Iterator<Long> getVertexHistory(Object vertexId, Order order) {
this.tx().readWrite();
long timestamp = this.tx().getCurrentTransaction().getTimestamp();
return this.getVertexHistory(vertexId, 0, timestamp, order);
}
/**
* Returns the history of the vertex with the given id, in the form of timestamps.
*
* <p>
* Each returned timestamp reflects a point in time when a commit occurred that changed the vertex in question. The
* same commit may have simultaneously also changed other elements in the graph. Opening a transaction on this
* timestamp, and retrieving the vertex by id from it will produce the vertex in the state at that point in time.
*
* <p>
* <b>NOTE:</b> This method requires an open transaction! The returned history will always be the history up to and
* including (but not after) the transaction timestamp!
*
* @param vertexId The id of the vertex to fetch the history timestamps for. Must not be <code>null</code>.
* @param lowerBound The lower bound of timestamps to consider (inclusive). Must be less than or equal to <code>upperBound</code>. Must not be negative.
* @param upperBound The upper bound of timestamps to consider (inclusive). Must be less than or equal to <code>lowerBound</code>. Must not be negative.
* @return An iterator over the history timestamps. May be empty, but never <code>null</code>. The history will be in descending
* order (highest timestamp first).
*/
public default Iterator<Long> getVertexHistory(Object vertexId, long lowerBound, long upperBound) {
return this.getVertexHistory(vertexId, lowerBound, upperBound, Order.DESCENDING);
}
/**
* Returns the history of the vertex with the given id, in the form of timestamps.
*
* <p>
* Each returned timestamp reflects a point in time when a commit occurred that changed the vertex in question. The
* same commit may have simultaneously also changed other elements in the graph. Opening a transaction on this
* timestamp, and retrieving the vertex by id from it will produce the vertex in the state at that point in time.
*
* <p>
* <b>NOTE:</b> This method requires an open transaction! The returned history will always be the history up to and
* including (but not after) the transaction timestamp!
*
* @param vertexId The id of the vertex to fetch the history timestamps for. Must not be <code>null</code>.
* @param lowerBound The lower bound of timestamps to consider (inclusive). Must be less than or equal to <code>upperBound</code>. Must not be negative.
* @param upperBound The upper bound of timestamps to consider (inclusive). Must be less than or equal to <code>lowerBound</code>. Must not be negative.
* @param order The desired ordering of the history. Must not be <code>null</code>.
* @return An iterator over the history timestamps. May be empty, but never <code>null</code>.
*/
public Iterator<Long> getVertexHistory(Object vertexId, long lowerBound, long upperBound, Order order);
/**
* Returns the history of the given vertex, in the form of timestamps.
*
* <p>
* Each returned timestamp reflects a point in time when a commit occurred that changed the vertex in question. The
* same commit may have simultaneously also changed other elements in the graph. Opening a transaction on this
* timestamp, and retrieving the vertex by id from it will produce the vertex in the state at that point in time.
*
* <p>
* <b>NOTE:</b> This method requires an open transaction! The returned history will always be the history up to and
* including (but not after) the transaction timestamp!
*
* @param vertex The vertex to fetch the history timestamps for. Must not be <code>null</code>.
* @return An iterator over the history timestamps. May be empty, but never <code>null</code>. The history will be in descending
* order (highest timestamp first).
*/
public default Iterator<Long> getVertexHistory(Vertex vertex) {
this.tx().readWrite();
long timestamp = this.tx().getCurrentTransaction().getTimestamp();
return this.getVertexHistory(vertex.id(), 0, timestamp, Order.DESCENDING);
}
/**
* Returns the history of the given vertex, in the form of timestamps.
*
* <p>
* Each returned timestamp reflects a point in time when a commit occurred that changed the vertex in question. The
* same commit may have simultaneously also changed other elements in the graph. Opening a transaction on this
* timestamp, and retrieving the vertex by id from it will produce the vertex in the state at that point in time.
*
* <p>
* <b>NOTE:</b> This method requires an open transaction! The returned history will always be the history up to and
* including (but not after) the transaction timestamp!
*
* @param vertex The vertex to fetch the history timestamps for. Must not be <code>null</code>.
* @param lowerBound The lower bound of timestamps to consider (inclusive). Must be less than or equal to <code>upperBound</code>. Must not be negative.
* @param upperBound The upper bound of timestamps to consider (inclusive). Must be less than or equal to <code>lowerBound</code>. Must not be negative.
* @return An iterator over the history timestamps. May be empty, but never <code>null</code>. The history will be in descending
* order (highest timestamp first).
*/
public default Iterator<Long> getVertexHistory(Vertex vertex, long lowerBound, long upperBound) {
return this.getVertexHistory(vertex.id(), lowerBound, upperBound, Order.DESCENDING);
}
/**
* Returns the history of the given vertex, in the form of timestamps.
*
* <p>
* Each returned timestamp reflects a point in time when a commit occurred that changed the vertex in question. The
* same commit may have simultaneously also changed other elements in the graph. Opening a transaction on this
* timestamp, and retrieving the vertex by id from it will produce the vertex in the state at that point in time.
*
* <p>
* <b>NOTE:</b> This method requires an open transaction! The returned history will always be the history up to and
* including (but not after) the transaction timestamp!
*
* @param vertex The vertex to fetch the history timestamps for. Must not be <code>null</code>.
* @param order The desired ordering of the history. Must not be <code>null</code>.
* @return An iterator over the history timestamps. May be empty, but never <code>null</code>.
*/
public default Iterator<Long> getVertexHistory(Vertex vertex, Order order) {
this.tx().readWrite();
long timestamp = this.tx().getCurrentTransaction().getTimestamp();
return this.getVertexHistory(vertex.id(), 0, timestamp, order);
}
/**
* Returns the history of the given vertex, in the form of timestamps.
*
* <p>
* Each returned timestamp reflects a point in time when a commit occurred that changed the vertex in question. The
* same commit may have simultaneously also changed other elements in the graph. Opening a transaction on this
* timestamp, and retrieving the vertex by id from it will produce the vertex in the state at that point in time.
*
* <p>
* <b>NOTE:</b> This method requires an open transaction! The returned history will always be the history up to and
* including (but not after) the transaction timestamp!
*
* @param vertex The vertex to fetch the history timestamps for. Must not be <code>null</code>.
* @param lowerBound The lower bound of timestamps to consider (inclusive). Must be less than or equal to <code>upperBound</code>. Must not be negative.
* @param upperBound The upper bound of timestamps to consider (inclusive). Must be less than or equal to <code>lowerBound</code>. Must not be negative.
* @param order The desired ordering of the history. Must not be <code>null</code>.
* @return An iterator over the history timestamps. May be empty, but never <code>null</code>.
*/
public default Iterator<Long> getVertexHistory(Vertex vertex, long lowerBound, long upperBound, Order order) {
return this.getVertexHistory(vertex.id(), lowerBound, upperBound, order);
}
/**
* Returns the history of the edge with the given id, in the form of timestamps.
*
* <p>
* Each returned timestamp reflects a point in time when a commit occurred that changed the edge in question. The
* same commit may have simultaneously also changed other elements in the graph. Opening a transaction on this
* timestamp, and retrieving the edge by id from it will produce the vertex in the state at that point in time.
*
* <p>
* <b>NOTE:</b> This method requires an open transaction! The returned history will always be the history up to and
* including (but not after) the transaction timestamp!
*
* @param edgeId The id of the edge to fetch the history timestamps for. Must not be <code>null</code>.
* @return An iterator over the history timestamps. May be empty, but never <code>null</code>. The history will be in descending
* order (highest timestamp first).
*/
public default Iterator<Long> getEdgeHistory(Object edgeId) {
this.tx().readWrite();
long timestamp = this.tx().getCurrentTransaction().getTimestamp();
return this.getEdgeHistory(edgeId, 0, timestamp, Order.DESCENDING);
}
/**
* Returns the history of the edge with the given id, in the form of timestamps.
*
* <p>
* Each returned timestamp reflects a point in time when a commit occurred that changed the edge in question. The
* same commit may have simultaneously also changed other elements in the graph. Opening a transaction on this
* timestamp, and retrieving the edge by id from it will produce the vertex in the state at that point in time.
*
* <p>
* <b>NOTE:</b> This method requires an open transaction! The returned history will always be the history up to and
* including (but not after) the transaction timestamp!
*
* @param edgeId The id of the edge to fetch the history timestamps for. Must not be <code>null</code>.
* @param order The desired ordering of the history. Must not be <code>null</code>.
* @return An iterator over the history timestamps. May be empty, but never <code>null</code>.
*/
public default Iterator<Long> getEdgeHistory(Object edgeId, Order order) {
this.tx().readWrite();
long timestamp = this.tx().getCurrentTransaction().getTimestamp();
return this.getEdgeHistory(edgeId, timestamp, 0, order);
}
/**
* Returns the history of the edge with the given id, in the form of timestamps.
*
* <p>
* Each returned timestamp reflects a point in time when a commit occurred that changed the edge in question. The
* same commit may have simultaneously also changed other elements in the graph. Opening a transaction on this
* timestamp, and retrieving the edge by id from it will produce the vertex in the state at that point in time.
*
* <p>
* <b>NOTE:</b> This method requires an open transaction! The returned history will always be the history up to and
* including (but not after) the transaction timestamp!
*
* @param edgeId The id of the edge to fetch the history timestamps for. Must not be <code>null</code>.
* @param lowerBound The lower bound of timestamps to consider (inclusive). Must be less than or equal to <code>upperBound</code>. Must not be negative.
* @param upperBound The upper bound of timestamps to consider (inclusive). Must be less than or equal to <code>lowerBound</code>. Must not be negative.
* @return An iterator over the history timestamps. May be empty, but never <code>null</code>. The history will be in descending
* order (highest timestamp first).
*/
public default Iterator<Long> getEdgeHistory(Object edgeId, long lowerBound, long upperBound) {
return this.getEdgeHistory(edgeId, lowerBound, upperBound, Order.DESCENDING);
}
/**
* Returns the history of the edge with the given id, in the form of timestamps.
*
* <p>
* Each returned timestamp reflects a point in time when a commit occurred that changed the edge in question. The
* same commit may have simultaneously also changed other elements in the graph. Opening a transaction on this
* timestamp, and retrieving the edge by id from it will produce the vertex in the state at that point in time.
*
* <p>
* <b>NOTE:</b> This method requires an open transaction! The returned history will always be the history up to and
* including (but not after) the transaction timestamp!
*
* @param edgeId The id of the edge to fetch the history timestamps for. Must not be <code>null</code>.
* @param lowerBound The lower bound of timestamps to consider (inclusive). Must be less than or equal to <code>upperBound</code>. Must not be negative.
* @param upperBound The upper bound of timestamps to consider (inclusive). Must be less than or equal to <code>lowerBound</code>. Must not be negative.
* @param order The desired ordering of the history. Must not be <code>null</code>.
* @return An iterator over the history timestamps. May be empty, but never <code>null</code>.
*/
public Iterator<Long> getEdgeHistory(Object edgeId, long lowerBound, long upperBound, Order order);
/**
* Returns the history of the given edge, in the form of timestamps.
*
* <p>
* Each returned timestamp reflects a point in time when a commit occurred that changed the edge in question. The
* same commit may have simultaneously also changed other elements in the graph. Opening a transaction on this
* timestamp, and retrieving the edge by id from it will produce the edge in the state at that point in time.
*
* <p>
* <b>NOTE:</b> This method requires an open transaction! The returned history will always be the history up to and
* including (but not after) the transaction timestamp!
*
* @param edge The edge to fetch the history timestamps for. Must not be <code>null</code>.
* @return An iterator over the history timestamps. May be empty, but never <code>null</code>. The history will be in descending
* order (highest timestamp first).
*/
public default Iterator<Long> getEdgeHistory(Edge edge) {
this.tx().readWrite();
long timestamp = this.tx().getCurrentTransaction().getTimestamp();
return this.getEdgeHistory(edge.id(), 0, timestamp, Order.DESCENDING);
}
/**
* Returns the history of the given edge, in the form of timestamps.
*
* <p>
* Each returned timestamp reflects a point in time when a commit occurred that changed the edge in question. The
* same commit may have simultaneously also changed other elements in the graph. Opening a transaction on this
* timestamp, and retrieving the edge by id from it will produce the edge in the state at that point in time.
*
* <p>
* <b>NOTE:</b> This method requires an open transaction! The returned history will always be the history up to and
* including (but not after) the transaction timestamp!
*
* @param edge The edge to fetch the history timestamps for. Must not be <code>null</code>.
* @param order The desired ordering of the history. Must not be <code>null</code>.
* @return An iterator over the history timestamps. May be empty, but never <code>null</code>.
*/
public default Iterator<Long> getEdgeHistory(Edge edge, Order order) {
this.tx().readWrite();
long timestamp = this.tx().getCurrentTransaction().getTimestamp();
return this.getEdgeHistory(edge.id(), 0, timestamp, order);
}
/**
* Returns the history of the given edge, in the form of timestamps.
*
* <p>
* Each returned timestamp reflects a point in time when a commit occurred that changed the edge in question. The
* same commit may have simultaneously also changed other elements in the graph. Opening a transaction on this
* timestamp, and retrieving the edge by id from it will produce the edge in the state at that point in time.
*
* <p>
* <b>NOTE:</b> This method requires an open transaction! The returned history will always be the history up to and
* including (but not after) the transaction timestamp!
*
* @param edge The edge to fetch the history timestamps for. Must not be <code>null</code>.
* @param lowerBound The lower bound of timestamps to consider (inclusive). Must be less than or equal to <code>upperBound</code>. Must not be negative.
* @param upperBound The upper bound of timestamps to consider (inclusive). Must be less than or equal to <code>lowerBound</code>. Must not be negative.
* @return An iterator over the history timestamps. May be empty, but never <code>null</code>. The history will be in descending
* order (highest timestamp first).
*/
public default Iterator<Long> getEdgeHistory(Edge edge, long lowerBound, long upperBound) {
return this.getEdgeHistory(edge.id(), lowerBound, upperBound, Order.DESCENDING);
}
/**
* Returns the history of the given edge, in the form of timestamps.
*
* <p>
* Each returned timestamp reflects a point in time when a commit occurred that changed the edge in question. The
* same commit may have simultaneously also changed other elements in the graph. Opening a transaction on this
* timestamp, and retrieving the edge by id from it will produce the edge in the state at that point in time.
*
* <p>
* <b>NOTE:</b> This method requires an open transaction! The returned history will always be the history up to and
* including (but not after) the transaction timestamp!
* </p>
*
* @param edge The edge to fetch the history timestamps for. Must not be <code>null</code>.
* @param lowerBound The lower bound of timestamps to consider (inclusive). Must be less than or equal to <code>upperBound</code>. Must not be negative.
* @param upperBound The upper bound of timestamps to consider (inclusive). Must be less than or equal to <code>lowerBound</code>. Must not be negative.
* @param order The desired ordering of the history. Must not be <code>null</code>.
* @return An iterator over the history timestamps. May be empty, but never <code>null</code>.
*/
public default Iterator<Long> getEdgeHistory(Edge edge, long lowerBound, long upperBound, Order order) {
return this.getEdgeHistory(edge.id(), lowerBound, upperBound, order);
}
/**
* Returns the last modification timestamp for the given <code>vertex</code>, up to and including the transaction timestamp.
*
* <p>
* <b>NOTE:</b> This method requires an open transaction!
* </p>
*
* @param vertex The vertex to get the last modification timestamp for. Must not be <code>null</code>.
* @return The last modification timestamp. May be negative if the vertex has never been created (up to and including the transaction timestamp).
*/
public long getLastModificationTimestampOfVertex(Vertex vertex);
/**
* Returns the last modification timestamp for the given <code>vertexId</code>, up to and including the transaction timestamp.
*
* <p>
* <b>NOTE:</b> This method requires an open transaction!
* </p>
*
* @param vertexId The ID of the vertex to get the last modification timestamp for. Must not be <code>null</code>.
* @return The last modification timestamp. May be negative if the vertex has never been created (up to and including the transaction timestamp).
*/
public long getLastModificationTimestampOfVertex(Object vertexId);
/**
* Returns the last modification timestamp for the given <code>edge</code>, up to and including the transaction timestamp.
*
* <p>
* <b>NOTE:</b> This method requires an open transaction!
* </p>
*
* @param edge The edge to get the last modification timestamp for. Must not be <code>null</code>.
* @return The last modification timestamp. May be negative if the edge has never been created (up to and including the transaction timestamp).
*/
public long getLastModificationTimestampOfEdge(Edge edge);
/**
* Returns the last modification timestamp for the given <code>edgeId</code>, up to and including the transaction timestamp.
*
* <p>
* <b>NOTE:</b> This method requires an open transaction!
* </p>
*
* @param edgeId The ID of the edge to get the last modification timestamp for. Must not be <code>null</code>.
* @return The last modification timestamp. May be negative if the edge has never been created (up to and including the transaction timestamp).
*/
public long getLastModificationTimestampOfEdge(Object edgeId);
/**
* Returns an iterator over all vertex modifications that have taken place in the given time range.
*
* @param timestampLowerBound The lower bound of the time range to search in. Must not be negative. Must be less than or equal to
* <code>timestampUpperBound</code>. Must be less than or equal to the transaction timestamp.
* @param timestampUpperBound The upper bound of the time range to search in. Must not be negative. Must be greater than or equal to
* <code>timestampLowerBound</code>. Must be less than or equal to the transaction timestamp.
* @return An iterator over pairs, containing the change timestamp at the first and the modified vertex id at the
* second position. May be empty, but never <code>null</code>.
*/
public Iterator<Pair<Long, String>> getVertexModificationsBetween(final long timestampLowerBound,
final long timestampUpperBound);
/**
* Returns an iterator over all edge modifications that have taken place in the given time range.
*
* @param timestampLowerBound The lower bound of the time range to search in. Must not be negative. Must be less than or equal to
* <code>timestampUpperBound</code>. Must be less than or equal to the transaction timestamp.
* @param timestampUpperBound The upper bound of the time range to search in. Must not be negative. Must be greater than or equal to
* <code>timestampLowerBound</code>. Must be less than or equal to the transaction timestamp.
* @return An iterator over pairs, containing the change timestamp at the first and the modified edge id at the
* second position. May be empty, but never <code>null</code>.
*/
public Iterator<Pair<Long, String>> getEdgeModificationsBetween(final long timestampLowerBound,
final long timestampUpperBound);
/**
* Returns the metadata for the commit on the {@linkplain ChronoDBConstants#MASTER_BRANCH_IDENTIFIER master} branch
* at the given timestamp.
*
* <p>
* This search will include origin branches (recursively), if the timestamp is before the branching timestamp.
*
* @param timestamp The timestamp to get the commit metadata for. Must match the commit timestamp exactly. Must not be
* negative.
* @return The commit metadata. May be <code>null</code> if there was no metadata for the commit, or there has not
* been a commit at the specified branch and timestamp.
*/
public default Object getCommitMetadata(final long timestamp) {
return this.getCommitMetadata(ChronoDBConstants.MASTER_BRANCH_IDENTIFIER, timestamp);
}
/**
* Returns the metadata for the commit on the given branch at the given timestamp.
*
* <p>
* This search will include origin branches (recursively), if the timestamp is before the branching timestamp.
*
* @param branch The branch to search for the commit metadata in. Must not be <code>null</code>.
* @param timestamp The timestamp to get the commit metadata for. Must match the commit timestamp exactly. Must not be
* negative.
* @return The commit metadata. May be <code>null</code> if there was no metadata for the commit, or there has not
* been a commit at the specified branch and timestamp.
*/
public Object getCommitMetadata(String branch, long timestamp);
/**
* Returns an iterator over all timestamps where commits have occurred on the
* {@linkplain ChronoDBConstants#MASTER_BRANCH_IDENTIFIER master} branch, bounded between <code>from</code> and
* <code>to</code>, in descending order.
*
* <p>
* If the <code>from</code> value is greater than the <code>to</code> value, this method always returns an empty
* iterator.
*
* @param from The lower bound of the time range to look for commits in (inclusive). Must not be negative. Must be
* less than or equal to the timestamp of this transaction.
* @param to The upper bound of the time range to look for commits in (inclusive). Must not be negative. Must be
* less than or equal to the timestamp of this transaction.
* @return The iterator over the commit timestamps in the given time range, in descending order. May be empty, but
* never <code>null</code>.
*/
default Iterator<Long> getCommitTimestampsBetween(final long from, final long to) {
return getCommitTimestampsBetween(from, to, false);
}
/**
* Returns an iterator over all timestamps where commits have occurred on the
* {@linkplain ChronoDBConstants#MASTER_BRANCH_IDENTIFIER master} branch, bounded between <code>from</code> and
* <code>to</code>, in descending order.
*
* <p>
* If the <code>from</code> value is greater than the <code>to</code> value, this method always returns an empty
* iterator.
*
* @param from The lower bound of the time range to look for commits in (inclusive). Must not be negative. Must be
* less than or equal to the timestamp of this transaction.
* @param to The upper bound of the time range to look for commits in (inclusive). Must not be negative. Must be
* less than or equal to the timestamp of this transaction.
* @param includeSystemInternalCommits Whether or not to include system-internal commits.
* @return The iterator over the commit timestamps in the given time range, in descending order. May be empty, but
* never <code>null</code>.
*/
public default Iterator<Long> getCommitTimestampsBetween(final long from, final long to, final boolean includeSystemInternalCommits) {
return this.getCommitTimestampsBetween(ChronoDBConstants.MASTER_BRANCH_IDENTIFIER, from, to, includeSystemInternalCommits);
}
/**
* Returns an iterator over all timestamps where commits have occurred on the given branch, bounded between
* <code>from</code> and <code>to</code>, in descending order.
*
* <p>
* If the <code>from</code> value is greater than the <code>to</code> value, this method always returns an empty
* iterator.
*
* @param branch The name of the branch to consider. Must not be <code>null</code>, must refer to an existing branch.
* @param from The lower bound of the time range to look for commits in (inclusive). Must not be negative. Must be
* less than or equal to the timestamp of this transaction.
* @param to The upper bound of the time range to look for commits in (inclusive). Must not be negative. Must be
* less than or equal to the timestamp of this transaction.
* @return The iterator over the commit timestamps in the given time range, in descending order. May be empty, but
* never <code>null</code>.
*/
default Iterator<Long> getCommitTimestampsBetween(final String branch, final long from, final long to) {
return getCommitTimestampsBetween(branch, from, to, false);
}
/**
* Returns an iterator over all timestamps where commits have occurred on the given branch, bounded between
* <code>from</code> and <code>to</code>, in descending order.
*
* <p>
* If the <code>from</code> value is greater than the <code>to</code> value, this method always returns an empty
* iterator.
*
* @param branch The name of the branch to consider. Must not be <code>null</code>, must refer to an existing branch.
* @param from The lower bound of the time range to look for commits in (inclusive). Must not be negative. Must be
* less than or equal to the timestamp of this transaction.
* @param to The upper bound of the time range to look for commits in (inclusive). Must not be negative. Must be
* less than or equal to the timestamp of this transaction.
* @param includeSystemInternalCommits Whether or not to include system-internal commits.
* @return The iterator over the commit timestamps in the given time range, in descending order. May be empty, but
* never <code>null</code>.
*/
public default Iterator<Long> getCommitTimestampsBetween(final String branch, final long from, final long to, final boolean includeSystemInternalCommits) {
return this.getCommitTimestampsBetween(branch, from, to, Order.DESCENDING, includeSystemInternalCommits);
}
/**
* Returns an iterator over all timestamps where commits have occurred on the
* {@linkplain ChronoDBConstants#MASTER_BRANCH_IDENTIFIER master} branch, bounded between <code>from</code> and
* <code>to</code>.
*
* <p>
* If the <code>from</code> value is greater than the <code>to</code> value, this method always returns an empty
* iterator.
*
* @param from The lower bound of the time range to look for commits in (inclusive). Must not be negative. Must be
* less than or equal to the timestamp of this transaction.
* @param to The upper bound of the time range to look for commits in (inclusive). Must not be negative. Must be
* less than or equal to the timestamp of this transaction.
* @param order The order of the returned timestamps. Must not be <code>null</code>.
* @return The iterator over the commit timestamps in the given time range. May be empty, but never
* <code>null</code>.
*/
default Iterator<Long> getCommitTimestampsBewteen(final long from, final long to, final Order order) {
return getCommitTimestampsBewteen(from, to, order, false);
}
/**
* Returns an iterator over all timestamps where commits have occurred on the
* {@linkplain ChronoDBConstants#MASTER_BRANCH_IDENTIFIER master} branch, bounded between <code>from</code> and
* <code>to</code>.
*
* <p>
* If the <code>from</code> value is greater than the <code>to</code> value, this method always returns an empty
* iterator.
*
* @param from The lower bound of the time range to look for commits in (inclusive). Must not be negative. Must be
* less than or equal to the timestamp of this transaction.
* @param to The upper bound of the time range to look for commits in (inclusive). Must not be negative. Must be
* less than or equal to the timestamp of this transaction.
* @param order The order of the returned timestamps. Must not be <code>null</code>.
* @param includeSystemInternalCommits Whether or not to include system-internal commits.
* @return The iterator over the commit timestamps in the given time range. May be empty, but never
* <code>null</code>.
*/
public default Iterator<Long> getCommitTimestampsBewteen(final long from, final long to, final Order order, final boolean includeSystemInternalCommits) {
return this.getCommitTimestampsBetween(ChronoDBConstants.MASTER_BRANCH_IDENTIFIER, from, to, order, includeSystemInternalCommits);
}
/**
* Returns an iterator over all timestamps where commits have occurred on the
* {@linkplain ChronoDBConstants#MASTER_BRANCH_IDENTIFIER master} branch, bounded between <code>from</code> and
* <code>to</code>.
*
* <p>
* If the <code>from</code> value is greater than the <code>to</code> value, this method always returns an empty
* iterator.
*
* @param from The lower bound of the time range to look for commits in (inclusive). Must not be negative. Must be
* less than or equal to the timestamp of this transaction.
* @param to The upper bound of the time range to look for commits in (inclusive). Must not be negative. Must be
* less than or equal to the timestamp of this transaction.
* @param order The order of the returned timestamps. Must not be <code>null</code>.
* @return The iterator over the commit timestamps in the given time range. May be empty, but never
* <code>null</code>.
*/
default Iterator<Long> getCommitTimestampsBetween(final long from, final long to, final Order order) {
return getCommitTimestampsBetween(from, to, order, false);
}
/**
* Returns an iterator over all timestamps where commits have occurred on the
* {@linkplain ChronoDBConstants#MASTER_BRANCH_IDENTIFIER master} branch, bounded between <code>from</code> and
* <code>to</code>.
*
* <p>
* If the <code>from</code> value is greater than the <code>to</code> value, this method always returns an empty
* iterator.
*
* @param from The lower bound of the time range to look for commits in (inclusive). Must not be negative. Must be
* less than or equal to the timestamp of this transaction.
* @param to The upper bound of the time range to look for commits in (inclusive). Must not be negative. Must be
* less than or equal to the timestamp of this transaction.
* @param order The order of the returned timestamps. Must not be <code>null</code>.
* @param includeSystemInternalCommits Whether or not to include system-internal commits.
* @return The iterator over the commit timestamps in the given time range. May be empty, but never
* <code>null</code>.
*/
public default Iterator<Long> getCommitTimestampsBetween(final long from, final long to, final Order order, final boolean includeSystemInternalCommits) {
return this.getCommitTimestampsBetween(ChronoDBConstants.MASTER_BRANCH_IDENTIFIER, from, to, order, includeSystemInternalCommits);
}
/**
* Returns an iterator over all timestamps where commits have occurred, bounded between <code>from</code> and
* <code>to</code>.
*
* <p>
* If the <code>from</code> value is greater than the <code>to</code> value, this method always returns an empty
* iterator.
*
* @param branch The name of the branch to consider. Must not be <code>null</code>, must refer to an existing branch.
* @param from The lower bound of the time range to look for commits in (inclusive). Must not be negative. Must be
* less than or equal to the timestamp of this transaction.
* @param to The upper bound of the time range to look for commits in (inclusive). Must not be negative. Must be
* less than or equal to the timestamp of this transaction.
* @param order The order of the returned timestamps. Must not be <code>null</code>.
* @return The iterator over the commit timestamps in the given time range. May be empty, but never
* <code>null</code>.
*/
default Iterator<Long> getCommitTimestampsBetween(final String branch, long from, long to, Order order) {
return getCommitTimestampsBetween(branch, from, to, order, false);
}
/**
* Returns an iterator over all timestamps where commits have occurred, bounded between <code>from</code> and
* <code>to</code>.
*
* <p>
* If the <code>from</code> value is greater than the <code>to</code> value, this method always returns an empty
* iterator.
*
* @param branch The name of the branch to consider. Must not be <code>null</code>, must refer to an existing branch.
* @param from The lower bound of the time range to look for commits in (inclusive). Must not be negative. Must be
* less than or equal to the timestamp of this transaction.
* @param to The upper bound of the time range to look for commits in (inclusive). Must not be negative. Must be
* less than or equal to the timestamp of this transaction.
* @param order The order of the returned timestamps. Must not be <code>null</code>.
* @param includeSystemInternalCommits Whether or not to include system-internal commits.
* @return The iterator over the commit timestamps in the given time range. May be empty, but never
* <code>null</code>.
*/
public Iterator<Long> getCommitTimestampsBetween(final String branch, long from, long to, Order order, final boolean includeSystemInternalCommits);
/**
* Returns an iterator over the entries of commit timestamp and associated metadata on the
* {@linkplain ChronoDBConstants#MASTER_BRANCH_IDENTIFIER master} branch, bounded between <code>from</code> and
* <code>to</code>, in descending order.
*
* <p>
* If the <code>from</code> value is greater than the <code>to</code> value, this method always returns an empty
* iterator.
*
* <p>
* Please keep in mind that some commits may not have any metadata attached. In this case, the
* {@linkplain Entry#getValue() value} component of the {@link Entry} will be set to <code>null</code>.
*
* @param from The lower bound of the time range to look for commits in (inclusive). Must not be negative. Must be
* less than or equal to the timestamp of this transaction.
* @param to The upper bound of the time range to look for commits in (inclusive). Must not be negative. Must be
* less than or equal to the timestamp of this transaction.
* @return An iterator over the commits in the given time range in descending order. The contained entries have the
* timestamp as the {@linkplain Entry#getKey() key} component and the associated metadata as their
* {@linkplain Entry#getValue() value} component (which may be <code>null</code>). May be empty, but never
* <code>null</code>.
*/
default Iterator<Entry<Long, Object>> getCommitMetadataBetween(final long from, final long to) {
return getCommitMetadataBetween(from, to, false);
}
/**
* Returns an iterator over the entries of commit timestamp and associated metadata on the
* {@linkplain ChronoDBConstants#MASTER_BRANCH_IDENTIFIER master} branch, bounded between <code>from</code> and
* <code>to</code>, in descending order.
*
* <p>
* If the <code>from</code> value is greater than the <code>to</code> value, this method always returns an empty
* iterator.
*
* <p>
* Please keep in mind that some commits may not have any metadata attached. In this case, the
* {@linkplain Entry#getValue() value} component of the {@link Entry} will be set to <code>null</code>.
*
* @param from The lower bound of the time range to look for commits in (inclusive). Must not be negative. Must be
* less than or equal to the timestamp of this transaction.
* @param to The upper bound of the time range to look for commits in (inclusive). Must not be negative. Must be
* less than or equal to the timestamp of this transaction.
* @param includeSystemInternalCommits Whether or not to include system-internal commits.
* @return An iterator over the commits in the given time range in descending order. The contained entries have the
* timestamp as the {@linkplain Entry#getKey() key} component and the associated metadata as their
* {@linkplain Entry#getValue() value} component (which may be <code>null</code>). May be empty, but never
* <code>null</code>.
*/
public default Iterator<Entry<Long, Object>> getCommitMetadataBetween(final long from, final long to, final boolean includeSystemInternalCommits) {
return this.getCommitMetadataBetween(ChronoDBConstants.MASTER_BRANCH_IDENTIFIER, from, to, Order.DESCENDING, includeSystemInternalCommits);
}
/**
* Returns an iterator over the entries of commit timestamp and associated metadata, bounded between
* <code>from</code> and <code>to</code>, in descending order.
*
* <p>
* If the <code>from</code> value is greater than the <code>to</code> value, this method always returns an empty
* iterator.
*
* <p>
* Please keep in mind that some commits may not have any metadata attached. In this case, the
* {@linkplain Entry#getValue() value} component of the {@link Entry} will be set to <code>null</code>.
*
* @param branch The name of the branch to consider. Must not be <code>null</code>, must refer to an existing branch.
* @param from The lower bound of the time range to look for commits in (inclusive). Must not be negative. Must be
* less than or equal to the timestamp of this transaction.
* @param to The upper bound of the time range to look for commits in (inclusive). Must not be negative. Must be
* less than or equal to the timestamp of this transaction.
* @return An iterator over the commits in the given time range in descending order. The contained entries have the
* timestamp as the {@linkplain Entry#getKey() key} component and the associated metadata as their
* {@linkplain Entry#getValue() value} component (which may be <code>null</code>). May be empty, but never
* <code>null</code>.
*/
default Iterator<Entry<Long, Object>> getCommitMetadataBetween(final String branch, final long from,
final long to) {
return getCommitMetadataBetween(branch, from, to, false);
}
/**
* Returns an iterator over the entries of commit timestamp and associated metadata, bounded between
* <code>from</code> and <code>to</code>, in descending order.
*
* <p>
* If the <code>from</code> value is greater than the <code>to</code> value, this method always returns an empty
* iterator.
*
* <p>
* Please keep in mind that some commits may not have any metadata attached. In this case, the
* {@linkplain Entry#getValue() value} component of the {@link Entry} will be set to <code>null</code>.
*
* @param branch The name of the branch to consider. Must not be <code>null</code>, must refer to an existing branch.
* @param from The lower bound of the time range to look for commits in (inclusive). Must not be negative. Must be
* less than or equal to the timestamp of this transaction.
* @param to The upper bound of the time range to look for commits in (inclusive). Must not be negative. Must be
* less than or equal to the timestamp of this transaction.
* @param includeSystemInternalCommits Whether or not to include system-internal commits.
* @return An iterator over the commits in the given time range in descending order. The contained entries have the
* timestamp as the {@linkplain Entry#getKey() key} component and the associated metadata as their
* {@linkplain Entry#getValue() value} component (which may be <code>null</code>). May be empty, but never
* <code>null</code>.
*/
public default Iterator<Entry<Long, Object>> getCommitMetadataBetween(final String branch, final long from,
final long to, final boolean includeSystemInternalCommits) {
return this.getCommitMetadataBetween(branch, from, to, Order.DESCENDING, includeSystemInternalCommits);
}
/**
* Returns an iterator over the entries of commit timestamp and associated metadata on the
* {@linkplain ChronoDBConstants#MASTER_BRANCH_IDENTIFIER master} branch, bounded between <code>from</code> and
* <code>to</code>.
*
* <p>
* If the <code>from</code> value is greater than the <code>to</code> value, this method always returns an empty
* iterator.
*
* <p>
* Please keep in mind that some commits may not have any metadata attached. In this case, the
* {@linkplain Entry#getValue() value} component of the {@link Entry} will be set to <code>null</code>.
*
* @param from The lower bound of the time range to look for commits in (inclusive). Must not be negative. Must be
* less than or equal to the timestamp of this transaction.
* @param to The upper bound of the time range to look for commits in (inclusive). Must not be negative. Must be
* less than or equal to the timestamp of this transaction.
* @param order The order of the returned commits. Must not be <code>null</code>.
* @return An iterator over the commits in the given time range. The contained entries have the timestamp as the
* {@linkplain Entry#getKey() key} component and the associated metadata as their
* {@linkplain Entry#getValue() value} component (which may be <code>null</code>). May be empty, but never
* <code>null</code>.
*/
default Iterator<Entry<Long, Object>> getCommitMetadataBetween(final long from, final long to,
final Order order) {
return getCommitMetadataBetween(from, to, order, false);
}
/**
* Returns an iterator over the entries of commit timestamp and associated metadata on the
* {@linkplain ChronoDBConstants#MASTER_BRANCH_IDENTIFIER master} branch, bounded between <code>from</code> and
* <code>to</code>.
*
* <p>
* If the <code>from</code> value is greater than the <code>to</code> value, this method always returns an empty
* iterator.
*
* <p>
* Please keep in mind that some commits may not have any metadata attached. In this case, the
* {@linkplain Entry#getValue() value} component of the {@link Entry} will be set to <code>null</code>.
*
* @param from The lower bound of the time range to look for commits in (inclusive). Must not be negative. Must be
* less than or equal to the timestamp of this transaction.
* @param to The upper bound of the time range to look for commits in (inclusive). Must not be negative. Must be
* less than or equal to the timestamp of this transaction.
* @param order The order of the returned commits. Must not be <code>null</code>.
* @param includeSystemInternalCommits Whether or not to include system-internal commits.
* @return An iterator over the commits in the given time range. The contained entries have the timestamp as the
* {@linkplain Entry#getKey() key} component and the associated metadata as their
* {@linkplain Entry#getValue() value} component (which may be <code>null</code>). May be empty, but never
* <code>null</code>.
*/
public default Iterator<Entry<Long, Object>> getCommitMetadataBetween(final long from, final long to,
final Order order, final boolean includeSystemInternalCommits) {
return this.getCommitMetadataBetween(ChronoDBConstants.MASTER_BRANCH_IDENTIFIER, from, to, order, includeSystemInternalCommits);
}
/**
* Returns an iterator over the entries of commit timestamp and associated metadata, bounded between
* <code>from</code> and <code>to</code>.
*
* <p>
* If the <code>from</code> value is greater than the <code>to</code> value, this method always returns an empty
* iterator.
*
* <p>
* Please keep in mind that some commits may not have any metadata attached. In this case, the
* {@linkplain Entry#getValue() value} component of the {@link Entry} will be set to <code>null</code>.
*
* @param branch The name of the branch to consider. Must not be <code>null</code>, must refer to an existing branch.
* @param from The lower bound of the time range to look for commits in (inclusive). Must not be negative. Must be
* less than or equal to the timestamp of this transaction.
* @param to The upper bound of the time range to look for commits in (inclusive). Must not be negative. Must be
* less than or equal to the timestamp of this transaction.
* @param order The order of the returned commits. Must not be <code>null</code>.
* @return An iterator over the commits in the given time range. The contained entries have the timestamp as the
* {@linkplain Entry#getKey() key} component and the associated metadata as their
* {@linkplain Entry#getValue() value} component (which may be <code>null</code>). May be empty, but never
* <code>null</code>.
*/
default Iterator<Entry<Long, Object>> getCommitMetadataBetween(String branch, long from, long to, Order order) {
return getCommitMetadataBetween(branch, from, to, order, false);
}
/**
* Returns an iterator over the entries of commit timestamp and associated metadata, bounded between
* <code>from</code> and <code>to</code>.
*
* <p>
* If the <code>from</code> value is greater than the <code>to</code> value, this method always returns an empty
* iterator.
*
* <p>
* Please keep in mind that some commits may not have any metadata attached. In this case, the
* {@linkplain Entry#getValue() value} component of the {@link Entry} will be set to <code>null</code>.
*
* @param branch The name of the branch to consider. Must not be <code>null</code>, must refer to an existing branch.
* @param from The lower bound of the time range to look for commits in (inclusive). Must not be negative. Must be
* less than or equal to the timestamp of this transaction.
* @param to The upper bound of the time range to look for commits in (inclusive). Must not be negative. Must be
* less than or equal to the timestamp of this transaction.
* @param order The order of the returned commits. Must not be <code>null</code>.
* @param includeSystemInternalCommits Whether or not to include system-internal commits.
* @return An iterator over the commits in the given time range. The contained entries have the timestamp as the
* {@linkplain Entry#getKey() key} component and the associated metadata as their
* {@linkplain Entry#getValue() value} component (which may be <code>null</code>). May be empty, but never
* <code>null</code>.
*/
public Iterator<Entry<Long, Object>> getCommitMetadataBetween(String branch, long from, long to, Order order, final boolean includeSystemInternalCommits);
/**
* Returns an iterator over commit timestamps on the {@linkplain ChronoDBConstants#MASTER_BRANCH_IDENTIFIER master}
* branch in a paged fashion.
*
* <p>
* For example, calling {@code getCommitTimestampsPaged(10000, 100, 0, Order.DESCENDING)} will give the latest 100
* commit timestamps that have occurred before timestamp 10000. Calling
* {@code getCommitTimestampsPaged(123456, 200, 2, Order.DESCENDING} will return 200 commit timestamps, skipping the
* 400 latest commit timestamps, which are smaller than 123456.
*
* @param minTimestamp The minimum timestamp to consider (inclusive). All lower timestamps will be excluded from the
* pagination. Must be less than or equal to the timestamp of this transaction.
* @param maxTimestamp The highest timestamp to consider (inclusive). All higher timestamps will be excluded from the
* pagination. Must be less than or equal to the timestamp of this transaction.
* @param pageSize The size of the page, i.e. the maximum number of elements allowed to be contained in the resulting
* iterator. Must be greater than zero.
* @param pageIndex The index of the page to retrieve. Must not be negative.
* @param order The desired ordering for the commit timestamps
* @return An iterator that contains the commit timestamps for the requested page. Never <code>null</code>, may be
* empty. If the requested page does not exist, this iterator will always be empty.
*/
default Iterator<Long> getCommitTimestampsPaged(final long minTimestamp, final long maxTimestamp,
final int pageSize, final int pageIndex, final Order order) {
return getCommitTimestampsPaged(minTimestamp, maxTimestamp, pageSize, pageIndex, order, false);
}
/**
* Returns an iterator over commit timestamps on the {@linkplain ChronoDBConstants#MASTER_BRANCH_IDENTIFIER master}
* branch in a paged fashion.
*
* <p>
* For example, calling {@code getCommitTimestampsPaged(10000, 100, 0, Order.DESCENDING)} will give the latest 100
* commit timestamps that have occurred before timestamp 10000. Calling
* {@code getCommitTimestampsPaged(123456, 200, 2, Order.DESCENDING} will return 200 commit timestamps, skipping the
* 400 latest commit timestamps, which are smaller than 123456.
*
* @param minTimestamp The minimum timestamp to consider (inclusive). All lower timestamps will be excluded from the
* pagination. Must be less than or equal to the timestamp of this transaction.
* @param maxTimestamp The highest timestamp to consider (inclusive). All higher timestamps will be excluded from the
* pagination. Must be less than or equal to the timestamp of this transaction.
* @param pageSize The size of the page, i.e. the maximum number of elements allowed to be contained in the resulting
* iterator. Must be greater than zero.
* @param pageIndex The index of the page to retrieve. Must not be negative.
* @param order The desired ordering for the commit timestamps
* @param includeSystemInternalCommits Whether or not to include system-internal commits.
* @return An iterator that contains the commit timestamps for the requested page. Never <code>null</code>, may be
* empty. If the requested page does not exist, this iterator will always be empty.
*/
public default Iterator<Long> getCommitTimestampsPaged(final long minTimestamp, final long maxTimestamp,
final int pageSize, final int pageIndex, final Order order,
final boolean includeSystemInternalCommits) {
return this.getCommitTimestampsPaged(ChronoDBConstants.MASTER_BRANCH_IDENTIFIER, minTimestamp, maxTimestamp,
pageSize, pageIndex, order, includeSystemInternalCommits);
}
/**
* Returns an iterator over commit timestamps in a paged fashion.
*
* <p>
* For example, calling {@code getCommitTimestampsPaged(10000, 100, 0, Order.DESCENDING)} will give the latest 100
* commit timestamps that have occurred before timestamp 10000. Calling
* {@code getCommitTimestampsPaged(123456, 200, 2, Order.DESCENDING} will return 200 commit timestamps, skipping the
* 400 latest commit timestamps, which are smaller than 123456.
*
* @param branch The name of the branch to consider. Must not be <code>null</code>, must refer to an existing branch.
* @param minTimestamp The minimum timestamp to consider (inclusive). All lower timestamps will be excluded from the
* pagination. Must be less than or equal to the timestamp of this transaction.
* @param maxTimestamp The highest timestamp to consider (inclusive). All higher timestamps will be excluded from the
* pagination. Must be less than or equal to the timestamp of this transaction.
* @param pageSize The size of the page, i.e. the maximum number of elements allowed to be contained in the resulting
* iterator. Must be greater than zero.
* @param pageIndex The index of the page to retrieve. Must not be negative.
* @param order The desired ordering for the commit timestamps
* @return An iterator that contains the commit timestamps for the requested page. Never <code>null</code>, may be
* empty. If the requested page does not exist, this iterator will always be empty.
*/
default Iterator<Long> getCommitTimestampsPaged(final String branch, final long minTimestamp,
final long maxTimestamp, final int pageSize, final int pageIndex, final Order order) {
return getCommitTimestampsPaged(branch, minTimestamp, maxTimestamp, pageSize, pageIndex, order, false);
}
/**
* Returns an iterator over commit timestamps in a paged fashion.
*
* <p>
* For example, calling {@code getCommitTimestampsPaged(10000, 100, 0, Order.DESCENDING)} will give the latest 100
* commit timestamps that have occurred before timestamp 10000. Calling
* {@code getCommitTimestampsPaged(123456, 200, 2, Order.DESCENDING} will return 200 commit timestamps, skipping the
* 400 latest commit timestamps, which are smaller than 123456.
*
* @param branch The name of the branch to consider. Must not be <code>null</code>, must refer to an existing branch.
* @param minTimestamp The minimum timestamp to consider (inclusive). All lower timestamps will be excluded from the
* pagination. Must be less than or equal to the timestamp of this transaction.
* @param maxTimestamp The highest timestamp to consider (inclusive). All higher timestamps will be excluded from the
* pagination. Must be less than or equal to the timestamp of this transaction.
* @param pageSize The size of the page, i.e. the maximum number of elements allowed to be contained in the resulting
* iterator. Must be greater than zero.
* @param pageIndex The index of the page to retrieve. Must not be negative.
* @param order The desired ordering for the commit timestamps
* @param includeSystemInternalCommits Whether or not to include system-internal commits.
* @return An iterator that contains the commit timestamps for the requested page. Never <code>null</code>, may be
* empty. If the requested page does not exist, this iterator will always be empty.
*/
public Iterator<Long> getCommitTimestampsPaged(final String branch, final long minTimestamp,
final long maxTimestamp, final int pageSize, final int pageIndex, final Order order,
final boolean includeSystemInternalCommits);
/**
* Returns an iterator over commit timestamps and associated metadata on the
* {@linkplain ChronoDBConstants#MASTER_BRANCH_IDENTIFIER master} branch in a paged fashion.
*
* <p>
* For example, calling {@code getCommitTimestampsPaged(10000, 100, 0, Order.DESCENDING)} will give the latest 100
* commit timestamps that have occurred before timestamp 10000. Calling
* {@code getCommitTimestampsPaged(123456, 200, 2, Order.DESCENDING} will return 200 commit timestamps, skipping the
* 400 latest commit timestamps, which are smaller than 123456.
*
* <p>
* The {@link Entry Entries} returned by the iterator always have the commit timestamp as their first component and
* the metadata associated with this commit as their second component. The second component can be <code>null</code>
* if the commit was executed without providing metadata.
*
* @param minTimestamp The minimum timestamp to consider (inclusive). All lower timestamps will be excluded from the
* pagination. Must be less than or equal to the timestamp of this transaction.
* @param maxTimestamp The highest timestamp to consider. All higher timestamps will be excluded from the pagination. Must be
* less than or equal to the timestamp of this transaction.
* @param pageSize The size of the page, i.e. the maximum number of elements allowed to be contained in the resulting
* iterator. Must be greater than zero.
* @param pageIndex The index of the page to retrieve. Must not be negative.
* @param order The desired ordering for the commit timestamps
* @return An iterator that contains the commits for the requested page. Never <code>null</code>, may be empty. If
* the requested page does not exist, this iterator will always be empty.
*/
default Iterator<Entry<Long, Object>> getCommitMetadataPaged(final long minTimestamp,
final long maxTimestamp, final int pageSize,
final int pageIndex, final Order order) {
return getCommitMetadataPaged(minTimestamp, maxTimestamp, pageSize, pageIndex, order, false);
}
/**
* Returns an iterator over commit timestamps and associated metadata on the
* {@linkplain ChronoDBConstants#MASTER_BRANCH_IDENTIFIER master} branch in a paged fashion.
*
* <p>
* For example, calling {@code getCommitTimestampsPaged(10000, 100, 0, Order.DESCENDING)} will give the latest 100
* commit timestamps that have occurred before timestamp 10000. Calling
* {@code getCommitTimestampsPaged(123456, 200, 2, Order.DESCENDING} will return 200 commit timestamps, skipping the
* 400 latest commit timestamps, which are smaller than 123456.
*
* <p>
* The {@link Entry Entries} returned by the iterator always have the commit timestamp as their first component and
* the metadata associated with this commit as their second component. The second component can be <code>null</code>
* if the commit was executed without providing metadata.
*
* @param minTimestamp The minimum timestamp to consider (inclusive). All lower timestamps will be excluded from the
* pagination. Must be less than or equal to the timestamp of this transaction.
* @param maxTimestamp The highest timestamp to consider. All higher timestamps will be excluded from the pagination. Must be
* less than or equal to the timestamp of this transaction.
* @param pageSize The size of the page, i.e. the maximum number of elements allowed to be contained in the resulting
* iterator. Must be greater than zero.
* @param pageIndex The index of the page to retrieve. Must not be negative.
* @param order The desired ordering for the commit timestamps
* @param includeSystemInternalCommits Whether or not to include system-internal commits.
* @return An iterator that contains the commits for the requested page. Never <code>null</code>, may be empty. If
* the requested page does not exist, this iterator will always be empty.
*/
public default Iterator<Entry<Long, Object>> getCommitMetadataPaged(final long minTimestamp,
final long maxTimestamp, final int pageSize,
final int pageIndex, final Order order, final boolean includeSystemInternalCommits) {
return this.getCommitMetadataPaged(ChronoDBConstants.MASTER_BRANCH_IDENTIFIER, minTimestamp, maxTimestamp,
pageSize, pageIndex, order, includeSystemInternalCommits);
}
/**
* Returns an iterator over commit timestamps and associated metadata in a paged fashion.
*
* <p>
* For example, calling {@code getCommitTimestampsPaged(10000, 100, 0, Order.DESCENDING)} will give the latest 100
* commit timestamps that have occurred before timestamp 10000. Calling
* {@code getCommitTimestampsPaged(123456, 200, 2, Order.DESCENDING} will return 200 commit timestamps, skipping the
* 400 latest commit timestamps, which are smaller than 123456.
*
* <p>
* The {@link Entry Entries} returned by the iterator always have the commit timestamp as their first component and
* the metadata associated with this commit as their second component. The second component can be <code>null</code>
* if the commit was executed without providing metadata.
*
* @param branch The name of the branch to consider. Must not be <code>null</code>, must refer to an existing branch.
* @param minTimestamp The minimum timestamp to consider (inclusive). All lower timestamps will be excluded from the
* pagination. Must be less than or equal to the timestamp of this transaction.
* @param maxTimestamp The highest timestamp to consider. All higher timestamps will be excluded from the pagination. Must be
* less than or equal to the timestamp of this transaction.
* @param pageSize The size of the page, i.e. the maximum number of elements allowed to be contained in the resulting
* iterator. Must be greater than zero.
* @param pageIndex The index of the page to retrieve. Must not be negative.
* @param order The desired ordering for the commit timestamps
* @return An iterator that contains the commits for the requested page. Never <code>null</code>, may be empty. If
* the requested page does not exist, this iterator will always be empty.
*/
default Iterator<Entry<Long, Object>> getCommitMetadataPaged(final String branch, final long minTimestamp,
final long maxTimestamp, final int pageSize, final int pageIndex, final Order order) {
return getCommitMetadataPaged(branch, minTimestamp, maxTimestamp, pageSize, pageIndex, order, false);
}
/**
* Returns an iterator over commit timestamps and associated metadata in a paged fashion.
*
* <p>
* For example, calling {@code getCommitTimestampsPaged(10000, 100, 0, Order.DESCENDING)} will give the latest 100
* commit timestamps that have occurred before timestamp 10000. Calling
* {@code getCommitTimestampsPaged(123456, 200, 2, Order.DESCENDING} will return 200 commit timestamps, skipping the
* 400 latest commit timestamps, which are smaller than 123456.
*
* <p>
* The {@link Entry Entries} returned by the iterator always have the commit timestamp as their first component and
* the metadata associated with this commit as their second component. The second component can be <code>null</code>
* if the commit was executed without providing metadata.
*
* @param branch The name of the branch to consider. Must not be <code>null</code>, must refer to an existing branch.
* @param minTimestamp The minimum timestamp to consider (inclusive). All lower timestamps will be excluded from the
* pagination. Must be less than or equal to the timestamp of this transaction.
* @param maxTimestamp The highest timestamp to consider. All higher timestamps will be excluded from the pagination. Must be
* less than or equal to the timestamp of this transaction.
* @param pageSize The size of the page, i.e. the maximum number of elements allowed to be contained in the resulting
* iterator. Must be greater than zero.
* @param pageIndex The index of the page to retrieve. Must not be negative.
* @param order The desired ordering for the commit timestamps
* @param includeSystemInternalCommits Whether or not to include system-internal commits.
* @return An iterator that contains the commits for the requested page. Never <code>null</code>, may be empty. If
* the requested page does not exist, this iterator will always be empty.
*/
public Iterator<Entry<Long, Object>> getCommitMetadataPaged(final String branch, final long minTimestamp,
final long maxTimestamp, final int pageSize, final int pageIndex, final Order order,
final boolean includeSystemInternalCommits);
/**
* Returns pairs of commit timestamp and commit metadata which are "around" the given timestamp on the time axis and
* on the {@linkplain ChronoDBConstants#MASTER_BRANCH_IDENTIFIER master} branch.
*
* <p>
* By default, this method will attempt to return the closest <code>count/2</code> commits before and after the
* given timestamp. However, if there are not enough elements on either side, the other side will have more entries
* in the result list (e.g. if the request count is 10 and there are only two commits before the request timestamp,
* the list of commits after the request timestamp will have 8 entries instead of 5 to create a list of total length
* 10). In other words, the result list will always have as many entries as the request <code>count</code>, except
* when there are not as many commits on the store yet.
*
* @param timestamp The request timestamp around which the commits should be centered. Must not be negative.
* @param count How many commits to retrieve around the request timestamp. By default, the closest
* <code>count/2</code> commits will be taken on both sides of the request timestamp. Must not be
* negative.
* @return A list of pairs. The keys are commit timsetamps, the corresponding values are the commit metadata objects
* (which may be <code>null</code>). The list itself will never be <code>null</code>, but may be empty (if
* there are no commits to report). The list is sorted in descending order by timestamps.
*/
default List<Entry<Long, Object>> getCommitMetadataAround(final long timestamp, final int count) {
return getCommitMetadataAround(timestamp, count, false);
}
/**
* Returns pairs of commit timestamp and commit metadata which are "around" the given timestamp on the time axis and
* on the {@linkplain ChronoDBConstants#MASTER_BRANCH_IDENTIFIER master} branch.
*
* <p>
* By default, this method will attempt to return the closest <code>count/2</code> commits before and after the
* given timestamp. However, if there are not enough elements on either side, the other side will have more entries
* in the result list (e.g. if the request count is 10 and there are only two commits before the request timestamp,
* the list of commits after the request timestamp will have 8 entries instead of 5 to create a list of total length
* 10). In other words, the result list will always have as many entries as the request <code>count</code>, except
* when there are not as many commits on the store yet.
*
* @param timestamp The request timestamp around which the commits should be centered. Must not be negative.
* @param count How many commits to retrieve around the request timestamp. By default, the closest
* <code>count/2</code> commits will be taken on both sides of the request timestamp. Must not be
* negative.
* @param includeSystemInternalCommits Whether or not to include system-internal commits.
* @return A list of pairs. The keys are commit timsetamps, the corresponding values are the commit metadata objects
* (which may be <code>null</code>). The list itself will never be <code>null</code>, but may be empty (if
* there are no commits to report). The list is sorted in descending order by timestamps.
*/
public default List<Entry<Long, Object>> getCommitMetadataAround(final long timestamp, final int count, final boolean includeSystemInternalCommits) {
return this.getCommitMetadataAround(ChronoDBConstants.MASTER_BRANCH_IDENTIFIER, timestamp, count, includeSystemInternalCommits);
}
/**
* Returns pairs of commit timestamp and commit metadata which are "around" the given timestamp on the time axis.
*
* <p>
* By default, this method will attempt to return the closest <code>count/2</code> commits before and after the
* given timestamp. However, if there are not enough elements on either side, the other side will have more entries
* in the result list (e.g. if the request count is 10 and there are only two commits before the request timestamp,
* the list of commits after the request timestamp will have 8 entries instead of 5 to create a list of total length
* 10). In other words, the result list will always have as many entries as the request <code>count</code>, except
* when there are not as many commits on the store yet.
*
* @param branch The name of the branch to execute the search on. Must refer to an existing branch, and must in
* particular not be <code>null</code>.
* @param timestamp The request timestamp around which the commits should be centered. Must not be negative.
* @param count How many commits to retrieve around the request timestamp. By default, the closest
* <code>count/2</code> commits will be taken on both sides of the request timestamp. Must not be
* negative.
* @return A list of pairs. The keys are commit timsetamps, the corresponding values are the commit metadata objects
* (which may be <code>null</code>). The list itself will never be <code>null</code>, but may be empty (if
* there are no commits to report). The list is sorted in descending order by timestamps.
*/
default List<Entry<Long, Object>> getCommitMetadataAround(final String branch, final long timestamp,
final int count) {
return getCommitMetadataAround(branch, timestamp, count, false);
}
/**
* Returns pairs of commit timestamp and commit metadata which are "around" the given timestamp on the time axis.
*
* <p>
* By default, this method will attempt to return the closest <code>count/2</code> commits before and after the
* given timestamp. However, if there are not enough elements on either side, the other side will have more entries
* in the result list (e.g. if the request count is 10 and there are only two commits before the request timestamp,
* the list of commits after the request timestamp will have 8 entries instead of 5 to create a list of total length
* 10). In other words, the result list will always have as many entries as the request <code>count</code>, except
* when there are not as many commits on the store yet.
*
* @param branch The name of the branch to execute the search on. Must refer to an existing branch, and must in
* particular not be <code>null</code>.
* @param timestamp The request timestamp around which the commits should be centered. Must not be negative.
* @param count How many commits to retrieve around the request timestamp. By default, the closest
* <code>count/2</code> commits will be taken on both sides of the request timestamp. Must not be
* negative.
* @param includeSystemInternalCommits Whether or not to include system-internal commits.
* @return A list of pairs. The keys are commit timsetamps, the corresponding values are the commit metadata objects
* (which may be <code>null</code>). The list itself will never be <code>null</code>, but may be empty (if
* there are no commits to report). The list is sorted in descending order by timestamps.
*/
public List<Entry<Long, Object>> getCommitMetadataAround(final String branch, final long timestamp,
final int count, final boolean includeSystemInternalCommits);
/**
* Returns pairs of commit timestamp and commit metadata which are strictly before the given timestamp on the time
* axis and on the {@linkplain ChronoDBConstants#MASTER_BRANCH_IDENTIFIER master} branch.
*
* <p>
* For example, calling {@link #getCommitMetadataBefore(long, int)} with a timestamp and a count of 10, this method
* will return the latest 10 commits (strictly) before the given request timestamp.
*
* @param timestamp The timestamp to investigate. Must not be negative.
* @param count How many commits to retrieve before the given request timestamp. Must not be negative.
* @return A list of pairs. The keys are commit timsetamps, the corresponding values are the commit metadata objects
* (which may be <code>null</code>). The list itself will never be <code>null</code>, but may be empty (if
* there are no commits to report). The list is sorted in descending order by timestamps.
*/
default List<Entry<Long, Object>> getCommitMetadataBefore(final long timestamp, final int count) {
return getCommitMetadataBefore(timestamp, count, false);
}
/**
* Returns pairs of commit timestamp and commit metadata which are strictly before the given timestamp on the time
* axis and on the {@linkplain ChronoDBConstants#MASTER_BRANCH_IDENTIFIER master} branch.
*
* <p>
* For example, calling {@link #getCommitMetadataBefore(long, int)} with a timestamp and a count of 10, this method
* will return the latest 10 commits (strictly) before the given request timestamp.
*
* @param timestamp The timestamp to investigate. Must not be negative.
* @param count How many commits to retrieve before the given request timestamp. Must not be negative.
* @param includeSystemInternalCommits Whether or not to include system-internal commits.
* @return A list of pairs. The keys are commit timsetamps, the corresponding values are the commit metadata objects
* (which may be <code>null</code>). The list itself will never be <code>null</code>, but may be empty (if
* there are no commits to report). The list is sorted in descending order by timestamps.
*/
public default List<Entry<Long, Object>> getCommitMetadataBefore(final long timestamp, final int count, final boolean includeSystemInternalCommits) {
return this.getCommitMetadataBefore(ChronoDBConstants.MASTER_BRANCH_IDENTIFIER, timestamp, count, includeSystemInternalCommits);
}
/**
* Returns pairs of commit timestamp and commit metadata which are strictly before the given timestamp on the time
* axis.
*
* <p>
* For example, calling {@link #getCommitMetadataBefore(String, long, int)} with a timestamp and a count of 10, this
* method will return the latest 10 commits (strictly) before the given request timestamp.
*
* @param branch The name of the branch to execute the search on. Must refer to an existing branch, and must in
* particular not be <code>null</code>.
* @param timestamp The timestamp to investigate. Must not be negative.
* @param count How many commits to retrieve before the given request timestamp. Must not be negative.
* @return A list of pairs. The keys are commit timsetamps, the corresponding values are the commit metadata objects
* (which may be <code>null</code>). The list itself will never be <code>null</code>, but may be empty (if
* there are no commits to report). The list is sorted in descending order by timestamps.
*/
default List<Entry<Long, Object>> getCommitMetadataBefore(final String branch, final long timestamp,
final int count) {
return getCommitMetadataBefore(branch, timestamp, count, false);
}
/**
* Returns pairs of commit timestamp and commit metadata which are strictly before the given timestamp on the time
* axis.
*
* <p>
* For example, calling {@link #getCommitMetadataBefore(String, long, int)} with a timestamp and a count of 10, this
* method will return the latest 10 commits (strictly) before the given request timestamp.
*
* @param branch The name of the branch to execute the search on. Must refer to an existing branch, and must in
* particular not be <code>null</code>.
* @param timestamp The timestamp to investigate. Must not be negative.
* @param count How many commits to retrieve before the given request timestamp. Must not be negative.
* @param includeSystemInternalCommits Whether or not to include system-internal commits.
* @return A list of pairs. The keys are commit timsetamps, the corresponding values are the commit metadata objects
* (which may be <code>null</code>). The list itself will never be <code>null</code>, but may be empty (if
* there are no commits to report). The list is sorted in descending order by timestamps.
*/
public List<Entry<Long, Object>> getCommitMetadataBefore(final String branch, final long timestamp,
final int count, final boolean includeSystemInternalCommits);
/**
* Returns pairs of commit timestamp and commit metadata which are strictly after the given timestamp on the time
* axis and on the {@linkplain ChronoDBConstants#MASTER_BRANCH_IDENTIFIER master} branch.
*
* <p>
* For example, calling {@link #getCommitMetadataAfter(long, int)} with a timestamp and a count of 10, this method
* will return the oldest 10 commits (strictly) after the given request timestamp.
*
* @param timestamp The timestamp to investigate. Must not be negative.
* @param count How many commits to retrieve after the given request timestamp. Must not be negative.
* @return A list of pairs. The keys are commit timsetamps, the corresponding values are the commit metadata objects
* (which may be <code>null</code>). The list itself will never be <code>null</code>, but may be empty (if
* there are no commits to report). The list is sorted in descending order by timestamps.
*/
default List<Entry<Long, Object>> getCommitMetadataAfter(final long timestamp, final int count) {
return getCommitMetadataAfter(timestamp, count, false);
}
/**
* Returns pairs of commit timestamp and commit metadata which are strictly after the given timestamp on the time
* axis and on the {@linkplain ChronoDBConstants#MASTER_BRANCH_IDENTIFIER master} branch.
*
* <p>
* For example, calling {@link #getCommitMetadataAfter(long, int)} with a timestamp and a count of 10, this method
* will return the oldest 10 commits (strictly) after the given request timestamp.
*
* @param timestamp The timestamp to investigate. Must not be negative.
* @param count How many commits to retrieve after the given request timestamp. Must not be negative.
* @param includeSystemInternalCommits Whether or not to include system-internal commits.
* @return A list of pairs. The keys are commit timsetamps, the corresponding values are the commit metadata objects
* (which may be <code>null</code>). The list itself will never be <code>null</code>, but may be empty (if
* there are no commits to report). The list is sorted in descending order by timestamps.
*/
public default List<Entry<Long, Object>> getCommitMetadataAfter(final long timestamp, final int count, final boolean includeSystemInternalCommits) {
return this.getCommitMetadataAfter(ChronoDBConstants.MASTER_BRANCH_IDENTIFIER, timestamp, count, includeSystemInternalCommits);
}
/**
* Returns pairs of commit timestamp and commit metadata which are strictly after the given timestamp on the time
* axis.
*
* <p>
* For example, calling {@link #getCommitMetadataAfter(String, long, int)} with a timestamp and a count of 10, this
* method will return the oldest 10 commits (strictly) after the given request timestamp.
*
* @param branch The name of the branch to execute the search on. Must refer to an existing branch, and must in
* particular not be <code>null</code>.
* @param timestamp The timestamp to investigate. Must not be negative.
* @param count How many commits to retrieve after the given request timestamp. Must not be negative.
* @return A list of pairs. The keys are commit timsetamps, the corresponding values are the commit metadata objects
* (which may be <code>null</code>). The list itself will never be <code>null</code>, but may be empty (if
* there are no commits to report). The list is sorted in descending order by timestamps.
*/
default List<Entry<Long, Object>> getCommitMetadataAfter(final String branch, final long timestamp, final int count) {
return getCommitMetadataAfter(branch, timestamp, count, false);
}
/**
* Returns pairs of commit timestamp and commit metadata which are strictly after the given timestamp on the time
* axis.
*
* <p>
* For example, calling {@link #getCommitMetadataAfter(String, long, int)} with a timestamp and a count of 10, this
* method will return the oldest 10 commits (strictly) after the given request timestamp.
*
* @param branch The name of the branch to execute the search on. Must refer to an existing branch, and must in
* particular not be <code>null</code>.
* @param timestamp The timestamp to investigate. Must not be negative.
* @param count How many commits to retrieve after the given request timestamp. Must not be negative.
* @param includeSystemInternalCommits Whether or not to include system-internal commits.
* @return A list of pairs. The keys are commit timsetamps, the corresponding values are the commit metadata objects
* (which may be <code>null</code>). The list itself will never be <code>null</code>, but may be empty (if
* there are no commits to report). The list is sorted in descending order by timestamps.
*/
public List<Entry<Long, Object>> getCommitMetadataAfter(final String branch, final long timestamp, final int count, final boolean includeSystemInternalCommits);
/**
* Returns a list of commit timestamp which are "around" the given timestamp on the time axis and on the
* {@linkplain ChronoDBConstants#MASTER_BRANCH_IDENTIFIER master} branch.
*
* <p>
* By default, this method will attempt to return the closest <code>count/2</code> commits before and after the
* given timestamp. However, if there are not enough elements on either side, the other side will have more entries
* in the result list (e.g. if the request count is 10 and there are only two commits before the request timestamp,
* the list of commits after the request timestamp will have 8 entries instead of 5 to create a list of total length
* 10). In other words, the result list will always have as many entries as the request <code>count</code>, except
* when there are not as many commits on the store yet.
*
* @param timestamp The request timestamp around which the commits should be centered. Must not be negative.
* @param count How many commits to retrieve around the request timestamp. By default, the closest
* <code>count/2</code> commits will be taken on both sides of the request timestamp. Must not be
* negative.
* @return A list of timestamps. Never be <code>null</code>, but may be empty (if there are no commits to report).
* The list is sorted in descending order.
*/
public default List<Long> getCommitTimestampsAround(final long timestamp, final int count) {
return this.getCommitTimestampsAround(ChronoDBConstants.MASTER_BRANCH_IDENTIFIER, timestamp, count, false);
}
/**
* Returns a list of commit timestamp which are "around" the given timestamp on the time axis and on the
* {@linkplain ChronoDBConstants#MASTER_BRANCH_IDENTIFIER master} branch.
*
* <p>
* By default, this method will attempt to return the closest <code>count/2</code> commits before and after the
* given timestamp. However, if there are not enough elements on either side, the other side will have more entries
* in the result list (e.g. if the request count is 10 and there are only two commits before the request timestamp,
* the list of commits after the request timestamp will have 8 entries instead of 5 to create a list of total length
* 10). In other words, the result list will always have as many entries as the request <code>count</code>, except
* when there are not as many commits on the store yet.
*
* @param timestamp The request timestamp around which the commits should be centered. Must not be negative.
* @param count How many commits to retrieve around the request timestamp. By default, the closest
* <code>count/2</code> commits will be taken on both sides of the request timestamp. Must not be
* negative.
* @param includeSystemInternalCommits Whether or not to include system-internal commits.
* @return A list of timestamps. Never be <code>null</code>, but may be empty (if there are no commits to report).
* The list is sorted in descending order.
*/
public default List<Long> getCommitTimestampsAround(final long timestamp, final int count, final boolean includeSystemInternalCommits) {
return this.getCommitTimestampsAround(ChronoDBConstants.MASTER_BRANCH_IDENTIFIER, timestamp, count, includeSystemInternalCommits);
}
/**
* Returns a list of commit timestamp which are "around" the given timestamp on the time axis.
*
* <p>
* By default, this method will attempt to return the closest <code>count/2</code> commits before and after the
* given timestamp. However, if there are not enough elements on either side, the other side will have more entries
* in the result list (e.g. if the request count is 10 and there are only two commits before the request timestamp,
* the list of commits after the request timestamp will have 8 entries instead of 5 to create a list of total length
* 10). In other words, the result list will always have as many entries as the request <code>count</code>, except
* when there are not as many commits on the store yet.
*
* @param branch The name of the branch to execute the search on. Must refer to an existing branch, and must in
* particular not be <code>null</code>.
* @param timestamp The request timestamp around which the commits should be centered. Must not be negative.
* @param count How many commits to retrieve around the request timestamp. By default, the closest
* <code>count/2</code> commits will be taken on both sides of the request timestamp. Must not be
* negative.
* @return A list of timestamps. Never be <code>null</code>, but may be empty (if there are no commits to report).
* The list is sorted in descending order.
*/
default List<Long> getCommitTimestampsAround(final String branch, final long timestamp, final int count) {
return getCommitTimestampsAround(branch, timestamp, count, false);
}
/**
* Returns a list of commit timestamp which are "around" the given timestamp on the time axis.
*
* <p>
* By default, this method will attempt to return the closest <code>count/2</code> commits before and after the
* given timestamp. However, if there are not enough elements on either side, the other side will have more entries
* in the result list (e.g. if the request count is 10 and there are only two commits before the request timestamp,
* the list of commits after the request timestamp will have 8 entries instead of 5 to create a list of total length
* 10). In other words, the result list will always have as many entries as the request <code>count</code>, except
* when there are not as many commits on the store yet.
*
* @param branch The name of the branch to execute the search on. Must refer to an existing branch, and must in
* particular not be <code>null</code>.
* @param timestamp The request timestamp around which the commits should be centered. Must not be negative.
* @param count How many commits to retrieve around the request timestamp. By default, the closest
* <code>count/2</code> commits will be taken on both sides of the request timestamp. Must not be
* negative.
* @param includeSystemInternalCommits Whether or not to include system-internal commits.
* @return A list of timestamps. Never be <code>null</code>, but may be empty (if there are no commits to report).
* The list is sorted in descending order.
*/
public List<Long> getCommitTimestampsAround(final String branch, final long timestamp, final int count, final boolean includeSystemInternalCommits);
/**
* Returns a list of commit timestamps which are strictly before the given timestamp on the time axis and on the
* {@linkplain ChronoDBConstants#MASTER_BRANCH_IDENTIFIER master} branch.
*
* <p>
* For example, calling {@link #getCommitTimestampsBefore(long, int)} with a timestamp and a count of 10, this
* method will return the latest 10 commits (strictly) before the given request timestamp.
*
* @param timestamp The timestamp to investigate. Must not be negative.
* @param count How many commits to retrieve before the given request timestamp. Must not be negative.
* @return A list of timestamps. Never be <code>null</code>, but may be empty (if there are no commits to report).
* The list is sorted in descending order.
*/
default List<Long> getCommitTimestampsBefore(final long timestamp, final int count) {
return getCommitTimestampsBefore(timestamp, count, false);
}
/**
* Returns a list of commit timestamps which are strictly before the given timestamp on the time axis and on the
* {@linkplain ChronoDBConstants#MASTER_BRANCH_IDENTIFIER master} branch.
*
* <p>
* For example, calling {@link #getCommitTimestampsBefore(long, int)} with a timestamp and a count of 10, this
* method will return the latest 10 commits (strictly) before the given request timestamp.
*
* @param timestamp The timestamp to investigate. Must not be negative.
* @param count How many commits to retrieve before the given request timestamp. Must not be negative.
* @param includeSystemInternalCommits Whether or not to include system-internal commits.
* @return A list of timestamps. Never be <code>null</code>, but may be empty (if there are no commits to report).
* The list is sorted in descending order.
*/
public default List<Long> getCommitTimestampsBefore(final long timestamp, final int count, final boolean includeSystemInternalCommits) {
return this.getCommitTimestampsBefore(ChronoDBConstants.MASTER_BRANCH_IDENTIFIER, timestamp, count, includeSystemInternalCommits);
}
/**
* Returns a list of commit timestamps which are strictly before the given timestamp on the time axis.
*
* <p>
* For example, calling {@link #getCommitTimestampsBefore(String, long, int)} with a timestamp and a count of 10,
* this method will return the latest 10 commits (strictly) before the given request timestamp.
*
* @param branch The name of the branch to execute the search on. Must refer to an existing branch, and must in
* particular not be <code>null</code>.
* @param timestamp The timestamp to investigate. Must not be negative.
* @param count How many commits to retrieve before the given request timestamp. Must not be negative.
* @return A list of timestamps. Never be <code>null</code>, but may be empty (if there are no commits to report).
* The list is sorted in descending order.
*/
default List<Long> getCommitTimestampsBefore(final String branch, final long timestamp, final int count) {
return getCommitTimestampsBefore(branch, timestamp, count, false);
}
/**
* Returns a list of commit timestamps which are strictly before the given timestamp on the time axis.
*
* <p>
* For example, calling {@link #getCommitTimestampsBefore(String, long, int)} with a timestamp and a count of 10,
* this method will return the latest 10 commits (strictly) before the given request timestamp.
*
* @param branch The name of the branch to execute the search on. Must refer to an existing branch, and must in
* particular not be <code>null</code>.
* @param timestamp The timestamp to investigate. Must not be negative.
* @param count How many commits to retrieve before the given request timestamp. Must not be negative.
* @param includeSystemInternalCommits Whether or not to include system-internal commits.
* @return A list of timestamps. Never be <code>null</code>, but may be empty (if there are no commits to report).
* The list is sorted in descending order.
*/
public List<Long> getCommitTimestampsBefore(final String branch, final long timestamp, final int count, final boolean includeSystemInternalCommits);
/**
* Returns a list of commit timestamps which are strictly after the given timestamp on the time axis and on the
* {@linkplain ChronoDBConstants#MASTER_BRANCH_IDENTIFIER master} branch.
*
* <p>
* For example, calling {@link #getCommitTimestampsAfter(long, int)} with a timestamp and a count of 10, this method
* will return the oldest 10 commits (strictly) after the given request timestamp.
*
* @param timestamp The timestamp to investigate. Must not be negative.
* @param count How many commits to retrieve after the given request timestamp. Must not be negative.
* @return A list of timestamps. Never be <code>null</code>, but may be empty (if there are no commits to report).
* The list is sorted in descending order.
*/
default List<Long> getCommitTimestampsAfter(final long timestamp, final int count) {
return getCommitTimestampsAfter(timestamp, count, false);
}
/**
* Returns a list of commit timestamps which are strictly after the given timestamp on the time axis and on the
* {@linkplain ChronoDBConstants#MASTER_BRANCH_IDENTIFIER master} branch.
*
* <p>
* For example, calling {@link #getCommitTimestampsAfter(long, int)} with a timestamp and a count of 10, this method
* will return the oldest 10 commits (strictly) after the given request timestamp.
*
* @param timestamp The timestamp to investigate. Must not be negative.
* @param count How many commits to retrieve after the given request timestamp. Must not be negative.
* @param includeSystemInternalCommits Whether or not to include system-internal commits.
* @return A list of timestamps. Never be <code>null</code>, but may be empty (if there are no commits to report).
* The list is sorted in descending order.
*/
public default List<Long> getCommitTimestampsAfter(final long timestamp, final int count, final boolean includeSystemInternalCommits) {
return this.getCommitTimestampsAfter(ChronoDBConstants.MASTER_BRANCH_IDENTIFIER, timestamp, count, includeSystemInternalCommits);
}
/**
* Returns a list of commit timestamps which are strictly after the given timestamp on the time axis.
*
* <p>
* For example, calling {@link #getCommitTimestampsAfter(String, long, int)} with a timestamp and a count of 10,
* this method will return the oldest 10 commits (strictly) after the given request timestamp.
*
* @param branch The name of the branch to execute the search on. Must refer to an existing branch, and must in
* particular not be <code>null</code>.
* @param timestamp The timestamp to investigate. Must not be negative.
* @param count How many commits to retrieve after the given request timestamp. Must not be negative.
* @return A list of timestamps. Never be <code>null</code>, but may be empty (if there are no commits to report).
* The list is sorted in descending order.
*/
default List<Long> getCommitTimestampsAfter(final String branch, final long timestamp, final int count) {
return getCommitTimestampsAfter(branch, timestamp, count, false);
}
/**
* Returns a list of commit timestamps which are strictly after the given timestamp on the time axis.
*
* <p>
* For example, calling {@link #getCommitTimestampsAfter(String, long, int)} with a timestamp and a count of 10,
* this method will return the oldest 10 commits (strictly) after the given request timestamp.
*
* @param branch The name of the branch to execute the search on. Must refer to an existing branch, and must in
* particular not be <code>null</code>.
* @param timestamp The timestamp to investigate. Must not be negative.
* @param count How many commits to retrieve after the given request timestamp. Must not be negative.
* @param includeSystemInternalCommits Whether or not to include system-internal commits.
* @return A list of timestamps. Never be <code>null</code>, but may be empty (if there are no commits to report).
* The list is sorted in descending order.
*/
public List<Long> getCommitTimestampsAfter(final String branch, final long timestamp, final int count, final boolean includeSystemInternalCommits);
/**
* Counts the number of commit timestamps on the {@link ChronoDBConstants#MASTER_BRANCH_IDENTIFIER master} branch
* between <code>from</code> (inclusive) and <code>to</code> (inclusive).
*
* <p>
* If <code>from</code> is greater than <code>to</code>, this method will always return zero.
*
* @param from The minimum timestamp to include in the search (inclusive). Must not be negative. Must be less than or
* equal to the timestamp of this transaction.
* @param to The maximum timestamp to include in the search (inclusive). Must not be negative. Must be less than or
* equal to the timestamp of this transaction.
* @return The number of commits that have occurred in the specified time range. May be zero, but never negative.
*/
default int countCommitTimestampsBetween(final long from, final long to) {
return countCommitTimestampsBetween(from, to, false);
}
/**
* Counts the number of commit timestamps on the {@link ChronoDBConstants#MASTER_BRANCH_IDENTIFIER master} branch
* between <code>from</code> (inclusive) and <code>to</code> (inclusive).
*
* <p>
* If <code>from</code> is greater than <code>to</code>, this method will always return zero.
*
* @param from The minimum timestamp to include in the search (inclusive). Must not be negative. Must be less than or
* equal to the timestamp of this transaction.
* @param to The maximum timestamp to include in the search (inclusive). Must not be negative. Must be less than or
* equal to the timestamp of this transaction.
* @param includeSystemInternalCommits Whether or not to include system-internal commits.
* @return The number of commits that have occurred in the specified time range. May be zero, but never negative.
*/
public default int countCommitTimestampsBetween(final long from, final long to, final boolean includeSystemInternalCommits) {
return this.countCommitTimestampsBetween(ChronoDBConstants.MASTER_BRANCH_IDENTIFIER, from, to, includeSystemInternalCommits);
}
/**
* Counts the number of commit timestamps between <code>from</code> (inclusive) and <code>to</code> (inclusive).
*
* <p>
* If <code>from</code> is greater than <code>to</code>, this method will always return zero.
*
* @param branch The name of the branch to consider. Must not be <code>null</code>, must refer to an existing branch.
* @param from The minimum timestamp to include in the search (inclusive). Must not be negative. Must be less than or
* equal to the timestamp of this transaction.
* @param to The maximum timestamp to include in the search (inclusive). Must not be negative. Must be less than or
* equal to the timestamp of this transaction.
* @return The number of commits that have occurred in the specified time range. May be zero, but never negative.
*/
default int countCommitTimestampsBetween(final String branch, long from, long to) {
return countCommitTimestampsBetween(branch, from, to, false);
}
/**
* Counts the number of commit timestamps between <code>from</code> (inclusive) and <code>to</code> (inclusive).
*
* <p>
* If <code>from</code> is greater than <code>to</code>, this method will always return zero.
*
* @param branch The name of the branch to consider. Must not be <code>null</code>, must refer to an existing branch.
* @param from The minimum timestamp to include in the search (inclusive). Must not be negative. Must be less than or
* equal to the timestamp of this transaction.
* @param to The maximum timestamp to include in the search (inclusive). Must not be negative. Must be less than or
* equal to the timestamp of this transaction.
* @param includeSystemInternalCommits Whether or not to include system-internal commits.
* @return The number of commits that have occurred in the specified time range. May be zero, but never negative.
*/
public int countCommitTimestampsBetween(final String branch, long from, long to, final boolean includeSystemInternalCommits);
/**
* Counts the total number of commit timestamps on the {@link ChronoDBConstants#MASTER_BRANCH_IDENTIFIER master}
* branch.
*
* @return The total number of commits in the graph.
*/
default int countCommitTimestamps() {
return countCommitTimestamps(false);
}
/**
* Counts the total number of commit timestamps on the {@link ChronoDBConstants#MASTER_BRANCH_IDENTIFIER master}
* branch.
*
* @param includeSystemInternalCommits Whether or not to include system-internal commits.
* @return The total number of commits in the graph.
*/
public default int countCommitTimestamps(final boolean includeSystemInternalCommits) {
return this.countCommitTimestamps(ChronoDBConstants.MASTER_BRANCH_IDENTIFIER, includeSystemInternalCommits);
}
/**
* Counts the total number of commit timestamps in the graph.
*
* @param branch The name of the branch to consider. Must not be <code>null</code>, must refer to an existing branch.
* @return The total number of commits in the graph.
*/
public default int countCommitTimestamps(String branch) {
return this.countCommitTimestamps(branch, false);
}
/**
* Counts the total number of commit timestamps in the graph.
*
* @param branch The name of the branch to consider. Must not be <code>null</code>, must refer to an existing branch.
* @param includeSystemInternalCommits Whether or not to include system-internal commits.
* @return The total number of commits in the graph.
*/
public int countCommitTimestamps(String branch, boolean includeSystemInternalCommits);
/**
* Returns an iterator over the IDs of all vertices which have changed on the
* {@linkplain ChronoDBConstants#MASTER_BRANCH_IDENTIFIER master} branch at the given commit timestamp.
*
* @param commitTimestamp The commit timestamp to scan. Must match the commit timestamp exactly, otherwise the resulting
* iterator might be empty. Use methods like {@link #getCommitTimestampsBetween(long, long)} in order to
* search for commit timestamps. Must not be negative. Must be less than {@link #getNow()}.
* @return An iterator over the IDs of vertices that have changed in the master branch at the given commit
* timestamp. May be empty, but never <code>null</code>.
*/
public default Iterator<String> getChangedVerticesAtCommit(final long commitTimestamp) {
return this.getChangedVerticesAtCommit(ChronoDBConstants.MASTER_BRANCH_IDENTIFIER, commitTimestamp);
}
/**
* Returns an iterator over the IDs of all vertices which have changed on the given branch at the given commit
* timestamp.
*
* @param branch The name of the branch to search in. Must not be <code>null</code>. Must refer to an existing branch.
* @param commitTimestamp The commit timestamp to scan. Must match the commit timestamp exactly, otherwise the resulting
* iterator might be empty. Use methods like {@link #getCommitTimestampsBetween(String, long, long)} in
* order to search for commit timestamps. Must not be negative. Must be less than
* {@link #getNow(String))} of the given branch.
* @return An iterator over the IDs of vertices that have changed in the given branch at the given commit timestamp.
* May be empty, but never <code>null</code>.
*/
public Iterator<String> getChangedVerticesAtCommit(String branch, long commitTimestamp);
/**
* Returns an iterator over the IDs of all edges which have changed on the
* {@linkplain ChronoDBConstants#MASTER_BRANCH_IDENTIFIER master} branch at the given commit timestamp.
*
* @param commitTimestamp The commit timestamp to scan. Must match the commit timestamp exactly, otherwise the resulting
* iterator might be empty. Use methods like {@link #getCommitTimestampsBetween(long, long)} in order to
* search for commit timestamps. Must not be negative. Must be less than {@link #getNow()}.
* @return An iterator over the IDs of vertices that have changed in the master branch at the given commit
* timestamp. May be empty, but never <code>null</code>.
*/
public default Iterator<String> getChangedEgesAtCommit(final long commitTimestamp) {
return this.getChangedEdgesAtCommit(ChronoDBConstants.MASTER_BRANCH_IDENTIFIER, commitTimestamp);
}
/**
* Returns an iterator over the IDs of all edges which have changed on the given branch at the given commit
* timestamp.
*
* @param branch The name of the branch to search in. Must not be <code>null</code>. Must refer to an existing branch.
* @param commitTimestamp The commit timestamp to scan. Must match the commit timestamp exactly, otherwise the resulting
* iterator might be empty. Use methods like {@link #getCommitTimestampsBetween(String, long, long)} in
* order to search for commit timestamps. Must not be negative. Must be less than {@link #getNow(String)}
* of the given branch.
* @return An iterator over the IDs of edges that have changed in the given branch at the given commit timestamp.
* May be empty, but never <code>null</code>.
*/
public Iterator<String> getChangedEdgesAtCommit(String branch, long commitTimestamp);
/**
* Returns an iterator over the keys of all graph variables which have changed on the
* {@linkplain ChronoDBConstants#MASTER_BRANCH_IDENTIFIER master} branch at the given commit timestamp, across all variable keyspaces.
*
* @param commitTimestamp The commit timestamp to scan. Must match the commit timestamp exactly, otherwise the resulting
* iterator might be empty. Use methods like {@link #getCommitTimestampsBetween(long, long)} in order to
* search for commit timestamps. Must not be negative. Must be less than {@link #getNow()}.
* @return An iterator over the graph variable keys that have changed in the master branch at the given commit timestamp.
* * May be empty, but never <code>null</code>. The {@link Pair#getLeft() left} part of the pair contains the keyspace (<code>null</code> for the default keyspace),
* * the {@link Pair#getRight() right} part of the pair contains the key. May be empty, but never <code>null</code>.
*/
public Iterator<Pair<String, String>> getChangedGraphVariablesAtCommit(final long commitTimestamp);
/**
* Returns an iterator over the keys of all graph variables which have changed on the
* {@linkplain ChronoDBConstants#MASTER_BRANCH_IDENTIFIER master} branch at the given commit timestamp, limited to the default variable keyspace.
*
* @param commitTimestamp The commit timestamp to scan. Must match the commit timestamp exactly, otherwise the resulting
* iterator might be empty. Use methods like {@link #getCommitTimestampsBetween(long, long)} in order to
* search for commit timestamps. Must not be negative. Must be less than {@link #getNow()}.
* @return An iterator over the graph variable keys that have changed in the master branch at the given commit in the default variables keyspace.
* timestamp. May be empty, but never <code>null</code>.
*/
public Iterator<String> getChangedGraphVariablesAtCommitInDefaultKeyspace(final long commitTimestamp);
/**
* Returns an iterator over the keys of all graph variables which have changed on the
* {@linkplain ChronoDBConstants#MASTER_BRANCH_IDENTIFIER master} branch at the given commit timestamp, limited to the given variable keyspace.
*
* @param commitTimestamp The commit timestamp to scan. Must match the commit timestamp exactly, otherwise the resulting
* iterator might be empty. Use methods like {@link #getCommitTimestampsBetween(long, long)} in order to
* search for commit timestamps. Must not be negative. Must be less than {@link #getNow()}.
* @param keyspace The keyspace to limit the search to. Must not be <code>null</code>.
* @return An iterator over the graph variable keys that have changed in the master branch at the given commit in the given variables keyspace. May be empty, but never <code>null</code>.
*/
public Iterator<String> getChangedGraphVariablesAtCommitInKeyspace(final long commitTimestamp, final String keyspace);
/**
* Returns an iterator over the keys of all graph variables which have changed on the
* given branch at the given commit timestamp.
*
* @param commitTimestamp The commit timestamp to scan. Must match the commit timestamp exactly, otherwise the resulting
* iterator might be empty. Use methods like {@link #getCommitTimestampsBetween(String, long, long)} in order to
* search for commit timestamps. Must not be negative. Must be less than {@link #getNow()}.
* @return An iterator over the graph variable keys that have changed in the given branch at the given commit timestamp.
* May be empty, but never <code>null</code>. The {@link Pair#getLeft() left} part of the pair contains the keyspace (<code>null</code> for the default keyspace),
* the {@link Pair#getRight() right} part of the pair contains the key. May be empty, but never <code>null</code>.
*/
public Iterator<Pair<String, String>> getChangedGraphVariablesAtCommit(final String branch, final long commitTimestamp);
/**
* Returns an iterator over the keys of all graph variables which have changed on the given branch at the given commit timestamp, limited to the default variable keyspace.
*
* @param branch The name of the branch to search in. Must not be <code>null</code>. Must refer to an existing branch.
* @param commitTimestamp The commit timestamp to scan. Must match the commit timestamp exactly, otherwise the resulting
* iterator might be empty. Use methods like {@link #getCommitTimestampsBetween(long, long)} in order to
* search for commit timestamps. Must not be negative. Must be less than {@link #getNow()}.
* @return An iterator over the graph variable keys that have changed in the given branch at the given commit in the default variables keyspace. May be empty, but never <code>null</code>.
*/
public Iterator<String> getChangedGraphVariablesAtCommitInDefaultKeyspace(final String branch, final long commitTimestamp);
/**
* Returns an iterator over the keys of all graph variables which have changed on the given branch at the given commit timestamp, limited to the given variable keyspace.
*
* @param branch The name of the branch to search in. Must not be <code>null</code>. Must refer to an existing branch.
* @param commitTimestamp The commit timestamp to scan. Must match the commit timestamp exactly, otherwise the resulting
* iterator might be empty. Use methods like {@link #getCommitTimestampsBetween(long, long)} in order to
* search for commit timestamps. Must not be negative. Must be less than {@link #getNow()}.
* @param keyspace The keyspace to limit the search to. Must not be <code>null</code>.
* @return An iterator over the graph variable keys that have changed in the given branch at the given commit in the given variables keyspace. May be empty, but never <code>null</code>.
*/
public Iterator<String> getChangedGraphVariablesAtCommitInKeyspace(final String branch, final long commitTimestamp, final String keyspace);
// =================================================================================================================
// GRAPH VARIABLES
// =================================================================================================================
/**
* Returns the variables associated with this graph.
*
* @return The variables. Never <code>null</code>.
*/
@Override
public ChronoGraphVariables variables();
// =================================================================================================================
// GRAPH ITERATOR
// =================================================================================================================
/**
* Starts a new Chrono Graph Iterator builder.
*
* <p>
* Unlike {@linkplain #traversal() traversals} which operate on a <b>single</b> graph state, graph iterators
* allow you to quickly and conveniently iterate over the history and/or branches of the graph, inspecting each
* individual state.
* </p>
*
* <p>
* This method is the start of a builder. Please use the code completion of your IDE to complete the builder.
* </p>
*
* <p>
* <b>IMPORTANT:</b> Iterating over several different branches and/or timestamps implies that multiple transactions
* will need to be created, opened, used and closed (one per branch/timestamp combination). The iterator will handle
* all of this internally. However, this means that <b>any graph elements created within the iterator lambda will NOT
* be usable outside of the iterator lambda.</b>
* </p>
*
* @return The iterator builder. Call one of its methods to continue the builder.
*/
public default ChronoGraphRootIteratorBuilder createIterator() {
return ChronoGraphIterators.createIteratorOn(this);
}
// =====================================================================================================================
// INDEX MANAGEMENT
// =====================================================================================================================
/**
* Returns the index manager for this graph.
*
* <p>
* This will return the index manager for the <i>master</i> branch.
*
* @return The index manager. Never <code>null</code>.
*/
public ChronoGraphIndexManager getIndexManagerOnMaster();
/**
* Returns The index manager for the given branch.
*
* @param branchName The name of the branch to get the index manager for. Must not be <code>null</code>.
* @return The index manger for the given branch. Never <code>null</code>.
*/
public ChronoGraphIndexManager getIndexManagerOnBranch(String branchName);
/**
* Returns The index manager for the given branch.
*
* @param branch The branch to get the index manager for. Must not be <code>null</code>.
* @return The index manger for the given branch. Never <code>null</code>.
*/
public default ChronoGraphIndexManager getIndexManagerOnBranch(GraphBranch branch) {
return this.getIndexManagerOnBranch(branch.getName());
}
// =====================================================================================================================
// BRANCH MANAGEMENT
// =====================================================================================================================
/**
* Returns the branch manager associated with this {@link ChronoGraph}.
*
* @return The branch manager. Never <code>null</code>.
*/
public ChronoGraphBranchManager getBranchManager();
// =================================================================================================================
// TRIGGER MANAGEMENT
// =================================================================================================================
/**
* Returns the trigger manager associated with this {@link ChronoGraph}.
*
* @return The trigger manager. Never <code>null</code>.
*/
public ChronoGraphTriggerManager getTriggerManager();
// =================================================================================================================
// SCHEMA MANAGEMENT
// =================================================================================================================
/**
* Returns the schema manager associated with this {@link ChronoGraph}.
*
* @return The schema manager. Never <code>null</code>.
*/
public ChronoGraphSchemaManager getSchemaManager();
// =================================================================================================================
// MAINTENANCE
// =================================================================================================================
/**
* Returns the maintenance manager associated with this {@link ChronoGraph}.
*
* @return The maintenance manager. Never <code>null</code>.
*/
public ChronoGraphMaintenanceManager getMaintenanceManager();
// =================================================================================================================
// HISTORY
// =================================================================================================================
/**
* Returns the history manager associated with this {@link ChronoGraph}.
*
* @return The history manager. Never <code>null</code>.
*/
public ChronoGraphHistoryManager getHistoryManager();
// =================================================================================================================
// STATISTICS
// =================================================================================================================
/**
* Returns the statistics manager associated with this {@link ChronoGraph}.
*
* @return The statistics manager. Never <code>null</code>.
*/
public ChronoGraphStatisticsManager getStatisticsManager();
// =====================================================================================================================
// DUMP API
// =====================================================================================================================
/**
* Creates a database dump of the entire current database state.
*
* <p>
* Please note that the database is not available for write operations while the dump process is running. Read
* operations will work concurrently as usual.
*
* <p>
* <b>WARNING:</b> The file created by this process may be very large (several gigabytes), depending on the size of
* the database. It is the responsibility of the user of this API to ensure that enough disk space is available;
* this method does not perform any checks regarding disk space availability!
*
* <p>
* <b>WARNING:</b> The given file will be <b>overwritten</b> without further notice!
*
* @param dumpFile The file to store the dump into. Must not be <code>null</code>. Must point to a file (not a
* directory). The standard file extension <code>*.chronodump</code> is recommmended, but not required.
* If the file does not exist, the file (and any missing parent directory) will be created.
* @param dumpOptions The options to use for this dump (optional). Please refer to the documentation of the invididual
* constants for details.
*/
public void writeDump(File dumpFile, DumpOption... dumpOptions);
/**
* Reads the contents of the given dump file into this database.
*
* <p>
* This is a management operation; it completely locks the database. No concurrent writes or reads will be permitted
* while this operation is being executed.
*
* <p>
* <b>WARNING:</b> The current contents of the database will be <b>merged</b> with the contents of the dump! In case
* of conflicts, the data stored in the dump file will take precedence. It is <i>strongly recommended</i> to perform
* this operation only on an <b>empty</b> database!
*
* <p>
* <b>WARNING:</b> As this is a management operation, there is no rollback or undo option!
*
* @param dumpFile The dump file to read the data from. Must not be <code>null</code>, must exist, and must point to a
* file (not a directory).
* @param options The options to use while reading (optional). May be empty.
*/
public void readDump(File dumpFile, DumpOption... options);
}
| 148,057 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
ChronoElement.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/structure/ChronoElement.java | package org.chronos.chronograph.api.structure;
import org.apache.tinkerpop.gremlin.structure.Element;
import org.apache.tinkerpop.gremlin.structure.Property;
import org.chronos.chronograph.api.transaction.ChronoGraphTransaction;
import org.chronos.chronograph.internal.impl.structure.graph.ElementLifecycleEvent;
/**
* A {@link ChronoElement} is a {@link ChronoGraph}-specific extension of the general TinkerPop {@link Element} class.
*
* <p>
* This interface defines additional methods for all graph elements, mostly intended for internal use only.
*
* @author martin.haeusler@uibk.ac.at -- Initial Contribution and API
*/
public interface ChronoElement extends Element {
/**
* Gets the unique identifier for the graph {@code ChronoElement}.
*
* <p>
* This method has been redefined from {@link Element#id()} to have a return type of {@link String} (instead of {@link Object}).
*
* @return The id of the element. Never <code>null</code>.
*/
@Override
public String id();
/**
* Get the {@link ChronoGraph} that this element is within.
*
* @return The graph of this element. Never <code>null</code>.
*/
@Override
public ChronoGraph graph();
/**
* Remove the property with the given key (name) from this element.
*
* @param key The key (name) of the property to remove. Must not be <code>null</code>.
*/
public void removeProperty(String key);
/**
* Checks if this element has been {@linkplain #remove() removed} from the graph or not.
*
* @return <code>true</code> if this element has been removed from the graph, or <code>true</code> if it is still a member of the graph.
*/
public boolean isRemoved();
/**
* Returns the {@link ChronoGraphTransaction} to which this element belongs.
*
* @return The owning transaction. Never <code>null</code>.
*/
public ChronoGraphTransaction getOwningTransaction();
/**
* Returns the state of the transaction rollback counter that was valid at the time when this element was loaded.
*
* @return The number of rollbacks done on the graph transaction before loading this element. Always greater than or equal to zero.
*/
public long getLoadedAtRollbackCount();
/**
* Updates the lifecycle status of this element, based on the given event. For internal use only.
*
* <i>For internal use only</i>.
*
* @param event The lifecycle event which has occurred. Must not be <code>null</code>.
*/
public void updateLifecycleStatus(final ElementLifecycleEvent event);
/**
* Returns the current status of the {@link Property} with the given key.
*
* <p>
* The result may be one of the following:
* <ul>
* <li>{@link PropertyStatus#UNKNOWN}: indicates that a property with the given key has never existed on this vertex.
* <li>{@link PropertyStatus#NEW}: the property has been newly added in this transaction.
* <li>{@link PropertyStatus#MODIFIED}: the property has existed before, but was modified in this transaction.
* <li>{@link PropertyStatus#REMOVED}: the property has existed before, but was removed in this transaction.
* <li>{@link PropertyStatus#PERSISTED}: the property exists and is unchanged.
* </ul>
*
* @param propertyKey The property key to search for. Must not be <code>null</code>.
* @return The status of the property with the given key, as outlined above. Never <code>null</code>.
*/
public PropertyStatus getPropertyStatus(String propertyKey);
/**
* Returns the current lifecycle status of this element.
*
* @return the lifecycle status. Never <code>null</code>.
*/
public ElementLifecycleStatus getStatus();
/**
* Returns <code>true</code> if this element is lazy-loading and has yet to be fetched from the backing store.
*
* Returns <code>false</code> if the element has already been fully loaded.
*
* @return <code>true</code> if this element is lazy-loading and has yet to be fetched from the backing store,
* or <code>false</code> if the element has already been fully loaded.
*/
public boolean isLazy();
}
| 4,256 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
ChronoGraphVariables.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/structure/ChronoGraphVariables.java | package org.chronos.chronograph.api.structure;
import org.apache.tinkerpop.gremlin.structure.Graph;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
public interface ChronoGraphVariables extends Graph.Variables {
/**
* Gets the key set of the <b>default</b> graph variables keyspace.
*/
public Set<String> keys();
/**
* Gets the key set of the given graph variables keyspace.
*
* @param keyspace The keyspace to get the keys for. Must not be <code>null</code>.
* @return The key set. Will be empty if the keyspace is unknown. Never <code>null</code>.
*/
public Set<String> keys(String keyspace);
/**
* Gets a variable from the <b>default</b> graph variables keyspace.
*
* @param key The key to get the value for.
* @return The value, as an {@link Optional}. Will never be <code>null</code>, but may be {@linkplain Optional#isPresent() absent} if the variable doesn't exist.
*/
public <R> Optional<R> get(final String key);
/**
* Gets a variable from the given graph variables keyspace.
*
* @param keyspace The keyspace in which to search for the key. Must not be <code>null</code>.
* @param key The key to get the value for. Must not be <code>null</code>.
* @param <R> The expected type of the value.
* @return The value, as an {@link Optional}. Will never be <code>null</code>, but may be {@linkplain Optional#isPresent() absent} if the variable doesn't exist.
*/
public <R> Optional<R> get(final String keyspace, final String key);
/**
* Sets a variable in the <b>default</b> graph variables keyspace.
* <p>
* Any previous value will be silently overwritten.
*
* @param key The variable to set. Must not be <code>null</code>.
* @param value The value to assign to the variable. Must not be <code>null</code>. If you wish to clear a variable, use {@link #remove(String)} instead.
* @see #set(String, String, Object)
*/
public void set(final String key, Object value);
/**
* Sets a variable in the given keyspace to the given value.
*
* @param keyspace The keyspace of the variable to set. Must not be <code>null</code>.
* @param key The key to set the value for. Must not be <code>null</code>.
* @param value The value to assign. Must not be <code>null</code>. If you wish to clear a variable, use {@link #remove(String, String)} instead.
* @see #set(String, Object)
*/
public void set(final String keyspace, final String key, final Object value);
/**
* Removes a variable from the <b>default</b> graph variables keyspace.
*/
public void remove(final String key);
/**
* Removes a variable from the given keyspace.
*
* @param keyspace The keyspace of the variable to remove. Must not be <code>null</code>.
* @param key The key to remove. Must not be <code>null</code>.
*/
public void remove(final String keyspace, final String key);
/**
* Gets the variables of the <b>default</b> variables keyspace as a {@code Map}.
*/
public Map<String, Object> asMap();
/**
* Gets the variables of the given variables keyspace as a {@link Map}.
*
* @param keyspace
* @return
*/
public Map<String, Object> asMap(String keyspace);
/**
* Gets the set of known variables keyspaces.
*
* @return The set of known keyspaces.
*/
public Set<String> keyspaces();
}
| 3,551 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
ElementLifecycleStatus.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/structure/ElementLifecycleStatus.java | package org.chronos.chronograph.api.structure;
import org.chronos.chronograph.internal.impl.structure.graph.ElementLifecycleEvent;
import org.chronos.common.exceptions.UnknownEnumLiteralException;
import java.util.function.Function;
import static com.google.common.base.Preconditions.*;
public enum ElementLifecycleStatus {
// =================================================================================================================
// ENUM CONSTANTS
// =================================================================================================================
/**
* The element was newly added in this transaction. It has never been persisted before.
*/
NEW(ElementLifecycleStatus::stateTransitionFromNew),
/**
* The element is in-sync with the persistence backend and unchanged.
*/
PERSISTED(ElementLifecycleStatus::stateTransitionFromPersisted),
/**
* The element was removed by the user in this transaction.
*/
REMOVED(ElementLifecycleStatus::stateTransitionFromRemoved),
/**
* Properties of the element have changed. This includes also edge changes.
*/
PROPERTY_CHANGED(ElementLifecycleStatus::stateTransitionFromPropertyChanged),
/**
* Edges of the vertex have changed. Properties are unchanged so far.
*/
EDGE_CHANGED(ElementLifecycleStatus::stateTransitionFromEdgeChanged),
/**
* The element has been in state {@link #NEW}, but has been removed before ever being persisted.
*/
OBSOLETE(ElementLifecycleStatus::stateTransitionFromObsolete);
// =================================================================================================================
// FIELDS
// =================================================================================================================
private final Function<ElementLifecycleEvent, ElementLifecycleStatus> transitionFunction;
// =================================================================================================================
// CONSTRUCTOR
// =================================================================================================================
ElementLifecycleStatus(Function<ElementLifecycleEvent, ElementLifecycleStatus> transitionFunction) {
checkNotNull(transitionFunction, "Precondition violation - argument 'transitionFunction' must not be NULL!");
this.transitionFunction = transitionFunction;
}
// =================================================================================================================
// PUBLIC API
// =================================================================================================================
public boolean isDirty() {
return this.equals(PERSISTED) == false;
}
// =================================================================================================================
// STATE TRANSITION FUNCTIONS
// =================================================================================================================
private static ElementLifecycleStatus stateTransitionFromNew(ElementLifecycleEvent event) {
ElementLifecycleStatus self = ElementLifecycleStatus.NEW;
switch (event) {
case CREATED:
// no-op
return self;
case ADJACENT_EDGE_ADDED_OR_REMOVED:
// ignore; NEW already includes EDGE_CHANGED
return self;
case DELETED:
// new element was deleted -> obsolete
return ElementLifecycleStatus.OBSOLETE;
case SAVED:
// new element was saved -> persisted
return ElementLifecycleStatus.PERSISTED;
case PROPERTY_CHANGED:
// ignore; NEW already includes PROPERTY_CHANGED
return self;
case RECREATED_FROM_OBSOLETE:
// the element has been recreated but it was obsolete before -> it's new now
return self;
case RECREATED_FROM_REMOVED:
// the element has been recreated, but it was REMOVED before -> it is changed now
return ElementLifecycleStatus.PROPERTY_CHANGED;
case RELOADED_FROM_DB_AND_NO_LONGER_EXISTENT:
return ElementLifecycleStatus.REMOVED;
case RELOADED_FROM_DB_AND_IN_SYNC:
return ElementLifecycleStatus.PERSISTED;
default:
throw new UnknownEnumLiteralException(event);
}
}
private static ElementLifecycleStatus stateTransitionFromPersisted(ElementLifecycleEvent event) {
ElementLifecycleStatus self = ElementLifecycleStatus.PERSISTED;
switch (event) {
case CREATED:
// we cannot "create" an element that already exists
// and is in sync with persistence...
throw new IllegalStateTransitionException(self, event);
case ADJACENT_EDGE_ADDED_OR_REMOVED:
// accept
return ElementLifecycleStatus.EDGE_CHANGED;
case PROPERTY_CHANGED:
// accept
return ElementLifecycleStatus.PROPERTY_CHANGED;
case RECREATED_FROM_OBSOLETE:
// we cannot be recreated, we still exist
throw new IllegalStateTransitionException(self, event);
case RECREATED_FROM_REMOVED:
// we cannot be recreated, we still exist
throw new IllegalStateTransitionException(self, event);
case SAVED:
// no-op
return self;
case DELETED:
// accept
return ElementLifecycleStatus.REMOVED;
case RELOADED_FROM_DB_AND_NO_LONGER_EXISTENT:
return ElementLifecycleStatus.REMOVED;
case RELOADED_FROM_DB_AND_IN_SYNC:
return ElementLifecycleStatus.PERSISTED;
default:
throw new UnknownEnumLiteralException(event);
}
}
private static ElementLifecycleStatus stateTransitionFromRemoved(ElementLifecycleEvent event) {
ElementLifecycleStatus self = ElementLifecycleStatus.REMOVED;
switch (event) {
case CREATED:
// we cannot be created when we are removed (would have to be RE-created)
throw new IllegalStateTransitionException(self, event);
case ADJACENT_EDGE_ADDED_OR_REMOVED:
// on a removed element, no edges may be added and/or removed
throw new IllegalStateTransitionException(self, event);
case PROPERTY_CHANGED:
// on a removed element, no property may be changed
throw new IllegalStateTransitionException(self, event);
case RECREATED_FROM_OBSOLETE:
// cannot recreate an already existing element...
throw new IllegalStateTransitionException(self, event);
case RECREATED_FROM_REMOVED:
// cannot recreate an already existing element...
throw new IllegalStateTransitionException(self, event);
case SAVED:
// when we are removed, we cannot be saved
throw new IllegalStateTransitionException(self, event);
case DELETED:
// well, we are already deleted...
throw new IllegalStateTransitionException(self, event);
case RELOADED_FROM_DB_AND_NO_LONGER_EXISTENT:
return ElementLifecycleStatus.REMOVED;
case RELOADED_FROM_DB_AND_IN_SYNC:
return ElementLifecycleStatus.PERSISTED;
default:
throw new UnknownEnumLiteralException(event);
}
}
private static ElementLifecycleStatus stateTransitionFromPropertyChanged(ElementLifecycleEvent event) {
ElementLifecycleStatus self = ElementLifecycleStatus.PROPERTY_CHANGED;
switch (event) {
case CREATED:
// we cannot be created when we already exist
throw new IllegalStateTransitionException(self, event);
case ADJACENT_EDGE_ADDED_OR_REMOVED:
// this state subsumes adjacent edge modification, so we stay in this state
return self;
case PROPERTY_CHANGED:
// no-op
return self;
case RECREATED_FROM_OBSOLETE:
// we cannot be recreated, we still exist
throw new IllegalStateTransitionException(self, event);
case RECREATED_FROM_REMOVED:
// we cannot be recreated, we still exist
throw new IllegalStateTransitionException(self, event);
case SAVED:
// this element has been saved and is clean now
return ElementLifecycleStatus.PERSISTED;
case DELETED:
// the element has been deleted
return ElementLifecycleStatus.REMOVED;
case RELOADED_FROM_DB_AND_NO_LONGER_EXISTENT:
return ElementLifecycleStatus.REMOVED;
case RELOADED_FROM_DB_AND_IN_SYNC:
return ElementLifecycleStatus.PERSISTED;
default:
throw new UnknownEnumLiteralException(event);
}
}
private static ElementLifecycleStatus stateTransitionFromEdgeChanged(ElementLifecycleEvent event) {
ElementLifecycleStatus self = ElementLifecycleStatus.EDGE_CHANGED;
switch (event) {
case CREATED:
// an element that already exists cannot be recreated...
throw new IllegalStateTransitionException(self, event);
case ADJACENT_EDGE_ADDED_OR_REMOVED:
// no-op
return self;
case PROPERTY_CHANGED:
// property change subsumes edge change, so we accept this change
return ElementLifecycleStatus.PROPERTY_CHANGED;
case SAVED:
// accept
return ElementLifecycleStatus.PERSISTED;
case DELETED:
// accept
return ElementLifecycleStatus.REMOVED;
case RECREATED_FROM_OBSOLETE:
// cannot recreate an already existing element...
throw new IllegalStateTransitionException(self, event);
case RECREATED_FROM_REMOVED:
// cannot recreate an already existing element...
throw new IllegalStateTransitionException(self, event);
case RELOADED_FROM_DB_AND_NO_LONGER_EXISTENT:
return ElementLifecycleStatus.REMOVED;
case RELOADED_FROM_DB_AND_IN_SYNC:
return ElementLifecycleStatus.PERSISTED;
default:
throw new UnknownEnumLiteralException(event);
}
}
private static ElementLifecycleStatus stateTransitionFromObsolete(ElementLifecycleEvent event) {
ElementLifecycleStatus self = ElementLifecycleStatus.OBSOLETE;
switch (event) {
case CREATED:
// an element that is obsolete cannot be created (only RE-created)
throw new IllegalStateTransitionException(self, event);
case ADJACENT_EDGE_ADDED_OR_REMOVED:
// an element that is obsolete cannot receive any changes
throw new IllegalStateTransitionException(self, event);
case PROPERTY_CHANGED:
// an element that is obsolete cannot receive any changes
throw new IllegalStateTransitionException(self, event);
case SAVED:
// an obsolete element cannot be saved
throw new IllegalStateTransitionException(self, event);
case DELETED:
// an obsolete element has already been deleted
throw new IllegalStateTransitionException(self, event);
case RECREATED_FROM_OBSOLETE:
// this never occurs on an existing element; recreations
// always occur on NEW elements.
throw new IllegalStateTransitionException(self, event);
case RECREATED_FROM_REMOVED:
// this never occurs on an existing element; recreations
// always occur on NEW elements.
throw new IllegalStateTransitionException(self, event);
case RELOADED_FROM_DB_AND_NO_LONGER_EXISTENT:
return ElementLifecycleStatus.REMOVED;
case RELOADED_FROM_DB_AND_IN_SYNC:
return ElementLifecycleStatus.PERSISTED;
default:
throw new UnknownEnumLiteralException(event);
}
}
public ElementLifecycleStatus nextState(ElementLifecycleEvent event) {
checkNotNull(event, "Precondition violation - argument 'event' must not be NULL!");
return this.transitionFunction.apply(event);
}
public static class IllegalStateTransitionException extends RuntimeException {
private final ElementLifecycleStatus status;
private final ElementLifecycleEvent event;
public IllegalStateTransitionException(ElementLifecycleStatus status, ElementLifecycleEvent event) {
this.status = status;
this.event = event;
}
@Override
public String getMessage() {
return "There is no transition from state '" + this.status + "' with event '" + this.event + "'!";
}
}
}
| 13,622 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
ChronoEdge.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/structure/ChronoEdge.java | package org.chronos.chronograph.api.structure;
import org.apache.tinkerpop.gremlin.structure.Edge;
/**
* The {@link ChronoGraph}-specific representation of the general-purpose TinkerPop {@link Edge} interface.
*
* <p>
* This interface defines additional methods for all graph elements, mostly intended for internal use only.
*
* @author martin.haeusler@uibk.ac.at -- Initial Contribution and API
*/
public interface ChronoEdge extends Edge, ChronoElement {
} | 468 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
ChronoVertex.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/structure/ChronoVertex.java | package org.chronos.chronograph.api.structure;
import org.apache.tinkerpop.gremlin.structure.Vertex;
/**
* The {@link ChronoGraph}-specific representation of the general-purpose TinkerPop {@link Vertex} interface.
*
* <p>
* This interface defines additional methods for all graph elements, mostly intended for internal use only.
*
* @author martin.haeusler@uibk.ac.at -- Initial Contribution and API
*/
public interface ChronoVertex extends Vertex, ChronoElement {
} | 477 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
PropertyStatus.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/structure/PropertyStatus.java | package org.chronos.chronograph.api.structure;
import org.apache.tinkerpop.gremlin.structure.Property;
/**
* Describes the lifecycle status of a single {@link Property}.
*/
public enum PropertyStatus {
/**
* The property has been newly added in this transaction.
*
* The key was unused before that.
*/
NEW,
/**
* The property has existed before, but was removed in this transaction.
*/
REMOVED,
/**
* The property has existed before, but was modified in this transaction.
*/
MODIFIED,
/**
* The property exists and is unchanged with respect to the already persisted version.
*/
PERSISTED,
/**
* Indicates that the property has never existed on the graph element.
*
* The property key is therefore "unknown to the element".
*/
UNKNOWN
}
| 784 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
IPropertyRecord.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/structure/record/IPropertyRecord.java | package org.chronos.chronograph.api.structure.record;
public interface IPropertyRecord extends Record {
public String getKey();
public Object getValue();
public Object getSerializationSafeValue();
}
| 215 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
IEdgeRecord.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/structure/record/IEdgeRecord.java | package org.chronos.chronograph.api.structure.record;
public interface IEdgeRecord extends IElementRecord {
String getOutVertexId();
String getInVertexId();
public static IEdgeRecordBuilder builder(){
return new IEdgeRecordBuilder();
}
}
| 267 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
IVertexRecord.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/structure/record/IVertexRecord.java | package org.chronos.chronograph.api.structure.record;
import com.google.common.collect.SetMultimap;
import org.chronos.chronograph.internal.impl.structure.record.EdgeTargetRecordWithLabel;
import java.util.List;
import java.util.Set;
public interface IVertexRecord extends IElementRecord {
public List<EdgeTargetRecordWithLabel> getIncomingEdges();
public List<EdgeTargetRecordWithLabel> getIncomingEdges(String... labels);
public SetMultimap<String, IEdgeTargetRecord> getIncomingEdgesByLabel();
public List<EdgeTargetRecordWithLabel> getOutgoingEdges();
public List<EdgeTargetRecordWithLabel> getOutgoingEdges(String... labels);
public SetMultimap<String, IEdgeTargetRecord> getOutgoingEdgesByLabel();
@Override
public Set<IVertexPropertyRecord> getProperties();
@Override
public IVertexPropertyRecord getProperty(String propertyKey);
public static IVertexRecordBuilder builder(){
return new IVertexRecordBuilder();
}
}
| 991 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
IEdgeTargetRecord.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/structure/record/IEdgeTargetRecord.java | package org.chronos.chronograph.api.structure.record;
public interface IEdgeTargetRecord extends Record {
public String getEdgeId();
public String getOtherEndVertexId();
}
| 184 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
IVertexPropertyRecord.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/structure/record/IVertexPropertyRecord.java | package org.chronos.chronograph.api.structure.record;
import java.util.Map;
public interface IVertexPropertyRecord extends IPropertyRecord {
public Map<String, IPropertyRecord> getProperties();
}
| 204 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
IElementRecord.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/structure/record/IElementRecord.java | package org.chronos.chronograph.api.structure.record;
import java.util.Set;
public interface IElementRecord extends Record {
public String getId();
public String getLabel();
public Set<? extends IPropertyRecord> getProperties();
public IPropertyRecord getProperty(String propertyKey);
}
| 310 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
ChronoGraphIteratorBuilder.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/iterators/ChronoGraphIteratorBuilder.java | package org.chronos.chronograph.api.iterators;
import org.chronos.chronograph.api.structure.ChronoGraph;
public interface ChronoGraphIteratorBuilder {
public ChronoGraph getGraph();
}
| 192 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
ChronoGraphTimestampIteratorBuilder.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/iterators/ChronoGraphTimestampIteratorBuilder.java | package org.chronos.chronograph.api.iterators;
import org.chronos.chronograph.api.iterators.states.AllChangedEdgeIdsAndTheirPreviousNeighborhoodState;
import org.chronos.chronograph.api.iterators.states.AllChangedEdgeIdsState;
import org.chronos.chronograph.api.iterators.states.AllChangedElementIdsAndTheirNeighborhoodState;
import org.chronos.chronograph.api.iterators.states.AllChangedElementIdsState;
import org.chronos.chronograph.api.iterators.states.AllChangedVertexIdsAndTheirPreviousNeighborhoodState;
import org.chronos.chronograph.api.iterators.states.AllChangedVertexIdsState;
import org.chronos.chronograph.api.iterators.states.AllEdgesState;
import org.chronos.chronograph.api.iterators.states.AllElementsState;
import org.chronos.chronograph.api.iterators.states.AllVerticesState;
import org.chronos.chronograph.api.iterators.states.GraphIteratorState;
import java.util.function.Consumer;
public interface ChronoGraphTimestampIteratorBuilder extends ChronoGraphIteratorBuilder {
public void visitCoordinates(Consumer<GraphIteratorState> consumer);
public void overAllVertices(Consumer<AllVerticesState> consumer);
public void overAllEdges(Consumer<AllEdgesState> consumer);
public void overAllElements(Consumer<AllElementsState> consumer);
public void overAllChangedVertexIds(Consumer<AllChangedVertexIdsState> consumer);
public void overAllChangedEdgeIds(Consumer<AllChangedEdgeIdsState> consumer);
public void overAllChangedElementIds(Consumer<AllChangedElementIdsState> consumer);
public void overAllChangedVertexIdsAndTheirPreviousNeighborhood(Consumer<AllChangedVertexIdsAndTheirPreviousNeighborhoodState> consumer);
public void overAllChangedEdgeIdsAndTheirPreviousNeighborhood(Consumer<AllChangedEdgeIdsAndTheirPreviousNeighborhoodState> consumer);
public void overAllChangedElementIdsAndTheirPreviousNeighborhood(Consumer<AllChangedElementIdsAndTheirNeighborhoodState> consumer);
}
| 1,960 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
ChronoGraphBranchIteratorBuilder.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/iterators/ChronoGraphBranchIteratorBuilder.java | package org.chronos.chronograph.api.iterators;
import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
import org.chronos.chronograph.api.iterators.callbacks.TimestampChangeCallback;
import org.chronos.chronograph.api.structure.ChronoGraph;
import org.chronos.chronograph.internal.impl.transaction.threaded.ChronoThreadedTransactionGraph;
import java.util.Iterator;
import java.util.List;
import java.util.function.Function;
import java.util.function.Predicate;
import static com.google.common.base.Preconditions.*;
public interface ChronoGraphBranchIteratorBuilder extends ChronoGraphIteratorBuilder {
public default ChronoGraphTimestampIteratorBuilder overAllCommitTimestampsDescendingBefore(long timestamp) {
checkArgument(timestamp >= 0, "Precondition violation - argument 'timestamp' must not be negative!");
return this.overAllCommitTimestampsDescendingBefore(timestamp, TimestampChangeCallback.IGNORE);
}
public default ChronoGraphTimestampIteratorBuilder overAllCommitTimestampsDescendingBefore(long timestamp, TimestampChangeCallback callback) {
checkArgument(timestamp >= 0, "Precondition violation - argument 'timestamp' must not be negative!");
checkNotNull(callback, "Precondition violation - argument 'callback' must not be NULL!");
return this.overAllCommitTimestampsDescendingBefore(timestamp, Integer.MAX_VALUE, callback);
}
public default ChronoGraphTimestampIteratorBuilder overAllCommitTimestampsDescendingBefore(long timestamp, int limit) {
checkArgument(timestamp >= 0, "Precondition violation - argument 'timestamp' must not be negative!");
checkArgument(limit > 0, "Precondition violation - argument 'limit' must be greater than zero!");
return this.overAllCommitTimestampsDescendingBefore(timestamp, limit, TimestampChangeCallback.IGNORE);
}
public default ChronoGraphTimestampIteratorBuilder overAllCommitTimestampsDescendingBefore(long timestamp, int limit, TimestampChangeCallback callback) {
checkArgument(timestamp >= 0, "Precondition violation - argument 'timestamp' must not be negative!");
checkArgument(limit > 0, "Precondition violation - argument 'limit' must be greater than zero!");
checkNotNull(callback, "Precondition violation - argument 'callback' must not be NULL!");
return this.overAllCommitTimestampsDescendingBefore(timestamp, limit, t -> true, callback);
}
public default ChronoGraphTimestampIteratorBuilder overAllCommitTimestampsDescendingBefore(long timestamp, Predicate<Long> filter) {
checkArgument(timestamp >= 0, "Precondition violation - argument 'timestamp' must not be negative!");
checkNotNull(filter, "Precondition violation - argument 'filter' must not be NULL!");
return this.overAllCommitTimestampsDescendingBefore(timestamp, Integer.MAX_VALUE, filter);
}
public default ChronoGraphTimestampIteratorBuilder overAllCommitTimestampsDescendingBefore(long timestamp, Predicate<Long> filter, TimestampChangeCallback callback) {
checkArgument(timestamp >= 0, "Precondition violation - argument 'timestamp' must not be negative!");
checkNotNull(filter, "Precondition violation - argument 'filter' must not be NULL!");
checkNotNull(callback, "Precondition violation - argument 'callback' must not be NULL!");
return this.overAllCommitTimestampsDescendingBefore(timestamp, Integer.MAX_VALUE, filter, callback);
}
public default ChronoGraphTimestampIteratorBuilder overAllCommitTimestampsDescendingBefore(long timestamp, int limit, Predicate<Long> filter) {
checkArgument(timestamp >= 0, "Precondition violation - argument 'timestamp' must not be negative!");
checkArgument(limit > 0, "Precondition violation - argument 'limit' must be greater than zero!");
checkNotNull(filter, "Precondition violation - argument 'filter' must not be NULL!");
return this.overAllCommitTimestampsDescendingBefore(timestamp, limit, filter, TimestampChangeCallback.IGNORE);
}
public default ChronoGraphTimestampIteratorBuilder overAllCommitTimestampsDescendingBefore(long timestamp, int limit, Predicate<Long> filter, TimestampChangeCallback callback) {
checkArgument(timestamp >= 0, "Precondition violation - argument 'timestamp' must not be negative!");
checkArgument(limit > 0, "Precondition violation - argument 'limit' must be greater than zero!");
checkNotNull(filter, "Precondition violation - argument 'filter' must not be NULL!");
checkNotNull(callback, "Precondition violation - argument 'callback' must not be NULL!");
return this.overTimestamps(branch -> {
Iterator<Long> timestamps = this.getGraph().getCommitTimestampsBefore(branch, timestamp, limit).iterator();
return Iterators.filter(timestamps, t -> filter.test(t));
}, callback);
}
public default ChronoGraphTimestampIteratorBuilder overAllCommitTimestampsDescendingAfter(long timestamp) {
checkArgument(timestamp >= 0, "Precondition violation - argument 'timestamp' must not be negative!");
return this.overAllCommitTimestampsDescendingAfter(timestamp, TimestampChangeCallback.IGNORE);
}
public default ChronoGraphTimestampIteratorBuilder overAllCommitTimestampsDescendingAfter(long timestamp, TimestampChangeCallback callback) {
checkArgument(timestamp >= 0, "Precondition violation - argument 'timestamp' must not be negative!");
checkNotNull(callback, "Precondition violation - argument 'callback' must not be NULL!");
return this.overAllCommitTimestampsDescendingAfter(timestamp, Integer.MAX_VALUE, callback);
}
public default ChronoGraphTimestampIteratorBuilder overAllCommitTimestampsDescendingAfter(long timestamp, int limit) {
checkArgument(timestamp >= 0, "Precondition violation - argument 'timestamp' must not be negative!");
checkArgument(limit > 0, "Precondition violation - argument 'limit' must be greater than zero!");
return this.overAllCommitTimestampsDescendingAfter(timestamp, limit, TimestampChangeCallback.IGNORE);
}
public default ChronoGraphTimestampIteratorBuilder overAllCommitTimestampsDescendingAfter(long timestamp, int limit, TimestampChangeCallback callback) {
checkArgument(timestamp >= 0, "Precondition violation - argument 'timestamp' must not be negative!");
checkArgument(limit > 0, "Precondition violation - argument 'limit' must be greater than zero!");
checkNotNull(callback, "Precondition violation - argument 'callback' must not be NULL!");
return this.overAllCommitTimestampsDescendingAfter(timestamp, limit, t -> true, callback);
}
public default ChronoGraphTimestampIteratorBuilder overAllCommitTimestampsDescendingAfter(long timestamp, Predicate<Long> filter) {
checkArgument(timestamp >= 0, "Precondition violation - argument 'timestamp' must not be negative!");
checkNotNull(filter, "Precondition violation - argument 'filter' must not be NULL!");
return this.overAllCommitTimestampsDescendingAfter(timestamp, Integer.MAX_VALUE, filter);
}
public default ChronoGraphTimestampIteratorBuilder overAllCommitTimestampsDescendingAfter(long timestamp, Predicate<Long> filter, TimestampChangeCallback callback) {
checkArgument(timestamp >= 0, "Precondition violation - argument 'timestamp' must not be negative!");
checkNotNull(filter, "Precondition violation - argument 'filter' must not be NULL!");
checkNotNull(callback, "Precondition violation - argument 'callback' must not be NULL!");
return this.overAllCommitTimestampsDescendingAfter(timestamp, Integer.MAX_VALUE, filter, callback);
}
public default ChronoGraphTimestampIteratorBuilder overAllCommitTimestampsDescendingAfter(long timestamp, int limit, Predicate<Long> filter) {
checkArgument(timestamp >= 0, "Precondition violation - argument 'timestamp' must not be negative!");
checkArgument(limit > 0, "Precondition violation - argument 'limit' must be greater than zero!");
checkNotNull(filter, "Precondition violation - argument 'filter' must not be NULL!");
return this.overAllCommitTimestampsDescendingAfter(timestamp, limit, filter, TimestampChangeCallback.IGNORE);
}
public default ChronoGraphTimestampIteratorBuilder overAllCommitTimestampsDescendingAfter(long timestamp, int limit, Predicate<Long> filter, TimestampChangeCallback callback) {
checkArgument(timestamp >= 0, "Precondition violation - argument 'timestamp' must not be negative!");
checkArgument(limit > 0, "Precondition violation - argument 'limit' must be greater than zero!");
checkNotNull(filter, "Precondition violation - argument 'filter' must not be NULL!");
checkNotNull(callback, "Precondition violation - argument 'callback' must not be NULL!");
return this.overTimestamps(branch -> {
Iterator<Long> timestamps = this.getGraph().getCommitTimestampsAfter(branch, timestamp, limit).iterator();
return Iterators.filter(timestamps, t -> filter.test(t));
}, callback);
}
public default ChronoGraphTimestampIteratorBuilder overAllCommitTimestampsDescending() {
return this.overAllCommitTimestampsDescending(TimestampChangeCallback.IGNORE);
}
public default ChronoGraphTimestampIteratorBuilder overAllCommitTimestampsDescending(TimestampChangeCallback callback) {
checkNotNull(callback, "Precondition violation - argument 'callback' must not be NULL!");
return this.overAllCommitTimestampsDescending(Integer.MAX_VALUE, (timestamp -> true), callback);
}
public default ChronoGraphTimestampIteratorBuilder overAllCommitTimestampsDescending(Predicate<Long> filter) {
checkNotNull(filter, "Precondition violation - argument 'filter' must not be NULL!");
return this.overAllCommitTimestampsDescending(Integer.MAX_VALUE, filter, TimestampChangeCallback.IGNORE);
}
public default ChronoGraphTimestampIteratorBuilder overAllCommitTimestampsDescending(Predicate<Long> filter, TimestampChangeCallback callback) {
checkNotNull(filter, "Precondition violation - argument 'filter' must not be NULL!");
checkNotNull(callback, "Precondition violation - argument 'callback' must not be NULL!");
return this.overAllCommitTimestampsDescending(Integer.MAX_VALUE, filter, callback);
}
public default ChronoGraphTimestampIteratorBuilder overAllCommitTimestampsDescending(int limit, Predicate<Long> filter, TimestampChangeCallback callback) {
checkNotNull(filter, "Precondition violation - argument 'filter' must not be NULL!");
checkArgument(limit > 0, "Precondition violation - argument 'limit' must be greater than zero!");
checkNotNull(callback, "Precondition violation - argument 'callback' must not be NULL!");
return this.overTimestamps(branch -> {
Iterator<Long> timestamps = this.getGraph().getCommitTimestampsAfter(branch, 0L, limit).iterator();
return Iterators.filter(timestamps, t -> filter.test(t));
}, callback);
}
public default ChronoGraphTimestampIteratorBuilder overHistoryOfVertex(String vertexId) {
checkNotNull(vertexId, "Precondition violation - argument 'vertexId' must not be NULL!");
return this.overHistoryOfVertex(vertexId, Integer.MAX_VALUE);
}
public default ChronoGraphTimestampIteratorBuilder overHistoryOfVertex(String vertexId, Predicate<Long> filter) {
checkNotNull(vertexId, "Precondition violation - argument 'vertexId' must not be NULL!");
checkNotNull(filter, "Precondition violation - argument 'filter' must not be NULL!");
return this.overHistoryOfVertex(vertexId, Integer.MAX_VALUE, filter);
}
public default ChronoGraphTimestampIteratorBuilder overHistoryOfVertex(String vertexId, TimestampChangeCallback callback) {
checkNotNull(vertexId, "Precondition violation - argument 'vertexId' must not be NULL!");
checkNotNull(callback, "Precondition violation - argument 'callback' must not be NULL!");
return this.overHistoryOfVertex(vertexId, Integer.MAX_VALUE, callback);
}
public default ChronoGraphTimestampIteratorBuilder overHistoryOfVertex(String vertexId, int limit) {
checkNotNull(vertexId, "Precondition violation - argument 'vertexId' must not be NULL!");
checkArgument(limit > 0, "Precondition violation - argument 'limit' must be greater than zero!");
return this.overHistoryOfVertex(vertexId, limit, TimestampChangeCallback.IGNORE);
}
public default ChronoGraphTimestampIteratorBuilder overHistoryOfVertex(String vertexId, Predicate<Long> filter, TimestampChangeCallback callback) {
checkNotNull(vertexId, "Precondition violation - argument 'vertexId' must not be NULL!");
checkNotNull(filter, "Precondition violation - argument 'filter' must not be NULL!");
checkNotNull(callback, "Precondition violation - argument 'callback' must not be NULL!");
return this.overHistoryOfVertex(vertexId, Integer.MAX_VALUE, filter, callback);
}
public default ChronoGraphTimestampIteratorBuilder overHistoryOfVertex(String vertexId, int limit, TimestampChangeCallback callback) {
checkNotNull(vertexId, "Precondition violation - argument 'vertexId' must not be NULL!");
checkArgument(limit > 0, "Precondition violation - argument 'limit' must be greater than zero!");
checkNotNull(callback, "Precondition violation - argument 'callback' must not be NULL!");
return this.overHistoryOfVertex(vertexId, limit, t -> true, callback);
}
public default ChronoGraphTimestampIteratorBuilder overHistoryOfVertex(String vertexId, int limit, Predicate<Long> filter) {
checkNotNull(vertexId, "Precondition violation - argument 'vertexId' must not be NULL!");
checkArgument(limit > 0, "Precondition violation - argument 'limit' must be greater than zero!");
checkNotNull(filter, "Precondition violation - argument 'filter' must not be NULL!");
return this.overHistoryOfVertex(vertexId, limit, filter, TimestampChangeCallback.IGNORE);
}
public default ChronoGraphTimestampIteratorBuilder overHistoryOfVertex(String vertexId, int limit, Predicate<Long> filter, TimestampChangeCallback callback) {
checkNotNull(vertexId, "Precondition violation - argument 'vertexId' must not be NULL!");
checkArgument(limit > 0, "Precondition violation - argument 'limit' must be greater than zero!");
checkNotNull(filter, "Precondition violation - argument 'filter' must not be NULL!");
checkNotNull(callback, "Precondition violation - argument 'callback' must not be NULL!");
return this.overTimestamps(branch -> {
ChronoGraph graph = this.getGraph();
if (graph instanceof ChronoThreadedTransactionGraph) {
graph = ((ChronoThreadedTransactionGraph) graph).getOriginalGraph();
}
List<Long> vertexHistory;
ChronoGraph txGraph = graph.tx().createThreadedTx(branch);
try {
vertexHistory = Lists.newArrayList(txGraph.getVertexHistory(vertexId));
} finally {
txGraph.tx().rollback();
}
Iterator<Long> filtered = Iterators.filter(vertexHistory.iterator(), filter::test);
return Iterators.limit(filtered, limit);
}, callback);
}
public default ChronoGraphTimestampIteratorBuilder overHistoryOfEdge(String edgeId) {
checkNotNull(edgeId, "Precondition violation - argument 'edgeId' must not be NULL!");
return this.overHistoryOfEdge(edgeId, Integer.MAX_VALUE);
}
public default ChronoGraphTimestampIteratorBuilder overHistoryOfEdge(String edgeId, Predicate<Long> filter) {
checkNotNull(edgeId, "Precondition violation - argument 'edgeId' must not be NULL!");
checkNotNull(filter, "Precondition violation - argument 'filter' must not be NULL!");
return this.overHistoryOfEdge(edgeId, Integer.MAX_VALUE, filter);
}
public default ChronoGraphTimestampIteratorBuilder overHistoryOfEdge(String edgeId, TimestampChangeCallback callback) {
checkNotNull(edgeId, "Precondition violation - argument 'edgeId' must not be NULL!");
checkNotNull(callback, "Precondition violation - argument 'callback' must not be NULL!");
return this.overHistoryOfEdge(edgeId, Integer.MAX_VALUE, callback);
}
public default ChronoGraphTimestampIteratorBuilder overHistoryOfEdge(String edgeId, int limit) {
checkNotNull(edgeId, "Precondition violation - argument 'edgeId' must not be NULL!");
checkArgument(limit > 0, "Precondition violation - argument 'limit' must be greater than zero!");
return this.overHistoryOfEdge(edgeId, limit, TimestampChangeCallback.IGNORE);
}
public default ChronoGraphTimestampIteratorBuilder overHistoryOfEdge(String edgeId, Predicate<Long> filter, TimestampChangeCallback callback) {
checkNotNull(edgeId, "Precondition violation - argument 'edgeId' must not be NULL!");
checkNotNull(filter, "Precondition violation - argument 'filter' must not be NULL!");
checkNotNull(callback, "Precondition violation - argument 'callback' must not be NULL!");
return this.overHistoryOfEdge(edgeId, Integer.MAX_VALUE, filter, callback);
}
public default ChronoGraphTimestampIteratorBuilder overHistoryOfEdge(String edgeId, int limit, TimestampChangeCallback callback) {
checkNotNull(edgeId, "Precondition violation - argument 'edgeId' must not be NULL!");
checkArgument(limit > 0, "Precondition violation - argument 'limit' must be greater than zero!");
checkNotNull(callback, "Precondition violation - argument 'callback' must not be NULL!");
return this.overHistoryOfEdge(edgeId, limit, t -> true, callback);
}
public default ChronoGraphTimestampIteratorBuilder overHistoryOfEdge(String edgeId, int limit, Predicate<Long> filter) {
checkNotNull(edgeId, "Precondition violation - argument 'edgeId' must not be NULL!");
checkArgument(limit > 0, "Precondition violation - argument 'limit' must be greater than zero!");
checkNotNull(filter, "Precondition violation - argument 'filter' must not be NULL!");
return this.overHistoryOfEdge(edgeId, limit, filter, TimestampChangeCallback.IGNORE);
}
public default ChronoGraphTimestampIteratorBuilder overHistoryOfEdge(String edgeId, int limit, Predicate<Long> filter, TimestampChangeCallback callback) {
checkNotNull(edgeId, "Precondition violation - argument 'edgeId' must not be NULL!");
checkArgument(limit > 0, "Precondition violation - argument 'limit' must be greater than zero!");
checkNotNull(filter, "Precondition violation - argument 'filter' must not be NULL!");
checkNotNull(callback, "Precondition violation - argument 'callback' must not be NULL!");
return this.overTimestamps(branch -> {
ChronoGraph graph = this.getGraph();
if (graph instanceof ChronoThreadedTransactionGraph) {
graph = ((ChronoThreadedTransactionGraph) graph).getOriginalGraph();
}
List<Long> edgeHistory;
ChronoGraph txGraph = graph.tx().createThreadedTx(branch);
try {
edgeHistory = Lists.newArrayList(txGraph.getEdgeHistory(edgeId));
} finally {
txGraph.tx().rollback();
}
Iterator<Long> filtered = Iterators.filter(edgeHistory.iterator(), filter::test);
return Iterators.limit(filtered, limit);
}, callback);
}
public default ChronoGraphTimestampIteratorBuilder atHead() {
return this.overTimestamps((branch -> Iterators.singletonIterator(this.getGraph().getNow(branch))), TimestampChangeCallback.IGNORE);
}
public default ChronoGraphTimestampIteratorBuilder atTimestamp(long timestamp) {
return this.overTimestamps((branch -> Iterators.singletonIterator(timestamp)), TimestampChangeCallback.IGNORE);
}
public default ChronoGraphTimestampIteratorBuilder overTimestamps(Iterable<Long> timestamps) {
checkNotNull(timestamps, "Precondition violation - argument 'timestamps' must not be NULL!");
return this.overTimestamps(timestamps, TimestampChangeCallback.IGNORE);
}
public default ChronoGraphTimestampIteratorBuilder overTimestamps(Iterable<Long> timestamps, TimestampChangeCallback callback) {
checkNotNull(timestamps, "Precondition violation - argument 'timestamps' must not be NULL!");
checkNotNull(callback, "Precondition violation - argument 'callback' must not be NULL!");
return this.overTimestamps((branch -> timestamps.iterator()), callback);
}
public ChronoGraphTimestampIteratorBuilder overTimestamps(Function<String, Iterator<Long>> branchToTimestampsFunction, TimestampChangeCallback callback);
}
| 21,188 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
ChronoGraphRootIteratorBuilder.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/iterators/ChronoGraphRootIteratorBuilder.java | package org.chronos.chronograph.api.iterators;
import org.chronos.chronodb.api.ChronoDBConstants;
import org.chronos.chronograph.api.branch.GraphBranch;
import org.chronos.chronograph.api.iterators.callbacks.BranchChangeCallback;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import static com.google.common.base.Preconditions.*;
public interface ChronoGraphRootIteratorBuilder extends ChronoGraphIteratorBuilder {
public default ChronoGraphBranchIteratorBuilder overAllBranches() {
return this.overAllBranches(BranchChangeCallback.IGNORE);
}
public default ChronoGraphBranchIteratorBuilder overAllBranches(BranchChangeCallback callback) {
return this.overAllBranches(GraphBranchIterationOrder.ORIGIN_FIRST, callback);
}
public default ChronoGraphBranchIteratorBuilder overAllBranches(Comparator<GraphBranch> comparator, BranchChangeCallback callback) {
checkNotNull(comparator, "Precondition violation - argument 'comparator' must not be NULL!");
checkNotNull(callback, "Precondition violation - argument 'callback' must not be NULL!");
List<String> branchNames = this.getGraph().getBranchManager().getBranches().stream()
.sorted(comparator)
.map(GraphBranch::getName)
.collect(Collectors.toList());
return this.overBranches(branchNames, callback);
}
public default ChronoGraphBranchIteratorBuilder onMasterBranch() {
return this.onBranch(ChronoDBConstants.MASTER_BRANCH_IDENTIFIER);
}
public default ChronoGraphBranchIteratorBuilder onBranch(String branchName) {
checkNotNull(branchName, "Precondition violation - argument 'branchName' must not be NULL!");
return this.overBranches(Collections.singleton(branchName));
}
public default ChronoGraphBranchIteratorBuilder overBranches(Iterable<String> branchNames) {
checkNotNull(branchNames, "Precondition violation - argument 'branchNames' must not be NULL!");
return this.overBranches(branchNames, BranchChangeCallback.IGNORE);
}
public ChronoGraphBranchIteratorBuilder overBranches(Iterable<String> branchNames, BranchChangeCallback callback);
}
| 2,259 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
GraphBranchIterationOrder.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/iterators/GraphBranchIterationOrder.java | package org.chronos.chronograph.api.iterators;
import org.chronos.chronograph.api.branch.GraphBranch;
import java.util.Comparator;
import static com.google.common.base.Preconditions.*;
public enum GraphBranchIterationOrder implements Comparator<GraphBranch> {
// =================================================================================================================
// ENUM LITERALS
// =================================================================================================================
ORIGIN_FIRST(GraphBranchIterationOrder::compareOriginFirst),
BRANCHING_TIMESTAMPS(GraphBranchIterationOrder::compareBranchingTimestamps);
// =================================================================================================================
// FIELDS
// =================================================================================================================
private final Comparator<GraphBranch> compareFunction;
// =================================================================================================================
// CONSTRUCTOR
// =================================================================================================================
private GraphBranchIterationOrder(Comparator<GraphBranch> compareFunction) {
checkNotNull(compareFunction, "Precondition violation - argument 'compareFunction' must not be NULL!");
this.compareFunction = compareFunction;
}
// =================================================================================================================
// PUBLIC API
// =================================================================================================================
@Override
public int compare(final GraphBranch o1, final GraphBranch o2) {
return this.compareFunction.compare(o1, o2);
}
// =================================================================================================================
// INTERNAL HELPER METHODS
// =================================================================================================================
private static int compareOriginFirst(final GraphBranch gb1, final GraphBranch gb2) {
if (gb1 == null && gb2 == null) {
return 0;
}
if (gb1 == null && gb2 != null) {
return -1;
}
if (gb1 != null && gb2 == null) {
return 1;
}
if (gb1.getOriginsRecursive().contains(gb2)) {
return 1;
} else if (gb2.getOriginsRecursive().contains(gb1)) {
return -1;
} else {
return 0;
}
}
private static int compareBranchingTimestamps(final GraphBranch gb1, final GraphBranch gb2) {
return Comparator.comparing(GraphBranch::getBranchingTimestamp).compare(gb1, gb2);
}
}
| 2,912 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
ChronoGraphIterators.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/iterators/ChronoGraphIterators.java | package org.chronos.chronograph.api.iterators;
import org.chronos.chronograph.api.structure.ChronoGraph;
import org.chronos.chronograph.internal.impl.iterators.builder.ChronoGraphRootIteratorBuilderImpl;
import static com.google.common.base.Preconditions.*;
public interface ChronoGraphIterators {
public static ChronoGraphRootIteratorBuilder createIteratorOn(ChronoGraph graph) {
checkNotNull(graph, "Precondition violation - argument 'graph' must not be NULL!");
checkArgument(graph.isClosed() == false, "Precondition violation - argument 'graph' must not be closed!");
return new ChronoGraphRootIteratorBuilderImpl(graph);
}
}
| 667 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
TimestampChangeCallback.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/iterators/callbacks/TimestampChangeCallback.java | package org.chronos.chronograph.api.iterators.callbacks;
@FunctionalInterface
public interface TimestampChangeCallback {
public static final TimestampChangeCallback IGNORE = (previousTimestamp, newTimestamp) -> {
};
public void handleTimestampChange(Long previousTimestamp, Long newTimestamp);
}
| 314 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
BranchChangeCallback.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/iterators/callbacks/BranchChangeCallback.java | package org.chronos.chronograph.api.iterators.callbacks;
@FunctionalInterface
public interface BranchChangeCallback {
public static final BranchChangeCallback IGNORE = (previousBranch, nextBranch) -> {
};
public void handleBranchChanged(String previousBranch, String nextBranch);
}
| 298 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
AllChangedVertexIdsState.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/iterators/states/AllChangedVertexIdsState.java | package org.chronos.chronograph.api.iterators.states;
public interface AllChangedVertexIdsState extends GraphIteratorState {
public String getCurrentVertexId();
public boolean isCurrentVertexRemoved();
}
| 216 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
AllChangedElementIdsState.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/iterators/states/AllChangedElementIdsState.java | package org.chronos.chronograph.api.iterators.states;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Element;
import org.apache.tinkerpop.gremlin.structure.Vertex;
public interface AllChangedElementIdsState extends GraphIteratorState {
public String getCurrentElementId();
public Class<? extends Element> getCurrentElementClass();
public boolean isCurrentElementRemoved();
public default boolean isCurrentElementAVertex() {
return Vertex.class.isAssignableFrom(this.getCurrentElementClass());
}
public default boolean isCurrentElementAnEdge() {
return Edge.class.isAssignableFrom(this.getCurrentElementClass());
}
}
| 719 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
AllChangedElementIdsAndTheirNeighborhoodState.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/iterators/states/AllChangedElementIdsAndTheirNeighborhoodState.java | package org.chronos.chronograph.api.iterators.states;
import java.util.Set;
public interface AllChangedElementIdsAndTheirNeighborhoodState extends AllChangedElementIdsState {
public Set<String> getNeighborhoodVertexIds();
public Set<String> getNeighborhoodEdgeIds();
}
| 283 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
GraphIteratorState.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/iterators/states/GraphIteratorState.java | package org.chronos.chronograph.api.iterators.states;
import com.google.common.collect.Iterators;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.chronos.chronograph.api.structure.ChronoGraph;
import java.util.Iterator;
import java.util.Optional;
import static com.google.common.base.Preconditions.*;
public interface GraphIteratorState {
public ChronoGraph getTransactionGraph();
public default String getBranch() {
return this.getTransactionGraph().tx().getCurrentTransaction().getBranchName();
}
public default long getTimestamp() {
return this.getTransactionGraph().tx().getCurrentTransaction().getTimestamp();
}
public default Optional<Vertex> getVertexById(String vertexId) {
checkNotNull(vertexId, "Precondition violation - argument 'vertexId' must not be NULL!");
Iterator<Vertex> vertices = this.getTransactionGraph().vertices(vertexId);
if (vertices.hasNext() == false) {
return Optional.empty();
} else {
return Optional.of(Iterators.getOnlyElement(vertices));
}
}
public default Optional<Edge> getEdgeById(String edgeId) {
checkNotNull(edgeId, "Precondition violation - argument 'edgeId' must not be NULL!");
Iterator<Edge> edges = this.getTransactionGraph().edges(edgeId);
if (edges.hasNext() == false) {
return Optional.empty();
} else {
return Optional.of(Iterators.getOnlyElement(edges));
}
}
}
| 1,570 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
AllVerticesState.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/iterators/states/AllVerticesState.java | package org.chronos.chronograph.api.iterators.states;
import org.apache.tinkerpop.gremlin.structure.Vertex;
public interface AllVerticesState extends GraphIteratorState {
public Vertex getCurrentVertex();
}
| 216 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
AllEdgesState.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/iterators/states/AllEdgesState.java | package org.chronos.chronograph.api.iterators.states;
import org.apache.tinkerpop.gremlin.structure.Edge;
public interface AllEdgesState extends GraphIteratorState {
public Edge getCurrentEdge();
}
| 206 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
AllChangedEdgeIdsState.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/iterators/states/AllChangedEdgeIdsState.java | package org.chronos.chronograph.api.iterators.states;
public interface AllChangedEdgeIdsState extends GraphIteratorState {
public String getCurrentEdgeId();
public boolean isCurrentEdgeRemoved();
}
| 210 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
AllElementsState.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/iterators/states/AllElementsState.java | package org.chronos.chronograph.api.iterators.states;
import org.apache.tinkerpop.gremlin.structure.Element;
public interface AllElementsState extends GraphIteratorState {
public Element getCurrentElement();
}
| 218 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
AllChangedVertexIdsAndTheirPreviousNeighborhoodState.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/iterators/states/AllChangedVertexIdsAndTheirPreviousNeighborhoodState.java | package org.chronos.chronograph.api.iterators.states;
import java.util.Set;
public interface AllChangedVertexIdsAndTheirPreviousNeighborhoodState extends GraphIteratorState {
public String getCurrentVertexId();
public boolean isCurrentVertexRemoved();
public Set<String> getNeighborhoodEdgeIds();
}
| 317 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
AllChangedEdgeIdsAndTheirPreviousNeighborhoodState.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/iterators/states/AllChangedEdgeIdsAndTheirPreviousNeighborhoodState.java | package org.chronos.chronograph.api.iterators.states;
import java.util.Set;
public interface AllChangedEdgeIdsAndTheirPreviousNeighborhoodState extends GraphIteratorState {
public String getCurrentEdgeId();
public boolean isCurrentEdgeRemoved();
public Set<String> getNeighborhoodVertexIds();
}
| 313 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
ChronoGraphStatisticsManager.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/statistics/ChronoGraphStatisticsManager.java | package org.chronos.chronograph.api.statistics;
import org.chronos.chronodb.api.BranchHeadStatistics;
import org.chronos.chronodb.api.ChronoDBConstants;
public interface ChronoGraphStatisticsManager {
/**
* Returns the statistics for the "head portion" of the {@linkplain ChronoDBConstants#MASTER_BRANCH_IDENTIFIER master} branch.
*
* <p>
* The definition of what the "head portion" is, is up to the backend at hand. In general, it refers to the more recent history.
*
* @return The statistics. Never <code>null</code>.
*/
public default BranchHeadStatistics getMasterBranchHeadStatistics(){
return this.getBranchHeadStatistics(ChronoDBConstants.MASTER_BRANCH_IDENTIFIER);
}
/**
* Returns the statistics for the "head portion" of the given branch.
*
* <p>
* The definition of what the "head portion" is, is up to the backend at hand. In general, it refers to the more recent history.
*
* @param branchName
* The name of the branch to retrieve the statistics for. Must not be <code>null</code>, must refer to an existing branch.
*
* @return The statistics. Never <code>null</code>.
*/
public BranchHeadStatistics getBranchHeadStatistics(String branchName);
}
| 1,287 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
ChronoGraphIndexManager.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/index/ChronoGraphIndexManager.java | package org.chronos.chronograph.api.index;
import com.google.common.collect.Sets;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Element;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.chronos.chronograph.api.builder.index.FinalizableVertexIndexBuilder;
import org.chronos.chronograph.api.builder.index.IndexBuilderStarter;
import org.chronos.chronograph.api.structure.ChronoGraph;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.stream.Collectors;
import static com.google.common.base.Preconditions.*;
/**
* The {@link ChronoGraphIndexManager} is responsible for managing the secondary indices for a {@link ChronoGraph} instance.
*
* <p>
* You can get the instance of your graph by calling {@link ChronoGraph#getIndexManagerOnMaster()}.
*
* @author martin.haeusler@uibk.ac.at -- Initial Contribution and API
*/
public interface ChronoGraphIndexManager {
// =====================================================================================================================
// INDEX BUILDING
// =====================================================================================================================
/**
* Starting point for the fluent graph index creation API.
*
* <p>
* Use method chaining on the returned object, and call {@link FinalizableVertexIndexBuilder#build()} on the last builder to create the new index.
*
* <p>
* Adding a new graph index marks that particular index as dirty. When you are done adding all your secondary indices to the graph,
* call {@link #reindexAll()} in order to build them.
*
* @return The next builder in the fluent API, for method chaining. Never <code>null</code>.
*/
public IndexBuilderStarter create();
// =====================================================================================================================
// INDEX METADATA QUERYING
// =====================================================================================================================
/**
* Returns the currently available secondary indices for the given graph element class, at the given timestamp.
*
* @param clazz Either <code>{@link Vertex}.class</code> or <code>{@link Edge}.class</code>. Must not be <code>null</code>.
* @param timestamp The timestamp to check. Must not be negative.
* @return The currently available secondary indices for the given graph element class. May be empty, but never <code>null</code>.
* @see #getIndexedVertexPropertiesAtTimestamp(long)
* @see #getIndexedEdgePropertyNamesAtTimestamp(long)
* @see #getIndexedEdgePropertiesAtTimestamp(long)
* @see #getIndexedEdgePropertyNamesAtTimestamp(long)
*/
public Set<ChronoGraphIndex> getIndexedPropertiesAtTimestamp(Class<? extends Element> clazz, long timestamp);
/**
* Returns the currently available secondary indices for the given graph element class.
*
* @param clazz Either <code>{@link Vertex}.class</code> or <code>{@link Edge}.class</code>. Must not be <code>null</code>.
* @return The currently available secondary indices for the given graph element class. May be empty, but never <code>null</code>.
* @see #getIndexedVertexPropertiesAtAnyPointInTime()
* @see #getIndexedEdgePropertyNamesAtAnyPointInTime()
* @see #getIndexedEdgePropertiesAtAnyPointInTime()
* @see #getIndexedEdgePropertyNamesAtAnyPointInTime()
*/
public Set<ChronoGraphIndex> getIndexedPropertiesAtAnyPointInTime(Class<? extends Element> clazz);
/**
* Returns the currently available secondary indices for vertices, at the given timestamp.
*
* @param timestamp The timestamp to check. Must not be negative.
* @return The currently available secondary indices for vertices. May be empty, but never <code>null</code>.
* @see #getIndexedVertexPropertyNamesAtTimestamp(long)
* @see #getIndexedEdgePropertiesAtTimestamp(long)
* @see #getIndexedEdgePropertyNamesAtTimestamp(long)
*/
public default Set<ChronoGraphIndex> getIndexedVertexPropertiesAtTimestamp(long timestamp) {
return getIndexedPropertiesAtTimestamp(Vertex.class, timestamp);
}
/**
* Returns the currently available secondary indices for vertices.
*
* @return The currently available secondary indices for vertices. May be empty, but never <code>null</code>.
* @see #getIndexedVertexPropertyNamesAtAnyPointInTime()
* @see #getIndexedEdgePropertiesAtAnyPointInTime()
* @see #getIndexedEdgePropertyNamesAtAnyPointInTime()
*/
public default Set<ChronoGraphIndex> getIndexedVertexPropertiesAtAnyPointInTime() {
return getIndexedPropertiesAtAnyPointInTime(Vertex.class);
}
/**
* Returns the names (keys) of the vertex properties that are currently part of a secondary index, at the given timestamp.
*
* @param timestamp The timestamp to check. Must not be negative.
* @return The set of indexed vertex property names (keys). May be empty, but never <code>null</code>.
* @see #getIndexedVertexPropertiesAtTimestamp(long)
* @see #getIndexedEdgePropertiesAtTimestamp(long)
* @see #getIndexedEdgePropertyNamesAtTimestamp(long)
*/
public default Set<String> getIndexedVertexPropertyNamesAtTimestamp(long timestamp) {
Set<ChronoGraphIndex> indices = this.getIndexedVertexPropertiesAtTimestamp(timestamp);
return indices.stream().map(ChronoGraphIndex::getIndexedProperty).collect(Collectors.toSet());
}
/**
* Returns the names (keys) of the vertex properties that are currently part of a secondary index.
*
* @return The set of indexed vertex property names (keys). May be empty, but never <code>null</code>.
* @see #getIndexedVertexPropertiesAtAnyPointInTime()
* @see #getIndexedEdgePropertiesAtAnyPointInTime()
* @see #getIndexedEdgePropertyNamesAtAnyPointInTime()
*/
public default Set<String> getIndexedVertexPropertyNamesAtAnyPointInTime() {
Set<ChronoGraphIndex> indices = this.getIndexedVertexPropertiesAtAnyPointInTime();
return indices.stream().map(ChronoGraphIndex::getIndexedProperty).collect(Collectors.toSet());
}
/**
* Returns the currently available secondary indices for edges, at the given timestamp.
*
* @param timestamp The timestamp to check. Must not be negative.
* @return The currently available secondary indices for edges. May be empty, but never <code>null</code>.
* @see #getIndexedVertexPropertiesAtTimestamp(long)
* @see #getIndexedVertexPropertyNamesAtTimestamp(long)
* @see #getIndexedEdgePropertyNamesAtTimestamp(long)
*/
public default Set<ChronoGraphIndex> getIndexedEdgePropertiesAtTimestamp(long timestamp) {
return getIndexedPropertiesAtTimestamp(Edge.class, timestamp);
}
/**
* Returns the currently available secondary indices for edges.
*
* @return The currently available secondary indices for edges. May be empty, but never <code>null</code>.
* @see #getIndexedVertexPropertiesAtAnyPointInTime()
* @see #getIndexedVertexPropertyNamesAtAnyPointInTime()
* @see #getIndexedEdgePropertyNamesAtAnyPointInTime()
*/
public default Set<ChronoGraphIndex> getIndexedEdgePropertiesAtAnyPointInTime() {
return getIndexedPropertiesAtAnyPointInTime(Edge.class);
}
/**
* Returns the names (keys) of the edge properties that are currently part of a secondary index, at the given timestamp.
*
* @param timestamp The timestamp to check. Must not be negative.
* @return The set of indexed edge property names (keys). May be empty, but never <code>null</code>.
* @see #getIndexedVertexPropertiesAtTimestamp(long)
* @see #getIndexedVertexPropertyNamesAtTimestamp(long)
* @see #getIndexedEdgePropertiesAtTimestamp(long)
*/
public default Set<String> getIndexedEdgePropertyNamesAtTimestamp(long timestamp) {
Set<ChronoGraphIndex> indices = this.getIndexedEdgePropertiesAtTimestamp(timestamp);
return indices.stream().map(ChronoGraphIndex::getIndexedProperty).collect(Collectors.toSet());
}
/**
* Returns the names (keys) of the edge properties that are currently part of a secondary index.
*
* @return The set of indexed edge property names (keys). May be empty, but never <code>null</code>.
* @see #getIndexedVertexPropertiesAtAnyPointInTime()
* @see #getIndexedVertexPropertyNamesAtAnyPointInTime()
* @see #getIndexedEdgePropertiesAtAnyPointInTime()
*/
public default Set<String> getIndexedEdgePropertyNamesAtAnyPointInTime() {
Set<ChronoGraphIndex> indices = this.getIndexedEdgePropertiesAtAnyPointInTime();
return indices.stream().map(ChronoGraphIndex::getIndexedProperty).collect(Collectors.toSet());
}
/**
* Returns the set of all currently available secondary graph indices.
*
* @return The set of all secondary graph indices. May be empty, but never <code>null</code>.
*/
public Set<ChronoGraphIndex> getAllIndicesAtAnyPointInTime();
/**
* Returns the set of all currently available secondary graph indices, at the given timestamp.
*
* @param timestamp The timestamp to check. Must not be negative.
* @return The set of known indices at the given timestamp.
*/
public Set<ChronoGraphIndex> getAllIndicesAtTimestamp(long timestamp);
/**
* Returns the vertex index for the given property name (key) at the given timestamp.
*
* @param indexedPropertyName The name (key) of the vertex property to get the secondary index for. Must not be <code>null</code>.
* @param timestamp The timestamp to check. Must not be negative.
* @return The secondary index for the given property, or <code>null</code> if the property is not indexed.
*/
public ChronoGraphIndex getVertexIndexAtTimestamp(final String indexedPropertyName, long timestamp);
/**
* Returns the vertex indices for the given property name (key) over time.
*
* @param indexedPropertyName The name (key) of the vertex property to get the secondary index for. Must not be <code>null</code>.
* @return The secondary indices for the given property over time. May be empty but never <code>null</code>.
*/
public Set<ChronoGraphIndex> getVertexIndicesAtAnyPointInTime(final String indexedPropertyName);
/**
* Returns the edge index for the given property name (key) at the given timestamp.
*
* @param indexedPropertyName The name (key) of the edge property to get the secondary index for. Must not be <code>null</code>.
* @param timestamp The timestamp to check. Must not be negative.
* @return The secondary index for the given property, or <code>null</code> if the property is not indexed.
*/
public ChronoGraphIndex getEdgeIndexAtTimestamp(final String indexedPropertyName, long timestamp);
/**
* Returns the edge indices for the given property name (key) over time.
*
* @param indexedPropertyName The name (key) of the edge property to get the secondary index for. Must not be <code>null</code>.
* @return The secondary indices for the given property over time. May be empty but never <code>null</code>.
*/
public Set<ChronoGraphIndex> getEdgeIndicesAtAnyPointInTime(final String indexedPropertyName);
/**
* Checks if the given property name (key) is indexed for the given graph element class, at the given timestamp.
*
* @param clazz The graph element class to check (either <code>{@link Vertex}.class</code> or <code>{@link Edge}.class</code>). Must not be <code>null</code>.
* @param property The name (key) of the property to check. Must not be <code>null</code>.
* @param timestamp The timestamp to check. Must not be negative.
* @return <code>true</code> if the given property is indexed for the given graph element class and timestamp, otherwise <code>false</code>.
* @see #isVertexPropertyIndexedAtTimestamp(String, long)
* @see #isEdgePropertyIndexedAtTimestamp(String, long)
*/
public default boolean isPropertyIndexedAtTimestamp(final Class<? extends Element> clazz, final String property, long timestamp) {
checkNotNull(clazz, "Precondition violation - argument 'clazz' must not be NULL!");
checkNotNull(property, "Precondition violation - argument 'property' must not be NULL!");
checkArgument(timestamp >= 0, "Precondition violation - argument 'timestamp' must not be negative!");
if (Vertex.class.isAssignableFrom(clazz)) {
ChronoGraphIndex index = this.getVertexIndexAtTimestamp(property, timestamp);
return index != null;
} else if (Edge.class.isAssignableFrom(clazz)) {
ChronoGraphIndex index = this.getEdgeIndexAtTimestamp(property, timestamp);
return index != null;
} else {
throw new IllegalArgumentException("Unknown graph element class: '" + clazz.getName() + "'!");
}
}
/**
* Checks if the given property name (key) is indexed for the given graph element class at any point in time.
*
* @param clazz The graph element class to check (either <code>{@link Vertex}.class</code> or <code>{@link Edge}.class</code>). Must not be <code>null</code>.
* @param property The name (key) of the property to check. Must not be <code>null</code>.
* @return <code>true</code> if the given property is indexed for the given graph element class and timestamp, otherwise <code>false</code>.
* @see #isVertexPropertyIndexedAtAnyPointInTime(String)
* @see #isEdgePropertyIndexedAtAnyPointInTime(String)
*/
public default boolean isPropertyIndexedAtAnyPointInTime(final Class<? extends Element> clazz, final String property) {
checkNotNull(clazz, "Precondition violation - argument 'clazz' must not be NULL!");
checkNotNull(property, "Precondition violation - argument 'property' must not be NULL!");
if (Vertex.class.isAssignableFrom(clazz)) {
return !this.getVertexIndicesAtAnyPointInTime(property).isEmpty();
} else if (Edge.class.isAssignableFrom(clazz)) {
return !this.getEdgeIndicesAtAnyPointInTime(property).isEmpty();
} else {
throw new IllegalArgumentException("Unknown graph element class: '" + clazz.getName() + "'!");
}
}
/**
* Checks if the given {@link Vertex} property name (key) is indexed or not.
*
* @param property The vertex property name (key) to check. Must not be <code>null</code>.
* @return <code>true</code> if the given property is indexed on vertices, otherwise <code>false</code>.
* @see #isEdgePropertyIndexedAtAnyPointInTime(String)
*/
public default boolean isVertexPropertyIndexedAtAnyPointInTime(final String property) {
checkNotNull(property, "Precondition violation - argument 'property' must not be NULL!");
return this.isPropertyIndexedAtAnyPointInTime(Vertex.class, property);
}
/**
* Checks if the given {@link Vertex} property name (key) is indexed or not, at the given timestamp.
*
* @param property The vertex property name (key) to check. Must not be <code>null</code>.
* @param timestamp The timestamp to check. Must not be negative.
* @return <code>true</code> if the given property is indexed on vertices, otherwise <code>false</code>.
* @see #isEdgePropertyIndexedAtTimestamp(String, long)
*/
public default boolean isVertexPropertyIndexedAtTimestamp(final String property, long timestamp) {
checkNotNull(property, "Precondition violation - argument 'property' must not be NULL!");
checkArgument(timestamp >= 0, "Precondition violation - argument 'timestamp' must not be negative!");
return this.isPropertyIndexedAtTimestamp(Vertex.class, property, timestamp);
}
/**
* Checks if the given {@link Edge} property name (key) is indexed or not.
*
* @param property The edge property name (key) to check. Must not be <code>null</code>.
* @param timestamp The timestamp to check. Must not be negative.
* @return <code>true</code> if the given property is indexed on edges, otherwise <code>false</code>.
* @see #isVertexPropertyIndexedAtTimestamp(String, long)
*/
public default boolean isEdgePropertyIndexedAtTimestamp(final String property, final long timestamp) {
checkNotNull(property, "Precondition violation - argument 'property' must not be NULL!");
checkArgument(timestamp >= 0, "Precondition violation - argument 'timestamp' must not be negative!");
return this.isPropertyIndexedAtTimestamp(Edge.class, property, timestamp);
}
/**
* Checks if the given {@link Edge} property name (key) is indexed or not.
*
* @param property The edge property name (key) to check. Must not be <code>null</code>.
* @return <code>true</code> if the given property is indexed on edges, otherwise <code>false</code>.
* @see #isVertexPropertyIndexedAtAnyPointInTime(String)
*/
public default boolean isEdgePropertyIndexedAtAnyPointInTime(final String property) {
checkNotNull(property, "Precondition violation - argument 'property' must not be NULL!");
return this.isPropertyIndexedAtAnyPointInTime(Edge.class, property);
}
// =====================================================================================================================
// INDEX CONTENT MANIPULATION
// =====================================================================================================================
/**
* Rebuilds all <i>dirty</i> secondary graph indices from scratch.
*
* <p>
* This operation is mandatory after adding/removing graph indices. Depending on the backend and size of the database, this operation may take considerable amounts of time and should be used with care.
* </p>
*
* <p>
* To force a rebuild of <i>all</i> secondary graph indices, use {@link #reindexAll(boolean)}.
* </p>
*/
public default void reindexAll() {
this.reindexAll(false);
}
/**
* Rebuilds the secondary graph indices from scratch.
*
* <p>
* This operation is mandatory after adding/removing graph indices. Depending on the backend and size of the database, this operation may take considerable amounts of time and should be used with care.
* </p>
*
* @param force Set to <code>true</code> to reindex <i>all</i> indices, or to <code>false</code> to reindex only <i>dirty</i> indices.
*/
public void reindexAll(boolean force);
/**
* Drops the given graph index.
*
* <p>
* This operation cannot be undone. Use with care.
*
* @param index The index to drop. Must not be <code>null</code>.
*/
public void dropIndex(ChronoGraphIndex index);
/**
* Drops all graph indices.
*
* <p>
* This operation cannot be undone. Use with care.
*
* @param commitMetadata The metadata for the commit of dropping all indices. May be <code>null</code>.
*/
public void dropAllIndices(Object commitMetadata);
/**
* Drops all graph indices.
*
* <p>
* This operation cannot be undone. Use with care.
*/
public void dropAllIndices();
/**
* Terminates the indexing for the given index.
*
* The index will receive the given timestamp as upper bound and will
* receive no further updates. Any timestamp larger than the given one
* will not have this index available for querying anymore.
*
* @param index The index to terminate.
* @param timestamp The timestamp at which to terminate the index.
* @return the updated index.
* @throws IllegalArgumentException if the timestamp is invalid (e.g. if it is less than the start timestamp of the index).
* @throws IllegalStateException if the index doesn't exist or has already been terminated.
*/
public ChronoGraphIndex terminateIndex(ChronoGraphIndex index, long timestamp);
/**
* Checks if {@linkplain #reindexAll() reindexing} is required or not.
*
* <p>
* Reindexing is required if at least one graph index is dirty.
*
* @return <code>true</code> if at least one graph index requires rebuilding, otherwise <code>false</code>.
*/
public boolean isReindexingRequired();
/**
* Returns the set of secondary graph indices that are currently dirty, i.e. require re-indexing.
*
* @return The set of dirty secondary indices. May be empty, but never <code>null</code>.
*/
public default Set<ChronoGraphIndex> getDirtyIndicesAtAnyPointInTime() {
Set<ChronoGraphIndex> indices = Sets.newHashSet(this.getAllIndicesAtAnyPointInTime());
indices.removeIf(idx -> !idx.isDirty());
return indices;
}
/**
* Returns the set of secondary graph indices that are currently dirty (i.e. require re-indexing) at the given timestamp.
*
* @param timestamp The timestamp to check. Must not be negative.
* @return The set of dirty secondary indices affecting the given timestamp. May be empty, but never <code>null</code>.
*/
public default Set<ChronoGraphIndex> getDirtyIndicesAtTimestamp(long timestamp) {
checkArgument(timestamp >= 0, "Precondition violation - argument 'timestamp' must not be negative!");
Set<ChronoGraphIndex> indices = this.getDirtyIndicesAtAnyPointInTime();
indices.removeIf(idx -> !idx.getValidPeriod().contains(timestamp));
return indices;
}
/**
* Returns the indices which are known and currently clean.
*
* @return The set of all indices, without the ones which are currently dirty. May be empty.
*/
public default Set<ChronoGraphIndex> getCleanIndicesAtAnyPointInTime() {
Set<ChronoGraphIndex> indices = Sets.newHashSet(this.getAllIndicesAtAnyPointInTime());
indices.removeIf(ChronoGraphIndex::isDirty);
return indices;
}
/**
* Returns the indices which are known and currently clean at the given timestamp.
*
* @param timestamp The timestamp to check. Must not be negative.
* @return The set of all indices, without the ones which are currently dirty. May be empty.
*/
public default Set<ChronoGraphIndex> getCleanIndicesAtTimestamp(long timestamp) {
checkArgument(timestamp >= 0, "Precondition violation - argument 'timestamp' must not be negative!");
Set<ChronoGraphIndex> indices = Sets.newHashSet(this.getAllIndicesAtTimestamp(timestamp));
indices.removeIf(ChronoGraphIndex::isDirty);
return indices;
}
}
| 23,018 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
ChronoGraphIndex.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/index/ChronoGraphIndex.java | package org.chronos.chronograph.api.index;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Element;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.chronos.chronodb.internal.api.Period;
import org.chronos.chronograph.api.branch.GraphBranch;
import org.chronos.chronograph.internal.impl.index.IndexType;
/**
* Specifies metadata about an existing graph index.
*
* <p>
* Instances of this class are created when a new index is specified via the fluent builder API in {@link ChronoGraphIndexManager#create()}.
* All existing instances can be queried by using the graph index manager methods, e.g. {@link ChronoGraphIndexManager#getAllIndices()}.
*
*
* @author martin.haeusler@uibk.ac.at -- Initial Contribution and API
*
*/
public interface ChronoGraphIndex {
/**
* The unique ID of this index.
*
* @return The unique ID. Never <code>null</code>.
*/
public String getId();
/**
* Returns the unique ID of the parent index (i.e. the corresponding index on the parent branch), if any.
*
* @return The unique ID of the parent index, or <code>null</code> if this index has no parent.
*/
public String getParentIndexId();
/**
* Returns the branch to which this index is bound.
*
* @return The branch name. Never <code>null</code>.
*/
public String getBranch();
/**
* Returns the period in which this index is valid.
*
* @return The valid period. Never <code>null</code>.
*/
public Period getValidPeriod();
/**
* Returns the name (key) of the graph element property that is being indexed.
*
* @return The name (key) of the indexed graph element property. Never <code>null</code>.
*/
public String getIndexedProperty();
/**
* Returns the type of graph element that is being indexed ({@linkplain Vertex} or {@linkplain Edge}).
*
* @return The graph element class that is being indexed ({@linkplain Vertex} or {@linkplain Edge}). Never <code>null</code>.
*/
public Class<? extends Element> getIndexedElementClass();
/**
* Returns the index type, i.e. the type of the actual indexed values.
*
* <p>
* Please refer to the documentation of the individual {@link IndexType} literals for details.
*
* @return The index type. Never <code>null</code>.
*/
public IndexType getIndexType();
public boolean isDirty();
}
| 2,360 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
GraphBranch.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/branch/GraphBranch.java | package org.chronos.chronograph.api.branch;
import org.chronos.chronodb.api.ChronoDBConstants;
import java.util.List;
/**
* A {@link GraphBranch} represents a single stream of changes in the versioning system.
*
* <p>
* Branches work much like in document versioning systems, such as GIT or SVN. Every branch has an
* "{@linkplain #getOrigin() origin}" (or "parent") branch from which it was created, as well as a
* "{@linkplain #getBranchingTimestamp() branching timestamp}" that reflects the point in time from which this branch
* was created. There is one special branch, which is the {@linkplain ChronoDBConstants#MASTER_BRANCH_IDENTIFIER master
* branch}. It is the transitive origin of all other branches. It always has the same name, an origin of
* <code>null</code>, and a branching timestamp of zero. Unlike other branches, the master branch is created by default
* and always exists.
*
* @author martin.haeusler@uibk.ac.at -- Initial Contribution and API
*/
public interface GraphBranch {
/**
* Returns the name of this branch, which also acts as its unique identifier.
*
* @return The branch name. Never <code>null</code>. Branch names are unique.
*/
public String getName();
/**
* Returns the branch from which this branch originates.
*
* @return The origin (parent) branch. May be <code>null</code> if this branch is the master branch.
*/
public GraphBranch getOrigin();
/**
* Returns the timestamp at which this branch was created from the origin (parent) branch.
*
* @return The branching timestamp. Never negative.
*/
public long getBranchingTimestamp();
/**
* Returns the list of direct and transitive origin branches.
*
* <p>
* The first entry in the list will always be the {@link ChronoDBConstants#MASTER_BRANCH_IDENTIFIER master} branch.
* The remaining entries are the descendants of the previous branch in the list which are also direct or transitive
* origins of the current branch.
*
* <p>
* For example, if there were the following branching actions:
* <ol>
* <li>master is forked into new branch A
* <li>A is forked into new branch B
* <li>B is forked into new branch C
* </ol>
*
* ... and <code>C.getOriginsRecursive()</code> is invoked, then the returned list will consist of
* <code>[master, A, B]</code> (in exactly this order).
*
* @return The list of origin branches. Will be empty for the master branch, and will start with the master branch
* for all other branches. Never <code>null</code>. The returned list is a calculated object which may
* freely be modified without changing any internal state.
*/
public List<GraphBranch> getOriginsRecursive();
/**
* Returns the "now" timestamp on this branch, i.e. the timestamp at which the last full commit was successfully
* executed.
*
* @return The "now" timestamp. The minimum is the branching timestamp (or zero for the master branch). Never
* negative.
*/
public long getNow();
public default boolean isMaster() {
return ChronoDBConstants.MASTER_BRANCH_IDENTIFIER.equals(this.getName());
}
}
| 3,256 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
ChronoGraphBranchManager.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/branch/ChronoGraphBranchManager.java | package org.chronos.chronograph.api.branch;
import org.chronos.chronodb.api.Branch;
import org.chronos.chronodb.api.ChronoDBConstants;
import org.chronos.chronograph.api.structure.ChronoGraph;
import java.util.List;
import java.util.Set;
/**
* The {@link ChronoGraphBranchManager} is responsible for managing the branching functionality inside a
* {@link ChronoGraph} instance.
*
* <p>
* By default, every ChronoGraph instance contains at least one branch, the master branch. Any other branches are
* children of the master branch.
*
* @author martin.haeusler@uibk.ac.at -- Initial Contribution and API
*/
public interface ChronoGraphBranchManager {
/**
* Creates a new child of the master branch with the given name.
*
* <p>
* This will use the head revision as the base revision for the new branch.
*
* @param branchName The name of the new branch. Must not be <code>null</code>. Must not refer to an already existing
* branch. Branch names must be unique.
* @return The newly created branch. Never <code>null</code>.
* @see #createBranch(String, long)
* @see #createBranch(String, String)
* @see #createBranch(String, String, long)
*/
public GraphBranch createBranch(String branchName);
/**
* Creates a new child of the master branch with the given name.
*
* @param branchName The name of the new branch. Must not be <code>null</code>. Must not refer to an already existing
* branch. Branch names must be unique.
* @param branchingTimestamp The timestamp at which to branch away from the master branch. Must not be negative. Must be less than
* or equal to the timestamp of the latest commit on the master branch.
* @return The newly created branch. Never <code>null</code>.
* @see #createBranch(String)
* @see #createBranch(String, String)
* @see #createBranch(String, String, long)
*/
public GraphBranch createBranch(String branchName, long branchingTimestamp);
/**
* Creates a new child of the given parent branch with the given name.
*
* <p>
* This will use the head revision of the given parent branch as the base revision for the new branch.
*
* @param parentName The name of the parent branch. Must not be <code>null</code>. Must refer to an existing branch.
* @param newBranchName The name of the new child branch. Must not be <code>null</code>. Must not refere to an already
* existing branch. Branch names must be unique.
* @return The newly created branch. Never <code>null</code>.
* @see #createBranch(String)
* @see #createBranch(String, long)
* @see #createBranch(String, String, long)
*/
public GraphBranch createBranch(String parentName, String newBranchName);
/**
* Creates a new child of the given parent branch with the given name.
*
* @param parentName The name of the parent branch. Must not be <code>null</code>. Must refer to an existing branch.
* @param newBranchName The name of the new child branch. Must not be <code>null</code>. Must not refere to an already
* existing branch. Branch names must be unique.
* @param branchingTimestamp The timestamp at which to branch away from the parent branch. Must not be negative. Must be less than
* or equal to the timestamp of the latest commit on the parent branch.
* @return The newly created branch. Never <code>null</code>.
* @see #createBranch(String)
* @see #createBranch(String, long)
* @see #createBranch(String, String, long)
*/
public GraphBranch createBranch(String parentName, String newBranchName, long branchingTimestamp);
/**
* Checks if a branch with the given name exists or not.
*
* @param branchName The branch name to check. Must not be <code>null</code>.
* @return <code>true</code> if there is an existing branch with the given name, otherwise <code>false</code>.
*/
public boolean existsBranch(String branchName);
/**
* Returns the branch with the given name.
*
* @param branchName The name of the branch to retrieve. Must not be <code>null</code>. Must refer to an existing branch.
* @return The branch with the given name. Never <code>null</code>.
*/
public GraphBranch getBranch(String branchName);
/**
* Returns the master branch.
*
* @return The master branch. Never <code>null</code>.
*/
public default GraphBranch getMasterBranch() {
return this.getBranch(ChronoDBConstants.MASTER_BRANCH_IDENTIFIER);
}
/**
* Returns the name of all existing branches.
*
* @return An unmodifiable view on the names of all branches. May be empty, but never <code>null</code>.
*/
public Set<String> getBranchNames();
/**
* Returns the set of all existing branches.
*
* @return An unmodifiable view on the set of all branches. May be empty, but never <code>null</code>.
*/
public Set<GraphBranch> getBranches();
/**
* Deletes the branch with the given name, and its child branches (recursively).
*
* <p>
* <b>/!\ WARNING /!\</b><br>
* This is a <i>management operation</i> which <b>should not be used</b> while the database is under
* active use! The behaviour for all current and future transactions on the given branch is <b>undefined</b>!
* This operation is <b>not atomic</b>: if a child branch is deleted and an error occurs, the parent branch may still continue to exist.
* Child branches are deleted before parent branches.
* </p>
*
* @param branchName The name of the branch to delete. Must not be <code>null</code>. The {@link ChronoDBConstants#MASTER_BRANCH_IDENTIFIER master} branch cannot be deleted!
* @return The list of branch names which were deleted by this operation. May be empty, but never <code>null</code>.
*/
public List<String> deleteBranchRecursively(String branchName);
/**
* Gets the actual branch which is referred to by the given coordinates.
*
* <p>
* If a query is executed on a (non-master) branch, and the query timestamp is
* before the branching timestamp, the actual branch that is being queried is
* the parent branch (maybe recursively).
* </p>
*
* @param branchName The name of the target branch. Must refer to an existing branch. Must not be <code>null</code>.
* @param timestamp The timestamp to resolve. Must not be negative.
* @return The actual branch which will be affected by the query. This branch may either be the same as,
* or a direct or indirect parent of the given branch
*/
public GraphBranch getActualBranchForQuerying(String branchName, long timestamp);
}
| 6,966 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
GraphTransactionContext.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/transaction/GraphTransactionContext.java | package org.chronos.chronograph.api.transaction;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.chronos.chronograph.api.structure.ChronoEdge;
import org.chronos.chronograph.api.structure.ChronoElement;
import org.chronos.chronograph.api.structure.ChronoVertex;
import java.util.Set;
public interface GraphTransactionContext {
public Set<ChronoVertex> getModifiedVertices();
public Set<ChronoEdge> getModifiedEdges();
public Set<String> getModifiedVariables(String keyspace);
public Set<ChronoElement> getModifiedElements();
public boolean isDirty();
public boolean isVertexModified(Vertex vertex);
public boolean isVertexModified(String vertexId);
public boolean isEdgeModified(Edge edge);
public boolean isEdgeModified(String edgeId);
public boolean isVariableModified(String keyspace, String variableName);
public boolean isVariableRemoved(String keyspace, String variableName);
public Object getModifiedVariableValue(String keyspace, String variableName);
public Set<String> getModifiedVariableKeyspaces();
public Set<String> getRemovedVariables(String keyspace);
public void clear();
public ChronoVertex getModifiedVertex(String id);
public ChronoEdge getModifiedEdge(String id);
}
| 1,345 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
AllEdgesIterationHandler.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/transaction/AllEdgesIterationHandler.java | package org.chronos.chronograph.api.transaction;
public interface AllEdgesIterationHandler {
public void onAllEdgesIteration();
}
| 141 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
AllVerticesIterationHandler.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/transaction/AllVerticesIterationHandler.java | package org.chronos.chronograph.api.transaction;
public interface AllVerticesIterationHandler {
public void onAllVerticesIteration();
}
| 143 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
ChronoGraphTransaction.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/transaction/ChronoGraphTransaction.java | package org.chronos.chronograph.api.transaction;
import com.google.common.collect.Iterators;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.chronos.chronodb.api.ChronoDBTransaction;
import org.chronos.chronodb.api.Order;
import org.chronos.chronodb.internal.api.query.ChronoDBQuery;
import org.chronos.chronograph.api.structure.ChronoEdge;
import org.chronos.chronograph.api.structure.ChronoGraph;
import org.chronos.chronograph.api.structure.ChronoVertex;
import org.chronos.chronograph.internal.impl.transaction.ElementLoadMode;
import java.util.*;
import static com.google.common.base.Preconditions.*;
public interface ChronoGraphTransaction {
// =====================================================================================================================
// TRANSACTION METADATA
// =====================================================================================================================
public ChronoGraph getGraph();
public default long getTimestamp() {
return this.getBackingDBTransaction().getTimestamp();
}
public default String getBranchName() {
return this.getBackingDBTransaction().getBranchName();
}
public String getTransactionId();
public long getRollbackCount();
public boolean isThreadedTx();
public boolean isThreadLocalTx();
public boolean isOpen();
// =====================================================================================================================
// ELEMENT CREATION
// =====================================================================================================================
public ChronoVertex addVertex(Object... keyValues);
public ChronoEdge addEdge(final ChronoVertex outVertex, final ChronoVertex inVertex, final String id,
boolean isUserProvidedId, final String label, final Object... keyValues);
// =====================================================================================================================
// QUERY METHODS
// =====================================================================================================================
public Iterator<Vertex> vertices(Object... vertexIds);
public Iterator<Vertex> getAllVerticesIterator();
public default Iterator<Vertex> getVerticesIterator(final Iterable<String> chronoVertexIds) {
checkNotNull(chronoVertexIds, "Precondition violation - argument 'chronoVertexIds' must not be NULL!");
return this.getVerticesIterator(chronoVertexIds, ElementLoadMode.EAGER);
}
public Iterator<Vertex> getVerticesIterator(Iterable<String> chronoVertexIds, ElementLoadMode loadMode);
public Iterator<Edge> edges(Object... edgeIds);
public Iterator<Edge> getAllEdgesIterator();
public default Iterator<Edge> getEdgesIterator(final Iterable<String> chronoEdgeIds) {
checkNotNull(chronoEdgeIds, "Precondition violation - argument 'chronoEdgeIds' must not be NULL!");
return this.getEdgesIterator(chronoEdgeIds, ElementLoadMode.EAGER);
}
public Iterator<Edge> getEdgesIterator(Iterable<String> chronoEdgeIds, ElementLoadMode loadMode);
public default Vertex getVertex(final String vertexId) throws NoSuchElementException {
checkNotNull(vertexId, "Precondition violation - argument 'vertexId' must not be NULL!");
return this.getVertex(vertexId, ElementLoadMode.EAGER);
}
public default Vertex getVertexOrNull(final String vertexId) {
checkNotNull(vertexId, "Precondition violation - argument 'vertexId' must not be NULL!");
return this.getVertexOrNull(vertexId, ElementLoadMode.EAGER);
}
public default Vertex getVertex(final String vertexId, final ElementLoadMode loadMode) throws NoSuchElementException {
checkNotNull(vertexId, "Precondition violation - argument 'vertexId' must not be NULL!");
checkNotNull(loadMode, "Precondition violation - argument 'loadMode' must not be NULL!");
Set<String> ids = Collections.singleton(vertexId);
Iterator<Vertex> vertices = this.getVerticesIterator(ids, loadMode);
return Iterators.getOnlyElement(vertices);
}
public default Vertex getVertexOrNull(final String vertexId, final ElementLoadMode loadMode){
checkNotNull(vertexId, "Precondition violation - argument 'vertexId' must not be NULL!");
checkNotNull(loadMode, "Precondition violation - argument 'loadMode' must not be NULL!");
Set<String> ids = Collections.singleton(vertexId);
Iterator<Vertex> vertices = this.getVerticesIterator(ids, loadMode);
if(!vertices.hasNext()){
return null;
}else{
return Iterators.getOnlyElement(vertices);
}
}
public default Edge getEdge(final String edgeId) throws NoSuchElementException {
checkNotNull(edgeId, "Precondition violation - argument 'edgeId' must not be NULL!");
return this.getEdge(edgeId, ElementLoadMode.EAGER);
}
public default Edge getEdgeOrNull(final String edgeId) {
checkNotNull(edgeId, "Precondition violation - argument 'edgeId' must not be NULL!");
return this.getEdgeOrNull(edgeId, ElementLoadMode.EAGER);
}
public default Edge getEdge(final String edgeId, final ElementLoadMode loadMode) throws NoSuchElementException {
checkNotNull(edgeId, "Precondition violation - argument 'edgeId' must not be NULL!");
checkNotNull(loadMode, "Precondition violation - argument 'loadMode' must not be NULL!");
Set<String> ids = Collections.singleton(edgeId);
Iterator<Edge> edges = this.getEdgesIterator(ids, loadMode);
return Iterators.getOnlyElement(edges);
}
public default Edge getEdgeOrNull(final String edgeId, final ElementLoadMode loadMode) {
checkNotNull(edgeId, "Precondition violation - argument 'edgeId' must not be NULL!");
checkNotNull(loadMode, "Precondition violation - argument 'loadMode' must not be NULL!");
Set<String> ids = Collections.singleton(edgeId);
Iterator<Edge> edges = this.getEdgesIterator(ids, loadMode);
if(!edges.hasNext()){
return null;
}
return Iterators.getOnlyElement(edges);
}
// =====================================================================================================================
// TEMPORAL QUERY METHODS
// =====================================================================================================================
public default Iterator<Long> getVertexHistory(Object vertexId){
return this.getVertexHistory(vertexId, 0, this.getTimestamp(), Order.DESCENDING);
}
public default Iterator<Long> getVertexHistory(Object vertexId, Order order){
return this.getVertexHistory(vertexId, 0, this.getTimestamp(), order);
}
public default Iterator<Long> getVertexHistory(Object vertexId, long lowerBound, long upperBound){
return this.getVertexHistory(vertexId, lowerBound, upperBound, Order.DESCENDING);
}
public Iterator<Long> getVertexHistory(Object vertexId, long lowerBound, long upperBound, Order order);
public default Iterator<Long> getVertexHistory(Vertex vertex){
return this.getVertexHistory(vertex.id(), 0, this.getTimestamp(), Order.DESCENDING);
}
public default Iterator<Long> getVertexHistory(Vertex vertex, long lowerBound, long upperBound){
return this.getVertexHistory(vertex.id(), lowerBound, upperBound, Order.DESCENDING);
}
public default Iterator<Long> getVertexHistory(Vertex vertex, Order order){
return this.getVertexHistory(vertex.id(), 0, this.getTimestamp(), order);
}
public default Iterator<Long> getVertexHistory(Vertex vertex, long lowerBound, long upperBound, Order order){
return this.getVertexHistory(vertex.id(), lowerBound, upperBound, order);
}
public default Iterator<Long> getEdgeHistory(Object edgeId){
return this.getEdgeHistory(edgeId, 0, this.getTimestamp(), Order.DESCENDING);
}
public default Iterator<Long> getEdgeHistory(Object vertexId, Order order){
return this.getEdgeHistory(vertexId, 0, this.getTimestamp(), order);
}
public default Iterator<Long> getEdgeHistory(Object vertexId, long lowerBound, long upperBound){
return this.getEdgeHistory(vertexId, lowerBound, upperBound, Order.DESCENDING);
}
public Iterator<Long> getEdgeHistory(Object vertexId, long lowerBound, long upperBound, Order order);
public default Iterator<Long> getEdgeHistory(Edge edge){
return this.getEdgeHistory(edge.id(), 0, this.getTimestamp(), Order.DESCENDING);
}
public default Iterator<Long> getEdgeHistory(Edge edge, Order order){
return this.getEdgeHistory(edge.id(), 0, this.getTimestamp(), order);
}
public default Iterator<Long> getEdgeHistory(Edge edge, long lowerBound, long upperBound){
return this.getEdgeHistory(edge.id(), lowerBound, upperBound, Order.DESCENDING);
}
public default Iterator<Long> getEdgeHistory(Edge edge, long lowerBound, long upperBound, Order order){
return this.getEdgeHistory(edge.id(), lowerBound, upperBound, order);
}
public long getLastModificationTimestampOfVertex(Vertex vertex);
public long getLastModificationTimestampOfVertex(Object vertexId);
public long getLastModificationTimestampOfEdge(Edge edge);
public long getLastModificationTimestampOfEdge(Object edgeId);
public Iterator<Pair<Long, String>> getVertexModificationsBetween(long timestampLowerBound, long timestampUpperBound);
public Iterator<Pair<Long, String>> getEdgeModificationsBetween(long timestampLowerBound, long timestampUpperBound);
public Object getCommitMetadata(long commitTimestamp);
// =====================================================================================================================
// COMMIT & ROLLBACK
// =====================================================================================================================
public long commit();
public long commit(Object metadata);
public void commitIncremental();
public void rollback();
// =====================================================================================================================
// CONTEXT & BACKING TRANSACTION
// =====================================================================================================================
public ChronoDBTransaction getBackingDBTransaction();
public GraphTransactionContext getContext();
}
| 10,780 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
ChronoGraphTransactionManager.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/transaction/ChronoGraphTransactionManager.java | package org.chronos.chronograph.api.transaction;
import java.util.Date;
import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource;
import org.apache.tinkerpop.gremlin.structure.Transaction;
import org.chronos.chronodb.api.exceptions.ChronoDBBranchingException;
import org.chronos.chronograph.api.structure.ChronoGraph;
/**
* A specialized version of the Apache Gremlin {@link Transaction} manager.
*
* <p>
* Classes that implement this interface offer extended capabilities for transactions that work on temporal data stores.
*
* <p>
* Clients can retrieve an instance of this interface via {@link ChronoGraph#tx()}. Classes that implement this
* interface must not be manually instantiated by clients.
*
* @author martin.haeusler@uibk.ac.at -- Initial Contribution and API
*
*/
public interface ChronoGraphTransactionManager extends Transaction {
/**
* Opens a new transaction on the master branch, at the given timestamp.
*
* <p>
* Please note that only one transaction can be active on a thread at any given time. If a transaction is already
* open on this thread, this method will cause an {@link IllegalStateException}.
*
* @param timestamp
* The timestamp to read at. Must not be negative. Must not be larger than the timestamp of the last
* commit on the branch.
*
* @throws IllegalStateException
* If there already exists an open transaction for this thread.
*/
public void open(long timestamp);
/**
* Opens a new transaction on the master branch, at the given date.
*
* <p>
* Please note that only one transaction can be active on a thread at any given time. If a transaction is already
* open on this thread, this method will cause an {@link IllegalStateException}.
*
* @param date
* The date to read at. Must not be <code>null</code>. Must not be larger after the date of the last
* commit on the branch.
*
* @throws IllegalStateException
* If there already exists an open transaction for this thread.
*/
public void open(Date date);
/**
* Opens a new transaction on the given branch, reading the latest available version.
*
* <p>
* Please note that only one transaction can be active on a thread at any given time. If a transaction is already
* open on this thread, this method will cause an {@link IllegalStateException}.
*
* @param branch
* The branch to open the transaction on. Must not be <code>null</code>. Must refer to an existing
* branch.
*
* @throws ChronoDBBranchingException
* Thrown if there is no branch with the given name.
* @throws IllegalStateException
* If there already exists an open transaction for this thread.
*/
public void open(String branch);
/**
* Opens a new transaction on the given branch, at the given timestamp.
*
* <p>
* Please note that only one transaction can be active on a thread at any given time. If a transaction is already
* open on this thread, this method will cause an {@link IllegalStateException}.
*
* @param branch
* The branch to open the transaction on. Must not be <code>null</code>. Must refer to an existing
* branch.
* @param timestamp
* The timestamp to read at. Must not be negative. Must not be larger than the timestamp of the last
* commit on the branch.
*
* @throws ChronoDBBranchingException
* Thrown if there is no branch with the given name.
* @throws IllegalStateException
* If there already exists an open transaction for this thread.
*/
public void open(String branch, long timestamp);
/**
* Opens a new transaction on the given branch, at the given date.
*
* <p>
* Please note that only one transaction can be active on a thread at any given time. If a transaction is already
* open on this thread, this method will cause an {@link IllegalStateException}.
*
* @param branch
* The branch to open the transaction on. Must not be <code>null</code>. Must refer to an existing
* branch.
* @param date
* The date to read at. Must not be <code>null</code>. Must not be larger after the date of the last
* commit on the branch.
*
* @throws ChronoDBBranchingException
* Thrown if there is no branch with the given name.
* @throws IllegalStateException
* If there already exists an open transaction for this thread.
*/
public void open(String branch, Date date);
/**
* Resets the current transaction.
*
* <p>
* By resetting the graph transaction, the transaction timestamp is updated to the latest available version. In
* other words, after calling {@link #reset()}, all read operations will retrieve the latest available version. The
* transaction remains open after calling this method, i.e. clients must not call {@link #open()} after calling this
* method.
*
* <p>
* The transaction will <b>not</b> switch branches during this operation. After calling this method, the working
* branch will still be the same as before.
*
* <p>
* Please note that calling {@link #reset()} will <b>clear</b> the transaction context, i.e. any uncommitted changes
* will be lost!
*/
public void reset();
/**
* Resets the current transaction and jumps to the given timestamp.
*
* <p>
* By resetting the graph transaction, the transaction timestamp is updated to the given one. In other words, after
* calling {@link #reset()}, all read operations will retrieve the given version. The transaction remains open after
* calling this method, i.e. clients must not call {@link #open()} after calling this method.
*
* <p>
* The transaction will <b>not</b> switch branches during this operation. After calling this method, the working
* branch will still be the same as before.
*
* <p>
* Please note that calling {@link #reset()} will <b>clear</b> the transaction context, i.e. any uncommitted changes
* will be lost!
*
* @param timestamp
* The timestamp to jump to. Must not be negative. Must not be larger than the timestamp of the last
* commit to the branch.
*/
public void reset(long timestamp);
/**
* Resets the current transaction and jumps to the given date.
*
* <p>
* By resetting the graph transaction, the transaction date is updated to the given one. In other words, after
* calling {@link #reset()}, all read operations will retrieve the given version. The transaction remains open after
* calling this method, i.e. clients must not call {@link #open()} after calling this method.
*
* <p>
* The transaction will <b>not</b> switch branches during this operation. After calling this method, the working
* branch will still be the same as before.
*
* <p>
* Please note that calling {@link #reset()} will <b>clear</b> the transaction context, i.e. any uncommitted changes
* will be lost!
*
* @param date
* The date to jump to. Must not be <code>null</code>. Must not refer to a point in time after the latest
* commit to the branch.
*/
public void reset(Date date);
/**
* Resets the current transaction and jumps to the given timestamp on the given branch.
*
* <p>
* By resetting the graph transaction, the transaction timestamp is updated to the given one. In other words, after
* calling {@link #reset()}, all read operations will retrieve the given version. The transaction remains open after
* calling this method, i.e. clients must not call {@link #open()} after calling this method.
*
* <p>
* Please note that calling {@link #reset()} will <b>clear</b> the transaction context, i.e. any uncommitted changes
* will be lost!
*
* @param branch
* The branch to jump to. Must not be <code>null</code>. Must refer to an existing branch. If the branch
* does not exist, this method throws a {@link ChronoDBBranchingException} and does not modify the
* transaction state.
* @param timestamp
* The timestamp to jump to. Must not be negative. Must not be larger than the timestamp of the last
* commit to the target branch.
*
* @throws ChronoDBBranchingException
* Thrown if the given branch does not exist.
*/
public void reset(String branch, long timestamp);
/**
* Resets the current transaction and jumps to the given date on the given branch.
*
* <p>
* By resetting the graph transaction, the transaction date is updated to the given one. In other words, after
* calling {@link #reset()}, all read operations will retrieve the given version. The transaction remains open after
* calling this method, i.e. clients must not call {@link #open()} after calling this method.
*
* <p>
* Please note that calling {@link #reset()} will <b>clear</b> the transaction context, i.e. any uncommitted changes
* will be lost!
*
*
* @param branch
* The branch to jump to. Must not be <code>null</code>. Must refer to an existing branch. If the branch
* does not exist, this method throws a {@link ChronoDBBranchingException} and does not modify the
* transaction state.
* @param date
* The date to jump to. Must not be <code>null</code>. Must not refer to a point in time after the latest
* commit to the branch.
*
* @throws ChronoDBBranchingException
* Thrown if the given branch does not exist.
*/
public void reset(String branch, Date date);
// =====================================================================================================================
// THREADED TX
// =====================================================================================================================
/**
* Creates a child graph instance that acts as a transaction.
*
* <p>
* Multiple threads may collaborate on the returned graph instance, sharing the produced graph elements. When the
* first {@link ChronoGraphTransactionManager#commit() commit()} or {@link ChronoGraphTransactionManager#rollback()
* rollback()} is invoked, the resulting graph transaction will be closed. Any element generated from that graph
* will no longer be accessible afterwards. The transaction is also closed when {@link #close()} is invoked on the
* graph.
*
* <p>
* <b>!!! IMPORTANT !!!</b><br>
* <b>WARNING:</b> Even though the graph can be shared across multiple threads (in contrast to regular thread-bound
* transactions), neither the graph itself nor the elements are <b>safe for concurrent access</b>!
*
* @return The child graph that acts as a thread-independent transaction. Never <code>null</code>.
*/
@Override
@SuppressWarnings("unchecked")
public ChronoGraph createThreadedTx();
/**
* Creates a child graph instance that acts as a transaction on the given timestamp.
*
* <p>
* Multiple threads may collaborate on the returned graph instance, sharing the produced graph elements. When the
* first {@link ChronoGraphTransactionManager#commit() commit()} or {@link ChronoGraphTransactionManager#rollback()
* rollback()} is invoked, the resulting graph transaction will be closed. Any element generated from that graph
* will no longer be accessible afterwards. The transaction is also closed when {@link #close()} is invoked on the
* graph.
*
* <p>
* <b>!!! IMPORTANT !!!</b><br>
* <b>WARNING:</b> Even though the graph can be shared across multiple threads (in contrast to regular thread-bound
* transactions), neither the graph itself nor the elements are <b>safe for concurrent access</b>!
*
* @param timestamp
* The timestamp on which to open the transaction. Must not be negative.
*
* @return The child graph that acts as a thread-independent transaction. Never <code>null</code>.
*/
public ChronoGraph createThreadedTx(long timestamp);
/**
* Creates a child graph instance that acts as a transaction on the given date.
*
* <p>
* Multiple threads may collaborate on the returned graph instance, sharing the produced graph elements. When the
* first {@link ChronoGraphTransactionManager#commit() commit()} or {@link ChronoGraphTransactionManager#rollback()
* rollback()} is invoked, the resulting graph transaction will be closed. Any element generated from that graph
* will no longer be accessible afterwards. The transaction is also closed when {@link #close()} is invoked on the
* graph.
*
* <p>
* <b>!!! IMPORTANT !!!</b><br>
* <b>WARNING:</b> Even though the graph can be shared across multiple threads (in contrast to regular thread-bound
* transactions), neither the graph itself nor the elements are <b>safe for concurrent access</b>!
*
* @param date
* The date on which to open the transaction. Must not be <code>null</code>.
*
* @return The child graph that acts as a thread-independent transaction. Never <code>null</code>.
*/
public ChronoGraph createThreadedTx(Date date);
/**
* Creates a child graph instance that acts as a transaction on the given branch.
*
* <p>
* Multiple threads may collaborate on the returned graph instance, sharing the produced graph elements. When the
* first {@link ChronoGraphTransactionManager#commit() commit()} or {@link ChronoGraphTransactionManager#rollback()
* rollback()} is invoked, the resulting graph transaction will be closed. Any element generated from that graph
* will no longer be accessible afterwards. The transaction is also closed when {@link #close()} is invoked on the
* graph.
*
* <p>
* <b>!!! IMPORTANT !!!</b><br>
* <b>WARNING:</b> Even though the graph can be shared across multiple threads (in contrast to regular thread-bound
* transactions), neither the graph itself nor the elements are <b>safe for concurrent access</b>!
*
* @param branchName
* The name of the branch on which to open the transaction. Must not be <code>null</code>. Must refer to
* an existing branch.
*
* @return The child graph that acts as a thread-independent transaction. Never <code>null</code>.
*/
public ChronoGraph createThreadedTx(String branchName);
/**
* Creates a child graph instance that acts as a transaction on the given branch and timestamp.
*
* <p>
* Multiple threads may collaborate on the returned graph instance, sharing the produced graph elements. When the
* first {@link ChronoGraphTransactionManager#commit() commit()} or {@link ChronoGraphTransactionManager#rollback()
* rollback()} is invoked, the resulting graph transaction will be closed. Any element generated from that graph
* will no longer be accessible afterwards. The transaction is also closed when {@link #close()} is invoked on the
* graph.
*
* <p>
* <b>!!! IMPORTANT !!!</b><br>
* <b>WARNING:</b> Even though the graph can be shared across multiple threads (in contrast to regular thread-bound
* transactions), neither the graph itself nor the elements are <b>safe for concurrent access</b>!
*
* @param branchName
* The name of the branch on which to open the transaction. Must not be <code>null</code>. Must refer to
* an existing branch.
* @param timestamp
* The timestamp on which to open the transaction. Must not be negative.
*
* @return The child graph that acts as a thread-independent transaction. Never <code>null</code>.
*/
public ChronoGraph createThreadedTx(String branchName, long timestamp);
/**
* Creates a child graph instance that acts as a transaction on the given branch and date.
*
* <p>
* Multiple threads may collaborate on the returned graph instance, sharing the produced graph elements. When the
* first {@link ChronoGraphTransactionManager#commit() commit()} or {@link ChronoGraphTransactionManager#rollback()
* rollback()} is invoked, the resulting graph transaction will be closed. Any element generated from that graph
* will no longer be accessible afterwards. The transaction is also closed when {@link #close()} is invoked on the
* graph.
*
* <p>
* <b>!!! IMPORTANT !!!</b><br>
* <b>WARNING:</b> Even though the graph can be shared across multiple threads (in contrast to regular thread-bound
* transactions), neither the graph itself nor the elements are <b>safe for concurrent access</b>!
*
* @param branchName
* The name of the branch on which to open the transaction. Must not be <code>null</code>. Must refer to
* an existing branch.
* @param date
* The date on which to open the transaction. Must not be <code>null</code>.
*
* @return The child graph that acts as a thread-independent transaction. Never <code>null</code>.
*/
public ChronoGraph createThreadedTx(String branchName, Date date);
// =================================================================================================================
// COMMITTING
// =================================================================================================================
/**
*
*
*/
public void commitIncremental();
/**
* Commits the transaction and stores the given metadata alongside the commit.
*
* @param metadata The metadata to record for this commit.
*/
public void commit(Object metadata);
/**
* Same as {@link #commit()}, except that the commit timestamp is returned.
*
* @return The exact commit timestamp. Always greater than zero.
*/
public long commitAndReturnTimestamp();
/**
* Same as {@link #commit(Object)}, except that the commit timestamp is returned.
*
* @param metadata The metadata to store alongside the commit.
* @return The exact commit timestamp. Always greater than zero.
*/
public long commitAndReturnTimestamp(Object metadata);
// =====================================================================================================================
// CURRENT THREAD-LOCAL TX
// =====================================================================================================================
/**
* Returns the actual graph transaction that is serving the current thread.
*
* <p>
* For internal purposes only.
*
* @return The transaction for the current thread, or <code>null</code> if there is no graph transaction bound to
* the current thread.
*/
public ChronoGraphTransaction getCurrentTransaction();
// =================================================================================================================
// TX().BEGIN()
// =================================================================================================================
@Override
public default <T extends TraversalSource> T begin(Class<T> traversalSourceClass) {
throw new UnsupportedOperationException(
"tx().begin() is not supported in ChronoGraph." +
" To open an ambient (thread-bound) transaction, please use tx().open(...)." +
" To open an explicit (threaded) transaction, please use tx().createThreadedTx(...)."
);
}
}
| 19,128 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
ChronoGraphPostCommitTrigger.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/transaction/trigger/ChronoGraphPostCommitTrigger.java | package org.chronos.chronograph.api.transaction.trigger;
public interface ChronoGraphPostCommitTrigger extends ChronoGraphTrigger {
public void onPostCommit(PostCommitTriggerContext context);
}
| 201 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
ChronoGraphPrePersistTrigger.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/transaction/trigger/ChronoGraphPrePersistTrigger.java | package org.chronos.chronograph.api.transaction.trigger;
public interface ChronoGraphPrePersistTrigger extends ChronoGraphTrigger {
public void onPrePersist(PrePersistTriggerContext context) throws CancelCommitException;
}
| 230 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
GraphTriggerMetadata.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/transaction/trigger/GraphTriggerMetadata.java | package org.chronos.chronograph.api.transaction.trigger;
import org.chronos.chronograph.api.exceptions.GraphTriggerException;
public interface GraphTriggerMetadata {
public String getTriggerName();
public String getTriggerClassName();
public int getPriority();
public boolean isPreCommitTrigger();
public boolean isPrePersistTrigger();
public boolean isPostPersistTrigger();
public boolean isPostCommitTrigger();
public String getUserScriptContent();
public GraphTriggerException getInstantiationException();
}
| 559 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
State.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/transaction/trigger/State.java | package org.chronos.chronograph.api.transaction.trigger;
import org.chronos.chronograph.api.branch.GraphBranch;
import org.chronos.chronograph.api.structure.ChronoGraph;
public interface State {
public ChronoGraph getGraph();
public long getTimestamp();
public GraphBranch getBranch();
}
| 305 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
TriggerContext.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/transaction/trigger/TriggerContext.java | package org.chronos.chronograph.api.transaction.trigger;
import org.chronos.chronograph.api.branch.GraphBranch;
public interface TriggerContext extends AutoCloseable {
public CurrentState getCurrentState();
public AncestorState getAncestorState();
public StoreState getStoreState();
public String getTriggerName();
public GraphBranch getBranch();
public Object getCommitMetadata();
@Override
void close();
}
| 449 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
ChronoGraphTrigger.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/transaction/trigger/ChronoGraphTrigger.java | package org.chronos.chronograph.api.transaction.trigger;
import org.chronos.chronograph.api.structure.ChronoGraph;
import org.chronos.chronograph.api.transaction.ChronoGraphTransaction;
import java.io.Serializable;
import java.util.Set;
/**
* A {@link ChronoGraphTrigger} is a handler that gets invoked by {@link ChronoGraph} during a {@link ChronoGraphTransaction#commit()} operation.
*
* <p>
* This interface is intended to be implemented by clients. All implementations must be serializable/deserializable.
* However, <b>do not implement it directly</b>. Instead, please implement at least one of:
* <ul>
* <li>{@link ChronoGraphPreCommitTrigger}</li>
* <li>{@link ChronoGraphPrePersistTrigger}</li>
* <li>{@link ChronoGraphPostPersistTrigger}</li>
* <li>{@link ChronoGraphPostCommitTrigger}</li>
* </ul>
* </p>
*
* Implementing multiple trigger timing interfaces on the same class is supported as well.
*
* @author martin.haeusler@uibk.ac.at -- Initial Contribution and API
*/
public interface ChronoGraphTrigger extends Serializable {
/**
* Returns the priority of this trigger.
*
* <p>
* The higher the priority of a trigger, the earlier it is invoked among all triggers with the same timing. For example, a trigger with priority 100 will be fired <b>before</b> a trigger with priority 99, but <b>after</b> a trigger with priority 50.
* </p>
*
* <p>
* If two triggers have the same {@link #getPriority() priority}, then the execution order is unspecified.
* </p>
*
* @return The priority of the trigger. Is assumed to remain unchanged over time.
*/
public int getPriority();
}
| 1,673 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
CurrentState.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/transaction/trigger/CurrentState.java | package org.chronos.chronograph.api.transaction.trigger;
import org.chronos.chronograph.api.structure.ChronoEdge;
import org.chronos.chronograph.api.structure.ChronoVertex;
import java.util.Set;
public interface CurrentState extends State {
public Set<ChronoVertex> getModifiedVertices();
public Set<ChronoEdge> getModifiedEdges();
public Set<String> getModifiedGraphVariables();
public Set<String> getModifiedGraphVariables(String keyspace);
}
| 469 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
PostTriggerContext.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/transaction/trigger/PostTriggerContext.java | package org.chronos.chronograph.api.transaction.trigger;
public interface PostTriggerContext extends TriggerContext {
public long getCommitTimestamp();
public PreCommitStoreState getPreCommitStoreState();
}
| 219 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
TriggerTiming.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/transaction/trigger/TriggerTiming.java | package org.chronos.chronograph.api.transaction.trigger;
import org.chronos.common.exceptions.UnknownEnumLiteralException;
public enum TriggerTiming {
/**
* Triggers with this timing will be fired <b>before</b> an actual commit occurs, <b>before</b> the state merge with the store and <b>before</b> the commit lock has been acquired.
*
* <p>
* This is the earliest trigger timing. The {@linkplain TriggerContext#getCurrentState() current transaction state} is passed as-is from the user (it may have been modified by other {@link #PRE_COMMIT} triggers though).
* </p>
*
* <p>
* Triggers in this timing <b>can</b> cancel the commit by throwing a {@link CancelCommitException}.
* </p>
*
* <p>
* Triggers in this timing <b>can</b> modify the {@linkplain TriggerContext#getCurrentState() current state} of the transaction.
* </p>
*/
PRE_COMMIT,
/**
* Triggers with this timing will be fired <b>before</b> an actual commit occurs, <b>after</b> the state merge with the store and <b>after</b> the commit lock has been acquired.
*
* <p>
* This trigger timing occurs after {@link #PRE_COMMIT} and before {@link #POST_PERSIST}. This is the latest timing where the {@linkplain TriggerContext#getCurrentState() current transaction state} can be modified. The current transaction state will be the result of the merge / conflict resolution between the transaction and the {@link TriggerContext#getStoreState() current store state}.
* </p>
*
* <p>
* Triggers in this timing <b>can</b> cancel the commit by throwing a {@link CancelCommitException}.
* </p>
*
* <p>
* Triggers in this timing <b>can</b> modify the {@linkplain TriggerContext#getCurrentState() current state} of the transaction.
* </p>
*/
PRE_PERSIST,
/**
* Triggers with this timing will be fired <b>after</b> an actual commit occurs and <b>before</b> the commit lock has been released.
*
* <p>
* This trigger timing occurs after {@link #PRE_PERSIST} and before {@link #POST_COMMIT}. This is the first timing after the {@linkplain TriggerContext#getCurrentState() current transaction state} has been committed. The current transaction state will be the result of the merge / conflict resolution between the transaction and the {@link TriggerContext#getStoreState() current store state}.
* </p>
*
* <p>
* Triggers in this timing <b>can not</b> cancel the commit by throwing a {@link CancelCommitException}.
* </p>
*
* <p>
* Triggers in this timing <b>can not</b> modify the {@linkplain TriggerContext#getCurrentState() current state} of the transaction.
* </p>
*/
POST_PERSIST,
/**
* Triggers with this timing will be fired <b>after</b> an actual commit occurs and <b>after</b> the commit lock has been released.
*
* <p>
* This trigger timing occurs after {@link #POST_PERSIST} and is the latest possible trigger timing.
* </p>
*
* <p>
* Triggers in this timing <b>can not</b> cancel the commit by throwing a {@link CancelCommitException}.
* </p>
*
* <p>
* Triggers in this timing <b>can not</b> modify the {@linkplain TriggerContext#getCurrentState() current state} of the transaction.
* </p>
*/
POST_COMMIT;
public boolean isBeforePersist() {
switch (this) {
case PRE_COMMIT:
return true;
case PRE_PERSIST:
return true;
case POST_PERSIST:
return false;
case POST_COMMIT:
return false;
default:
throw new UnknownEnumLiteralException(this);
}
}
public boolean isAfterPersist() {
return !this.isBeforePersist();
}
}
| 3,866 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
ChronoGraphPreCommitTrigger.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/transaction/trigger/ChronoGraphPreCommitTrigger.java | package org.chronos.chronograph.api.transaction.trigger;
public interface ChronoGraphPreCommitTrigger extends ChronoGraphTrigger {
public void onPreCommit(PreCommitTriggerContext context) throws CancelCommitException;
}
| 227 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
CancelCommitException.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/transaction/trigger/CancelCommitException.java | package org.chronos.chronograph.api.transaction.trigger;
public class CancelCommitException extends RuntimeException {
public CancelCommitException() {
}
public CancelCommitException(final String message) {
super(message);
}
public CancelCommitException(final String message, final Throwable cause) {
super(message, cause);
}
public CancelCommitException(final Throwable cause) {
super(cause);
}
protected CancelCommitException(final String message, final Throwable cause, final boolean enableSuppression, final boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
}
| 686 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
ScriptedGraphTrigger.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/transaction/trigger/ScriptedGraphTrigger.java | package org.chronos.chronograph.api.transaction.trigger;
import org.chronos.chronograph.internal.impl.transaction.trigger.script.ScriptedGraphPostCommitTrigger;
import org.chronos.chronograph.internal.impl.transaction.trigger.script.ScriptedGraphPostPersistTrigger;
import org.chronos.chronograph.internal.impl.transaction.trigger.script.ScriptedGraphPreCommitTrigger;
import org.chronos.chronograph.internal.impl.transaction.trigger.script.ScriptedGraphPrePersistTrigger;
import static com.google.common.base.Preconditions.*;
public interface ScriptedGraphTrigger {
public static ChronoGraphPreCommitTrigger createPreCommitTrigger(String scriptContent, int priority){
checkNotNull(scriptContent, "Precondition violation - argument 'scriptContent' must not be NULL!");
return new ScriptedGraphPreCommitTrigger(scriptContent, priority);
}
public static ChronoGraphPrePersistTrigger createPrePersistTrigger(String scriptContent, int priority){
checkNotNull(scriptContent, "Precondition violation - argument 'scriptContent' must not be NULL!");
return new ScriptedGraphPrePersistTrigger(scriptContent, priority);
}
public static ChronoGraphPostPersistTrigger createPostPersistTrigger(String scriptContent, int priority){
checkNotNull(scriptContent, "Precondition violation - argument 'scriptContent' must not be NULL!");
return new ScriptedGraphPostPersistTrigger(scriptContent, priority);
}
public static ChronoGraphPostCommitTrigger createPostCommitTrigger(String scriptContent, int priority){
checkNotNull(scriptContent, "Precondition violation - argument 'scriptContent' must not be NULL!");
return new ScriptedGraphPostCommitTrigger(scriptContent, priority);
}
}
| 1,770 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
ChronoGraphPostPersistTrigger.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/transaction/trigger/ChronoGraphPostPersistTrigger.java | package org.chronos.chronograph.api.transaction.trigger;
public interface ChronoGraphPostPersistTrigger extends ChronoGraphTrigger {
public void onPostPersist(PostPersistTriggerContext context);
}
| 204 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
ChronoGraphTriggerManager.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/transaction/trigger/ChronoGraphTriggerManager.java | package org.chronos.chronograph.api.transaction.trigger;
import org.chronos.chronograph.api.exceptions.TriggerAlreadyExistsException;
import org.chronos.chronograph.api.structure.ChronoGraph;
import java.util.List;
import java.util.Set;
import java.util.function.Supplier;
/**
* The {@link ChronoGraphTriggerManager} manages the {@link ChronoGraphTrigger}s in a {@link ChronoGraph} instance.
*
* <p>
* An instance of this class can be retrieved via {@link ChronoGraph#getTriggerManager()}.
* </p>
*
* @author martin.haeusler@uibk.ac.at -- Initial Contribution and API
*/
public interface ChronoGraphTriggerManager {
/**
* Checks if the trigger with the given name exists.
*
* @param triggerName The unique name of the trigger to check. Must not be <code>null</code> or empty.
* @return <code>true</code> if the trigger exists, otherwise <code>false</code>.
*/
public boolean existsTrigger(String triggerName);
/**
* Creates a trigger if there is no trigger registered to the given name.
*
* <p>
* If there already exists a trigger with the given name, this method does nothing and returns immmediately.
* </p>
*
* @param triggerName The unique name of the trigger. Must not be <code>null</code> or empty.
* @param triggerSupplier The supplier for the trigger. Will be invoked if and only if there is no trigger with the given name yet. Will be invoked at most once. Must not be <code>null</code>. The {@link Supplier#get()} method must not return <code>null</code>.
* @return <code>true</code> code if the trigger was added successfully, or <code>false</code> if there already was a trigger registered to the given name.
* @see #createTrigger(String, ChronoGraphTrigger)
* @see #createTriggerAndOverwrite(String, ChronoGraphTrigger)
*/
public boolean createTriggerIfNotPresent(String triggerName, Supplier<ChronoGraphTrigger> triggerSupplier);
/**
* Creates a trigger if there is no trigger registered to the given name.
*
* <p>
* If there already exists a trigger with the given name, this method does nothing and returns immmediately.
* </p>
*
* @param triggerName The unique name of the trigger. Must not be <code>null</code> or empty.
* @param triggerSupplier The supplier for the trigger. Will be invoked if and only if there is no trigger with the given name yet. Will be invoked at most once. Must not be <code>null</code>. The {@link Supplier#get()} method must not return <code>null</code>.
* @param commitMetadata The metadata for the commit of creating a new trigger. May be <code>null</code>.
* @return <code>true</code> code if the trigger was added successfully, or <code>false</code> if there already was a trigger registered to the given name.
* @see #createTrigger(String, ChronoGraphTrigger)
* @see #createTriggerAndOverwrite(String, ChronoGraphTrigger)
*/
public boolean createTriggerIfNotPresent(String triggerName, Supplier<ChronoGraphTrigger> triggerSupplier, Object commitMetadata);
/**
* Creates a trigger with the given unique name, overriding any previous trigger.
*
* @param triggerName The unique name of the trigger. Must not be <code>null</code> or empty.
* @param trigger The trigger to create. Must not be <code>null</code>.
* @return <code>true</code> if an existing trigger has been overwritten, or <code>false</code> if no trigger existed previously for the given name.
* @see #createTrigger(String, ChronoGraphTrigger)
* @see #createTriggerIfNotPresent(String, Supplier)
*/
public boolean createTriggerAndOverwrite(String triggerName, ChronoGraphTrigger trigger);
/**
* Creates a trigger with the given unique name, overriding any previous trigger.
*
* @param triggerName The unique name of the trigger. Must not be <code>null</code> or empty.
* @param trigger The trigger to create. Must not be <code>null</code>.
* @param commitMetadata The metadata for the commit of creating a new trigger. May be <code>null</code>.
* @return <code>true</code> if an existing trigger has been overwritten, or <code>false</code> if no trigger existed previously for the given name.
* @see #createTrigger(String, ChronoGraphTrigger)
* @see #createTriggerIfNotPresent(String, Supplier)
*/
public boolean createTriggerAndOverwrite(String triggerName, ChronoGraphTrigger trigger, Object commitMetadata);
/**
* Creates a trigger with the given unique name.
*
* <p>
* If a trigger is already bound to the given name, a {@link TriggerAlreadyExistsException} will be thrown.
* </p>
*
* @param triggerName The unique name of the trigger. Must not be <code>null</code> or empty.
* @param trigger The trigger to create. Must not be <code>null</code>.
* @throws TriggerAlreadyExistsException if there already exists a trigger with the given unique name.
*/
public void createTrigger(String triggerName, ChronoGraphTrigger trigger) throws TriggerAlreadyExistsException;
/**
* Creates a trigger with the given unique name.
*
* <p>
* If a trigger is already bound to the given name, a {@link TriggerAlreadyExistsException} will be thrown.
* </p>
*
* @param triggerName The unique name of the trigger. Must not be <code>null</code> or empty.
* @param trigger The trigger to create. Must not be <code>null</code>.
* @param commitMetadata The metadata for the commit of creating a new trigger. May be <code>null</code>.
* @throws TriggerAlreadyExistsException if there already exists a trigger with the given unique name.
*/
public void createTrigger(String triggerName, ChronoGraphTrigger trigger, Object commitMetadata) throws TriggerAlreadyExistsException;
/**
* Unconditionally drops the trigger with the given unique name.
*
* @param triggerName The name of the trigger to drop. Must not be <code>null</code> or empty.
* @return <code>true</code> if a trigger with the given name was dropped, or <code>false</code> if there was no such trigger.
*/
public boolean dropTrigger(String triggerName);
/**
* Unconditionally drops the trigger with the given unique name.
*
* @param triggerName The name of the trigger to drop. Must not be <code>null</code> or empty.
* @param commitMetadata The metadata for the commit of dropping a trigger. May be <code>null</code>.
* @return <code>true</code> if a trigger with the given name was dropped, or <code>false</code> if there was no such trigger.
*/
public boolean dropTrigger(String triggerName, Object commitMetadata);
/**
* Returns the unique names of all known triggers.
*
* @return The unique names of all known triggers. May be empty, but never <code>null</code>. Returns an immutable view.
*/
public Set<String> getTriggerNames();
/**
* Returns the {@link GraphTriggerMetadata metadata} of all known triggers, including invalid ones.
*
* The resulting list will be ordered in the actual trigger execution order.
*
* @return
*/
public List<GraphTriggerMetadata> getTriggers();
public GraphTriggerMetadata getTrigger(final String triggerName);
}
| 7,386 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
PropertyConflictResolutionStrategy.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/transaction/conflict/PropertyConflictResolutionStrategy.java | package org.chronos.chronograph.api.transaction.conflict;
import org.chronos.chronograph.internal.impl.transaction.conflict.strategies.OverwriteWithStoreValueStrategy;
import org.chronos.chronograph.internal.impl.transaction.conflict.strategies.OverwriteWithTransactionValueStrategy;
import org.chronos.chronograph.internal.impl.transaction.conflict.strategies.ThrowExceptionStrategy;
public interface PropertyConflictResolutionStrategy {
// =================================================================================================================
// CONSTANTS
// =================================================================================================================
public static final PropertyConflictResolutionStrategy OVERWRITE_WITH_TRANSACTION_VALUE = OverwriteWithTransactionValueStrategy.INSTANCE;
public static final PropertyConflictResolutionStrategy OVERWRITE_WITH_STORE_VALUE = OverwriteWithStoreValueStrategy.INSTANCE;
public static final PropertyConflictResolutionStrategy DO_NOT_MERGE = ThrowExceptionStrategy.INSTANCE;
// =================================================================================================================
// PUBLIC API
// =================================================================================================================
public Object resolve(PropertyConflict conflict);
}
| 1,370 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
PropertyConflict.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/transaction/conflict/PropertyConflict.java | package org.chronos.chronograph.api.transaction.conflict;
import org.apache.tinkerpop.gremlin.structure.Element;
import org.apache.tinkerpop.gremlin.structure.Property;
public interface PropertyConflict {
public String getPropertyKey();
public Element getTransactionElement();
public Property<?> getTransactionProperty();
public Element getStoreElement();
public Property<?> getStoreProperty();
public Element getAncestorElement();
public Property<?> getAncestorProperty();
}
| 492 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
ChronoGraphFinalizableBuilder.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/builder/graph/ChronoGraphFinalizableBuilder.java | package org.chronos.chronograph.api.builder.graph;
import org.apache.tinkerpop.gremlin.process.traversal.step.map.PropertiesStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.map.PropertyMapStep;
import org.chronos.chronograph.api.structure.ChronoGraph;
import org.chronos.chronograph.internal.api.configuration.ChronoGraphConfiguration;
import org.chronos.common.builder.ChronoBuilder;
/**
* A builder for instances of {@link ChronoGraph}.
*
* <p>
* When an instance of this interface is returned by the fluent builder API, then all information required for building
* the database is complete, and {@link #build()} can be called to finalize the build process.
*
* <p>
* Even though the {@link #build()} method becomes available at this stage, it is still possible to set properties
* defined by the concrete implementations.
*
* @author martin.haeusler@uibk.ac.at -- Initial Contribution and API
*/
public interface ChronoGraphFinalizableBuilder extends ChronoBuilder<ChronoGraphFinalizableBuilder> {
/**
* Enables or disables the check for ID existence when adding a new graph element with a user-provided ID.
*
* <p>
* For details, please refer to {@link ChronoGraphConfiguration#isCheckIdExistenceOnAddEnabled()}.
*
* @param enableIdExistenceCheckOnAdd Use <code>true</code> to enable the safety check, or <code>false</code> to disable it.
* @return <code>this</code>, for method chaining.
*/
public ChronoGraphFinalizableBuilder withIdExistenceCheckOnAdd(boolean enableIdExistenceCheckOnAdd);
/**
* Enables or disables automatic opening of new graph transactions on-demand.
*
* <p>
* For details, please refer to {@link ChronoGraphConfiguration#isTransactionAutoOpenEnabled()}.
*
* @param enableAutoStartTransactions Set this to <code>true</code> if auto-start of transactions should be enabled (default), otherwise set
* it to <code>false</code> to disable this feature.
* @return <code>this</code>, for method chaining.
*/
public ChronoGraphFinalizableBuilder withTransactionAutoStart(boolean enableAutoStartTransactions);
/**
* Enables or disables the static (i.e. shared) groovy compilation cache.
*
* <p>
* For details, please refer to {@link ChronoGraphConfiguration#isUseStaticGroovyCompilationCache()}.
* </p>
*
* @param enableStaticGroovyCompilationCache Set this to <code>true</code> to enable the static groovy compilation cache.
* Use <code>false</code> (default) if each ChronoGraph instance should have its own cache.
* @return <code>this</code>, for method chaining.
*/
public ChronoGraphFinalizableBuilder withStaticGroovyCompilationCache(boolean enableStaticGroovyCompilationCache);
/**
* Enables or disables utilization of secondary indices for the Gremlin {@link PropertiesStep values()} step.
*
* Please note that this has some side effects:
* <ul>
* <li>The values will be reported as a set, i.e. they will not contain duplicates, and they will be reported in no particular order.</li>
* <li>If a property contains multiple values, those values will be flattened.</li>
* <li>If there is a secondary index available, property values that do not match the type of the index will NOT be returned.</li>
* </ul>
*
* Use this setting only if all property values match the type of the index. If that isn't the case, index queries will produce wrong results
* without warning.
*
* This is the global setting that will affect all traversals performed on this graph. The setting can be
* overwritten on a per-traversal basis by calling:
*
* <pre>
* graph.traversal()
* .with(ChronoGraphConfiguration.USE_SECONDARY_INDEX_FOR_VALUES_STEP, false) // true to enable, false to disable
* .V()
* ...
* </pre>
*
* @param useSecondaryIndexForGremlinValuesStep Use <code>true</code> if secondary indices should be used for {@link PropertiesStep values()} steps.
* Please see the consequences listed above.
* @return <code>this</code>, for method chaining.
*/
public ChronoGraphFinalizableBuilder withUsingSecondaryIndicesForGremlinValuesStep(boolean useSecondaryIndexForGremlinValuesStep);
/**
* Enables or disables utilization of secondary indices for the Gremlin {@link PropertyMapStep valueMap()} step.
*
* Please note that this has some side effects:
* <ul>
* <li>The values will be reported as a set, i.e. they will not contain duplicates, and they will be reported in no particular order.</li>
* <li>Even if your original property value was a single value (e.g. a single string), it will be reported as a set (of size 1).</li>
* <li>If there is a secondary index available, property values that do not match the type of the index will NOT be returned.</li>
* </ul>
*
* <p>
* Use this setting only if all property values match the type of the index. If that isn't the case, index queries will produce wrong results
* without warning.
* </p>
*
* <p>
* This is the global setting that will affect all traversals performed on this graph. The setting can be
* overwritten on a per-traversal basis by calling:
* </p>
*
* <pre>
* graph.traversal()
* .with(ChronoGraphConfiguration.USE_SECONDARY_INDEX_FOR_VALUE_MAP_STEP, false) // true to enable, false to disable
* .V()
* ...
* </pre>
*
* @param useSecondaryIndexForGremlinValueMapStep Use <code>true</code> if secondary indices should be used for {@link PropertyMapStep valueMap()} steps.
* Please see the consequences listed above.
* @return <code>this</code>, for method chaining.
*/
public ChronoGraphFinalizableBuilder withUsingSecondaryIndicesForGremlinValueMapStep(boolean useSecondaryIndexForGremlinValueMapStep);
/**
* Builds the {@link ChronoGraph} instance, using the properties specified by the fluent API.
*
* <p>
* This method finalizes the build process. Afterwards, the builder should be discarded.
*
* @return The new {@link ChronoGraph} instance. Never <code>null</code>.
*/
public ChronoGraph build();
} | 6,521 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
ChronoGraphBaseBuilder.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/builder/graph/ChronoGraphBaseBuilder.java | package org.chronos.chronograph.api.builder.graph;
import org.apache.commons.configuration2.Configuration;
import org.chronos.chronodb.api.builder.database.ChronoDBBackendBuilder;
import org.chronos.chronodb.api.builder.database.ChronoDBFinalizableBuilder;
import org.chronos.chronodb.inmemory.builder.ChronoDBInMemoryBuilder;
import org.chronos.chronograph.api.ChronoGraphFactory;
import org.chronos.chronograph.api.structure.ChronoGraph;
import java.io.File;
import java.util.Properties;
import java.util.function.Function;
/**
* This class acts as the first step in the fluent ChronoGraph builder API.
*
* <p>
* You can get access to an instance of this class via {@link ChronoGraphFactory#create()}.
*
* @author martin.haeusler@uibk.ac.at -- Initial Contribution and API
*/
public interface ChronoGraphBaseBuilder {
/**
* A generic way for creating a ChronoGraph instance.
*
* <p>
* Most users will not need to use this method directly. Instead, use e.g. {@link #exodusGraph(File)}, {@link #inMemoryGraph(Function)} or {@link #fromProperties(Properties)},
* which are essentially shortcuts for this method.
* </p>
*
* @param builder The ChronoDB-Builder to use for store configuration. Must not be <code>null</code>.
* @return The builder for the Graph, for method chaining. Never <code>null</code>.
*/
public ChronoGraphFinalizableBuilder graphOnChronoDB(ChronoDBFinalizableBuilder<?> builder);
/**
* Creates a {@link ChronoGraph} based on a {@linkplain Properties properties} file.
*
* @param file The properties file to read the graph configuration from. Must not be <code>null</code>, must refer to an existing properties file.
* @return The builder for the Graph, for method chaining. Never <code>null</code>.
*/
public ChronoGraphFinalizableBuilder fromPropertiesFile(File file);
/**
* Creates a {@link ChronoGraph} based on a {@linkplain Properties properties} file.
*
* @param filePath
* The path to the properties file to read. Must not be <code>null</code>. Must refer to an existing file.
*
* @return The builder for the Graph, for method chaining. Never <code>null</code>.
*/
public ChronoGraphFinalizableBuilder fromPropertiesFile(String filePath);
/**
* Creates a {@link ChronoGraph} based on an Apache Commons {@link Configuration} object.
*
* @param configuration
* The configuration to use for the new graph. Must not be <code>null</code>.
*
* @return The builder for the Graph, for method chaining. Never <code>null</code>.
*/
public ChronoGraphFinalizableBuilder fromConfiguration(Configuration configuration);
/**
* Creates a {@link ChronoGraph} based on a {@linkplain Properties properties} object.
*
* @param properties The properties object to read the settings from. Must not be <code>null</code>.
* @return The builder for the Graph, for method chaining. Never <code>null</code>.
*/
public ChronoGraphFinalizableBuilder fromProperties(Properties properties);
/**
* Creates a basic in-memory ChronoGraph in its default configuration.
*
* <p>
* The in-memory graph is shipped together with the ChronoGraph API; no additional artifacts are necessary.
* </p>
*
* <p>
* While the in-memory backend is subject to the same suite of tests as all other backends, it is primarily
* intended as a stand-in for testing purposes.
* </p>
*
* @return The graph builder for further customization on graph-level. If you want customization on key-value-store level, please use {@link #inMemoryGraph(Function)} instead.
* @see #inMemoryGraph(Function)
*/
public ChronoGraphFinalizableBuilder inMemoryGraph();
/**
* Creates an in-memory ChronoGraph and allows for customization of its configuration via the argument function.
*
* <p>
* The in-memory graph is shipped together with the ChronoGraph API; no additional artifacts are necessary.
* </p>
*
* <p>
* While the in-memory backend is subject to the same suite of tests as all other backends, it is primarily
* intended as a stand-in for testing purposes.
* </p>
*
* @param configureStore Configures the backing key-value-store. Please note that some settings which are mandatory for ChronoGraph will be silently overwritten.
* Important: do <b>not</b> call {@link ChronoDBFinalizableBuilder#build()} on the builder, ChronoGraph will do this internally.
* @return The graph builder for further customization on graph-level.
*/
public ChronoGraphFinalizableBuilder inMemoryGraph(Function<ChronoDBInMemoryBuilder, ChronoDBFinalizableBuilder<ChronoDBInMemoryBuilder>> configureStore);
/**
* Creates a ChronoGraph based on the Exodus backend (the default production backend for ChronoGraph as of version 1.0.0) in its default configuration.
*
* <p>
* Please note that in order to use this backend, you need to have the <code>org.chronos.chronodb.exodus</code> artifact on your classpath.
* </p>
*
* @param directoryPath The path to the directory where you wish your graph data to be stored. Must not be <code>null</code>. Must point to a valid directory.
* @return The graph builder for further customization on graph-level.
* @see #exodusGraph(String, Function)
*/
public ChronoGraphFinalizableBuilder exodusGraph(String directoryPath);
/**
* Creates a ChronoGraph based on the Exodus backend (the default production backend for ChronoGraph as of version 1.0.0) in its default configuration.
*
* <p>
* Please note that in order to use this backend, you need to have the <code>org.chronos.chronodb.exodus</code> artifact on your classpath.
* </p>
*
* @param directory The directory where you wish your graph data to be stored. Must not be <code>null</code>. Must point to a valid directory.
* @return The graph builder for further customization on graph-level.
* @see #exodusGraph(File, Function)
*/
public ChronoGraphFinalizableBuilder exodusGraph(File directory);
/**
* Creates a ChronoGraph based on the Exodus backend (the default production backend for ChronoGraph as of version 1.0.0).
*
* <p>
* Please note that in order to use this backend, you need to have the <code>org.chronos.chronodb.exodus</code> artifact on your classpath.
* </p>
*
* @param directoryPath The path to the directory where you wish your graph data to be stored. Must not be <code>null</code>. Must point to a valid directory.
* @param configureStore Configures the backing key-value-store. Please note that some settings which are mandatory for ChronoGraph will be silently overwritten.
* Important: do <b>not</b> call {@link ChronoDBFinalizableBuilder#build()} on the builder, ChronoGraph will do this internally.
* @return The graph builder for further customization on graph-level.
*/
public ChronoGraphFinalizableBuilder exodusGraph(String directoryPath, Function<ChronoDBFinalizableBuilder<?>, ChronoDBFinalizableBuilder<?>> configureStore);
/**
* Creates a ChronoGraph based on the Exodus backend (the default production backend for ChronoGraph as of version 1.0.0).
*
* <p>
* Please note that in order to use this backend, you need to have the <code>org.chronos.chronodb.exodus</code> artifact on your classpath.
* </p>
*
* @param directory The directory where you wish your graph data to be stored. Must not be <code>null</code>. Must point to a valid directory.
* @param configureStore Configures the backing key-value-store. Please note that some settings which are mandatory for ChronoGraph will be silently overwritten.
* Important: do <b>not</b> call {@link ChronoDBFinalizableBuilder#build()} on the builder, ChronoGraph will do this internally.
* @return The graph builder for further customization on graph-level.
* @see #exodusGraph(File, Function)
*/
public ChronoGraphFinalizableBuilder exodusGraph(File directory, Function<ChronoDBFinalizableBuilder<?>, ChronoDBFinalizableBuilder<?>> configureStore);
/**
* Allows to create a ChronoGraph instance using a custom user-provided store implementation.
*
* <p>
* This method serves as an extension point for advanced usage. Only required if you want to use a custom backend.
* </p>
*
* @param builderClass The builder class for the backing store.
* @param configureStore Configures the backing key-value-store. Please note that some settings which are mandatory for ChronoGraph will be silently overwritten.
* Important: do <b>not</b> call {@link ChronoDBFinalizableBuilder#build()} on the builder, ChronoGraph will do this internally.
* @param <T> The type of the builder.
* @return The graph builder for further customization on graph-level.
*/
public <T extends ChronoDBBackendBuilder> ChronoGraphFinalizableBuilder customGraph(Class<T> builderClass, Function<T, ChronoDBFinalizableBuilder<?>> configureStore);
}
| 8,933 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
StringWithoutCP.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/builder/query/StringWithoutCP.java | package org.chronos.chronograph.api.builder.query;
import org.chronos.chronodb.internal.impl.query.TextMatchMode;
import org.chronos.common.exceptions.UnknownEnumLiteralException;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
import java.util.function.BiPredicate;
import static com.google.common.base.Preconditions.*;
public class StringWithoutCP implements BiPredicate<Object, Collection> {
private final TextMatchMode matchMode;
public StringWithoutCP(TextMatchMode matchMode) {
checkNotNull(matchMode, "Precondition violation - argument 'matchMode' must not be NULL!");
this.matchMode = matchMode;
}
public TextMatchMode getMatchMode() {
return this.matchMode;
}
@Override
public boolean test(final Object o, final Collection collection) {
return !this.negate().test(o, collection);
}
@NotNull
@Override
public BiPredicate<Object, Collection> negate() {
return new StringWithinCP(this.matchMode);
}
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
StringWithoutCP that = (StringWithoutCP) o;
return matchMode == that.matchMode;
}
@Override
public int hashCode() {
return matchMode != null ? matchMode.hashCode() : 0;
}
@Override
public String toString() {
return "String Without" + (this.matchMode == TextMatchMode.CASE_INSENSITIVE ? " [CI]" : "");
}
}
| 1,605 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
DoubleWithoutCP.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/builder/query/DoubleWithoutCP.java | package org.chronos.chronograph.api.builder.query;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
import java.util.function.BiPredicate;
public class DoubleWithoutCP implements BiPredicate<Object, Collection> {
private final double tolerance;
public DoubleWithoutCP(final double tolerance) {
this.tolerance = tolerance;
}
public double getTolerance() {
return tolerance;
}
@Override
public boolean test(final Object o, final Collection collection) {
return !this.negate().test(o, collection);
}
@NotNull
@Override
public BiPredicate<Object, Collection> negate() {
return new DoubleWithinCP(this.tolerance);
}
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
DoubleWithoutCP that = (DoubleWithoutCP) o;
return Double.compare(that.tolerance, tolerance) == 0;
}
@Override
public int hashCode() {
long temp = Double.doubleToLongBits(tolerance);
return (int) (temp ^ (temp >>> 32));
}
@Override
public String toString() {
return "Double Without";
}
}
| 1,291 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
CP.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/builder/query/CP.java | package org.chronos.chronograph.api.builder.query;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import org.apache.tinkerpop.gremlin.process.traversal.P;
import org.chronos.chronodb.internal.impl.query.TextMatchMode;
import org.chronos.chronograph.internal.impl.query.ChronoCompare;
import org.chronos.chronograph.internal.impl.query.ChronoStringCompare;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.function.BiPredicate;
import java.util.stream.Collectors;
public class CP<V> extends P<V> {
protected CP(final BiPredicate<V, V> biPredicate, final V value) {
super(biPredicate, value);
}
public static <V> CP<V> cEq(Object value) {
if(value instanceof Collection){
if(((Collection<?>)value).isEmpty()){
// gremlin standard: if an empty collection is passed
// to "eq" it means that the predicate matches NOTHING.
return new CP(ChronoCompare.EQ, Collections.emptySet());
}
// in general, collection values are not allowed.
throw new IllegalArgumentException("Error in has clause: 'equals' with a collection value is not supported! If required, use .filter(...) with a lambda expression instead.");
}
return new CP(ChronoCompare.EQ, value);
}
public static <V> CP<V> cNeq(Object value) {
if(value instanceof Collection){
throw new IllegalArgumentException("Error in has clause: 'not equals' with a collection value is not supported! If required, use .filter(...) with a lambda expression instead.");
}
return new CP(ChronoCompare.NEQ, value);
}
public static <V> CP<V> cGt(Object value) {
if(value instanceof Collection){
throw new IllegalArgumentException("Error in has clause: 'greater than' with a collection value is not supported! If required, use .filter(...) with a lambda expression instead.");
}
return new CP(ChronoCompare.GT, value);
}
public static <V> CP<V> cGte(Object value) {
if(value instanceof Collection){
throw new IllegalArgumentException("Error in has clause: 'greater than or equal to' with a collection value is not supported! If required, use .filter(...) with a lambda expression instead.");
}
return new CP(ChronoCompare.GTE, value);
}
public static <V> CP<V> cLt(Object value) {
if(value instanceof Collection){
throw new IllegalArgumentException("Error in has clause: 'less than' with a collection value is not supported! If required, use .filter(...) with a lambda expression instead.");
}
return new CP(ChronoCompare.LT, value);
}
public static <V> CP<V> cLte(Object value) {
if(value instanceof Collection){
throw new IllegalArgumentException("Error in has clause: 'less than or equal to' with a collection value is not supported! If required, use .filter(...) with a lambda expression instead.");
}
return new CP(ChronoCompare.LTE, value);
}
public static <V> CP<V> cWithin(final V... values) {
for(V value : values){
if(value instanceof Collection){
throw new IllegalArgumentException("Error in has clause: 'within' with nested collection values is not supported! If required, use .filter(...) with a lambda expression instead.");
}
}
return CP.cWithin(Arrays.asList(values));
}
public static <V> CP<V> cWithin(final Collection<V> value) {
for(V item : value){
if(item instanceof Collection){
throw new IllegalArgumentException("Error in has clause: 'within' with nested collection values is not supported! If required, use .filter(...) with a lambda expression instead.");
}
}
return new CP(ChronoCompare.WITHIN, value);
}
public static <V> CP<V> cWithout(final V... values) {
for(V value : values){
if(value instanceof Collection){
throw new IllegalArgumentException("Error in has clause: 'without' with nested collection values is not supported! If required, use .filter(...) with a lambda expression instead.");
}
}
return CP.cWithout(Arrays.asList(values));
}
public static <V> CP<V> cWithout(final Collection<V> value) {
for(V item : value){
if(item instanceof Collection){
throw new IllegalArgumentException("Error in has clause: 'without' with nested collection values is not supported! If required, use .filter(...) with a lambda expression instead.");
}
}
return new CP(ChronoCompare.WITHOUT, value);
}
@SuppressWarnings("unchecked")
public static CP<String> eqIgnoreCase(String value){
return new CP(ChronoStringCompare.STRING_EQUALS_IGNORE_CASE, value);
}
@SuppressWarnings("unchecked")
public static CP<String> neqIgnoreCase(String value){
return new CP(ChronoStringCompare.STRING_NOT_EQUALS_IGNORE_CASE, value);
}
@SuppressWarnings("unchecked")
public static CP<String> startsWith(String value){
return new CP(ChronoStringCompare.STRING_STARTS_WITH, value);
}
@SuppressWarnings("unchecked")
public static CP<String> notStartsWith(String value){
return new CP(ChronoStringCompare.STRING_NOT_STARTS_WITH, value);
}
@SuppressWarnings("unchecked")
public static CP<String> startsWithIgnoreCase(String value){
return new CP(ChronoStringCompare.STRING_STARTS_WITH_IGNORE_CASE, value);
}
@SuppressWarnings("unchecked")
public static CP<String> notStartsWithIgnoreCase(String value){
return new CP(ChronoStringCompare.STRING_NOT_STARTS_WITH_IGNORE_CASE, value);
}
@SuppressWarnings("unchecked")
public static CP<String> endsWith(String value){
return new CP(ChronoStringCompare.STRING_ENDS_WITH, value);
}
@SuppressWarnings("unchecked")
public static CP<String> notEndsWith(String value){
return new CP(ChronoStringCompare.STRING_NOT_ENDS_WITH, value);
}
@SuppressWarnings("unchecked")
public static CP<String> endsWithIgnoreCase(String value){
return new CP(ChronoStringCompare.STRING_ENDS_WITH_IGNORE_CASE, value);
}
@SuppressWarnings("unchecked")
public static CP<String> notEndsWithIgnoreCase(String value){
return new CP(ChronoStringCompare.STRING_NOT_ENDS_WITH_IGNORE_CASE, value);
}
@SuppressWarnings("unchecked")
public static CP<String> contains(String value){
return new CP(ChronoStringCompare.STRING_CONTAINS, value);
}
@SuppressWarnings("unchecked")
public static CP<String> notContains(String value){
return new CP(ChronoStringCompare.STRING_NOT_CONTAINS, value);
}
@SuppressWarnings("unchecked")
public static CP<String> containsIgnoreCase(String value){
return new CP(ChronoStringCompare.STRING_CONTAINS_IGNORE_CASE, value);
}
@SuppressWarnings("unchecked")
public static CP<String> notContainsIgnoreCase(String value){
return new CP(ChronoStringCompare.STRING_NOT_CONTAINS_IGNORE_CASE, value);
}
@SuppressWarnings("unchecked")
public static CP<String> matchesRegex(String value){
return new CP(ChronoStringCompare.STRING_MATCHES_REGEX, value);
}
@SuppressWarnings("unchecked")
public static CP<String> matchesRegexIgnoreCase(String value){
return new CP(ChronoStringCompare.STRING_MATCHES_REGEX_IGNORE_CASE, value);
}
@SuppressWarnings("unchecked")
public static CP<String> notMatchesRegex(String value){
return new CP(ChronoStringCompare.STRING_NOT_MATCHES_REGEX, value);
}
@SuppressWarnings("unchecked")
public static CP<String> notMatchesRegexIgnoreCase(String value){
return new CP(ChronoStringCompare.STRING_NOT_MATCHES_REGEX_IGNORE_CASE, value);
}
public static CP<String> withinIgnoreCase(String... values){
return withinIgnoreCase(Lists.newArrayList(values));
}
@SuppressWarnings("unchecked")
public static CP<String> withinIgnoreCase(Collection<String> values){
return new CP(new StringWithinCP(TextMatchMode.CASE_INSENSITIVE), values.stream().map(String::toLowerCase).collect(Collectors.toSet()));
}
public static CP<String> withoutIgnoreCase(String... values){
return withoutIgnoreCase(Lists.newArrayList(values));
}
@SuppressWarnings("unchecked")
public static CP<String> withoutIgnoreCase(Collection<String> values){
return new CP(new StringWithoutCP(TextMatchMode.CASE_INSENSITIVE), values.stream().map(String::toLowerCase).collect(Collectors.toSet()));
}
@SuppressWarnings("unchecked")
public static CP<Double> within(Collection<Double> values, double tolerance){
return new CP(new DoubleWithinCP(tolerance), Sets.newHashSet(values));
}
@SuppressWarnings("unchecked")
public static CP<Double> without(Collection<Double> values, double tolerance){
return new CP(new DoubleWithoutCP(tolerance), Sets.newHashSet(values));
}
@SuppressWarnings("unchecked")
public static CP<Double> eq(Double value, double tolerance){
return new CP(new DoubleEqualsCP(tolerance), value);
}
@SuppressWarnings("unchecked")
public static CP<Double> neq(Double value, double tolerance){
return new CP(new DoubleNotEqualsCP(tolerance), value);
}
}
| 9,583 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
LongWithoutCP.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/builder/query/LongWithoutCP.java | package org.chronos.chronograph.api.builder.query;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
import java.util.function.BiPredicate;
public class LongWithoutCP implements BiPredicate<Object, Collection> {
public LongWithoutCP() {
}
@Override
public boolean test(final Object o, final Collection collection) {
return !this.negate().test(o, collection);
}
@NotNull
@Override
public BiPredicate<Object, Collection> negate() {
return new LongWithinCP();
}
@Override
public int hashCode(){
return this.getClass().hashCode();
}
@Override
public boolean equals(Object other){
if(other == null){
return false;
}
return other instanceof LongWithoutCP;
}
@Override
public String toString() {
return "Long Without";
}
}
| 886 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
DoubleWithinCP.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/builder/query/DoubleWithinCP.java | package org.chronos.chronograph.api.builder.query;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
import java.util.function.BiPredicate;
public class DoubleWithinCP implements BiPredicate<Object, Collection> {
private final double tolerance;
public DoubleWithinCP(final double tolerance) {
this.tolerance = tolerance;
}
public double getTolerance() {
return tolerance;
}
@Override
@SuppressWarnings("unchecked")
public boolean test(final Object o, final Collection collection) {
if(collection == null || collection.isEmpty()){
return false;
}
if(o instanceof Double){
double value = (Double)o;
for(Object element : collection){
if(element instanceof Double){
double other = (Double)element;
if(Math.abs(value - other) <= this.tolerance){
return true;
}
}
}
} else if(o instanceof Collection){
for(Object element : (Collection<Object>)o){
if(test(element, collection)){
return true;
}
}
}
return false;
}
@NotNull
@Override
public BiPredicate<Object, Collection> negate() {
return new DoubleWithoutCP(tolerance);
}
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
DoubleWithinCP that = (DoubleWithinCP) o;
return Double.compare(that.tolerance, tolerance) == 0;
}
@Override
public int hashCode() {
long temp = Double.doubleToLongBits(tolerance);
return (int) (temp ^ (temp >>> 32));
}
@Override
public String toString() {
return "Double Within";
}
}
| 1,977 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
DoubleNotEqualsCP.java | /FileExtraction/Java_unseen/Txture_chronos/org.chronos.chronograph/src/main/java/org/chronos/chronograph/api/builder/query/DoubleNotEqualsCP.java | package org.chronos.chronograph.api.builder.query;
import org.jetbrains.annotations.NotNull;
import java.util.function.BiPredicate;
public class DoubleNotEqualsCP implements BiPredicate<Object, Object> {
private final double tolerance;
@SuppressWarnings({"unchecked", "rawtypes"})
public DoubleNotEqualsCP(final double tolerance) {
this.tolerance = tolerance;
}
public double getTolerance() {
return this.tolerance;
}
@Override
public boolean test(final Object o, final Object o2) {
return !this.negate().test(o, o2);
}
@NotNull
@Override
public BiPredicate<Object, Object> negate() {
return new DoubleEqualsCP(this.tolerance);
}
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
DoubleNotEqualsCP that = (DoubleNotEqualsCP) o;
return Double.compare(that.tolerance, tolerance) == 0;
}
@Override
public int hashCode() {
long temp = Double.doubleToLongBits(tolerance);
return (int) (temp ^ (temp >>> 32));
}
@Override
public String toString() {
return "Double Neq";
}
}
| 1,294 | Java | .java | Txture/chronos | 26 | 3 | 0 | 2020-05-19T17:35:13Z | 2023-03-10T16:19:01Z |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.