diff --git a/core/sail/nativerdf/src/main/java/org/eclipse/rdf4j/sail/nativerdf/ValueStore.java b/core/sail/nativerdf/src/main/java/org/eclipse/rdf4j/sail/nativerdf/ValueStore.java index 401d8705ff..d24541e3d1 100644 --- a/core/sail/nativerdf/src/main/java/org/eclipse/rdf4j/sail/nativerdf/ValueStore.java +++ b/core/sail/nativerdf/src/main/java/org/eclipse/rdf4j/sail/nativerdf/ValueStore.java @@ -543,7 +543,7 @@ private boolean isNamespaceData(byte[] data) { private NativeValue data2value(int id, byte[] data) throws IOException { if (data.length == 0) { if (softFailOnCorruptData) { - return new CorruptValue(revision, id); + return new CorruptValue(revision, id, data); } throw new SailException("Empty data array for value with id " + id); } @@ -556,7 +556,7 @@ private NativeValue data2value(int id, byte[] data) throws IOException { return data2literal(id, data); default: if (softFailOnCorruptData) { - return new CorruptValue(revision, id); + return new CorruptValue(revision, id, data); } throw new SailException("Invalid type " + data[0] + " for value with id " + id); } diff --git a/core/sail/nativerdf/src/main/java/org/eclipse/rdf4j/sail/nativerdf/model/CorruptValue.java b/core/sail/nativerdf/src/main/java/org/eclipse/rdf4j/sail/nativerdf/model/CorruptValue.java index 933bf9f614..53a3576e44 100644 --- a/core/sail/nativerdf/src/main/java/org/eclipse/rdf4j/sail/nativerdf/model/CorruptValue.java +++ b/core/sail/nativerdf/src/main/java/org/eclipse/rdf4j/sail/nativerdf/model/CorruptValue.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2024 Eclipse RDF4J contributors, Aduna, and others. + * Copyright (c) 2024 Eclipse RDF4J contributors. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Distribution License v1.0 @@ -7,7 +7,8 @@ * http://www.eclipse.org/org/documents/edl-v10.php. * * SPDX-License-Identifier: BSD-3-Clause - *******************************************************************************/ + ******************************************************************************/ + package org.eclipse.rdf4j.sail.nativerdf.model; import org.eclipse.rdf4j.sail.nativerdf.ValueStoreRevision; @@ -15,7 +16,7 @@ /** * CorruptValue is used when a NativeValue cannot be read from the ValueStore and if soft failure is enabled (see * ValueStore#softFailOnCorruptData). - * + *
* There is no method isCorruptValue() as it would exist for a "regular" implementation of NativeValue. Since * CorruptValue is only to be used in exceptional situations, the recommended way of checking for it is using * "instanceof". @@ -24,32 +25,17 @@ */ public class CorruptValue implements NativeValue { - /*-----------* - * Constants * - *-----------*/ - private static final long serialVersionUID = 8829067881854394802L; - /*----------* - * Variables * - *----------*/ - + private final byte[] data; private volatile ValueStoreRevision revision; - private volatile int internalID; - /*--------------* - * Constructors * - *--------------*/ - - public CorruptValue(ValueStoreRevision revision, int internalID) { + public CorruptValue(ValueStoreRevision revision, int internalID, byte[] data) { setInternalID(internalID, revision); + this.data = data; } - /*---------* - * Methods * - *---------*/ - @Override public void setInternalID(int internalID, ValueStoreRevision revision) { this.internalID = internalID; @@ -67,7 +53,17 @@ public int getInternalID() { } public String stringValue() { - return Integer.toString(internalID); + return "CorruptValue_with_ID_" + internalID; + } + + /** + * Returns the bytes that were read from the ValueStore for this value's internalID. Since the value is corrupt the + * data may be null or an empty array. + * + * @return null, empty array or corrupt data + */ + public byte[] getData() { + return data; } @Override @@ -88,4 +84,4 @@ public boolean equals(Object o) { return super.equals(o); } -} \ No newline at end of file +}