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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 DownExpand 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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"
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 DownExpand 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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"
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 DownExpand 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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"
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 DownExpand 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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"
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 DownExpand 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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"
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 DownExpand 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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"
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 DownExpand 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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"
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 DownExpand 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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"