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+
1112package org .eclipse .rdf4j .sail .nativerdf .model ;
1213
1314import 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".
2425 */
2526public 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