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: 31
100%
M: 0 C: 4
100%
M: 0 C: 3
100%
M: 0 C: 9
100%
M: 0 C: 1
100%

Coverage

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