Skip to content

Commit cad4af9

Browse files
committed
GH-5148 fixes based on review
1 parent 34807e1 commit cad4af9

2 files changed

Lines changed: 21 additions & 25 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ private boolean isNamespaceData(byte[] data) {
543543
private NativeValue data2value(int id, byte[] data) throws IOException {
544544
if (data.length == 0) {
545545
if (softFailOnCorruptData) {
546-
return new CorruptValue(revision, id);
546+
return new CorruptValue(revision, id, data);
547547
}
548548
throw new SailException("Empty data array for value with id " + id);
549549
}
@@ -556,7 +556,7 @@ private NativeValue data2value(int id, byte[] data) throws IOException {
556556
return data2literal(id, data);
557557
default:
558558
if (softFailOnCorruptData) {
559-
return new CorruptValue(revision, id);
559+
return new CorruptValue(revision, id, data);
560560
}
561561
throw new SailException("Invalid type " + data[0] + " for value with id " + id);
562562
}

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

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
/*******************************************************************************
2-
* Copyright (c) 2024 Eclipse RDF4J contributors, Aduna, and others.
2+
* Copyright (c) 2024 Eclipse RDF4J contributors.
33
*
44
* All rights reserved. This program and the accompanying materials
55
* are made available under the terms of the Eclipse Distribution License v1.0
66
* which accompanies this distribution, and is available at
77
* http://www.eclipse.org/org/documents/edl-v10.php.
88
*
99
* SPDX-License-Identifier: BSD-3-Clause
10-
*******************************************************************************/
10+
******************************************************************************/
11+
1112
package org.eclipse.rdf4j.sail.nativerdf.model;
1213

1314
import org.eclipse.rdf4j.sail.nativerdf.ValueStoreRevision;
1415

1516
/**
1617
* CorruptValue is used when a NativeValue cannot be read from the ValueStore and if soft failure is enabled (see
1718
* ValueStore#softFailOnCorruptData).
18-
*
19+
* <p>
1920
* There is no method isCorruptValue() as it would exist for a "regular" implementation of NativeValue. Since
2021
* CorruptValue is only to be used in exceptional situations, the recommended way of checking for it is using
2122
* "instanceof".
@@ -24,32 +25,17 @@
2425
*/
2526
public class CorruptValue implements NativeValue {
2627

27-
/*-----------*
28-
* Constants *
29-
*-----------*/
30-
3128
private static final long serialVersionUID = 8829067881854394802L;
3229

33-
/*----------*
34-
* Variables *
35-
*----------*/
36-
30+
private final byte[] data;
3731
private volatile ValueStoreRevision revision;
38-
3932
private volatile int internalID;
4033

41-
/*--------------*
42-
* Constructors *
43-
*--------------*/
44-
45-
public CorruptValue(ValueStoreRevision revision, int internalID) {
34+
public CorruptValue(ValueStoreRevision revision, int internalID, byte[] data) {
4635
setInternalID(internalID, revision);
36+
this.data = data;
4737
}
4838

49-
/*---------*
50-
* Methods *
51-
*---------*/
52-
5339
@Override
5440
public void setInternalID(int internalID, ValueStoreRevision revision) {
5541
this.internalID = internalID;
@@ -67,7 +53,17 @@ public int getInternalID() {
6753
}
6854

6955
public String stringValue() {
70-
return Integer.toString(internalID);
56+
return "CorruptValue_with_ID_" + internalID;
57+
}
58+
59+
/**
60+
* Returns the bytes that were read from the ValueStore for this value's internalID. Since the value is corrupt the
61+
* data may be null or an empty array.
62+
*
63+
* @return null, empty array or corrupt data
64+
*/
65+
public byte[] getData() {
66+
return data;
7167
}
7268

7369
@Override
@@ -88,4 +84,4 @@ public boolean equals(Object o) {
8884
return super.equals(o);
8985
}
9086

91-
}
87+
}

0 commit comments

Comments
 (0)