@Override
    protected void doLoad() {
      TitanKey weight = makeWeightPropertyKey("weight");
      TitanKey id = makeIntegerUIDPropertyKey("uid");
      TitanLabel knows = makeKeyedEdgeLabel("knows", id, weight);
      TitanKey name = makeUniqueStringPropertyKey("name");

      String[] names = new String[noNodes];
      TitanVertex[] nodes = new TitanVertex[noNodes];
      for (int i = 0; i < noNodes; i++) {
        do {
          names[i] = RandomGenerator.randomString();
          // Retry in case of collision with existing name
        } while (null != tx.getVertex(name, names[i]));
        nodes[i] = tx.addVertex();
        nodes[i].addProperty(name, names[i]);
        nodes[i].addProperty(id, i);
      }
      log.info("Nodes loaded.");
      int offsets[] = {-99, -71, -20, -17, -13, 2, 7, 15, 33, 89};
      assert offsets.length == noEdgesPerNode;

      for (int i = 0; i < noNodes; i++) {
        TitanVertex n = nodes[i];
        for (int e = 0; e < noEdgesPerNode; e++) {
          TitanVertex n2 = nodes[wrapAround(i + offsets[e], noNodes)];
          TitanEdge r = n.addEdge(knows, n2);
          r.addProperty(id, RandomGenerator.randomInt(0, Integer.MAX_VALUE));
          r.addProperty(weight, Math.random());
        }
        if ((i + 1) % 10000 == 0) System.out.println("" + (i + 1));
      }
    }
    @Override
    public void doLoad() {

      TitanLabel connect = makeSimpleEdgeLabel("connect");
      TitanKey name = makeUniqueStringPropertyKey("name");
      TitanKey id = makeIntegerUIDPropertyKey("uid");

      String[] names = new String[noNodes];
      TitanVertex[] nodes = new TitanVertex[noNodes];
      for (int i = 0; i < noNodes; i++) {
        do {
          names[i] = RandomGenerator.randomString();
          // Retry in case of collision with existing name
        } while (null != tx.getVertex(name, names[i]));
        nodes[i] = tx.addVertex();
        nodes[i].addProperty(name, names[i]);
        nodes[i].addProperty(id, i);
      }
      log.info("Nodes loaded.");
      int offsets[] = {-99, -71, -20, -17, -13, 2, 7, 15, 33, 89};
      assert offsets.length == noEdgesPerNode;

      for (int i = 0; i < noNodes; i++) {
        TitanVertex n = nodes[i];
        for (int e = 0; e < noEdgesPerNode; e++) {
          TitanVertex n2 = nodes[wrapAround(i + offsets[e], noNodes)];
          n.addEdge(connect, n2);
        }
        if ((i + 1) % 10000 == 0) System.out.println("" + (i + 1));
      }
    }
Example #3
0
  @Test
  public void testValueOrdering() {
    StandardTitanGraph graph = (StandardTitanGraph) StorageSetup.getInMemoryGraph();
    TitanLabel father = graph.makeLabel("father").manyToOne().make();
    for (int i = 1; i <= 5; i++) graph.makeKey("key" + i).single().dataType(Integer.class).make();

    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();
  }