|
|
|
@ -95,6 +95,7 @@ pub enum EncodedTerm { |
|
|
|
|
DurationLiteral(Duration), |
|
|
|
|
YearMonthDurationLiteral(YearMonthDuration), |
|
|
|
|
DayTimeDurationLiteral(DayTimeDuration), |
|
|
|
|
GeoPoint(GeoPoint), |
|
|
|
|
Triple(Arc<EncodedTriple>), |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -266,6 +267,7 @@ impl Hash for EncodedTerm { |
|
|
|
|
Self::YearMonthDurationLiteral(value) => value.hash(state), |
|
|
|
|
Self::DayTimeDurationLiteral(value) => value.hash(state), |
|
|
|
|
Self::Triple(value) => value.hash(state), |
|
|
|
|
EncodedTerm::GeoPoint(_) => {} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -713,19 +715,13 @@ pub fn insert_term<F: FnMut(&StrHash, &str) -> Result<(), StorageError>>( |
|
|
|
|
if let EncodedTerm::NamedNode { iri_id } = encoded { |
|
|
|
|
insert_str(iri_id, node.as_str()) |
|
|
|
|
} else { |
|
|
|
|
Err( |
|
|
|
|
CorruptionError::new(format!("Invalid term encoding {encoded:?} for {term}")) |
|
|
|
|
.into(), |
|
|
|
|
) |
|
|
|
|
Err(CorruptionError::from_encoded_term(encoded, &term).into()) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
TermRef::BlankNode(node) => match encoded { |
|
|
|
|
EncodedTerm::BigBlankNode { id_id } => insert_str(id_id, node.as_str()), |
|
|
|
|
EncodedTerm::SmallBlankNode(..) | EncodedTerm::NumericalBlankNode { .. } => Ok(()), |
|
|
|
|
_ => Err( |
|
|
|
|
CorruptionError::new(format!("Invalid term encoding {encoded:?} for {term}")) |
|
|
|
|
.into(), |
|
|
|
|
), |
|
|
|
|
_ => Err(CorruptionError::from_encoded_term(encoded, &term).into()), |
|
|
|
|
}, |
|
|
|
|
TermRef::Literal(literal) => match encoded { |
|
|
|
|
EncodedTerm::BigStringLiteral { value_id } |
|
|
|
@ -736,10 +732,7 @@ pub fn insert_term<F: FnMut(&StrHash, &str) -> Result<(), StorageError>>( |
|
|
|
|
if let Some(language) = literal.language() { |
|
|
|
|
insert_str(language_id, language) |
|
|
|
|
} else { |
|
|
|
|
Err(CorruptionError::new(format!( |
|
|
|
|
"Invalid term encoding {encoded:?} for {term}" |
|
|
|
|
)) |
|
|
|
|
.into()) |
|
|
|
|
Err(CorruptionError::from_encoded_term(encoded, &term).into()) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
EncodedTerm::BigBigLangStringLiteral { |
|
|
|
@ -750,10 +743,7 @@ pub fn insert_term<F: FnMut(&StrHash, &str) -> Result<(), StorageError>>( |
|
|
|
|
if let Some(language) = literal.language() { |
|
|
|
|
insert_str(language_id, language) |
|
|
|
|
} else { |
|
|
|
|
Err(CorruptionError::new(format!( |
|
|
|
|
"Invalid term encoding {encoded:?} for {term}" |
|
|
|
|
)) |
|
|
|
|
.into()) |
|
|
|
|
Err(CorruptionError::from_encoded_term(encoded, &term).into()) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
EncodedTerm::SmallTypedLiteral { datatype_id, .. } => { |
|
|
|
@ -784,10 +774,7 @@ pub fn insert_term<F: FnMut(&StrHash, &str) -> Result<(), StorageError>>( |
|
|
|
|
| EncodedTerm::DurationLiteral(..) |
|
|
|
|
| EncodedTerm::YearMonthDurationLiteral(..) |
|
|
|
|
| EncodedTerm::DayTimeDurationLiteral(..) => Ok(()), |
|
|
|
|
_ => Err( |
|
|
|
|
CorruptionError::new(format!("Invalid term encoding {encoded:?} for {term}")) |
|
|
|
|
.into(), |
|
|
|
|
), |
|
|
|
|
_ => Err(CorruptionError::from_encoded_term(encoded, &term).into()), |
|
|
|
|
}, |
|
|
|
|
TermRef::Triple(triple) => { |
|
|
|
|
if let EncodedTerm::Triple(encoded) = encoded { |
|
|
|
@ -799,10 +786,7 @@ pub fn insert_term<F: FnMut(&StrHash, &str) -> Result<(), StorageError>>( |
|
|
|
|
)?; |
|
|
|
|
insert_term(triple.object.as_ref(), &encoded.object, insert_str) |
|
|
|
|
} else { |
|
|
|
|
Err( |
|
|
|
|
CorruptionError::new(format!("Invalid term encoding {encoded:?} for {term}")) |
|
|
|
|
.into(), |
|
|
|
|
) |
|
|
|
|
Err(CorruptionError::from_encoded_term(encoded, &term).into()) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -1035,6 +1019,7 @@ impl<S: StrLookup> Decoder for S { |
|
|
|
|
EncodedTerm::DurationLiteral(value) => Ok(Literal::from(*value).into()), |
|
|
|
|
EncodedTerm::YearMonthDurationLiteral(value) => Ok(Literal::from(*value).into()), |
|
|
|
|
EncodedTerm::DayTimeDurationLiteral(value) => Ok(Literal::from(*value).into()), |
|
|
|
|
EncodedTerm::GeoPoint(value) => Ok(Literal::from(*value).into()), |
|
|
|
|
EncodedTerm::Triple(triple) => Ok(self.decode_triple(triple)?.into()), |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|