-
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.
GH-5148 add tests and extend corruption handling to more parts of the…
… code
- Loading branch information
1 parent
cad4af9
commit f6accf9
Showing
7 changed files
with
608 additions
and
45 deletions.
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
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
64 changes: 64 additions & 0 deletions
64
core/sail/nativerdf/src/main/java/org/eclipse/rdf4j/sail/nativerdf/model/CorruptIRI.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,64 @@ | ||
/******************************************************************************* | ||
* 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 | ||
* 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.model.IRI; | ||
import org.eclipse.rdf4j.sail.nativerdf.ValueStoreRevision; | ||
|
||
/** | ||
* CorruptIRI is used when a NativeValue cannot be read from the ValueStore and if soft failure is enabled (see | ||
* ValueStore#softFailOnCorruptData). | ||
* | ||
* @author Håvard M. Ottestad | ||
*/ | ||
public class CorruptIRI extends CorruptValue implements IRI { | ||
|
||
private static final long serialVersionUID = -6995615243794525852L; | ||
|
||
public CorruptIRI(ValueStoreRevision revision, int internalID, byte[] data) { | ||
super(revision, internalID, data); | ||
} | ||
|
||
public String stringValue() { | ||
return "CorruptIRI_with_ID_" + getInternalID(); | ||
} | ||
|
||
@Override | ||
public String getNamespace() { | ||
return "CORRUPT"; | ||
} | ||
|
||
@Override | ||
public String getLocalName() { | ||
return "CORRUPT"; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
|
||
if (o instanceof CorruptIRI && getInternalID() != NativeValue.UNKNOWN_ID) { | ||
CorruptIRI otherCorruptValue = (CorruptIRI) o; | ||
|
||
if (otherCorruptValue.getInternalID() != NativeValue.UNKNOWN_ID | ||
&& getValueStoreRevision().equals(otherCorruptValue.getValueStoreRevision())) { | ||
// CorruptValue is from the same revision of the same native store with both IDs set | ||
return getInternalID() == otherCorruptValue.getInternalID(); | ||
} | ||
} | ||
|
||
return super.equals(o); | ||
} | ||
|
||
} |
70 changes: 70 additions & 0 deletions
70
...ail/nativerdf/src/main/java/org/eclipse/rdf4j/sail/nativerdf/model/CorruptIRIOrBNode.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,70 @@ | ||
/******************************************************************************* | ||
* 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 | ||
* 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.model.BNode; | ||
import org.eclipse.rdf4j.model.IRI; | ||
import org.eclipse.rdf4j.sail.nativerdf.ValueStoreRevision; | ||
|
||
/** | ||
* CorruptIRIOrBNode is used when a NativeValue cannot be read from the ValueStore and if soft failure is enabled (see | ||
* ValueStore#softFailOnCorruptData). | ||
* | ||
* @author Håvard M. Ottestad | ||
*/ | ||
public class CorruptIRIOrBNode extends CorruptValue implements IRI, BNode { | ||
|
||
private static final long serialVersionUID = 3709784393454516043L; | ||
|
||
public CorruptIRIOrBNode(ValueStoreRevision revision, int internalID, byte[] data) { | ||
super(revision, internalID, data); | ||
} | ||
|
||
public String stringValue() { | ||
return "CorruptIRI_with_ID_" + getInternalID(); | ||
} | ||
|
||
@Override | ||
public String getNamespace() { | ||
return "CORRUPT"; | ||
} | ||
|
||
@Override | ||
public String getLocalName() { | ||
return "CORRUPT"; | ||
} | ||
|
||
@Override | ||
public String getID() { | ||
return ""; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
|
||
if (o instanceof CorruptIRIOrBNode && getInternalID() != NativeValue.UNKNOWN_ID) { | ||
CorruptIRIOrBNode otherCorruptValue = (CorruptIRIOrBNode) o; | ||
|
||
if (otherCorruptValue.getInternalID() != NativeValue.UNKNOWN_ID | ||
&& getValueStoreRevision().equals(otherCorruptValue.getValueStoreRevision())) { | ||
// CorruptValue is from the same revision of the same native store with both IDs set | ||
return getInternalID() == otherCorruptValue.getInternalID(); | ||
} | ||
} | ||
|
||
return super.equals(o); | ||
} | ||
|
||
} |
Oops, something went wrong.