Skip to content

Commit

Permalink
Compact db with usage of dataset configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
frankyhollywood committed Jul 9, 2024
1 parent 402e3da commit 1edafd3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

import lombok.extern.log4j.*;
import org.apache.jena.datatypes.TypeMapper;
import org.apache.jena.dboe.base.file.Location;
import org.apache.jena.query.Dataset;
import org.apache.jena.query.DatasetFactory;
import org.apache.jena.tdb2.TDB2Factory;

import io.fairspace.saturn.config.*;
import io.fairspace.saturn.rdf.transactions.*;
Expand All @@ -15,6 +15,8 @@
import static io.fairspace.saturn.rdf.MarkdownDataType.MARKDOWN_DATA_TYPE;
import static io.fairspace.saturn.rdf.transactions.Restore.restore;

import static org.apache.jena.tdb2.sys.DatabaseConnection.connectCreate;

@Log4j2
public class SaturnDatasetFactory {
/**
Expand All @@ -30,8 +32,8 @@ public static Dataset connect(Config.Jena config, ViewStoreClientFactory viewSto
var restoreNeeded = isRestoreNeeded(config.datasetPath);

// Create a TDB2 dataset graph
Dataset ds = TDB2Factory.connectDataset(config.datasetPath.getAbsolutePath());
var dsg = ds.asDatasetGraph();
var dsg = connectCreate(Location.create(config.datasetPath.getAbsolutePath()), config.storeParams, null)
.getDatasetGraph();

var txnLog = new LocalTransactionLog(config.transactionLogPath, new SparqlTransactionCodec());

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
package io.fairspace.saturn.services.maintenance;

import java.sql.SQLException;
import java.util.Date;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

import lombok.NonNull;
import lombok.extern.log4j.Log4j2;
import org.apache.jena.query.Dataset;
import org.apache.jena.sparql.core.DatasetGraph;
import org.apache.jena.tdb2.DatabaseMgr;
import org.apache.jena.tdb2.store.DatasetGraphSwitchable;

import io.fairspace.saturn.config.ConfigLoader;
import io.fairspace.saturn.rdf.transactions.TxnIndexDatasetGraph;
import io.fairspace.saturn.rdf.transactions.TxnLogDatasetGraph;
Expand All @@ -10,26 +23,14 @@
import io.fairspace.saturn.services.views.ViewService;
import io.fairspace.saturn.services.views.ViewStoreClientFactory;
import io.fairspace.saturn.services.views.ViewUpdater;
import lombok.NonNull;
import lombok.extern.log4j.Log4j2;
import org.apache.jena.query.Dataset;
import org.apache.jena.sparql.core.DatasetGraph;
import org.apache.jena.tdb2.DatabaseMgr;
import org.apache.jena.tdb2.store.DatasetGraphSwitchable;

import java.sql.SQLException;
import java.util.Date;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

@Log4j2
public class MaintenanceService {
public static final String SERVICE_NOT_AVAILABLE = "Service not available";
public static final String REINDEXING_IS_ALREADY_IN_PROGRESS = "Reindexing is already in progress.";

private final ThreadPoolExecutor threadpool = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<>());
private final ThreadPoolExecutor threadpool =
new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>());

private final UserService userService;
private final Dataset dataset;
Expand Down

0 comments on commit 1edafd3

Please sign in to comment.