1 package eu.fbk.knowledgestore.datastore;
2
3 import com.google.common.collect.Iterables;
4 import com.zaxxer.hikari.HikariDataSource;
5 import eu.fbk.knowledgestore.data.Record;
6 import eu.fbk.knowledgestore.data.Stream;
7 import eu.fbk.knowledgestore.data.XPath;
8 import eu.fbk.knowledgestore.runtime.DataCorruptedException;
9 import eu.fbk.knowledgestore.vocabulary.KS;
10 import org.openrdf.model.URI;
11 import org.slf4j.Logger;
12 import org.slf4j.LoggerFactory;
13
14 import javax.annotation.Nullable;
15 import java.io.*;
16 import java.sql.*;
17 import java.util.*;
18
19
20
21
22
23
24
25
26
27 public class SolrDataStore implements DataStore {
28
29 static Logger logger = LoggerFactory.getLogger(SolrDataStore.class);
30 public HikariDataSource dataSource;
31
32 public SolrDataStore() {
33
34 }
35
36 public class SolrTransaction implements DataTransaction {
37
38 private Connection con;
39 boolean readOnly;
40
41 public SolrTransaction(boolean readOnly) throws SQLException {
42 this.readOnly = readOnly;
43
44
45 }
46
47 private void connect(String dbUser, String dbPass) throws SQLException {
48
49 }
50
51 @Override
52 public Stream<Record> lookup(URI type, Set<? extends URI> ids, @Nullable Set<? extends URI> properties) throws IOException, IllegalArgumentException, IllegalStateException {
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86 return Stream.create();
87 }
88
89 @Override
90 public Stream<Record> retrieve(URI type, @Nullable XPath condition, @Nullable Set<? extends URI> properties) throws IOException, IllegalArgumentException, IllegalStateException {
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117 return Stream.create();
118 }
119
120 @Override
121 public long count(URI type, @Nullable XPath condition) throws IOException, IllegalArgumentException, IllegalStateException {
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138 return 0;
139 }
140
141 @Override
142 public Stream<Record> match(Map<URI, XPath> conditions, Map<URI, Set<URI>> ids, Map<URI, Set<URI>> properties) throws IOException, IllegalStateException {
143 return null;
144 }
145
146 @Override
147 public void store(URI type, Record record) throws IOException, IllegalStateException {
148
149 System.out.println(type);
150 System.out.println(record);
151 }
152
153 @Override
154 public void delete(URI type, URI id) throws IOException, IllegalStateException {
155
156 }
157
158 @Override
159 public void end(boolean commit) throws DataCorruptedException, IOException, IllegalStateException {
160
161 }
162 }
163
164 @Override
165 public DataTransaction begin(boolean readOnly) throws DataCorruptedException, IOException, IllegalStateException {
166
167 SolrTransaction ret = null;
168 try {
169 ret = new SolrTransaction(readOnly);
170 } catch (Exception e) {
171 throw new IOException(e);
172 }
173
174 return ret;
175 }
176
177 @Override
178 public void init() throws IOException, IllegalStateException {
179 }
180
181 @Override
182 public void close() {
183 }
184 }