Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
RangePartitionStats |
|
| 1.6666666666666667;1.667 |
1 | /* | |
2 | * Licensed to the Apache Software Foundation (ASF) under one | |
3 | * or more contributor license agreements. See the NOTICE file | |
4 | * distributed with this work for additional information | |
5 | * regarding copyright ownership. The ASF licenses this file | |
6 | * to you under the Apache License, Version 2.0 (the | |
7 | * "License"); you may not use this file except in compliance | |
8 | * with the License. You may obtain a copy of the License at | |
9 | * | |
10 | * http://www.apache.org/licenses/LICENSE-2.0 | |
11 | * | |
12 | * Unless required by applicable law or agreed to in writing, software | |
13 | * distributed under the License is distributed on an "AS IS" BASIS, | |
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
15 | * See the License for the specific language governing permissions and | |
16 | * limitations under the License. | |
17 | */ | |
18 | ||
19 | package org.apache.giraph.graph.partition; | |
20 | ||
21 | import java.io.DataInput; | |
22 | import java.io.DataOutput; | |
23 | import java.io.IOException; | |
24 | ||
25 | import org.apache.hadoop.io.WritableComparable; | |
26 | ||
27 | /** | |
28 | * Same as {@link PartitionStats}, but also includes the hint for range-based | |
29 | * partitioning. | |
30 | * | |
31 | * @param <I> Vertex index type | |
32 | */ | |
33 | @SuppressWarnings("rawtypes") | |
34 | 0 | public class RangePartitionStats<I extends WritableComparable> |
35 | extends PartitionStats { | |
36 | /** Can be null if no hint, otherwise a splitting hint */ | |
37 | private RangeSplitHint<I> hint; | |
38 | ||
39 | /** | |
40 | * Get the range split hint (if any) | |
41 | * | |
42 | * @return Hint of how to split the range if desired, null otherwise | |
43 | */ | |
44 | public RangeSplitHint<I> getRangeSplitHint() { | |
45 | 0 | return hint; |
46 | } | |
47 | ||
48 | @Override | |
49 | public void readFields(DataInput input) throws IOException { | |
50 | 0 | super.readFields(input); |
51 | 0 | boolean hintExists = input.readBoolean(); |
52 | 0 | if (hintExists) { |
53 | 0 | hint = new RangeSplitHint<I>(); |
54 | 0 | hint.readFields(input); |
55 | } else { | |
56 | 0 | hint = null; |
57 | } | |
58 | 0 | } |
59 | ||
60 | @Override | |
61 | public void write(DataOutput output) throws IOException { | |
62 | 0 | super.write(output); |
63 | 0 | output.writeBoolean(hint != null); |
64 | 0 | if (hint != null) { |
65 | 0 | hint.write(output); |
66 | } | |
67 | 0 | } |
68 | } |