diff --git a/hdt-api/src/main/java/org/rdfhdt/hdt/util/Profiler.java b/hdt-api/src/main/java/org/rdfhdt/hdt/util/Profiler.java index d32fa540..4c4b2d8a 100644 --- a/hdt-api/src/main/java/org/rdfhdt/hdt/util/Profiler.java +++ b/hdt-api/src/main/java/org/rdfhdt/hdt/util/Profiler.java @@ -196,7 +196,7 @@ public Profiler(String name, HDTOptions spec, boolean async) { this.name = Objects.requireNonNull(name, "name can't be null!"); if (spec != null) { String b = spec.get(async ? HDTOptionsKeys.PROFILER_ASYNC_KEY : HDTOptionsKeys.PROFILER_KEY); - disabled = b == null || b.length() == 0 || !(b.charAt(0) == '!' || "true".equalsIgnoreCase(b)); + disabled = b == null || b.length() == 0 || !("true".equalsIgnoreCase(b)); String profilerOutputLocation = spec.get(async ? HDTOptionsKeys.PROFILER_ASYNC_OUTPUT_KEY : HDTOptionsKeys.PROFILER_OUTPUT_KEY); if (profilerOutputLocation != null && !profilerOutputLocation.isEmpty()) { outputPath = Path.of(profilerOutputLocation); diff --git a/hdt-java-core/src/main/java/org/rdfhdt/hdt/hdt/impl/HDTImpl.java b/hdt-java-core/src/main/java/org/rdfhdt/hdt/hdt/impl/HDTImpl.java index f8ac2e37..f1c6d1a7 100644 --- a/hdt-java-core/src/main/java/org/rdfhdt/hdt/hdt/impl/HDTImpl.java +++ b/hdt-java-core/src/main/java/org/rdfhdt/hdt/hdt/impl/HDTImpl.java @@ -187,11 +187,11 @@ public void mapFromHDT(File f, long offset, ProgressListener listener) throws IO f = new File(hdtFileName); if(!f.exists()) { - System.err.println("We cannot map a gzipped HDT, decompressing into "+hdtFileName+" first."); + log.warn("We cannot map a gzipped HDT, decompressing into {} first.", hdtFileName); IOUtil.decompressGzip(old, f); - System.err.println("Gzipped HDT successfully decompressed. You might want to delete "+old.getAbsolutePath()+" to save disk space."); + log.warn("Gzipped HDT successfully decompressed. You might want to delete {} to save disk space.", old.getAbsolutePath()); } else { - System.err.println("We cannot map a gzipped HDT, using "+hdtFileName+" instead."); + log.warn("We cannot map a gzipped HDT, using {} instead.", hdtFileName); } } @@ -345,20 +345,16 @@ public void loadFromModifiableHDT(TempHDT modHdt, ProgressListener listener) { // Convert triples to final format if(triples.getClass().equals(modifiableTriples.getClass())) { - triples = modifiableTriples; + triples = modifiableTriples; } else { - //StopWatch tripleConvTime = new StopWatch(); - triples.load(modifiableTriples, listener); - //System.out.println("Triples conversion time: "+tripleConvTime.stopAndShow()); + triples.load(modifiableTriples, listener); } // Convert dictionary to final format if(dictionary.getClass().equals(modifiableDictionary.getClass())) { - dictionary = (DictionaryPrivate)modifiableDictionary; + dictionary = (DictionaryPrivate)modifiableDictionary; } else { - //StopWatch dictConvTime = new StopWatch(); - dictionary.load(modifiableDictionary, listener); - //System.out.println("Dictionary conversion time: "+dictConvTime.stopAndShow()); + dictionary.load(modifiableDictionary, listener); } this.baseUri = modHdt.getBaseURI(); @@ -396,8 +392,7 @@ public void loadOrCreateIndex(ProgressListener listener, HDTOptions spec) throws } } catch (Exception e) { if (!(e instanceof FileNotFoundException)) { - System.out.println("Error reading .hdt.index, generating a new one. The error was: "+e.getMessage()); - e.printStackTrace(); + log.error("Error reading .hdt.index, generating a new one.", e); } // GENERATE @@ -411,11 +406,9 @@ public void loadOrCreateIndex(ProgressListener listener, HDTOptions spec) throws out = new BufferedOutputStream(new FileOutputStream(versionName)); ci.clear(); triples.saveIndex(out, ci, listener); - out.close(); - System.out.println("Index generated and saved in "+st.stopAndShow()); + log.info("Index generated and saved in {}", st.stopAndShow()); } catch (IOException e2) { - System.err.println("Error writing index file."); - e2.printStackTrace(); + log.error("Error writing index file.", e2); } finally { IOUtil.closeQuietly(out); } diff --git a/hdt-java-core/src/main/java/org/rdfhdt/hdt/rdf/parsers/RDFParserSimple.java b/hdt-java-core/src/main/java/org/rdfhdt/hdt/rdf/parsers/RDFParserSimple.java index 54919cdf..2f264455 100644 --- a/hdt-java-core/src/main/java/org/rdfhdt/hdt/rdf/parsers/RDFParserSimple.java +++ b/hdt-java-core/src/main/java/org/rdfhdt/hdt/rdf/parsers/RDFParserSimple.java @@ -72,10 +72,7 @@ public void doParse(InputStream input, String baseUri, RDFNotation notation, boo try { doParse(reader, baseUri, notation, keepBNode, callback); } finally { - try { - reader.close(); - } catch (IOException e) { - } + IOUtil.closeQuietly(reader); } } @@ -110,7 +107,7 @@ private void doParse(BufferedReader reader, String baseUri, RDFNotation notation //System.out.println(triple); callback.processTriple(triple, 0); } else { - System.err.println("Warning: Could not parse triple at line "+numLine+", ignored and not processed.\n"+line); + log.warn("Could not parse triple at line {}, ignored and not processed.\n{}", numLine, line); } } numLine++; diff --git a/hdt-java-core/src/main/java/org/rdfhdt/hdt/triples/impl/BitmapTriples.java b/hdt-java-core/src/main/java/org/rdfhdt/hdt/triples/impl/BitmapTriples.java index fadef165..c2c5baa3 100644 --- a/hdt-java-core/src/main/java/org/rdfhdt/hdt/triples/impl/BitmapTriples.java +++ b/hdt-java-core/src/main/java/org/rdfhdt/hdt/triples/impl/BitmapTriples.java @@ -850,8 +850,8 @@ class Pair { } ArrayList> list=new ArrayList<>(); - - System.out.println("Generating HDT Index for ?PO, and ??O queries."); + + log.info("Generating HDT Index for ?PO, and ??O queries."); // Generate lists long total=seqZ.getNumberOfElements(); for(long i=0;i