pub fn introduce_batch(&mut self, batch: Option<B>, batch_index: usize) {
        // Step 0.  Determine an amount of fuel to use for the computation.
        //
        //          Fuel is used to drive maintenance of the data structure,
        //          and in particular are used to make progress through merges
        //          that are in progress. The amount of fuel to use should be
        //          proportional to the number of records introduced, so that
        //          we are guaranteed to complete all merges before they are
        //          required as arguments to merges again.
        //
        //          The fuel use policy is negotiable, in that we might aim
        //          to use relatively less when we can, so that we return
        //          control promptly, or we might account more work to larger
        //          batches. Not clear to me which are best, of if there
        //          should be a configuration knob controlling this.

        // The amount of fuel to use is proportional to 2^batch_index, scaled
        // by a factor of self.effort which determines how eager we are in
        // performing maintenance work. We need to ensure that each merge in
        // progress receives fuel for each introduced batch, and so multiply
        // by that as well.
        // Leonid: We deliberately hit this path in `consolidate`.
        /*
        if batch_index > 32 {
            println!("Large batch index: {}", batch_index);
        }
        */

        // We believe that eight units of fuel is sufficient for each introduced
        // record, accounted as four for each record, and a potential four more
        // for each virtual record associated with promoting existing smaller
        // batches. We could try and make this be less, or be scaled to merges
        // based on their deficit at time of instantiation. For now, we remain
        // conservative.
        let mut fuel = 8 << batch_index;
        // Scale up by the effort parameter, which is calibrated to one as the
        // minimum amount of effort.
        fuel *= self.effort;
        // Convert to an `isize` so we can observe any fuel shortfall.
        let mut fuel = fuel as isize;

        // Step 1.  Apply fuel to each in-progress merge.
        //
        //          Before we can introduce new updates, we must apply any
        //          fuel to in-progress merges, as this fuel is what ensures
        //          that the merges will be complete by the time we insert
        //          the updates.
        self.apply_fuel(&mut fuel);

        // Step 2.  We must ensure the invariant that adjacent layers do not
        //          contain two batches will be satisfied when we insert the
        //          batch. We forcibly completing all merges at layers lower
        //          than and including `batch_index`, so that the new batch
        //          is inserted into an empty layer.
        //
        //          We could relax this to "strictly less than `batch_index`"
        //          if the layer above has only a single batch in it, which
        //          seems not implausible if it has been the focus of effort.
        //
        //          This should be interpreted as the introduction of some
        //          volume of fake updates, and we will need to fuel merges
        //          by a proportional amount to ensure that they are not
        //          surprised later on. The number of fake updates should
        //          correspond to the deficit for the layer, which perhaps
        //          we should track explicitly.
        self.roll_up(batch_index);

        // Step 3. This insertion should be into an empty layer. It is a
        //         logical error otherwise, as we may be violating our
        //         invariant, from which all wonderment derives.
        self.insert_at(batch, batch_index);

        // Step 4. Tidy the largest layers.
        //
        //         It is important that we not tidy only smaller layers,
        //         as their ascension is what ensures the merging and
        //         eventual compaction of the largest layers.
        self.tidy_layers();
    }
/// Introduces a batch at an indicated level.
///
/// The level indication is often related to the size of the batch, but
/// it can also be used to artificially fuel the computation by supplying
/// empty batches at non-trivial indices, to move merges along.
Introduces a batch at an indicated level.
The level indication is often related to the size of the batch, but
it can also be used to artificially fuel the computation by supplying
empty batches at non-trivial indices, to move merges along.
Introduces a batch at an indicated level . The level indication is often related to the size of the batch but it can also be used to artificially fuel the computation by supplying empty batches at non - trivial indices to move merges along .
pub fn introduce_batch(&mut self, batch: Option<B>, batch_index: usize) {
        // Step 0.  Determine an amount of fuel to use for the computation.
        //
        //          Fuel is used to drive maintenance of the data structure,
        //          and in particular are used to make progress through merges
        //          that are in progress. The amount of fuel to use should be
        //          proportional to the number of records introduced, so that
        //          we are guaranteed to complete all merges before they are
        //          required as arguments to merges again.
        //
        //          The fuel use policy is negotiable, in that we might aim
        //          to use relatively less when we can, so that we return
        //          control promptly, or we might account more work to larger
        //          batches. Not clear to me which are best, of if there
        //          should be a configuration knob controlling this.
        // The amount of fuel to use is proportional to 2^batch_index, scaled
        // by a factor of self.effort which determines how eager we are in
        // performing maintenance work. We need to ensure that each merge in
        // progress receives fuel for each introduced batch, and so multiply
        // by that as well.
        // Leonid: We deliberately hit this path in `consolidate`.
        /*
        if batch_index > 32 {
            println!("Large batch index: {}", batch_index);
        }
        */
        // We believe that eight units of fuel is sufficient for each introduced
        // record, accounted as four for each record, and a potential four more
        // for each virtual record associated with promoting existing smaller
        // batches. We could try and make this be less, or be scaled to merges
        // based on their deficit at time of instantiation. For now, we remain
        // conservative.
        let mut fuel = 8 << batch_index;
        // Scale up by the effort parameter, which is calibrated to one as the
        // minimum amount of effort.
        fuel *= self.effort;
        // Convert to an `isize` so we can observe any fuel shortfall.
        let mut fuel = fuel as isize;
        // Step 1.  Apply fuel to each in-progress merge.
        //
        //          Before we can introduce new updates, we must apply any
        //          fuel to in-progress merges, as this fuel is what ensures
        //          that the merges will be complete by the time we insert
        //          the updates.
        self.apply_fuel(&mut fuel);
        // Step 2.  We must ensure the invariant that adjacent layers do not
        //          contain two batches will be satisfied when we insert the
        //          batch. We forcibly completing all merges at layers lower
        //          than and including `batch_index`, so that the new batch
        //          is inserted into an empty layer.
        //
        //          We could relax this to "strictly less than `batch_index`"
        //          if the layer above has only a single batch in it, which
        //          seems not implausible if it has been the focus of effort.
        //
        //          This should be interpreted as the introduction of some
        //          volume of fake updates, and we will need to fuel merges
        //          by a proportional amount to ensure that they are not
        //          surprised later on. The number of fake updates should
        //          correspond to the deficit for the layer, which perhaps
        //          we should track explicitly.
        self.roll_up(batch_index);
        // Step 3. This insertion should be into an empty layer. It is a
        //         logical error otherwise, as we may be violating our
        //         invariant, from which all wonderment derives.
        self.insert_at(batch, batch_index);
        // Step 4. Tidy the largest layers.
        //
        //         It is important that we not tidy only smaller layers,
        //         as their ascension is what ensures the merging and
        //         eventual compaction of the largest layers.
        self.tidy_layers();
    }
pub fn introduce_batch ( & mut self , batch : Option < B > , batch_index : usize ) { // Step 0.  Determine an amount of fuel to use for the computation. // //          Fuel is used to drive maintenance of the data structure, //          and in particular are used to make progress through merges //          that are in progress. The amount of fuel to use should be //          proportional to the number of records introduced, so that //          we are guaranteed to complete all merges before they are //          required as arguments to merges again. // //          The fuel use policy is negotiable, in that we might aim //          to use relatively less when we can, so that we return //          control promptly, or we might account more work to larger //          batches. Not clear to me which are best, of if there //          should be a configuration knob controlling this. // The amount of fuel to use is proportional to 2^batch_index, scaled // by a factor of self.effort which determines how eager we are in // performing maintenance work. We need to ensure that each merge in // progress receives fuel for each introduced batch, and so multiply // by that as well. // Leonid: We deliberately hit this path in `consolidate`. /*
        if batch_index > 32 {
            println!("Large batch index: {}", batch_index);
        }
        */ // We believe that eight units of fuel is sufficient for each introduced // record, accounted as four for each record, and a potential four more // for each virtual record associated with promoting existing smaller // batches. We could try and make this be less, or be scaled to merges // based on their deficit at time of instantiation. For now, we remain // conservative. let mut fuel = 8 << batch_index ; // Scale up by the effort parameter, which is calibrated to one as the // minimum amount of effort. fuel *= self . effort ; // Convert to an `isize` so we can observe any fuel shortfall. let mut fuel = fuel as isize ; // Step 1.  Apply fuel to each in-progress merge. // //          Before we can introduce new updates, we must apply any //          fuel to in-progress merges, as this fuel is what ensures //          that the merges will be complete by the time we insert //          the updates. self . apply_fuel ( & mut fuel ) ; // Step 2.  We must ensure the invariant that adjacent layers do not //          contain two batches will be satisfied when we insert the //          batch. We forcibly completing all merges at layers lower //          than and including `batch_index`, so that the new batch //          is inserted into an empty layer. // //          We could relax this to "strictly less than `batch_index`" //          if the layer above has only a single batch in it, which //          seems not implausible if it has been the focus of effort. // //          This should be interpreted as the introduction of some //          volume of fake updates, and we will need to fuel merges //          by a proportional amount to ensure that they are not //          surprised later on. The number of fake updates should //          correspond to the deficit for the layer, which perhaps //          we should track explicitly. self . roll_up ( batch_index ) ; // Step 3. This insertion should be into an empty layer. It is a //         logical error otherwise, as we may be violating our //         invariant, from which all wonderment derives. self . insert_at ( batch , batch_index ) ; // Step 4. Tidy the largest layers. // //         It is important that we not tidy only smaller layers, //         as their ascension is what ensures the merging and //         eventual compaction of the largest layers. self . tidy_layers ( ) ; }
Introduces a batch at an indicated level.
Introduces a batch at an indicated level .
&mut self
batch
Option<B>
batch_index
usize