Skip to content

Commit 2e075d5

Browse files
committed
GH-5148 cleanup naming and docs
1 parent 0076003 commit 2e075d5

12 files changed

Lines changed: 57 additions & 43 deletions

File tree

core/sail/nativerdf/src/main/java/org/eclipse/rdf4j/sail/nativerdf/NativeStatementIterator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*******************************************************************************/
1111
package org.eclipse.rdf4j.sail.nativerdf;
1212

13-
import static org.eclipse.rdf4j.sail.nativerdf.NativeStore.SOFT_FAIL_ON_CORRUPT_DATA;
13+
import static org.eclipse.rdf4j.sail.nativerdf.NativeStore.SOFT_FAIL_ON_CORRUPT_DATA_AND_REPAIR_INDEXES;
1414

1515
import java.io.IOException;
1616

@@ -89,7 +89,7 @@ public Statement getNextElement() throws SailException {
8989
if (contextID != 0) {
9090
context = valueStore.getResource(contextID);
9191
}
92-
if (SOFT_FAIL_ON_CORRUPT_DATA) {
92+
if (SOFT_FAIL_ON_CORRUPT_DATA_AND_REPAIR_INDEXES) {
9393
if (subj == null) {
9494
subj = new CorruptIRIOrBNode(valueStore.getRevision(), subjID, null);
9595
}

core/sail/nativerdf/src/main/java/org/eclipse/rdf4j/sail/nativerdf/NativeStore.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,13 @@ public class NativeStore extends AbstractNotifyingSail implements FederatedServi
6666
/**
6767
* Do not throw an exception when corrupt data is detected. Instead, try to return as much data as possible.
6868
*
69-
* Variable can be set through the system property org.eclipse.rdf4j.sail.nativerdf.softFailOnCorruptData.
69+
* Variable can be set through the system property
70+
* org.eclipse.rdf4j.sail.nativerdf.softFailOnCorruptDataAndRepairIndexes.
7071
*/
7172
@InternalUseOnly
72-
public static boolean SOFT_FAIL_ON_CORRUPT_DATA = "true"
73-
.equalsIgnoreCase(System.getProperty("org.eclipse.rdf4j.sail.nativerdf.softFailOnCorruptData"));;
73+
public static boolean SOFT_FAIL_ON_CORRUPT_DATA_AND_REPAIR_INDEXES = "true"
74+
.equalsIgnoreCase(
75+
System.getProperty("org.eclipse.rdf4j.sail.nativerdf.softFailOnCorruptDataAndRepairIndexes"));;
7476

7577
private static final Cleaner REMOVE_STORES_USED_FOR_MEMORY_OVERFLOW = Cleaner.create();
7678

core/sail/nativerdf/src/main/java/org/eclipse/rdf4j/sail/nativerdf/TripleStore.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -295,12 +295,12 @@ private void initIndexes(Set<String> indexSpecs) throws IOException {
295295
try {
296296
indexes.add(new TripleIndex(fieldSeq, false));
297297
} catch (Exception e) {
298-
if (NativeStore.SOFT_FAIL_ON_CORRUPT_DATA) {
298+
if (NativeStore.SOFT_FAIL_ON_CORRUPT_DATA_AND_REPAIR_INDEXES) {
299299
invalidIndexes.add(fieldSeq);
300300
logger.warn("Ignoring index because it failed to initialize index '{}'", fieldSeq, e);
301301
} else {
302302
logger.error(
303-
"Failed to initialize index '{}', consider setting org.eclipse.rdf4j.sail.nativerdf.softFailOnCorruptData to true.",
303+
"Failed to initialize index '{}', consider setting org.eclipse.rdf4j.sail.nativerdf.softFailOnCorruptDataAndRepairIndexes to true.",
304304
fieldSeq, e);
305305
throw e;
306306
}
@@ -309,7 +309,7 @@ private void initIndexes(Set<String> indexSpecs) throws IOException {
309309

310310
}
311311

312-
if (NativeStore.SOFT_FAIL_ON_CORRUPT_DATA) {
312+
if (NativeStore.SOFT_FAIL_ON_CORRUPT_DATA_AND_REPAIR_INDEXES) {
313313
indexSpecs.removeAll(invalidIndexes);
314314
}
315315

@@ -319,12 +319,12 @@ private void initIndexes(Set<String> indexSpecs) throws IOException {
319319
checkIfIndexesAreEmptyOrNot(nonEmptyIndexes, emptyIndexes);
320320

321321
if (!emptyIndexes.isEmpty() && !nonEmptyIndexes.isEmpty()) {
322-
if (NativeStore.SOFT_FAIL_ON_CORRUPT_DATA) {
322+
if (NativeStore.SOFT_FAIL_ON_CORRUPT_DATA_AND_REPAIR_INDEXES) {
323323
indexes.removeAll(emptyIndexes);
324324
} else {
325325
for (TripleIndex index : emptyIndexes) {
326326
throw new IOException("Index '" + new String(index.getFieldSeq())
327-
+ "' is unexpectedly empty while other indexes are not. Consider setting the system property org.eclipse.rdf4j.sail.nativerdf.softFailOnCorruptData to true. Index file: "
327+
+ "' is unexpectedly empty while other indexes are not. Consider setting the system property org.eclipse.rdf4j.sail.nativerdf.softFailOnCorruptDataAndRepairIndexes to true. Index file: "
328328
+ index.getBTree().getFile().getAbsolutePath());
329329
}
330330
}

core/sail/nativerdf/src/main/java/org/eclipse/rdf4j/sail/nativerdf/ValueStore.java

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*******************************************************************************/
1111
package org.eclipse.rdf4j.sail.nativerdf;
1212

13-
import static org.eclipse.rdf4j.sail.nativerdf.NativeStore.SOFT_FAIL_ON_CORRUPT_DATA;
13+
import static org.eclipse.rdf4j.sail.nativerdf.NativeStore.SOFT_FAIL_ON_CORRUPT_DATA_AND_REPAIR_INDEXES;
1414

1515
import java.io.File;
1616
import java.io.IOException;
@@ -223,11 +223,11 @@ public <T extends NativeValue & Resource> T getResource(int id) throws IOExcepti
223223
NativeValue resultValue = getValue(id);
224224

225225
if (resultValue != null && !(resultValue instanceof Resource)) {
226-
if (SOFT_FAIL_ON_CORRUPT_DATA && resultValue instanceof CorruptValue) {
226+
if (SOFT_FAIL_ON_CORRUPT_DATA_AND_REPAIR_INDEXES && resultValue instanceof CorruptValue) {
227227
return (T) new CorruptIRIOrBNode(revision, id, ((CorruptValue) resultValue).getData());
228228
}
229229
logger.warn(
230-
"Possible corrupt data consider setting the system property org.eclipse.rdf4j.sail.nativerdf.softFailOnCorruptData to true");
230+
"Possible corrupt data consider setting the system property org.eclipse.rdf4j.sail.nativerdf.softFailOnCorruptDataAndRepairIndexes to true");
231231
}
232232

233233
return (T) resultValue;
@@ -245,14 +245,14 @@ public <T extends NativeValue & IRI> T getIRI(int id) throws IOException {
245245
NativeValue resultValue = getValue(id);
246246

247247
if (resultValue != null && !(resultValue instanceof IRI)) {
248-
if (SOFT_FAIL_ON_CORRUPT_DATA && resultValue instanceof CorruptValue) {
248+
if (SOFT_FAIL_ON_CORRUPT_DATA_AND_REPAIR_INDEXES && resultValue instanceof CorruptValue) {
249249
if (resultValue instanceof CorruptIRI) {
250250
return (T) resultValue;
251251
}
252252
return (T) new CorruptIRI(revision, id, null, ((CorruptValue) resultValue).getData());
253253
}
254254
logger.warn(
255-
"Possible corrupt data consider setting the system property org.eclipse.rdf4j.sail.nativerdf.softFailOnCorruptData to true");
255+
"Possible corrupt data consider setting the system property org.eclipse.rdf4j.sail.nativerdf.softFailOnCorruptDataAndRepairIndexes to true");
256256
}
257257

258258
return (T) resultValue;
@@ -586,12 +586,12 @@ private boolean isNamespaceData(byte[] data) {
586586

587587
private NativeValue data2value(int id, byte[] data) throws IOException {
588588
if (data.length == 0) {
589-
if (SOFT_FAIL_ON_CORRUPT_DATA) {
589+
if (SOFT_FAIL_ON_CORRUPT_DATA_AND_REPAIR_INDEXES) {
590590
logger.error("Soft fail on corrupt data: Empty data array for value with id {}", id);
591591
return new CorruptUnknownValue(revision, id, data);
592592
}
593593
throw new SailException("Empty data array for value with id " + id
594-
+ " consider setting the system property org.eclipse.rdf4j.sail.nativerdf.softFailOnCorruptData to true");
594+
+ " consider setting the system property org.eclipse.rdf4j.sail.nativerdf.softFailOnCorruptDataAndRepairIndexes to true");
595595
}
596596
switch (data[0]) {
597597
case URI_VALUE:
@@ -601,12 +601,12 @@ private NativeValue data2value(int id, byte[] data) throws IOException {
601601
case LITERAL_VALUE:
602602
return data2literal(id, data);
603603
default:
604-
if (SOFT_FAIL_ON_CORRUPT_DATA) {
604+
if (SOFT_FAIL_ON_CORRUPT_DATA_AND_REPAIR_INDEXES) {
605605
logger.error("Soft fail on corrupt data: Invalid type {} for value with id {}", data[0], id);
606606
return new CorruptUnknownValue(revision, id, data);
607607
}
608608
throw new SailException("Invalid type " + data[0] + " for value with id " + id
609-
+ " consider setting the system property org.eclipse.rdf4j.sail.nativerdf.softFailOnCorruptData to true");
609+
+ " consider setting the system property org.eclipse.rdf4j.sail.nativerdf.softFailOnCorruptDataAndRepairIndexes to true");
610610
}
611611
}
612612

@@ -621,11 +621,12 @@ private <T extends IRI & NativeValue> T data2uri(int id, byte[] data) throws IOE
621621

622622
return (T) new NativeIRI(revision, namespace, localName, id);
623623
} catch (Throwable e) {
624-
if (SOFT_FAIL_ON_CORRUPT_DATA && (e instanceof Exception || e instanceof AssertionError)) {
624+
if (SOFT_FAIL_ON_CORRUPT_DATA_AND_REPAIR_INDEXES
625+
&& (e instanceof Exception || e instanceof AssertionError)) {
625626
return (T) new CorruptIRI(revision, id, namespace, data);
626627
}
627628
logger.error(
628-
"Possible corrupt data consider setting the system property org.eclipse.rdf4j.sail.nativerdf.softFailOnCorruptData to true");
629+
"Possible corrupt data consider setting the system property org.eclipse.rdf4j.sail.nativerdf.softFailOnCorruptDataAndRepairIndexes to true");
629630
throw e;
630631
}
631632

@@ -663,7 +664,8 @@ private <T extends NativeValue & Literal> T data2literal(int id, byte[] data) th
663664
return (T) new NativeLiteral(revision, label, CoreDatatype.XSD.STRING, id);
664665
}
665666
} catch (Throwable e) {
666-
if (SOFT_FAIL_ON_CORRUPT_DATA && (e instanceof Exception || e instanceof AssertionError)) {
667+
if (SOFT_FAIL_ON_CORRUPT_DATA_AND_REPAIR_INDEXES
668+
&& (e instanceof Exception || e instanceof AssertionError)) {
667669
return (T) new CorruptLiteral(revision, id, data);
668670
}
669671
throw e;

core/sail/nativerdf/src/main/java/org/eclipse/rdf4j/sail/nativerdf/datastore/DataFile.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*******************************************************************************/
1111
package org.eclipse.rdf4j.sail.nativerdf.datastore;
1212

13-
import static org.eclipse.rdf4j.sail.nativerdf.NativeStore.SOFT_FAIL_ON_CORRUPT_DATA;
13+
import static org.eclipse.rdf4j.sail.nativerdf.NativeStore.SOFT_FAIL_ON_CORRUPT_DATA_AND_REPAIR_INDEXES;
1414

1515
import java.io.Closeable;
1616
import java.io.File;
@@ -205,7 +205,7 @@ public byte[] getData(long offset) throws IOException {
205205

206206
// If the data length is larger than 750MB, we are likely reading the wrong data. Probably data corruption.
207207
if (dataLength > 128 * 1024 * 1024) {
208-
if (SOFT_FAIL_ON_CORRUPT_DATA) {
208+
if (SOFT_FAIL_ON_CORRUPT_DATA_AND_REPAIR_INDEXES) {
209209
logger.error(
210210
"Data length is {}MB which is larger than 750MB. This is likely data corruption. Truncating length to 32 MB.",
211211
dataLength / ((1024 * 1024)));
@@ -244,7 +244,7 @@ public byte[] getData(long offset) throws IOException {
244244
} catch (OutOfMemoryError e) {
245245
if (dataLength > 128 * 1024 * 1024) {
246246
logger.error(
247-
"Trying to read large amounts of data may be a sign of data corruption. Consider setting the system property org.eclipse.rdf4j.sail.nativerdf.softFailOnCorruptData to true");
247+
"Trying to read large amounts of data may be a sign of data corruption. Consider setting the system property org.eclipse.rdf4j.sail.nativerdf.softFailOnCorruptDataAndRepairIndexes to true");
248248
}
249249
throw e;
250250
}

core/sail/nativerdf/src/main/java/org/eclipse/rdf4j/sail/nativerdf/model/CorruptIRI.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@
1515

1616
import org.apache.commons.codec.binary.Hex;
1717
import org.eclipse.rdf4j.model.IRI;
18+
import org.eclipse.rdf4j.sail.nativerdf.NativeStore;
1819
import org.eclipse.rdf4j.sail.nativerdf.ValueStoreRevision;
1920

2021
import com.google.common.net.UrlEscapers;
2122

2223
/**
23-
* CorruptIRI is used when a NativeValue cannot be read from the ValueStore and if soft failure is enabled (see
24-
* ValueStore#softFailOnCorruptData).
24+
* CorruptIRI is used when a NativeValue cannot be read from the ValueStore and if soft failure is enabled
25+
*
26+
* @see NativeStore#SOFT_FAIL_ON_CORRUPT_DATA_AND_REPAIR_INDEXES .
2527
*
2628
* @author Håvard M. Ottestad
2729
*/

core/sail/nativerdf/src/main/java/org/eclipse/rdf4j/sail/nativerdf/model/CorruptIRIOrBNode.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@
1616
import org.apache.commons.codec.binary.Hex;
1717
import org.eclipse.rdf4j.model.BNode;
1818
import org.eclipse.rdf4j.model.IRI;
19+
import org.eclipse.rdf4j.sail.nativerdf.NativeStore;
1920
import org.eclipse.rdf4j.sail.nativerdf.ValueStoreRevision;
2021

2122
import com.google.common.net.UrlEscapers;
2223

2324
/**
24-
* CorruptIRIOrBNode is used when a NativeValue cannot be read from the ValueStore and if soft failure is enabled (see
25-
* ValueStore#softFailOnCorruptData).
25+
* CorruptIRIOrBNode is used when a NativeValue cannot be read from the ValueStore and if soft failure is enabled
26+
*
27+
* @see NativeStore#SOFT_FAIL_ON_CORRUPT_DATA_AND_REPAIR_INDEXES .
2628
*
2729
* @author Håvard M. Ottestad
2830
*/

core/sail/nativerdf/src/main/java/org/eclipse/rdf4j/sail/nativerdf/model/CorruptLiteral.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@
2222
import org.eclipse.rdf4j.model.Literal;
2323
import org.eclipse.rdf4j.model.base.CoreDatatype;
2424
import org.eclipse.rdf4j.model.util.Values;
25+
import org.eclipse.rdf4j.sail.nativerdf.NativeStore;
2526
import org.eclipse.rdf4j.sail.nativerdf.ValueStoreRevision;
2627

2728
/**
28-
* CorruptLiteral is used when a NativeValue cannot be read from the ValueStore and if soft failure is enabled (see
29-
* ValueStore#softFailOnCorruptData).
29+
* CorruptLiteral is used when a NativeValue cannot be read from the ValueStore and if soft failure is enabled
30+
*
31+
* @see NativeStore#SOFT_FAIL_ON_CORRUPT_DATA_AND_REPAIR_INDEXES .
3032
*
3133
* @author Håvard M. Ottestad
3234
*/

core/sail/nativerdf/src/main/java/org/eclipse/rdf4j/sail/nativerdf/model/CorruptUnknownValue.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@
2222
import org.eclipse.rdf4j.model.Literal;
2323
import org.eclipse.rdf4j.model.base.CoreDatatype;
2424
import org.eclipse.rdf4j.model.vocabulary.XSD;
25+
import org.eclipse.rdf4j.sail.nativerdf.NativeStore;
2526
import org.eclipse.rdf4j.sail.nativerdf.ValueStoreRevision;
2627

2728
/**
28-
* CorruptUnknownValue is used when a NativeValue cannot be read from the ValueStore and if soft failure is enabled (see
29-
* ValueStore#softFailOnCorruptData). Since a type is needed
29+
* CorruptUnknownValue is used when a NativeValue cannot be read from the ValueStore and if soft failure is enabled
30+
*
31+
* @see NativeStore#SOFT_FAIL_ON_CORRUPT_DATA_AND_REPAIR_INDEXES .
3032
*
3133
* @author Håvard M. Ottestad
3234
*/

core/sail/nativerdf/src/main/java/org/eclipse/rdf4j/sail/nativerdf/model/CorruptValue.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,17 @@
1111

1212
package org.eclipse.rdf4j.sail.nativerdf.model;
1313

14+
import org.eclipse.rdf4j.sail.nativerdf.NativeStore;
1415
import org.eclipse.rdf4j.sail.nativerdf.ValueStoreRevision;
1516

1617
/**
17-
* CorruptValue is used when a NativeValue cannot be read from the ValueStore and if soft failure is enabled (see
18-
* ValueStore#softFailOnCorruptData).
19-
* <p>
20-
* There is no method isCorruptValue() as it would exist for a "regular" implementation of NativeValue. Since
21-
* CorruptValue is only to be used in exceptional situations, the recommended way of checking for it is using
22-
* "instanceof".
18+
* CorruptValue is used when a NativeValue cannot be read from the ValueStore and if soft failure is enabled
19+
*
20+
* @see NativeStore#SOFT_FAIL_ON_CORRUPT_DATA_AND_REPAIR_INDEXES .
21+
* <p>
22+
* There is no method isCorruptValue() as it would exist for a "regular" implementation of NativeValue. Since
23+
* CorruptValue is only to be used in exceptional situations, the recommended way of checking for it is using
24+
* "instanceof".
2325
*
2426
* @author Hannes Ebner
2527
*/

0 commit comments

Comments
 (0)