Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Datomic blueprints implementation #238

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions README.textile
Expand Up @@ -12,6 +12,7 @@ Blueprints is a "property graph model interface":http://github.com/tinkerpop/gre
** "InfiniteGraph":http://www.infinitegraph.com/ (available "here":http://wiki.infinitegraph.com/2.1/w/index.php?title=InfiniteGraph_Tinkerpop_Blueprints_Implementation)
** "Titan":http://thinkaurelius.github.com/titan/ (available "here":http://thinkaurelius.github.com/titan/)
** "Rexster":http://rexster.tinkerpop.com graph server
** "Datomic":http://www.datomic.com/ database
** "Sesame 2.0":http://www.openrdf.org compliant RDF stores
**** "MemoryStore":http://www.openrdf.org/doc/sesame2/users/ch08.html#d0e705, "NativeStore":http://www.openrdf.org/doc/sesame2/users/ch08.html#d0e746, "LinkedDataSail":http://code.google.com/p/ripple/wiki/LinkedDataSail, "SPARQLRepository":http://www.openrdf.org/doc/sesame2/api/org/openrdf/repository/sparql/SPARQLRepository.html
* Ouplementations:
Expand Down
5 changes: 5 additions & 0 deletions blueprints-core/pom.xml
Expand Up @@ -34,6 +34,11 @@
<artifactId>colt</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down
Expand Up @@ -76,6 +76,10 @@ public class Features {
* Does the graph persist the graph to disk after shutdown?
*/
public Boolean isPersistent = null;
/**
* Does the graph support time-aware versioning of its elements
*/
public Boolean isTimeAware = null;
/**
* Is the graph an RDF framework?
* @deprecated thus far, isRDFModel describes a collection of features. Use actual features to describe your data model.
Expand Down
@@ -0,0 +1,27 @@
package com.tinkerpop.blueprints;

/**
* @author Davy Suvee (http://datablend.be)
*/
public interface TimeAwareEdge extends Edge, TimeAwareElement {

@Override
public TimeAwareEdge getPreviousVersion();

@Override
public Iterable<TimeAwareEdge> getPreviousVersions();

@Override
public Iterable<TimeAwareEdge> getPreviousVersions(TimeAwareFilter timeAwareFilter);

@Override
public TimeAwareEdge getNextVersion();

@Override
public Iterable<TimeAwareEdge> getNextVersions();

@Override
public Iterable<TimeAwareEdge> getNextVersions(TimeAwareFilter timeAwareFilter);


}
@@ -0,0 +1,85 @@
package com.tinkerpop.blueprints;

import org.joda.time.Interval;

/**
* A TimeAwareElement is the base interface for time-aware elements (i.e. time-aware vertices and edges).
* It extends the base blueprints Element interface with time-based operations
*
* @author Davy Suvee (http://datablend.be)
*/
public interface TimeAwareElement extends Element {

/**
* An identifier that specifies the time-scope in which it exists
*
* @return the time identifier of the element
*/
public Object getTimeId();

/**
* Returns true if this element instance is the current version
*
* @return true if this element instance is the current version
*/
public boolean isCurrentVersion();

/**
* Returns true if this element no longer exists (it is still the current version, but no longer an active element in the graph)
*
* @return true if this element instance is deleted
*/
public boolean isDeleted();

/**
* Returns the previous version of this element
*
* @return the previous (time-aware) version of this element
*/
public TimeAwareElement getPreviousVersion();

/**
* Returns the previous versions of this element
*
* @return an iterable of previous versions
*/
public Iterable<? extends TimeAwareElement> getPreviousVersions();

/**
* Returns the previous versions of this element that satisfy a particular condition implemented as a filter
*
* @param timeAwareFilter the particular time aware filter
* @return an iterable of previous versions
*/
public Iterable<? extends TimeAwareElement> getPreviousVersions(TimeAwareFilter timeAwareFilter);

/**
* Returns the next version of this element
*
* @return the next (time-aware) version of this element
*/
public TimeAwareElement getNextVersion();

/**
* Returns the next versions of this element
*
* @return an iterable of previous versions
*/
public Iterable<? extends TimeAwareElement> getNextVersions();

/**
* Returns the next versions of this element that satisfy a particular condition implemented as a filter
*
* @param timeAwareFilter the particular time aware filter
* @return an iterable of previous versions
*/
public Iterable<? extends TimeAwareElement> getNextVersions(TimeAwareFilter timeAwareFilter);

/**
* Returns the time interval in which this version of this node is scoped
*
* @return the joda time interval
*/
public Interval getTimeInterval();

}
@@ -0,0 +1,18 @@
package com.tinkerpop.blueprints;

/**
* Filters for time aware elements
*
* @author Davy Suvee (http://datablend.be)
*/
public interface TimeAwareFilter {

/**
* Returns the time aware element if a particular condition, implemented by the filter holds.
*
* @param timeAwareElement the time aware element to filter
* @return the original input or null in case the element does not satisfy the particular condition
*/
public TimeAwareElement filter(TimeAwareElement timeAwareElement);

}
@@ -0,0 +1,25 @@
package com.tinkerpop.blueprints;

import java.util.Date;

/**
* A time aware graph supports an explicit notion of time for all graph elements (vertices and edges). Each element has a specific scope in time and allows for time-scoped iteration
* where a user can retrieve previous or next versions of each element
*
* @author Davy Suvee (http://datablend.be)
*/
public interface TimeAwareGraph extends Graph {

/**
* Sets the time scope of the graph on a specific date
* @param time the time at which the scope should be placed
*/
public void setCheckpointTime(Date time);

/**
* Sets the time scope at which new elements (vertices and edges) need to be added
* @param time the time at which the transaction scope should be placed
*/
public void setTransactionTime(Date time);

}
@@ -0,0 +1,26 @@
package com.tinkerpop.blueprints;

/**
* @author Davy Suvee (http://datablend.be)
*/
public interface TimeAwareVertex extends Vertex, TimeAwareElement {

@Override
public TimeAwareVertex getPreviousVersion();

@Override
public Iterable<TimeAwareVertex> getPreviousVersions();

@Override
public Iterable<TimeAwareVertex> getPreviousVersions(TimeAwareFilter timeAwareFilter);

@Override
public TimeAwareVertex getNextVersion();

@Override
public Iterable<TimeAwareVertex> getNextVersions();

@Override
public Iterable<TimeAwareVertex> getNextVersions(TimeAwareFilter timeAwareFilter);

}
@@ -1,10 +1,6 @@
package com.tinkerpop.blueprints.util;

import com.tinkerpop.blueprints.Direction;
import com.tinkerpop.blueprints.Edge;
import com.tinkerpop.blueprints.Graph;
import com.tinkerpop.blueprints.Index;
import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.blueprints.*;


/**
Expand All @@ -18,6 +14,7 @@ public class StringFactory {
public static final String E = "e";
public static final String L_BRACKET = "[";
public static final String R_BRACKET = "]";
public static final String AT = " @ ";
public static final String DASH = "-";
public static final String ARROW = "->";
public static final String COLON = ":";
Expand All @@ -30,10 +27,20 @@ public static String vertexString(final Vertex vertex) {
return V + L_BRACKET + vertex.getId() + R_BRACKET;
}

public static String vertexString(final TimeAwareVertex vertex) {
return V + L_BRACKET + vertex.getId() + AT + vertex.getTimeId() + R_BRACKET;
}

public static String edgeString(final Edge edge) {
return E + L_BRACKET + edge.getId() + R_BRACKET + L_BRACKET + edge.getVertex(Direction.OUT).getId() + DASH + edge.getLabel() + ARROW + edge.getVertex(Direction.IN).getId() + R_BRACKET;
}

public static String edgeString(final TimeAwareEdge edge) {
return E + L_BRACKET + edge.getId() + AT + edge.getTimeId() + R_BRACKET +
L_BRACKET + edge.getVertex(Direction.OUT).getId() + AT + ((TimeAwareVertex)edge.getVertex(Direction.OUT)).getTimeId() +
" " + DASH + edge.getLabel() + ARROW + " " + edge.getVertex(Direction.IN).getId() + AT + ((TimeAwareVertex)edge.getVertex(Direction.IN)).getTimeId() + R_BRACKET;
}

public static String graphString(final Graph graph, final String internalString) {
return graph.getClass().getSimpleName().toLowerCase() + L_BRACKET + internalString + R_BRACKET;
}
Expand Down
89 changes: 89 additions & 0 deletions blueprints-datomic-graph/pom.xml
@@ -0,0 +1,89 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.tinkerpop.blueprints</groupId>
<artifactId>blueprints</artifactId>
<version>2.1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>blueprints-datomic-graph</artifactId>
<version>2.1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Blueprints-DatomicGraph</name>
<description>Blueprints property graph implementation for the Datomic database</description>
<repositories>
<repository>
<id>sonatype-nexus-snapshots</id>
<name>Sonatype Nexus Snapshots</name>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
<repository>
<id>clojars.org</id>
<url>http://clojars.org/repo</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.datomic</groupId>
<artifactId>datomic-free</artifactId>
<version>0.8.3488</version>
</dependency>
<dependency>
<groupId>com.tinkerpop.blueprints</groupId>
<artifactId>blueprints-core</artifactId>
<version>${blueprints.version}</version>
</dependency>
<dependency>
<groupId>com.tinkerpop.blueprints</groupId>
<artifactId>blueprints-test</artifactId>
<version>${blueprints.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<directory>${basedir}/target</directory>
<finalName>${project.artifactId}-${project.version}</finalName>
<resources>
<resource>
<directory>${basedir}/src/main/resources
</directory>
</resource>
</resources>
<testResources>
<testResource>
<directory>${basedir}/src/test/resources
</directory>
</testResource>
</testResources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.4.2</version>
<configuration>
<systemProperties>
<!-- DATOMICGRAPH TEST PROPERTIES -->
<property>
<name>testDatomicGraph</name>
<value>true</value>
</property>
<property>
<name>datomicGraphDirectory</name>
<value>/tmp/blueprints_test</value>
</property>
</systemProperties>
</configuration>
</plugin>
</plugins>
</build>
</project>