MCPcopy Create free account
hub / github.com/erans/pgsqlite / handle_blob_value

Method handle_blob_value

src/protocol/value_handler.rs:87–120  ·  view source on GitHub ↗

Handle BLOB values with potential memory mapping

(
        &self,
        blob_data: &[u8],
        pg_type_oid: i32,
        binary_format: bool,
    )

Source from the content-addressed store, hash-verified

85
86 /// Handle BLOB values with potential memory mapping
87 fn handle_blob_value(
88 &self,
89 blob_data: &[u8],
90 pg_type_oid: i32,
91 binary_format: bool,
92 ) -> io::Result<Option<MappedValue>> {
93 if blob_data.is_empty() {
94 return Ok(Some(MappedValue::Memory(Vec::new())));
95 }
96
97 // Check if this should use memory mapping
98 if self.config.enable_mmap && blob_data.len() >= self.config.large_value_threshold {
99 debug!("Using memory mapping for large BLOB value: {} bytes", blob_data.len());
100
101 // Convert to PostgreSQL format if needed
102 let pg_data = if binary_format {
103 // Binary format - use as-is for BYTEA
104 blob_data.to_vec()
105 } else {
106 // Text format - hex encode for BYTEA
107 if pg_type_oid == 17 { // BYTEA
108 format!("\\x{}", hex::encode(blob_data)).into_bytes()
109 } else {
110 blob_data.to_vec()
111 }
112 };
113
114 Ok(Some(self.mmap_factory.create_from_blob(&pg_data)?))
115 } else {
116 // Use regular memory storage
117 let pg_data = self.convert_blob_to_pg_format(blob_data, pg_type_oid, binary_format);
118 Ok(Some(MappedValue::Memory(pg_data)))
119 }
120 }
121
122 /// Handle text values with potential memory mapping for large strings
123 fn handle_text_value(

Callers 1

convert_valueMethod · 0.80

Calls 4

create_from_blobMethod · 0.80
is_emptyMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected