Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/data/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ sqlite = ["assembly-fdb/sqlite"]
serde-derives = ["assembly-fdb/serde-derives", "assembly-xml/serialize"]

[dependencies.assembly-fdb]
version = "0.1.0"
version = "0.2.0"
path = "../fdb"

[dependencies.assembly-xml]
Expand Down
37 changes: 17 additions & 20 deletions modules/data/examples/xmldb-to-fdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,25 +68,22 @@ fn main() -> color_eyre::Result<()> {

while let Some(col) = expect_column_or_end_columns(xml, buf)? {
let data_type = match col.r#type {
ValueType::Bit => common::ValueType::Boolean,
ValueType::Float => common::ValueType::Float,
ValueType::Real => common::ValueType::Float,
ValueType::Int => common::ValueType::Integer,
ValueType::BigInt => common::ValueType::BigInt,
ValueType::SmallInt => common::ValueType::Integer,
ValueType::TinyInt => common::ValueType::Integer,
ValueType::Binary => common::ValueType::Text,
ValueType::VarBinary => common::ValueType::Text,
ValueType::Char => common::ValueType::Text,
ValueType::VarChar => common::ValueType::Text,
ValueType::NChar => common::ValueType::Text,
ValueType::NVarChar => common::ValueType::Text,
ValueType::NText => common::ValueType::VarChar,
ValueType::Text => common::ValueType::VarChar,
ValueType::Image => common::ValueType::VarChar,
ValueType::DateTime => common::ValueType::BigInt,
ValueType::Xml => common::ValueType::VarChar,
ValueType::Null => common::ValueType::Nothing,
ValueType::Bit => common::ValueType::Boolean,
ValueType::Float | ValueType::Real => common::ValueType::Float,
ValueType::Int | ValueType::SmallInt | ValueType::TinyInt => {
common::ValueType::Integer
}
ValueType::BigInt | ValueType::DateTime => common::ValueType::BigInt,
ValueType::Binary
| ValueType::VarBinary
| ValueType::Char
| ValueType::VarChar
| ValueType::NChar
| ValueType::NVarChar => common::ValueType::Text,
ValueType::NText | ValueType::Text | ValueType::Image | ValueType::Xml => {
common::ValueType::Xml
}
};
if col_map.is_empty() {
// first col
Expand Down Expand Up @@ -121,7 +118,7 @@ fn main() -> color_eyre::Result<()> {
common::ValueType::Text => core::Field::Text(src_value),
common::ValueType::Boolean => core::Field::Boolean(&src_value != "0"),
common::ValueType::BigInt => core::Field::BigInt(src_value.parse().unwrap()),
common::ValueType::VarChar => core::Field::VarChar(src_value),
common::ValueType::Xml => core::Field::Xml(src_value),
};

if col_index == 0 {
Expand All @@ -136,7 +133,7 @@ fn main() -> color_eyre::Result<()> {
let lat1 = Latin1String::encode(text);
pk = Some((lat1.hash() % 128) as usize);
}
core::Field::VarChar(var_char) => {
core::Field::Xml(var_char) => {
let lat1 = Latin1String::encode(var_char);
pk = Some((lat1.hash() % 128) as usize);
}
Expand Down
2 changes: 1 addition & 1 deletion modules/fdb/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "assembly-fdb"
version = "0.1.0"
version = "0.2.0"
edition = "2018"
license = "MIT or Apache-2.0"

Expand Down
2 changes: 1 addition & 1 deletion modules/fdb/examples/fdb-index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fn field_to_cell(field: mem::Field) -> PCell {
Field::Text(v) => PCell::new(&format!("{:?}", v)),
Field::Boolean(v) => PCell::new(if v { "true" } else { "false" }),
Field::BigInt(v) => PCell::new(&format!("{} (i64)", v)),
Field::VarChar(v) => PCell::new(&format!("{:?}", v)),
Field::Xml(v) => PCell::new(&format!("{:?}", v)),
}
}

Expand Down
4 changes: 2 additions & 2 deletions modules/fdb/examples/fdb-stat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ fn main() -> color_eyre::Result<()> {
ValueType::Text => text_column_count += 1,
ValueType::Boolean => bool_column_count += 1,
ValueType::BigInt => bigint_column_count += 1,
ValueType::VarChar => xml_column_count += 1,
ValueType::Xml => xml_column_count += 1,
}
}

Expand All @@ -81,7 +81,7 @@ fn main() -> color_eyre::Result<()> {
Value::Text(_) => text_field_count += 1,
Value::Boolean(_) => bool_field_count += 1,
Value::BigInt(_) => bigint_field_count += 1,
Value::VarChar(_) => xml_field_count += 1,
Value::Xml(_) => xml_field_count += 1,
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion modules/fdb/examples/sqlite-to-fdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ fn main() -> eyre::Result<()> {
ValueRef::Real(f) => Field::Float(f as f32),
ValueRef::Text(t) => match target_types[index] {
ValueType::Text => Field::Text(String::from(std::str::from_utf8(t)?)),
ValueType::VarChar => Field::VarChar(String::from(std::str::from_utf8(t)?)),
ValueType::Xml => Field::Xml(String::from(std::str::from_utf8(t)?)),
_ => {
return Err(eyre!(
"Invalid target datatype; cannot store SQLite Text as FDB {:?}",
Expand Down
18 changes: 9 additions & 9 deletions modules/fdb/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ pub enum Value<T: Context> {
/// A 64 bit integer
BigInt(T::I64),
/// A (XML?) string
VarChar(T::XML),
Xml(T::XML),
}

impl<T: Context> Clone for Value<T>
Expand All @@ -227,7 +227,7 @@ where
Value::Text(v) => Value::Text(v.clone()),
Value::Boolean(v) => Value::Boolean(*v),
Value::BigInt(v) => Value::BigInt(v.clone()),
Value::VarChar(v) => Value::VarChar(v.clone()),
Value::Xml(v) => Value::Xml(v.clone()),
}
}
}
Expand All @@ -254,7 +254,7 @@ impl<T: Context> Value<T> {
Value::Text(v) => Value::Text(mapper.map_string(v)),
Value::Boolean(v) => Value::Boolean(*v),
Value::BigInt(v) => Value::BigInt(mapper.map_i64(v)),
Value::VarChar(v) => Value::VarChar(mapper.map_xml(v)),
Value::Xml(v) => Value::Xml(mapper.map_xml(v)),
}
}

Expand Down Expand Up @@ -305,7 +305,7 @@ impl<T: Context> Value<T> {

/// Returns `Some` with the value if the field contains a [`Value::VarChar`].
pub fn into_opt_varchar(self) -> Option<T::XML> {
if let Self::VarChar(value) = self {
if let Self::Xml(value) = self {
Some(value)
} else {
None
Expand All @@ -322,7 +322,7 @@ impl<T: Context> From<&Value<T>> for ValueType {
Value::Text(_) => ValueType::Text,
Value::Boolean(_) => ValueType::Boolean,
Value::BigInt(_) => ValueType::BigInt,
Value::VarChar(_) => ValueType::VarChar,
Value::Xml(_) => ValueType::Xml,
}
}
}
Expand All @@ -344,7 +344,7 @@ pub enum ValueType {
/// A 64 bit integer
BigInt,
/// An (XML?) string
VarChar,
Xml,
}

impl ValueType {
Expand All @@ -357,7 +357,7 @@ impl ValueType {
ValueType::Text => "TEXT",
ValueType::Boolean => "BOOLEAN",
ValueType::BigInt => "BIGINT",
ValueType::VarChar => "VARCHAR",
ValueType::Xml => "VARCHAR",
}
}
}
Expand All @@ -377,7 +377,7 @@ impl From<ValueType> for u8 {
ValueType::Text => 4,
ValueType::Boolean => 5,
ValueType::BigInt => 6,
ValueType::VarChar => 8,
ValueType::Xml => 8,
}
}
}
Expand Down Expand Up @@ -417,7 +417,7 @@ impl TryFrom<u32> for ValueType {
4 => Ok(ValueType::Text),
5 => Ok(ValueType::Boolean),
6 => Ok(ValueType::BigInt),
8 => Ok(ValueType::VarChar),
8 => Ok(ValueType::Xml),
_ => Err(UnknownValueType(value_type)),
}
}
Expand Down
6 changes: 3 additions & 3 deletions modules/fdb/src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl From<MemField<'_>> for Field {
MemField::Text(v) => Field::Text(v.decode().into_owned()),
MemField::Boolean(v) => Field::Boolean(v),
MemField::BigInt(v) => Field::BigInt(v),
MemField::VarChar(v) => Field::VarChar(v.decode().into_owned()),
MemField::Xml(v) => Field::Xml(v.decode().into_owned()),
}
}
}
Expand All @@ -62,7 +62,7 @@ impl PartialEq<MemField<'_>> for Field {
Value::Text(x) => matches!(self, Self::Text(y) if x.decode().as_ref() == y),
Value::Boolean(x) => matches!(self, Self::Boolean(y) if x == y),
Value::BigInt(x) => matches!(self, Self::BigInt(y) if x == y),
Value::VarChar(x) => matches!(self, Self::VarChar(y) if x.decode().as_ref() == y),
Value::Xml(x) => matches!(self, Self::Xml(y) if x.decode().as_ref() == y),
}
}
}
Expand All @@ -76,7 +76,7 @@ impl fmt::Display for Field {
Field::Text(t) => write!(f, "{:?}", t),
Field::Boolean(b) => write!(f, "{}", b),
Field::BigInt(i) => write!(f, "{}", i),
Field::VarChar(v) => write!(f, "{:?}", v),
Field::Xml(v) => write!(f, "{:?}", v),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion modules/fdb/src/file/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ impl TryFrom<FDBFieldData> for FDBFieldValue {
ValueType::BigInt => FDBFieldValue::BigInt(IndirectValue {
addr: u32::from_le_bytes(value.value),
}),
ValueType::VarChar => FDBFieldValue::VarChar(IndirectValue {
ValueType::Xml => FDBFieldValue::Xml(IndirectValue {
addr: u32::from_le_bytes(value.value),
}),
})
Expand Down
2 changes: 1 addition & 1 deletion modules/fdb/src/mem/c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ impl Repr for FDBFieldDataC {
ValueType::BigInt => FDBFieldValue::BigInt(IndirectValue {
addr: u32::from_le_bytes(self.value.0),
}),
ValueType::VarChar => FDBFieldValue::VarChar(IndirectValue {
ValueType::Xml => FDBFieldValue::Xml(IndirectValue {
addr: u32::from_le_bytes(self.value.0),
}),
}
Expand Down
4 changes: 2 additions & 2 deletions modules/fdb/src/mem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,10 +377,10 @@ fn get_field_raw(buf: Buffer, data_type: ValueType, bytes: [u8; 4]) -> Field {
let val = buf.cast::<LEI64>(addr).extract();
Field::BigInt(val)
}
ValueType::VarChar => {
ValueType::Xml => {
let addr = u32::from_le_bytes(bytes);
let text = get_latin1_str(buf.as_bytes(), addr);
Field::VarChar(text)
Field::Xml(text)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions modules/fdb/src/reader/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ where
.and_then(|addr| self.get_i64(addr))
.map(Field::BigInt)
.map_err(Into::into),
ValueType::VarChar => Ok(bytes)
ValueType::Xml => Ok(bytes)
.map(u32::from_le_bytes)
.and_then(|addr| self.get_string(addr))
.map(Field::VarChar)
.map(Field::Xml)
.map_err(Into::into),
}
}
Expand Down
8 changes: 3 additions & 5 deletions modules/fdb/src/sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl<'a> ToSql for Field<'a> {
Field::Text(s) => Value::Text(s.decode().into_owned()),
Field::Boolean(b) => Value::Integer(if b { 1 } else { 0 }),
Field::BigInt(i) => Value::Integer(i),
Field::VarChar(b) => Value::Text(b.decode().into_owned()),
Field::Xml(b) => Value::Text(b.decode().into_owned()),
};
Ok(ToSqlOutput::Owned(r))
}
Expand All @@ -36,7 +36,7 @@ impl ValueType {
ValueType::Text => "TEXT4",
ValueType::Boolean => "INT_BOOL",
ValueType::BigInt => "INT64",
ValueType::VarChar => "TEXT_XML",
ValueType::Xml => "TEXT_XML",
}
}

Expand Down Expand Up @@ -77,9 +77,7 @@ impl ValueType {
"TEXT4" | "text_4" | "TEXT" => Some(ValueType::Text),
"BIT" | "INT_BOOL" | "int_bool" => Some(ValueType::Boolean),
"INT64" | "int64" | "BIGINT" | "INTEGER" => Some(ValueType::BigInt),
"XML" | "TEXT_XML" | "xml" | "text_8" | "text_xml" | "VARCHAR" => {
Some(ValueType::VarChar)
}
"XML" | "TEXT_XML" | "xml" | "text_8" | "text_xml" | "VARCHAR" => Some(ValueType::Xml),
_ => None,
}
}
Expand Down
2 changes: 1 addition & 1 deletion modules/fdb/src/store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ impl Table {
let v = i64s_base_offset + (i64_ref.index * size_of::<u64>()) as u32;
v.to_le_bytes()
}),
Field::VarChar(text_ref) => (8, {
Field::Xml(text_ref) => (8, {
let v = string_len_offsets.get(&text_ref.outer).unwrap()
+ (text_ref.inner * text_ref.outer * 4) as u32;
v.to_le_bytes()
Expand Down
2 changes: 1 addition & 1 deletion modules/sysdiagram/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ displaydoc = "0.1"
thiserror = "1.0"

[dev-dependencies]
assembly-fdb = { path = "../fdb", version = "0.1.0" }
assembly-fdb = { path = "../fdb", version = "0.2.0" }
anyhow = "1.0"
getopts = "0.2"