Code Explainers
Code explainers tagged #batching
php
final class UserActivityStream { public function __construct( private readonly \PDO $db,
Streaming user activity with PHP generators
generators
pagination
lazy-evaluation
Intermediate
8 steps
rust
use std::collections::HashMap; #[derive(Debug, Clone)] struct Record {
Batched aggregation with fold in Rust
iterators
fold
hashmap
Intermediate
9 steps
ruby
class PurgeStaleExportsJob < ApplicationJob queue_as :maintenance retry_on ActiveRecord::Deadlocked, wait: :polynomially_longer, attempts: 5
Purging stale exports with an Active Job in Rails
background-jobs
batching
error-handling
Intermediate
7 steps
php
public function importUsers(array $users): int { $inserted = 0;
Bulk-inserting users with batched PDO upserts
batching
bulk-insert
prepared-statements
Intermediate
6 steps
python
from itertools import islice from typing import Iterable, Iterator, TypeVar T = TypeVar("T")
Batching an iterable for bulk indexing
generators
batching
lazy-evaluation
Intermediate
7 steps
ruby
class ReportBatcher BATCH_SIZE = 500 def initialize(account)
Batching monthly email summaries in Rails
batching
service-object
background-jobs
Intermediate
7 steps
typescript
export function chunk<T>(items: readonly T[], size: number): T[][] { if (size <= 0 || !Number.isInteger(size)) { throw new RangeError(`chunk size must be a positive integer, got ${size}`); }
Splitting work into sequential batches in TypeScript
generics
async-await
batching
Intermediate
5 steps