@@ -23,22 +23,22 @@ use arrow_schema::Schema;
2323use arrow_select:: concat:: concat_batches;
2424use itertools:: Itertools ;
2525
26- use crate :: utils:: arrow:: adapt_batch;
26+ use crate :: { option :: CONFIG , utils:: arrow:: adapt_batch} ;
2727
2828/// Structure to keep recordbatches in memory.
2929///
3030/// Any new schema is updated in the schema map.
3131/// Recordbatches are pushed to mutable buffer first and then concated together and pushed to read buffer
3232#[ derive( Debug ) ]
33- pub struct MemWriter < const N : usize > {
33+ pub struct MemWriter {
3434 schema : Schema ,
3535 // for checking uniqueness of schema
3636 schema_map : HashSet < String > ,
3737 read_buffer : Vec < RecordBatch > ,
38- mutable_buffer : MutableBuffer < N > ,
38+ mutable_buffer : MutableBuffer ,
3939}
4040
41- impl < const N : usize > Default for MemWriter < N > {
41+ impl Default for MemWriter {
4242 fn default ( ) -> Self {
4343 Self {
4444 schema : Schema :: empty ( ) ,
@@ -49,7 +49,7 @@ impl<const N: usize> Default for MemWriter<N> {
4949 }
5050}
5151
52- impl < const N : usize > MemWriter < N > {
52+ impl MemWriter {
5353 pub fn push ( & mut self , schema_key : & str , rb : RecordBatch ) {
5454 if !self . schema_map . contains ( schema_key) {
5555 self . schema_map . insert ( schema_key. to_owned ( ) ) ;
@@ -83,15 +83,17 @@ fn concat_records(schema: &Arc<Schema>, record: &[RecordBatch]) -> RecordBatch {
8383}
8484
8585#[ derive( Debug , Default ) ]
86- struct MutableBuffer < const N : usize > {
86+ struct MutableBuffer {
8787 pub inner : Vec < RecordBatch > ,
8888 pub rows : usize ,
8989}
9090
91- impl < const N : usize > MutableBuffer < N > {
91+ impl MutableBuffer {
9292 fn push ( & mut self , rb : RecordBatch ) -> Option < Vec < RecordBatch > > {
93- if self . rows + rb. num_rows ( ) >= N {
94- let left = N - self . rows ;
93+ let maxima = CONFIG . parseable . records_per_request ;
94+
95+ if self . rows + rb. num_rows ( ) >= maxima {
96+ let left = maxima - self . rows ;
9597 let right = rb. num_rows ( ) - left;
9698 let left_slice = rb. slice ( 0 , left) ;
9799 let right_slice = if left < rb. num_rows ( ) {
0 commit comments