-
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 corrupt data can be written as NQuads
- Loading branch information
1 parent
196cf9d
commit 0c58aac
Showing
6 changed files
with
244 additions
and
15 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
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
138 changes: 138 additions & 0 deletions
138
...l/nativerdf/src/main/java/org/eclipse/rdf4j/sail/nativerdf/model/CorruptUnknownValue.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,138 @@ | ||
/******************************************************************************* | ||
* 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 java.math.BigDecimal; | ||
import java.math.BigInteger; | ||
import java.nio.charset.StandardCharsets; | ||
import java.util.Optional; | ||
|
||
import javax.xml.datatype.XMLGregorianCalendar; | ||
|
||
import org.eclipse.rdf4j.model.IRI; | ||
import org.eclipse.rdf4j.model.Literal; | ||
import org.eclipse.rdf4j.model.base.CoreDatatype; | ||
import org.eclipse.rdf4j.model.vocabulary.XSD; | ||
import org.eclipse.rdf4j.sail.nativerdf.ValueStoreRevision; | ||
|
||
/** | ||
* CorruptUnknownValue is used when a NativeValue cannot be read from the ValueStore and if soft failure is enabled (see | ||
* ValueStore#softFailOnCorruptData). Since a type is needed | ||
* | ||
* @author Håvard M. Ottestad | ||
*/ | ||
public class CorruptUnknownValue extends CorruptValue implements Literal { | ||
|
||
private static final long serialVersionUID = -6650510290226676279L; | ||
|
||
public CorruptUnknownValue(ValueStoreRevision revision, int internalID, byte[] data) { | ||
super(revision, internalID, data); | ||
} | ||
|
||
@Override | ||
public String getLabel() { | ||
byte[] data = getData(); | ||
try { | ||
if (data != null && data.length < 1024) { | ||
return "CorruptUnknownValue with ID " + getInternalID() + " with possible data: " | ||
+ new String(data, StandardCharsets.UTF_8); | ||
} | ||
} catch (Throwable ignored) { | ||
} | ||
return "CorruptUnknownValue_with_ID_" + getInternalID(); | ||
} | ||
|
||
@Override | ||
public Optional<String> getLanguage() { | ||
return Optional.empty(); | ||
} | ||
|
||
@Override | ||
public IRI getDatatype() { | ||
return XSD.STRING; | ||
} | ||
|
||
@Override | ||
public boolean booleanValue() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public byte byteValue() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public short shortValue() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public int intValue() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public long longValue() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public BigInteger integerValue() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public BigDecimal decimalValue() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public float floatValue() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public double doubleValue() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public XMLGregorianCalendar calendarValue() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public CoreDatatype getCoreDatatype() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
|
||
if (o instanceof CorruptUnknownValue && getInternalID() != NativeValue.UNKNOWN_ID) { | ||
CorruptUnknownValue otherCorruptValue = (CorruptUnknownValue) 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.