Skip to content

Commit

Permalink
Make bdb implementations package private
Browse files Browse the repository at this point in the history
  • Loading branch information
Martijn Maas committed Feb 8, 2018
1 parent 854aef0 commit e9fd2c6
Show file tree
Hide file tree
Showing 13 changed files with 33 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import nl.knaw.huygens.timbuctoo.v5.berkeleydb.exceptions.BdbDbCreationException;
import nl.knaw.huygens.timbuctoo.v5.berkeleydb.isclean.IsCleanHandler;
import nl.knaw.huygens.timbuctoo.v5.dataset.StoreProvider;
import nl.knaw.huygens.timbuctoo.v5.datastores.implementations.bdb.BdbStoreProvider;
import nl.knaw.huygens.timbuctoo.v5.filehelper.FileHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
* A simple wrapper around serialized json so that we get the benefits of berkeley db for transactions
* without having to change the code too much.
*/
public class BdbBackedData implements DataStorage {
class BdbBackedData implements DataStorage {

private static final Logger LOG = getLogger(BdbBackedData.class);

private final BdbWrapper<String, String> bdbWrapper;
private String value;

public BdbBackedData(BdbWrapper<String, String> bdbWrapper)
BdbBackedData(BdbWrapper<String, String> bdbWrapper)
throws DataStoreCreationException {

this.bdbWrapper = bdbWrapper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
import static nl.knaw.huygens.timbuctoo.v5.util.RdfConstants.TIM_HAS_ROW;
import static org.apache.commons.lang3.StringEscapeUtils.escapeJava;

public class BdbRmlDataSourceStore implements RmlDataSourceStore {
class BdbRmlDataSourceStore implements RmlDataSourceStore {
private static final Logger LOG = LoggerFactory.getLogger(BdbRmlDataSourceStore.class);
protected final BdbWrapper<String, String> bdbWrapper;
private final BdbWrapper<String, String> bdbWrapper;
private final Map<String, Map<String, Property>> collectionProperties = new HashMap<>();
private ImportStatus importStatus;

public BdbRmlDataSourceStore(BdbWrapper<String, String> bdbWrapper, ImportStatus importStatus)
BdbRmlDataSourceStore(BdbWrapper<String, String> bdbWrapper, ImportStatus importStatus)
throws DataStoreCreationException {
this.bdbWrapper = bdbWrapper;
this.importStatus = importStatus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import static nl.knaw.huygens.timbuctoo.v5.util.RdfConstants.RDF_TYPE;
import static nl.knaw.huygens.timbuctoo.v5.util.RdfConstants.UNKNOWN;

public class BdbSchemaStore implements SchemaStore, OptimizedPatchListener {
class BdbSchemaStore implements SchemaStore, OptimizedPatchListener {
private static final Logger LOG = LoggerFactory.getLogger(BdbSchemaStore.class);
private static final Function<String, Type> TYPE_MAKER = Type::new;

Expand All @@ -48,7 +48,7 @@ public class BdbSchemaStore implements SchemaStore, OptimizedPatchListener {
private Map<String, Type> stableTypes = new HashMap<>();
private ImportStatus importStatus;

public BdbSchemaStore(DataStorage dataStore, ImportStatus importStatus) throws IOException {
BdbSchemaStore(DataStorage dataStore, ImportStatus importStatus) throws IOException {

this.dataStore = dataStore;
final String storedValue = this.dataStore.getValue();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package nl.knaw.huygens.timbuctoo.v5.berkeleydb;
package nl.knaw.huygens.timbuctoo.v5.datastores.implementations.bdb;

import com.sleepycat.bind.tuple.TupleBinding;
import nl.knaw.huygens.timbuctoo.v5.berkeleydb.BdbEnvironmentCreator;
import nl.knaw.huygens.timbuctoo.v5.berkeleydb.exceptions.BdbDbCreationException;
import nl.knaw.huygens.timbuctoo.v5.berkeleydb.isclean.IsCleanHandler;
import nl.knaw.huygens.timbuctoo.v5.berkeleydb.isclean.StringStringIsCleanHandler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
import static nl.knaw.huygens.timbuctoo.v5.berkeleydb.DatabaseGetter.Iterate.BACKWARDS;
import static nl.knaw.huygens.timbuctoo.v5.berkeleydb.DatabaseGetter.Iterate.FORWARDS;

public class BdbTripleStore implements QuadStore {
class BdbTripleStore implements QuadStore {

private static final Logger LOG = LoggerFactory.getLogger(BdbTripleStore.class);
private final BdbWrapper<String, String> bdbWrapper;

public BdbTripleStore(BdbWrapper<String, String> rdfData)
BdbTripleStore(BdbWrapper<String, String> rdfData)
throws DataStoreCreationException {
this.bdbWrapper = rdfData;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
import static nl.knaw.huygens.timbuctoo.v5.datastores.quadstore.dto.Direction.IN;
import static nl.knaw.huygens.timbuctoo.v5.datastores.quadstore.dto.Direction.OUT;

public class BdbTruePatchStore implements nl.knaw.huygens.timbuctoo.v5.datastores.truepatch.TruePatchStore {
class BdbTruePatchStore implements nl.knaw.huygens.timbuctoo.v5.datastores.truepatch.TruePatchStore {

private static final Logger LOG = LoggerFactory.getLogger(BdbTruePatchStore.class);
private final BdbWrapper<String, String> bdbWrapper;

public BdbTruePatchStore(BdbWrapper<String, String> bdbWrapper)
BdbTruePatchStore(BdbWrapper<String, String> bdbWrapper)
throws DataStoreCreationException {
this.bdbWrapper = bdbWrapper;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@
import java.util.Map;
import java.util.Optional;

public class BdbTypeNameStore implements TypeNameStore {
class BdbTypeNameStore implements TypeNameStore {

private static ObjectMapper objectMapper = new ObjectMapper()
.registerModule(new Jdk8Module())
.registerModule(new GuavaModule())
.registerModule(new TimbuctooCustomSerializers())
.enable(SerializationFeature.INDENT_OUTPUT);

protected final PrefixMapping prefixMapping;
private final PrefixMapping prefixMapping;
protected final TypeNames data;
private final DataStorage dataStore;
private final String dataStoreRdfPrefix;

public BdbTypeNameStore(DataStorage dataStore, String dataStoreRdfPrefix) throws IOException {
BdbTypeNameStore(DataStorage dataStore, String dataStoreRdfPrefix) throws IOException {
this.dataStoreRdfPrefix = dataStoreRdfPrefix;
prefixMapping = new PrefixMappingImpl();
final String storedValue = dataStore.getValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@

import java.util.stream.Stream;

public class BdbUpdatedPerPatchStore implements UpdatedPerPatchStore {
class BdbUpdatedPerPatchStore implements UpdatedPerPatchStore {

private static final Logger LOG = LoggerFactory.getLogger(BdbUpdatedPerPatchStore.class);
private final BdbWrapper<Integer, String> bdbWrapper;

public BdbUpdatedPerPatchStore(BdbWrapper<Integer, String> bdbWrapper)
BdbUpdatedPerPatchStore(BdbWrapper<Integer, String> bdbWrapper)
throws DataStoreCreationException {

this.bdbWrapper = bdbWrapper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@

import java.util.stream.Stream;

public class BdbVersionStore implements VersionStore {
class BdbVersionStore implements VersionStore {

private static final Logger LOG = LoggerFactory.getLogger(BdbVersionStore.class);
private final BdbWrapper<String, Integer> bdbWrapper;

public BdbVersionStore(BdbWrapper<String, Integer> bdbWrapper)
BdbVersionStore(BdbWrapper<String, Integer> bdbWrapper)
throws DataStoreCreationException {

this.bdbWrapper = bdbWrapper;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package nl.knaw.huygens.timbuctoo.v5.graphql.datafetchers.berkeleydb.stores;
package nl.knaw.huygens.timbuctoo.v5.datastores.implementations.bdb;

import com.sleepycat.bind.tuple.TupleBinding;
import nl.knaw.huygens.timbuctoo.v5.berkeleydb.isclean.StringStringIsCleanHandler;
import nl.knaw.huygens.timbuctoo.v5.datastores.implementations.bdb.BdbTripleStore;
import nl.knaw.huygens.timbuctoo.v5.dataset.StoreProvider;
import nl.knaw.huygens.timbuctoo.v5.datastores.quadstore.dto.CursorQuad;
import nl.knaw.huygens.timbuctoo.v5.datastores.quadstore.dto.Direction;
import nl.knaw.huygens.timbuctoo.v5.dropwizard.BdbNonPersistentEnvironmentCreator;
Expand All @@ -25,9 +25,9 @@
public class BdbTripleStoreTest {


public static final String EX = "http://example.org/";
protected BdbNonPersistentEnvironmentCreator databaseCreator;
protected BdbTripleStore tripleStore;
private static final String EX = "http://example.org/";
private BdbNonPersistentEnvironmentCreator databaseCreator;
private BdbTripleStore tripleStore;

@Before
public void makeCollection() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package nl.knaw.huygens.timbuctoo.v5.datastores.storeupdater;

import com.sleepycat.bind.tuple.TupleBinding;
import nl.knaw.huygens.timbuctoo.v5.berkeleydb.isclean.StringStringIsCleanHandler;
import nl.knaw.huygens.timbuctoo.v5.datastores.implementations.bdb.BdbTripleStore;
import nl.knaw.huygens.timbuctoo.v5.datastores.implementations.bdb.BdbTruePatchStore;
import nl.knaw.huygens.timbuctoo.v5.dataset.StoreProvider;
import nl.knaw.huygens.timbuctoo.v5.datastores.quadstore.QuadStore;
import nl.knaw.huygens.timbuctoo.v5.datastores.quadstore.dto.CursorQuad;
import nl.knaw.huygens.timbuctoo.v5.datastores.storeupdater.ChangeFetcherImpl;
import nl.knaw.huygens.timbuctoo.v5.datastores.truepatch.TruePatchStore;
import nl.knaw.huygens.timbuctoo.v5.dropwizard.BdbNonPersistentEnvironmentCreator;
import org.junit.Test;

Expand All @@ -20,24 +18,9 @@ public class ChangeFetcherImplTest {
@Test
public void showsAdditions() throws Exception {
final BdbNonPersistentEnvironmentCreator databaseCreator = new BdbNonPersistentEnvironmentCreator();
final BdbTripleStore bdbTripleStore = new BdbTripleStore(databaseCreator.getDatabase(
"a",
"b",
"rdfData",
true,
TupleBinding.getPrimitiveBinding(String.class),
TupleBinding.getPrimitiveBinding(String.class),
new StringStringIsCleanHandler()
));
final BdbTruePatchStore truePatchStore = new BdbTruePatchStore(databaseCreator.getDatabase(
"a",
"b",
"truePatch",
true,
TupleBinding.getPrimitiveBinding(String.class),
TupleBinding.getPrimitiveBinding(String.class),
new StringStringIsCleanHandler()
));
StoreProvider storeProvider = databaseCreator.createStoreProvider("a", "b");
final QuadStore bdbTripleStore = storeProvider.createTripleStore();
final TruePatchStore truePatchStore = storeProvider.createTruePatchStore();

bdbTripleStore.putQuad("subj", "pred", OUT, "obj", null, null);
truePatchStore.put("subj", 0, "pred", OUT, true, "obj", null, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import com.sleepycat.je.Environment;
import com.sleepycat.je.EnvironmentConfig;
import nl.knaw.huygens.timbuctoo.v5.berkeleydb.BdbEnvironmentCreator;
import nl.knaw.huygens.timbuctoo.v5.berkeleydb.BdbStoreProvider;
import nl.knaw.huygens.timbuctoo.v5.datastores.implementations.bdb.BdbStoreProvider;
import nl.knaw.huygens.timbuctoo.v5.berkeleydb.BdbWrapper;
import nl.knaw.huygens.timbuctoo.v5.berkeleydb.exceptions.BdbDbCreationException;
import nl.knaw.huygens.timbuctoo.v5.berkeleydb.isclean.IsCleanHandler;
Expand Down

0 comments on commit e9fd2c6

Please sign in to comment.