本文整理匯總了Java中com.thinkaurelius.titan.graphdb.database.idassigner.VertexIDAssigner類的典型用法代碼示例。如果您正苦於以下問題:Java VertexIDAssigner類的具體用法?Java VertexIDAssigner怎麽用?Java VertexIDAssigner使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
VertexIDAssigner類屬於com.thinkaurelius.titan.graphdb.database.idassigner包,在下文中一共展示了VertexIDAssigner類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testKeybasedGraphPartitioning
import com.thinkaurelius.titan.graphdb.database.idassigner.VertexIDAssigner; //導入依賴的package包/類
@Test
public void testKeybasedGraphPartitioning() {
Object[] options = {option(GraphDatabaseConfiguration.IDS_FLUSH), false,
option(VertexIDAssigner.PLACEMENT_STRATEGY), PropertyPlacementStrategy.class.getName(),
option(PropertyPlacementStrategy.PARTITION_KEY), "clusterId"};
clopen(options);
int[] groupDegrees = {5,5,5,5,5,5,5,5};
int numVertices = setupGroupClusters(groupDegrees,CommitMode.PER_VERTEX);
IntSet partitionIds = new IntHashSet(numVertices); //to track the "spread" of partition ids
for (int i=0;i<groupDegrees.length;i++) {
TitanVertex g = getOnlyVertex(tx.query().has("groupid","group"+i));
int partitionId = -1;
for (TitanVertex v : g.query().direction(Direction.IN).labels("member").vertices()) {
if (partitionId<0) partitionId = getPartitionID(v);
assertEquals(partitionId,getPartitionID(v));
partitionIds.add(partitionId);
}
}
assertTrue(partitionIds.size()>numPartitions/2); //This is a probabilistic test that might fail
}
示例2: VertexIDAssignerTest
import com.thinkaurelius.titan.graphdb.database.idassigner.VertexIDAssigner; //導入依賴的package包/類
/**
*
* @param numPartitionsBits The number of partitions bits to use. This means there are exactly (1<<numPartitionBits) partitions.
* @param partitionMax The maxium number of ids that can be allocated per partition. This is artifically constraint by the MockIDAuthority
* @param localPartitionDef This array contains three integers: 1+2) lower and upper bounds for the local partition range, and
* 3) the bit width of the local bounds. The bounds will be bitshifted forward to consume the bit width
*/
public VertexIDAssignerTest(int numPartitionsBits, int partitionMax, int[] localPartitionDef) {
MockIDAuthority idAuthority = new MockIDAuthority(11, partitionMax);
StandardStoreFeatures.Builder fb = new StandardStoreFeatures.Builder();
if (null != localPartitionDef) {
fb.localKeyPartition(true);
idAuthority.setLocalPartition(PartitionIDRangeTest.convert(localPartitionDef[0],localPartitionDef[1],localPartitionDef[2]));
}
StoreFeatures features = fb.build();
ModifiableConfiguration config = GraphDatabaseConfiguration.buildGraphConfiguration();
config.set(GraphDatabaseConfiguration.CLUSTER_MAX_PARTITIONS,1<<numPartitionsBits);
idAssigner = new VertexIDAssigner(config, idAuthority, features);
System.out.println(String.format("Configuration [%s|%s|%s]",numPartitionsBits,partitionMax,Arrays.toString(localPartitionDef)));
if (localPartitionDef!=null && localPartitionDef[0]<localPartitionDef[1] && localPartitionDef[2]<=numPartitionsBits) {
this.maxIDAssignments = ((localPartitionDef[1]-localPartitionDef[0])<<(numPartitionsBits-localPartitionDef[2]))*((long)partitionMax);
} else {
this.maxIDAssignments = (1<<numPartitionsBits)*((long)partitionMax);
}
}
示例3: VertexIDAssignerTest
import com.thinkaurelius.titan.graphdb.database.idassigner.VertexIDAssigner; //導入依賴的package包/類
public VertexIDAssignerTest(Boolean partition, int partitionMax, int[] localPartition) {
MockIDAuthority idAuthority = new MockIDAuthority(11, partitionMax);
StandardStoreFeatures.Builder fb = new StandardStoreFeatures.Builder();
if (null != localPartition) {
fb.localKeyPartition(true);
idAuthority.setLocalPartition(localPartition);
}
StoreFeatures features = fb.build();
ModifiableConfiguration config = GraphDatabaseConfiguration.buildConfiguration();
config.set(GraphDatabaseConfiguration.CLUSTER_PARTITION,partition);
config.set(GraphDatabaseConfiguration.CLUSTER_MAX_PARTITIONS,1024);
idAssigner = new VertexIDAssigner(config, idAuthority, features);
System.out.println("Partition: " + partition);
System.out.println("partitionMax: " + partitionMax);
System.out.println("localPartition: " + Arrays.toString(localPartition));
}
示例4: getIDAssigner
import com.thinkaurelius.titan.graphdb.database.idassigner.VertexIDAssigner; //導入依賴的package包/類
public VertexIDAssigner getIDAssigner(Backend backend) {
return new VertexIDAssigner(configuration, backend.getIDAuthority(), backend.getStoreFeatures());
}