当前位置: 首页>>代码示例>>Java>>正文


Java Multiplicity类代码示例

本文整理汇总了Java中com.thinkaurelius.titan.core.Multiplicity的典型用法代码示例。如果您正苦于以下问题:Java Multiplicity类的具体用法?Java Multiplicity怎么用?Java Multiplicity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Multiplicity类属于com.thinkaurelius.titan.core包,在下文中一共展示了Multiplicity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testValueOrdering

import com.thinkaurelius.titan.core.Multiplicity; //导入依赖的package包/类
@Test
public void testValueOrdering() {
    StandardTitanGraph graph = (StandardTitanGraph) StorageSetup.getInMemoryGraph();
    TitanManagement mgmt = graph.openManagement();
    EdgeLabel father = mgmt.makeEdgeLabel("father").multiplicity(Multiplicity.MANY2ONE).make();
    for (int i=1;i<=5;i++) mgmt.makePropertyKey("key" + i).dataType(Integer.class).make();
    mgmt.commit();

    TitanVertex v1 = graph.addVertex(), v2 = graph.addVertex();
    TitanEdge e1 = v1.addEdge("father",v2);
    for (int i=1;i<=5;i++) e1.property("key"+i,i);

    graph.tx().commit();

    e1.remove();
    graph.tx().commit();

}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:19,代码来源:EdgeSerializerTest.java

示例2: testMultiplicityCardinality

import com.thinkaurelius.titan.core.Multiplicity; //导入依赖的package包/类
@Test
public void testMultiplicityCardinality() {
    assertEquals(Multiplicity.MULTI,Multiplicity.convert(Cardinality.LIST));
    assertEquals(Multiplicity.SIMPLE,Multiplicity.convert(Cardinality.SET));
    assertEquals(Multiplicity.MANY2ONE,Multiplicity.convert(Cardinality.SINGLE));

    assertEquals(Multiplicity.MULTI.getCardinality(),Cardinality.LIST);
    assertEquals(Multiplicity.SIMPLE.getCardinality(),Cardinality.SET);
    assertEquals(Multiplicity.MANY2ONE.getCardinality(),Cardinality.SINGLE);

    assertFalse(Multiplicity.MULTI.isConstrained());
    assertTrue(Multiplicity.SIMPLE.isConstrained());
    assertTrue(Multiplicity.ONE2ONE.isConstrained());

    assertTrue(Multiplicity.ONE2ONE.isConstrained(Direction.BOTH));
    assertTrue(Multiplicity.SIMPLE.isConstrained(Direction.BOTH));

    assertFalse(Multiplicity.MULTI.isUnique(Direction.OUT));
    assertTrue(Multiplicity.MANY2ONE.isUnique(Direction.OUT));
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:21,代码来源:TestCoreElements.java

示例3: StandardRelationTypeMaker

import com.thinkaurelius.titan.core.Multiplicity; //导入依赖的package包/类
public StandardRelationTypeMaker(final StandardTitanTx tx, String name,
                                 final IndexSerializer indexSerializer,
                                 final AttributeHandler attributeHandler) {
    Preconditions.checkNotNull(tx);
    Preconditions.checkNotNull(indexSerializer);
    Preconditions.checkNotNull(attributeHandler);
    this.tx = tx;
    this.indexSerializer = indexSerializer;
    this.attributeHandler = attributeHandler;
    name(name);

    //Default assignments
    isInvisible = false;
    sortKey = new ArrayList<>(4);
    sortOrder = Order.ASC;
    signature = new ArrayList<>(4);
    multiplicity = Multiplicity.MULTI;
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:19,代码来源:StandardRelationTypeMaker.java

示例4: testValueOrdering

import com.thinkaurelius.titan.core.Multiplicity; //导入依赖的package包/类
@Test
public void testValueOrdering() {
    StandardTitanGraph graph = (StandardTitanGraph) StorageSetup.getInMemoryGraph();
    TitanManagement mgmt = graph.getManagementSystem();
    EdgeLabel father = mgmt.makeEdgeLabel("father").multiplicity(Multiplicity.MANY2ONE).make();
    for (int i=1;i<=5;i++) mgmt.makePropertyKey("key" + i).dataType(Integer.class).make();
    mgmt.commit();

    TitanVertex v1 = graph.addVertex(null), v2 = graph.addVertex(null);
    TitanEdge e1 = v1.addEdge("father",v2);
    for (int i=1;i<=5;i++) e1.setProperty("key"+i,i);

    graph.commit();

    e1.remove();
    graph.commit();

}
 
开发者ID:graben1437,项目名称:titan0.5.4-hbase1.1.1-custom,代码行数:19,代码来源:EdgeSerializerTest.java

示例5: StandardRelationTypeMaker

import com.thinkaurelius.titan.core.Multiplicity; //导入依赖的package包/类
public StandardRelationTypeMaker(final StandardTitanTx tx, final IndexSerializer indexSerializer,
                                 final AttributeHandling attributeHandler) {
    Preconditions.checkNotNull(tx);
    Preconditions.checkNotNull(indexSerializer);
    Preconditions.checkNotNull(attributeHandler);
    this.tx = tx;
    this.indexSerializer = indexSerializer;
    this.attributeHandler = attributeHandler;

    //Default assignments
    name = null;
    isHidden = false;
    sortKey = new ArrayList<RelationType>(4);
    sortOrder = Order.ASC;
    signature = new ArrayList<RelationType>(4);
    multiplicity = Multiplicity.MULTI;
}
 
开发者ID:graben1437,项目名称:titan0.5.4-hbase1.1.1-custom,代码行数:18,代码来源:StandardRelationTypeMaker.java

示例6: testBatchLoadingLocking

import com.thinkaurelius.titan.core.Multiplicity; //导入依赖的package包/类
public void testBatchLoadingLocking(boolean batchloading) {
        PropertyKey uid = makeKey("uid",Long.class);
        TitanGraphIndex uidIndex = mgmt.buildIndex("uid",Vertex.class).unique().addKey(uid).buildCompositeIndex();
        mgmt.setConsistency(uid, ConsistencyModifier.LOCK);
        mgmt.setConsistency(uidIndex,ConsistencyModifier.LOCK);
        EdgeLabel knows = mgmt.makeEdgeLabel("knows").multiplicity(Multiplicity.ONE2ONE).make();
        mgmt.setConsistency(knows,ConsistencyModifier.LOCK);
        finishSchema();

        TestLockerManager.ERROR_ON_LOCKING=true;
        clopen(option(GraphDatabaseConfiguration.STORAGE_BATCH),batchloading,
                option(GraphDatabaseConfiguration.LOCK_BACKEND),"test");


        int numV = 10000;
        long start = System.currentTimeMillis();
        for (int i=0;i<numV;i++) {
            TitanVertex v = tx.addVertex();
            v.setProperty("uid",i+1);
            v.addEdge("knows",v);
        }
        clopen();
//        System.out.println("Time: " + (System.currentTimeMillis()-start));

        for (int i=0;i<Math.min(numV,300);i++) {
            assertEquals(1, Iterables.size(graph.query().has("uid", i + 1).vertices()));
            assertEquals(1, Iterables.size(graph.query().has("uid", i + 1).vertices().iterator().next().getEdges(Direction.OUT, "knows")));
        }
    }
 
开发者ID:graben1437,项目名称:titan0.5.4-hbase1.1.1-custom,代码行数:30,代码来源:TitanEventualGraphTest.java

示例7: getEdgeLabel

import com.thinkaurelius.titan.core.Multiplicity; //导入依赖的package包/类
@Override
public EdgeLabelDefinition getEdgeLabel(String name) {
    Multiplicity multi = Multiplicity.MULTI;
    if (name.startsWith("m2o")) multi = Multiplicity.MANY2ONE;
    else if (name.startsWith("o2m")) multi = Multiplicity.ONE2MANY;
    else if (name.startsWith("o2o")) multi = Multiplicity.ONE2ONE;
    else if (name.startsWith("simple")) multi = Multiplicity.SIMPLE;
    return new EdgeLabelDefinition(name, getId(), multi, false);
}
 
开发者ID:graben1437,项目名称:titan0.5.4-hbase1.1.1-custom,代码行数:10,代码来源:TestSchemaProvider.java

示例8: asTitanMultiplicity

import com.thinkaurelius.titan.core.Multiplicity; //导入依赖的package包/类
public static final Multiplicity asTitanMultiplicity(Arity fromArity, Arity toArity) {
  switch(fromArity) {

    case One: switch (toArity) {
      case One:        return Multiplicity.ONE2ONE;
      case AtMostOne:  return Multiplicity.ONE2ONE;
      case AtLeastOne: return Multiplicity.ONE2MANY;
      default:         return Multiplicity.ONE2MANY;
    }

    case AtMostOne: switch (toArity) {
      case One:        return Multiplicity.ONE2ONE;
      case AtMostOne:  return Multiplicity.ONE2ONE;
      case AtLeastOne: return Multiplicity.ONE2MANY;
      default:         return Multiplicity.ONE2MANY;
    }

    case AtLeastOne: switch (toArity) {
      case One:        return Multiplicity.MANY2ONE;
      case AtMostOne:  return Multiplicity.MANY2ONE;
      case AtLeastOne: return Multiplicity.MULTI;
      default:         return Multiplicity.MULTI;
    }

    default: switch(toArity) {
      case One:        return Multiplicity.MANY2ONE;
      case AtMostOne:  return Multiplicity.MANY2ONE;
      case AtLeastOne: return Multiplicity.MULTI;
      default:         return Multiplicity.MULTI;
    }
  }
}
 
开发者ID:bio4j,项目名称:angulillos-titan,代码行数:33,代码来源:TitanConversions.java

示例9: testSchemaNameChange

import com.thinkaurelius.titan.core.Multiplicity; //导入依赖的package包/类
@Test
public void testSchemaNameChange() {
    PropertyKey time = mgmt.makePropertyKey("time").dataType(Integer.class).cardinality(Cardinality.SINGLE).make();
    EdgeLabel knows = mgmt.makeEdgeLabel("knows").multiplicity(Multiplicity.MULTI).make();
    mgmt.buildEdgeIndex(knows, "byTime", Direction.BOTH, time);
    mgmt.buildIndex("timeIndex", Vertex.class).addKey(time).buildCompositeIndex();
    mgmt.makeVertexLabel("people").make();
    finishSchema();

    //CREATE SMALL GRAPH
    TitanVertex v = tx.addVertex("people");
    v.property(VertexProperty.Cardinality.single, "time", 5);
    v.addEdge("knows", v, "time", 11);

    newTx();
    v = getOnlyElement(tx.query().has("time", 5).vertices());
    assertNotNull(v);
    assertEquals("people", v.label());
    assertEquals(5, v.<Integer>value("time").intValue());
    assertCount(1, v.query().direction(Direction.IN).labels("knows").edges());
    assertCount(1, v.query().direction(Direction.OUT).labels("knows").has("time", 11).edges());
    newTx();

    //UPDATE SCHEMA NAMES

    assertTrue(mgmt.containsRelationType("knows"));
    knows = mgmt.getEdgeLabel("knows");
    mgmt.changeName(knows, "know");
    assertEquals("know", knows.name());

    assertTrue(mgmt.containsRelationIndex(knows, "byTime"));
    RelationTypeIndex rindex = mgmt.getRelationIndex(knows, "byTime");
    assertEquals("byTime", rindex.name());
    mgmt.changeName(rindex, "overTime");
    assertEquals("overTime", rindex.name());

    assertTrue(mgmt.containsVertexLabel("people"));
    VertexLabel vl = mgmt.getVertexLabel("people");
    mgmt.changeName(vl, "person");
    assertEquals("person", vl.name());

    assertTrue(mgmt.containsGraphIndex("timeIndex"));
    TitanGraphIndex gindex = mgmt.getGraphIndex("timeIndex");
    mgmt.changeName(gindex, "byTime");
    assertEquals("byTime", gindex.name());

    finishSchema();

    //VERIFY UPDATES IN MGMT SYSTEM

    assertTrue(mgmt.containsRelationType("know"));
    assertFalse(mgmt.containsRelationType("knows"));
    knows = mgmt.getEdgeLabel("know");

    assertTrue(mgmt.containsRelationIndex(knows, "overTime"));
    assertFalse(mgmt.containsRelationIndex(knows, "byTime"));

    assertTrue(mgmt.containsVertexLabel("person"));
    assertFalse(mgmt.containsVertexLabel("people"));

    assertTrue(mgmt.containsGraphIndex("byTime"));
    assertFalse(mgmt.containsGraphIndex("timeIndex"));

    //VERIFY UPDATES IN TRANSACTION
    newTx();
    v = getOnlyElement(tx.query().has("time", 5).vertices());
    assertNotNull(v);
    assertEquals("person", v.label());
    assertEquals(5, v.<Integer>value("time").intValue());
    assertCount(1, v.query().direction(Direction.IN).labels("know").edges());
    assertCount(0, v.query().direction(Direction.IN).labels("knows").edges());
    assertCount(1, v.query().direction(Direction.OUT).labels("know").has("time", 11).edges());
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:74,代码来源:TitanGraphTest.java

示例10: testCreateDelete

import com.thinkaurelius.titan.core.Multiplicity; //导入依赖的package包/类
@Test
public void testCreateDelete() {
    makeKey("weight", Double.class);
    PropertyKey uid = makeVertexIndexedUniqueKey("uid", Integer.class);
    ((StandardEdgeLabelMaker) mgmt.makeEdgeLabel("knows")).sortKey(uid).sortOrder(Order.DESC).directed().make();
    mgmt.makeEdgeLabel("father").multiplicity(Multiplicity.MANY2ONE).make();
    finishSchema();

    TitanVertex v1 = graph.addVertex(), v3 = graph.addVertex("uid", 445);
    Edge e = v3.addEdge("knows", v1, "uid", 111);
    Edge e2 = v1.addEdge("friend", v3);
    assertEquals(111, e.<Integer>value("uid").intValue());
    graph.tx().commit();

    v3 = getV(graph, v3);
    assertEquals(445, v3.<Integer>value("uid").intValue());
    e = getOnlyElement(v3.query().direction(Direction.OUT).labels("knows").edges());
    assertEquals(111, e.<Integer>value("uid").intValue());
    assertEquals(e, getE(graph, e.id()));
    assertEquals(e, getE(graph, e.id().toString()));
    VertexProperty p = getOnlyElement(v3.properties("uid"));
    p.remove();
    v3.property("uid", 353);

    e = getOnlyElement(v3.query().direction(Direction.OUT).labels("knows").edges());
    e.property("uid", 222);

    e2 = getOnlyElement(v1.query().direction(Direction.OUT).labels("friend").edges());
    e2.property("uid", 1);
    e2.property("weight", 2.0);

    assertEquals(1, e2.<Integer>value("uid").intValue());
    assertEquals(2.0, e2.<Double>value("weight").doubleValue(), 0.0001);


    clopen();

    v3 = getV(graph, v3.id());
    assertEquals(353, v3.<Integer>value("uid").intValue());

    e = getOnlyElement(v3.query().direction(Direction.OUT).labels("knows").edges());
    assertEquals(222, e.<Integer>value("uid").intValue());
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:44,代码来源:TitanGraphTest.java

示例11: getMultiplicity

import com.thinkaurelius.titan.core.Multiplicity; //导入依赖的package包/类
protected Multiplicity getMultiplicity() {
    return multiplicity;
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:4,代码来源:StandardRelationTypeMaker.java

示例12: multiplicity

import com.thinkaurelius.titan.core.Multiplicity; //导入依赖的package包/类
@Override
public Multiplicity multiplicity() {
    return getDefinition().getValue(TypeDefinitionCategory.MULTIPLICITY, Multiplicity.class);
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:5,代码来源:RelationTypeVertex.java

示例13: multiplicity

import com.thinkaurelius.titan.core.Multiplicity; //导入依赖的package包/类
@Override
public Multiplicity multiplicity() {
    return Multiplicity.convert(cardinality());
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:5,代码来源:BaseKey.java

示例14: BaseLabel

import com.thinkaurelius.titan.core.Multiplicity; //导入依赖的package包/类
private BaseLabel(String name, int id, Direction uniDirectionality, Multiplicity multiplicity) {
    super(name, id, TitanSchemaCategory.EDGELABEL);
    this.directionality = uniDirectionality;
    this.multiplicity = multiplicity;
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:6,代码来源:BaseLabel.java

示例15: multiplicity

import com.thinkaurelius.titan.core.Multiplicity; //导入依赖的package包/类
@Override
public Multiplicity multiplicity() {
    return multiplicity;
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:5,代码来源:BaseLabel.java


注:本文中的com.thinkaurelius.titan.core.Multiplicity类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。