Skip to content

Commit

Permalink
Cleaned up loose ends
Browse files Browse the repository at this point in the history
  • Loading branch information
criminosis committed Nov 9, 2024
1 parent 2083461 commit e2cbd2c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 94 deletions.
51 changes: 3 additions & 48 deletions gremlin-client/src/io/graph_binary_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,10 @@ const POP: u8 = 0x1C;
// const LAMBDA: u8 = 0x1D;
const P: u8 = 0x1E;
const SCOPE: u8 = 0x1F;
//TODO fill in others

//...
const T: u8 = 0x20;
const TRAVERSER: u8 = 0x21;
//...
const BOOLEAN: u8 = 0x27;
const TEXTP: u8 = 0x28;
//...
const MERGE: u8 = 0x2E;
const UNSPECIFIED_NULL_OBEJECT: u8 = 0xFE;

Expand Down Expand Up @@ -127,8 +122,7 @@ impl GraphBinaryV1Deser for ResponseMessage {
.try_into()
.expect("Status code should fit in i16");
//Status message is nullable
let status_message = String::from_be_bytes_nullable(bytes)?
.expect("TODO what to do with null status message");
let status_message = String::from_be_bytes_nullable(bytes)?.unwrap_or_default();

let status_attributes = GraphBinaryV1Deser::from_be_bytes(bytes)?;
let result_meta: HashMap<GKey, GValue> = GraphBinaryV1Deser::from_be_bytes(bytes)?;
Expand Down Expand Up @@ -571,9 +565,8 @@ pub trait GraphBinaryV1Deser: Sized {
Some(VALUE_FLAG) => Self::from_be_bytes(bytes).map(Option::Some),
Some(VALUE_NULL_FLAG) => Ok(None),
other => {
let remainder: Vec<u8> = bytes.cloned().collect();
return Err(GremlinError::Cast(format!(
"Unexpected byte for nullable check: {other:?}. Remainder: {remainder:?}"
"Unexpected byte for nullable check: {other:?}"
)));
}
}
Expand Down Expand Up @@ -708,8 +701,7 @@ impl GraphBinaryV1Deser for GValue {
}
}
other => {
let remainder: Vec<u8> = bytes.cloned().collect();
unimplemented!("TODO {other}. Remainder: {remainder:?}");
unimplemented!("Unimplemented deserialization byte {other}");
}
}
}
Expand Down Expand Up @@ -1049,43 +1041,6 @@ impl GraphBinaryV1Ser for &Uuid {
}
}

impl GraphBinaryV1Ser for &Vertex {
fn to_be_bytes(self, buf: &mut Vec<u8>) -> GremlinResult<()> {
//Format: {id}{label}{properties}

//{id} is a fully qualified typed value composed of {type_code}{type_info}{value_flag}{value}.
self.id().to_be_bytes(buf)?;

//{label} is a String value
self.label().to_be_bytes(buf)?;

//{properties} is a fully qualified typed value composed of {type_code}{type_info}{value_flag}{value} which contains properties.
self.properties.len();
todo!()
}
}

impl GraphBinaryV1Ser for &VertexProperty {
fn to_be_bytes(self, buf: &mut Vec<u8>) -> GremlinResult<()> {
//Format: {id}{label}{value}{parent}{properties}

//{id} is a fully qualified typed value composed of {type_code}{type_info}{value_flag}{value}.
self.id().to_be_bytes(buf)?;

//{label} is a String value.
self.label().to_be_bytes(buf)?;

//{value} is a fully qualified typed value composed of {type_code}{type_info}{value_flag}{value}.
//???????

//{parent} is a fully qualified typed value composed of {type_code}{type_info}{value_flag}{value} which contains the parent Vertex. Note that as TinkerPop currently send "references" only, this value will always be null.}

//{properties} is a fully qualified typed value composed of {type_code}{type_info}{value_flag}{value} which contains properties.

todo!()
}
}

impl GraphBinaryV1Ser for &GID {
fn to_be_bytes(self, buf: &mut Vec<u8>) -> GremlinResult<()> {
match self {
Expand Down
11 changes: 0 additions & 11 deletions gremlin-client/src/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,6 @@ pub struct MiddleResponseResult {
}

impl IoProtocol {
pub fn read(&self, value: &Value) -> GremlinResult<Option<GValue>> {
if let Value::Null = value {
return Ok(None);
}
match self {
IoProtocol::GraphSONV2 => serializer_v2::deserializer_v2(value).map(Some),
IoProtocol::GraphSONV3 => serializer_v3::deserializer_v3(value).map(Some),
IoProtocol::GraphBinaryV1 => todo!(),
}
}

pub fn read_response(&self, response: Vec<u8>) -> GremlinResult<Response> {
match self {
IoProtocol::GraphSONV2 => {
Expand Down
35 changes: 0 additions & 35 deletions gremlin-client/tests/graph_binary_read_write_cycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,38 +37,3 @@ fn simple_value_rw_cycle<T: Into<GValue>>(#[case] payload: T) {
Some(payload)
)
}

// #[test]
// fn edge_rw_cycle() {
// todo!()
// }

// #[test]
// fn path_rw_cycle() {
// todo!()
// }

// #[test]
// fn property_rw_cycle() {
// todo!()
// }

// #[test]
// fn vertex_rw_cycle() {
// todo!()
// }

// #[test]
// fn vertex_property_rw_cycle() {
// todo!()
// }

// #[test]
// fn scope_rw_cycle() {
// todo!()
// }

// #[test]
// fn traverser_rw_cycle() {
// todo!()
// }

0 comments on commit e2cbd2c

Please sign in to comment.