Skip to content

Package: MemoryStorage

MemoryStorage

nameinstructionbranchcomplexitylinemethod
MemoryStorage(DriverConfiguration)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
setDataset(Dataset)
M: 0 C: 32
100%
M: 0 C: 4
100%
M: 0 C: 3
100%
M: 0 C: 9
100%
M: 0 C: 1
100%

Coverage

1: /**
2: * Copyright (C) 2020 Czech Technical University in Prague
3: * <p>
4: * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
5: * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
6: * version.
7: * <p>
8: * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
9: * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
10: * details. You should have received a copy of the GNU General Public License along with this program. If not, see
11: * <http://www.gnu.org/licenses/>.
12: */
13: package cz.cvut.kbss.ontodriver.jena.connector;
14:
15: import cz.cvut.kbss.ontodriver.config.DriverConfiguration;
16: import org.apache.jena.query.Dataset;
17: import org.apache.jena.query.DatasetFactory;
18:
19: import java.util.Objects;
20:
21: /**
22: * Storage accessor using an in-memory dataset.
23: */
24: class MemoryStorage extends LocalStorage {
25:
26: MemoryStorage(DriverConfiguration configuration) {
27: super(configuration);
28: this.dataset = DatasetFactory.createTxnMem();
29: }
30:
31: @Override
32: public void setDataset(Dataset dataset) {
33: Objects.requireNonNull(dataset);
34:• if (!dataset.supportsTransactions()) {
35: throw new IllegalArgumentException("The provided dataset does not support transactions.");
36: }
37: synchronized (this.dataset) {
38:• if (this.dataset.isInTransaction()) {
39: throw new IllegalStateException("Cannot replace dataset when it is in transaction.");
40: }
41: this.dataset = dataset;
42: }
43: }
44: }