This is an automated email from the ASF dual-hosted git repository. andy pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/jena.git
commit a3f86a13044528dce298e0a44e0ab806cab0ef73 Author: Andy Seaborne <a...@apache.org> AuthorDate: Sat Mar 9 13:19:31 2024 +0000 Code clearup --- jena-cmds/src/main/java/tdb2/tdbloader.java | 18 ++++++++++-------- .../apache/jena/tdb2/store/DatasetGraphSwitchable.java | 4 ++-- .../apache/jena/tdb2/store/PrefixMapSwitchable.java | 11 ++++------- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/jena-cmds/src/main/java/tdb2/tdbloader.java b/jena-cmds/src/main/java/tdb2/tdbloader.java index 330a02420f..0a41548577 100644 --- a/jena-cmds/src/main/java/tdb2/tdbloader.java +++ b/jena-cmds/src/main/java/tdb2/tdbloader.java @@ -18,6 +18,8 @@ package tdb2; +import static org.apache.jena.atlas.lib.ListUtils.toList; + import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -25,7 +27,6 @@ import java.util.List; import java.util.Objects; import org.apache.jena.atlas.lib.InternalErrorException; -import org.apache.jena.atlas.lib.ListUtils; import org.apache.jena.atlas.lib.Timer; import org.apache.jena.cmd.ArgDecl; import org.apache.jena.cmd.CmdException; @@ -159,13 +160,14 @@ public class tdbloader extends CmdTDBGraph { // Check files exists before starting. private void checkFiles(List<String> urls) { - List<String> problemFiles = ListUtils.toList(urls.stream().filter(u -> FileUtils.isFile(u)) // Local - // files. - .map(Paths::get) - .filter(p -> !Files.exists(p) || !Files.isRegularFile(p /* follow - * links */) - || !Files.isReadable(p)) - .map(Path::toString)); + List<String> problemFiles = toList(urls.stream() + // Local files. + .filter(u -> FileUtils.isFile(u)) + .map(Paths::get) + .filter(p -> !Files.exists(p) || + !Files.isRegularFile(p /* this follows links */) || + !Files.isReadable(p)) + .map(Path::toString)); if ( !problemFiles.isEmpty() ) { if ( problemFiles.size() == 1 ) throw new CmdException("Can't read file : " + problemFiles.get(0)); diff --git a/jena-tdb2/src/main/java/org/apache/jena/tdb2/store/DatasetGraphSwitchable.java b/jena-tdb2/src/main/java/org/apache/jena/tdb2/store/DatasetGraphSwitchable.java index 2496e0b23e..b677923350 100644 --- a/jena-tdb2/src/main/java/org/apache/jena/tdb2/store/DatasetGraphSwitchable.java +++ b/jena-tdb2/src/main/java/org/apache/jena/tdb2/store/DatasetGraphSwitchable.java @@ -41,7 +41,7 @@ public class DatasetGraphSwitchable extends DatasetGraphTxnCtl private final PrefixMapSwitchable prefixes; public DatasetGraphSwitchable(Path base, Location location, DatasetGraph dsg) { - // Don't use the slot in datasetGraphWrapper - use the AtomicReference + // Don't use the slot in DatasetGraphWrapper - use the AtomicReference super(null, dsg.getContext()); dsgx.set(dsg); this.basePath = base; @@ -50,7 +50,7 @@ public class DatasetGraphSwitchable extends DatasetGraphTxnCtl } /** - * The dataset to use for redirection - can be overridden. + * The dataset to use for redirection - this can be overridden. * It is also guaranteed that this is called only once per * delegated call. Changes to the wrapped object can be * made based on that contract. diff --git a/jena-tdb2/src/main/java/org/apache/jena/tdb2/store/PrefixMapSwitchable.java b/jena-tdb2/src/main/java/org/apache/jena/tdb2/store/PrefixMapSwitchable.java index 0f1a754837..707598da11 100644 --- a/jena-tdb2/src/main/java/org/apache/jena/tdb2/store/PrefixMapSwitchable.java +++ b/jena-tdb2/src/main/java/org/apache/jena/tdb2/store/PrefixMapSwitchable.java @@ -22,17 +22,14 @@ import org.apache.jena.riot.system.PrefixMap; import org.apache.jena.riot.system.PrefixMapWrapper; /** - * {@link PrefixMap} that goes to the current DatasetGraphTDB prefixes. + * A {@link PrefixMap} that indirects to the prefixes via the current storage + * setting of {@link DatasetGraphSwitchable}. */ -public class PrefixMapSwitchable extends PrefixMapWrapper { - // PrefixMapProxy not needed. - // TDB2 datasets already have switchability built-in. - +class PrefixMapSwitchable extends PrefixMapWrapper { private final DatasetGraphSwitchable dsgx; - protected DatasetGraphSwitchable getx() { return dsgx; } protected PrefixMapSwitchable(DatasetGraphSwitchable dsg) { - // We override get() so don't set the wrapped object + // We override PrefixMapWrapper getR() and getW() so don't set the wrapped object. super(null); this.dsgx = dsg; }