Skip to content

Commit

Permalink
Revert "fix: call before_first for call next"
Browse files Browse the repository at this point in the history
This reverts commit c93dbb0.
  • Loading branch information
cutsea110 committed Mar 31, 2024
1 parent c93dbb0 commit e7af634
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 44 deletions.
1 change: 0 additions & 1 deletion app/embedded/execquery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ fn print_result_set(mut results: EmbeddedResultSet) -> Result<i32> {
println!();
// scan record
let mut c = 0;
results.before_first()?;
while results.next() {
c += 1;
print_record(&mut results, &meta)?;
Expand Down
1 change: 0 additions & 1 deletion app/network/execquery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ async fn print_result_set(mut results: NetworkResultSet) -> Result<(i32, i32)> {
println!();
// scan record
let mut total_count = 0;
results.before_first().expect("before first");
loop {
let rows = results.get_rows(MAX_ROWS, &meta).await.expect("get rows");
let c = rows.len();
Expand Down
21 changes: 10 additions & 11 deletions capnp/remote.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -216,17 +216,16 @@ interface DateBox {
interface RemoteResultSet {
# result set

beforeFirst @0 () -> (val :BoolBox);
next @1 () -> (val :BoolBox);
close @2 () -> (res :TxBox);
getMetadata @3 () -> (metadata :RemoteMetaData);
getInt16 @4 (fldname :Text) -> (val :Int16Box);
getInt32 @5 (fldname :Text) -> (val :Int32Box);
getString @6 (fldname :Text) -> (val :StringBox);
getBool @7 (fldname :Text) -> (val :BoolBox);
getDate @8 (fldname :Text) -> (val :DateBox);
getRow @9 () -> (row :Row); # get one record
getRows @10 (limit :UInt32) -> (count :UInt32, rows :List(Row)); # get records up to limit
next @0 () -> (val :BoolBox);
close @1 () -> (res :TxBox);
getMetadata @2 () -> (metadata :RemoteMetaData);
getInt16 @3 (fldname :Text) -> (val :Int16Box);
getInt32 @4 (fldname :Text) -> (val :Int32Box);
getString @5 (fldname :Text) -> (val :StringBox);
getBool @6 (fldname :Text) -> (val :BoolBox);
getDate @7 (fldname :Text) -> (val :DateBox);
getRow @8 () -> (row :Row); # get one record
getRows @9 (limit :UInt32) -> (count :UInt32, rows :List(Row)); # get records up to limit

struct Row {
# record
Expand Down
4 changes: 0 additions & 4 deletions src/rdbc/embedded/resultset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ impl<'a> EmbeddedResultSet<'a> {

impl<'a> ResultSetAdapter for EmbeddedResultSet<'a> {
type Meta = EmbeddedMetaData;
type Setuped = ();
type Next = bool;
type Int16Value = i16;
type Int32Value = i32;
Expand All @@ -41,9 +40,6 @@ impl<'a> ResultSetAdapter for EmbeddedResultSet<'a> {
type DateValue = NaiveDate;
type Res = ();

fn before_first(&self) -> Result<Self::Setuped> {
self.s.lock().unwrap().before_first()
}
fn next(&self) -> Self::Next {
self.s.lock().unwrap().next()
}
Expand Down
25 changes: 0 additions & 25 deletions src/rdbc/network/resultset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,6 @@ use crate::{
remote_capnp::{bool_box, date_box, int16_box, int32_box, remote_result_set, string_box},
};

pub struct SetupedImpl {
client: bool_box::Client,
}
impl SetupedImpl {
pub fn new(client: bool_box::Client) -> Self {
Self { client }
}
pub async fn has_value(&self) -> Result<bool> {
let reply = self.client.read_request().send().promise.await?;
Ok(reply.get()?.get_val())
}
}

pub struct NextImpl {
client: bool_box::Client,
}
Expand Down Expand Up @@ -247,7 +234,6 @@ impl NetworkResultSet {

impl ResultSetAdapter for NetworkResultSet {
type Meta = NetworkResultSetMetaData;
type Setuped = SetupedImpl;
type Next = NextImpl;
type Int16Value = Int16ValueImpl;
type Int32Value = Int32ValueImpl;
Expand All @@ -256,17 +242,6 @@ impl ResultSetAdapter for NetworkResultSet {
type DateValue = DateValueImpl;
type Res = ResponseImpl;

fn before_first(&self) -> Result<Self::Setuped> {
let val = self
.resultset
.before_first_request()
.send()
.pipeline
.get_val();

Ok(Self::Setuped::new(val))
}

fn next(&self) -> Self::Next {
let exists = self.resultset.next_request().send().pipeline.get_val();

Expand Down
2 changes: 0 additions & 2 deletions src/rdbc/resultsetadapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ impl fmt::Display for ResultSetError {

pub trait ResultSetAdapter {
type Meta: ResultSetMetaDataAdapter;
type Setuped;
type Next;
type Int16Value;
type Int32Value;
Expand All @@ -42,7 +41,6 @@ pub trait ResultSetAdapter {
type DateValue;
type Res;

fn before_first(&self) -> Result<Self::Setuped>;
fn next(&self) -> Self::Next;
fn get_i16(&mut self, fldname: &str) -> Result<Self::Int16Value>;
fn get_i32(&mut self, fldname: &str) -> Result<Self::Int32Value>;
Expand Down

0 comments on commit e7af634

Please sign in to comment.