Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions geaflow/geaflow-plugins/geaflow-store/geaflow-store-sqlite/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--

~ Licensed to the Apache Software Foundation (ASF) under one

~ or more contributor license agreements. See the NOTICE file

~ distributed with this work for additional information

~ regarding copyright ownership. The ASF licenses this file

~ to you under the Apache License, Version 2.0 (the

~ "License"); you may not use this file except in compliance

~ with the License. You may obtain a copy of the License at

~

~ http://www.apache.org/licenses/LICENSE-2.0

~

~ Unless required by applicable law or agreed to in writing,

~ software distributed under the License is distributed on an

~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

~ KIND, either express or implied. See the License for the

~ specific language governing permissions and limitations

~ under the License.

-->
<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/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>geaflow-store</artifactId>
<groupId>org.apache.geaflow</groupId>
<version>0.8.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>geaflow-store-sqlite</artifactId>
<name>geaflow-store-sqlite</name>

<dependencies>
<dependency>
<groupId>org.apache.geaflow</groupId>
<artifactId>geaflow-store-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.geaflow</groupId>
<artifactId>geaflow-state-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.geaflow</groupId>
<artifactId>geaflow-state-common</artifactId>
</dependency>

<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.41.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.geaflow</groupId>
<artifactId>geaflow-collection</artifactId>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-core</artifactId>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.apache.geaflow.store.sqlite;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import org.apache.geaflow.common.config.Configuration;
import org.apache.geaflow.common.iterator.CloseableIterator;
import org.apache.geaflow.model.graph.edge.IEdge;
import org.apache.geaflow.model.graph.vertex.IVertex;
import org.apache.geaflow.state.data.DataType;
import org.apache.geaflow.state.data.OneDegreeGraph;
import org.apache.geaflow.state.pushdown.IStatePushDown;
import org.apache.geaflow.state.pushdown.inner.IFilterConverter;
import org.apache.geaflow.store.api.graph.IDynamicGraphStore;
import org.apache.geaflow.store.context.StoreContext;

public class SQLiteGraphStore<K, VV, EV> implements IDynamicGraphStore<K, VV, EV> {

private Connection connection;
private final String dbName;

public SQLiteGraphStore(String storeName, Configuration config) {
this.dbName = "jdbc:sqlite:geaflow_graph_" + storeName + ".db";
}

public void init(StoreContext storeContext) {
try {
Class.forName("org.sqlite.JDBC");
connection = DriverManager.getConnection(dbName);

try (Statement stmt = connection.createStatement()) {
String createVertices = "CREATE TABLE IF NOT EXISTS graph_vertices ("
+ "vertex_id TEXT PRIMARY KEY, "
+ "vertex_data TEXT)";
stmt.execute(createVertices);

String createEdges = "CREATE TABLE IF NOT EXISTS graph_edges ("
+ "src_id TEXT, "
+ "target_id TEXT, "
+ "edge_data TEXT, "
+ "PRIMARY KEY(src_id, target_id))";
stmt.execute(createEdges);
}
} catch (Exception e) {
throw new RuntimeException("Failed to initialize SQLite Graph Store", e);
}
}

public void addEdge(long version, IEdge<K, EV> edge) {
}

public void addVertex(long version, IVertex<K, VV> vertex) {
}

public IVertex<K, VV> getVertex(long version, K sid, IStatePushDown pushdown) {
return null;
}

public List<IEdge<K, EV>> getEdges(long version, K sid, IStatePushDown pushdown) {
return null;
}

public OneDegreeGraph<K, VV, EV> getOneDegreeGraph(long version, K sid, IStatePushDown pushdown) {
return null;
}

public CloseableIterator<K> vertexIDIterator() {
return null;
}

public CloseableIterator<K> vertexIDIterator(long version, IStatePushDown pushdown) {
return null;
}

public CloseableIterator<IVertex<K, VV>> getVertexIterator(long version, IStatePushDown pushdown) {
return null;
}

public CloseableIterator<IVertex<K, VV>> getVertexIterator(long version, List<K> keys, IStatePushDown pushdown) {
return null;
}

public CloseableIterator<IEdge<K, EV>> getEdgeIterator(long version, IStatePushDown pushdown) {
return null;
}

public CloseableIterator<IEdge<K, EV>> getEdgeIterator(long version, List<K> keys, IStatePushDown pushdown) {
return null;
}

public CloseableIterator<OneDegreeGraph<K, VV, EV>> getOneDegreeGraphIterator(long version, IStatePushDown pushdown) {
return null;
}

public CloseableIterator<OneDegreeGraph<K, VV, EV>> getOneDegreeGraphIterator(long version, List<K> keys, IStatePushDown pushdown) {
return null;
}

public List<Long> getAllVersions(K id, DataType dataType) {
return null;
}

public long getLatestVersion(K id, DataType dataType) {
return 0L;
}

public Map<Long, IVertex<K, VV>> getAllVersionData(K id, IStatePushDown pushdown, DataType dataType) {
return null;
}

public Map<Long, IVertex<K, VV>> getVersionData(K id, Collection<Long> versions,
IStatePushDown pushdown, DataType dataType) {
return null;
}

public void flush() {
}

public void archive(long checkpointId) {
}

public void recovery(long checkpointId) {
}

public long recoveryLatest() {
return 0L;
}

public void compact() {
}

public void drop() {
try {
if (connection != null) {
try (Statement stmt = connection.createStatement()) {
stmt.execute("DROP TABLE IF EXISTS graph_vertices");
stmt.execute("DROP TABLE IF EXISTS graph_edges");
}
}
} catch (SQLException e) {
throw new RuntimeException("Failed to drop graph tables", e);
}
}

public IFilterConverter getFilterConverter() {
return null;
}

public void close() {
try {
if (connection != null) {
connection.close();
}
} catch (SQLException e) {
throw new RuntimeException("Failed to close SQLite Graph connection", e);
}
}
}
Loading