This project has retired. For details please refer to its Attic page.
MappingStoreOps xref
View Javadoc

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.mapping;
20  
21  import org.apache.hadoop.io.Writable;
22  import org.apache.hadoop.io.WritableComparable;
23  
24  /**
25   * Interface of operations that can be done on mapping store
26   * once it is fully loaded
27   *
28   * @param <I> vertex id type
29   * @param <B> mapping target type
30   */
31  public interface MappingStoreOps<I extends WritableComparable,
32    B extends Writable> {
33  
34    /**
35     * Must be called before anything else can be done
36     * on this instance
37     * @param mappingStore mapping store instance to operate on
38     */
39    void initialize(MappingStore<I, B> mappingStore);
40  
41    /**
42     * True if MappingStoreOps is based on embedding info
43     *
44     * @return true if worker info is embedded into vertex ids
45     */
46    boolean hasEmbedding();
47  
48    /**
49     * Embed target information into vertexId
50     *
51     * @param id vertexId
52     */
53    void embedTargetInfo(I id);
54  
55    /**
56     * Remove target information from vertexId
57     *
58     * @param id vertexId
59     */
60    void removeTargetInfo(I id);
61  
62  
63    /**
64     * Get partition id for a vertex id
65     *
66     * @param id vertexId
67     * @param partitionCount partitionCount
68     * @param workerCount workerCount
69     * @return partition of vertex id
70     */
71    int getPartition(I id, int partitionCount, int workerCount);
72  }