]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_putobj.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab ft=cpp
5 * Ceph - scalable distributed file system
7 * Copyright (C) 2018 Red Hat, Inc.
9 * This is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License version 2.1, as published by the Free Software
12 * Foundation. See file COPYING.
18 #include "include/buffer.h"
20 namespace rgw::putobj
{
22 // a simple streaming data processing abstraction
25 virtual ~DataProcessor() {}
27 // consume a bufferlist in its entirety at the given object offset. an
28 // empty bufferlist is given to request that any buffered data be flushed,
29 // though this doesn't wait for completions
30 virtual int process(bufferlist
&& data
, uint64_t offset
) = 0;
33 // for composing data processors into a pipeline
34 class Pipe
: public DataProcessor
{
37 explicit Pipe(DataProcessor
*next
) : next(next
) {}
39 // passes the data on to the next processor
40 int process(bufferlist
&& data
, uint64_t offset
) override
{
41 return next
->process(std::move(data
), offset
);
45 // pipe that writes to the next processor in discrete chunks
46 class ChunkProcessor
: public Pipe
{
48 bufferlist chunk
; // leftover bytes from the last call to process()
50 ChunkProcessor(DataProcessor
*next
, uint64_t chunk_size
)
51 : Pipe(next
), chunk_size(chunk_size
)
54 int process(bufferlist
&& data
, uint64_t offset
) override
;
58 // interface to generate the next stripe description
59 class StripeGenerator
{
61 virtual ~StripeGenerator() {}
63 virtual int next(uint64_t offset
, uint64_t *stripe_size
) = 0;
66 // pipe that respects stripe boundaries and restarts each stripe at offset 0
67 class StripeProcessor
: public Pipe
{
69 std::pair
<uint64_t, uint64_t> bounds
; // bounds of current stripe
71 StripeProcessor(DataProcessor
*next
, StripeGenerator
*gen
,
72 uint64_t first_stripe_size
)
73 : Pipe(next
), gen(gen
), bounds(0, first_stripe_size
)
76 int process(bufferlist
&& data
, uint64_t data_offset
) override
;
79 } // namespace rgw::putobj