libfoedus-core
FOEDUS Core Library
sequential_partitioner_impl.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2015, Hewlett-Packard Development Company, LP.
3  * This program is free software; you can redistribute it and/or modify it
4  * under the terms of the GNU General Public License as published by the Free
5  * Software Foundation; either version 2 of the License, or (at your option)
6  * any later version.
7  *
8  * This program is distributed in the hope that it will be useful, but WITHOUT
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11  * more details. You should have received a copy of the GNU General Public
12  * License along with this program; if not, write to the Free Software
13  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14  *
15  * HP designates this particular file as subject to the "Classpath" exception
16  * as provided by HP in the LICENSE.txt file that accompanied this code.
17  */
19 
20 #include <cstring>
21 #include <ostream>
22 
23 namespace foedus {
24 namespace storage {
25 namespace sequential {
26 
28  : engine_(parent->get_engine()),
29  id_(parent->get_storage_id()),
30  metadata_(PartitionerMetadata::get_metadata(engine_, id_)) {
31 }
32 
34  const Partitioner::DesignPartitionArguments& /*args*/) {
35  // no data required for SequentialPartitioner
36  metadata_->data_offset_ = 0;
37  metadata_->data_size_ = 0;
38  metadata_->valid_ = true;
39  return kRetOk;
40 }
41 
43  const Partitioner::PartitionBatchArguments& args) const {
44  // all local
45  for (uint32_t i = 0; i < args.logs_count_; ++i) {
46  args.results_[i] = args.local_partition_;
47  }
48 }
49 
51  // no sorting needed.
52  std::memcpy(
53  args.output_buffer_,
54  args.log_positions_,
55  sizeof(snapshot::BufferPosition) * args.logs_count_);
56  *args.written_count_ = args.logs_count_;
57 }
58 
59 
60 std::ostream& operator<<(std::ostream& o, const SequentialPartitioner& /*v*/) {
61  o << "<SequentialPartitioner>"
62  << "</SequentialPartitioner>";
63  return o;
64 }
65 
66 } // namespace sequential
67 } // namespace storage
68 } // namespace foedus
bool valid_
Whether this partitioner information (metadata+data) has been constructed.
uint32_t * written_count_
[OUT] how many logs written to output_buffer.
PartitionId * results_
[OUT] this method will set the partition of logs[i] to results[i].
uint32_t logs_count_
number of entries to process.
std::ostream & operator<<(std::ostream &o, const SequentialCursor &v)
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
Definition: assert_nd.hpp:44
uint32_t logs_count_
number of entries to process.
uint32_t BufferPosition
Represents a position in some buffer.
Definition: snapshot_id.hpp:72
Brings error stacktrace information as return value of functions.
Definition: error_stack.hpp:81
ErrorStack design_partition(const Partitioner::DesignPartitionArguments &args)
snapshot::BufferPosition * output_buffer_
sorted results are written to this variable.
uint32_t data_size_
The size of the partitioner data.
void sort_batch(const Partitioner::SortBatchArguments &args) const
const snapshot::BufferPosition * log_positions_
positions of log records.
uint32_t data_offset_
Relative offset from the beginning of partitioner data block that points to variable-sized partitione...
Tiny metadata of partitioner for every storage used while log gleaning.
const ErrorStack kRetOk
Normal return value for no-error case.
Partitioning and sorting logic for one storage.
Definition: partitioner.hpp:70
void partition_batch(const Partitioner::PartitionBatchArguments &args) const
PartitionId local_partition_
The node the caller (mapper) resides in.