-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
2 changed files
with
116 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
core/sail/nativerdf/src/main/java/org/eclipse/rdf4j/sail/nativerdf/model/CorruptValue.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 Eclipse RDF4J contributors, Aduna, and others. | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Distribution License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* 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; | ||
|
||
/** | ||
* 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". | ||
* | ||
* @author Hannes Ebner | ||
*/ | ||
public class CorruptValue implements NativeValue { | ||
|
||
/*-----------* | ||
* Constants * | ||
*-----------*/ | ||
|
||
private static final long serialVersionUID = 8829067881854394802L; | ||
|
||
/*----------* | ||
* Variables * | ||
*----------*/ | ||
|
||
private volatile ValueStoreRevision revision; | ||
|
||
private volatile int internalID; | ||
|
||
/*--------------* | ||
* Constructors * | ||
*--------------*/ | ||
|
||
public CorruptValue(ValueStoreRevision revision, int internalID) { | ||
setInternalID(internalID, revision); | ||
} | ||
|
||
/*---------* | ||
* Methods * | ||
*---------*/ | ||
|
||
@Override | ||
public void setInternalID(int internalID, ValueStoreRevision revision) { | ||
this.internalID = internalID; | ||
this.revision = revision; | ||
} | ||
|
||
@Override | ||
public ValueStoreRevision getValueStoreRevision() { | ||
return revision; | ||
} | ||
|
||
@Override | ||
public int getInternalID() { | ||
return internalID; | ||
} | ||
|
||
public String stringValue() { | ||
return Integer.toString(internalID); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
|
||
if (o instanceof CorruptValue && internalID != NativeValue.UNKNOWN_ID) { | ||
CorruptValue otherCorruptValue = (CorruptValue) o; | ||
|
||
if (otherCorruptValue.internalID != NativeValue.UNKNOWN_ID && revision.equals(otherCorruptValue.revision)) { | ||
// CorruptValue is from the same revision of the same native store with both IDs set | ||
return internalID == otherCorruptValue.internalID; | ||
} | ||
} | ||
|
||
return super.equals(o); | ||
} | ||
|
||
} |