public void ingestPairsWithCalculatedIDs(int vert) {
    int idLength = 8;

    for (int i = 0; i < vert; i++) {
      Map<String, String> personProperties = new HashMap<String, String>();
      personProperties.put("age", i + "");
      personProperties.put("firstname", "John" + i);
      personProperties.put("lastname", "Doe" + i);

      // Calculate id of given size from attributes:
      String id = IDUtils.md5(personProperties, idLength);

      Vertex person = graph.addVertex(id);

      person.setProperty("age", i);
      person.setProperty("firstname", "John" + i);
      person.setProperty("lastname", "Doe" + i);

      Map<String, String> locationProperties = new HashMap<String, String>();
      locationProperties.put("address", i + "");

      // Calculate id of given size from attributes:
      String id2 = IDUtils.md5(locationProperties, idLength);

      Vertex location = graph.addVertex(id2);

      location.setProperty("address", i);
      Edge edge = graph.addEdge(i, person, location, "edge");
      edge.setProperty("fr", i);
    }
  }
  @Test
  public void testRemove() {
    ThunderGraph graph = new ThunderGraph(this.dbPath);
    try {
      graph.createKeyIndex("name", Vertex.class);
      graph.commit();

      Vertex v1 = graph.addVertex(null);
      v1.setProperty("name", 1);
      for (int i = 0; i < 10; i++) {
        Vertex v2 = graph.addVertex(null);
        v2.setProperty("name", 2);
        Edge e = graph.addEdge(null, v1, v2, "label1");
        e.setProperty("name", "cccc");
      }
      graph.commit();

      Assert.assertEquals(11, count(graph.getVertices()));
      Assert.assertEquals(1, count(graph.getVertices("name", 1)));
      Assert.assertEquals(10, count(graph.getVertices("name", 2)));
      Assert.assertEquals(10, count(graph.getEdges("name", "cccc")));

      Iterator<Vertex> iter = graph.getVertices("name", 2).iterator();
      Vertex v = iter.next();
      Assert.assertEquals(1L, v.getId());
      Assert.assertEquals(2, v.getProperty("name"));
      iter.remove();
      Assert.assertNull(graph.getVertex(1L));
      Assert.assertEquals(9, count(iter));
    } finally {
      graph.shutdown();
    }
  }
Пример #3
0
  public void addInEdge(final Edge edge) {
    boolean adding = false;
    String label = edge.getLabel();
    // Set<String> ins = getInEdges();
    Set<String> ins = getInEdgesSet(label);
    synchronized (ins) {
      if (!ins.contains((String) edge.getId())) {
        adding = true;
        ins.add((String) edge.getId());
      }
    }
    if (adding) {
      getParent().startTransaction(this);
      Map map = getInDirtyMap();
      synchronized (map) {
        map.put(label, true);
      }
      Set<Edge> inLabelObjs = getInEdgeCache(label);
      synchronized (inLabelObjs) {
        inLabelObjs.add(edge);
      }

      // inDirty_ = true;
      // Set<Edge> inObjs = getInEdgeObjects();
      // synchronized (inObjs) {
      // inObjs.add(edge);
      // }
    }
  }
  @Test
  public void testCursorRefreshOnFirst() {

    ThunderGraph graph = new ThunderGraph(this.dbPath);
    try {
      graph.createKeyIndex("name", Vertex.class);
      graph.commit();

      Vertex v1 = graph.addVertex(null);
      v1.setProperty("name", 1);
      for (int i = 0; i < 10; i++) {
        Vertex v2 = graph.addVertex(null);
        v2.setProperty("name", 2);
        Edge e = graph.addEdge(null, v1, v2, "label1");
        e.setProperty("name", "cccc");
      }
      graph.commit();

      Assert.assertEquals(11, count(graph.getVertices()));
      Assert.assertEquals(1, count(graph.getVertices("name", 1)));
      Assert.assertEquals(10, count(graph.getVertices("name", 2)));
      Assert.assertEquals(10, count(graph.getEdges("name", "cccc")));
      Iterator<Vertex> iter = graph.getVertices("name", 1).iterator();
      // This will cause the transaction to be upgraded to a writable transaction.
      // I.e. iter's cursor gets closed
      graph.getEdges("name", "cccc").iterator().next().setProperty("name", "cccd");
      Vertex v = iter.next();
      Assert.assertEquals(1, v.getProperty("name"));
    } finally {
      graph.shutdown();
    }
  }
Пример #5
0
  public void run2() {
    long testStartTime = System.nanoTime();
    marktime = System.nanoTime();

    try {
      timelog("Beginning graph2 test...");

      for (Vertex v : graph.getVertices()) {
        System.out.println("RESULT: " + v.getId().toString());
      }

      for (Edge e : graph.getEdges()) {
        System.out.println("RESULT: " + e.getId().toString() + ":" + e.getLabel());
      }
      //			lotus.domino.Session s = Factory.terminate();
      //			s.recycle();
      graph = null;
      System.gc();
    } catch (Throwable t) {
      t.printStackTrace();
    }
    long testEndTime = System.nanoTime();
    System.out.println(
        "Completed "
            + getClass().getSimpleName()
            + " run2 in "
            + ((testEndTime - testStartTime) / 1000000)
            + " ms");
  }
  public void testEdgesOnWeight() throws Exception {
    Configuration config = IntervalFilterMap.createConfiguration(Edge.class, "weight", 0.3f, 0.45f);
    mapReduceDriver.withConfiguration(config);
    Map<Long, FaunusVertex> graph =
        runWithGraph(
            startPath(generateGraph(BaseTest.ExampleGraph.TINKERGRAPH, config), Edge.class),
            mapReduceDriver);
    assertEquals(graph.size(), 6);

    long counter = 0;
    for (FaunusVertex vertex : graph.values()) {
      for (Edge edge : vertex.getEdges(Direction.BOTH)) {
        if (((StandardFaunusEdge) edge).hasPaths()) {
          counter = ((StandardFaunusEdge) edge).pathCount() + counter;
          assertEquals(edge.getProperty("weight"), 0.4d);
        }
      }
    }
    assertEquals(counter, 4);

    assertEquals(
        DEFAULT_COMPAT.getCounter(mapReduceDriver, IntervalFilterMap.Counters.VERTICES_FILTERED),
        0);
    assertEquals(
        DEFAULT_COMPAT.getCounter(mapReduceDriver, IntervalFilterMap.Counters.EDGES_FILTERED), 8);

    identicalStructure(graph, ExampleGraph.TINKERGRAPH);
  }
  @Test
  public void testIndexIntOnEdge() {
    ThunderGraph thunderGraph = new ThunderGraph(this.dbPath);
    try {
      thunderGraph.createKeyIndex("name1", Edge.class);
      Vertex v1 = thunderGraph.addVertex(null);
      Vertex v2 = thunderGraph.addVertex(null);
      Vertex v3 = thunderGraph.addVertex(null);
      Edge e1 = v1.addEdge("edge1", v2);
      e1.setProperty("name1", 1);
      Edge e2 = v1.addEdge("edge1", v3);
      e2.setProperty("name1", 1);
      thunderGraph.commit();

      Assert.assertEquals(1, thunderGraph.getIndexedKeys(Edge.class).size());
      Assert.assertEquals(0, count(thunderGraph.getEdges("name", 1).iterator()));
      Assert.assertEquals(2, count(thunderGraph.getEdges("name1", 1).iterator()));
      Assert.assertEquals(0, count(thunderGraph.getEdges("name1", 2).iterator()));

      thunderGraph.printDb(DbEnum.EDGE_INT_INDEX);

    } finally {
      thunderGraph.shutdown();
    }
  }
  @Override
  public void store(Item item) throws IOException {
    String userId = item.getUserId();
    String tweetId = item.getId();
    long timestamp = item.getPublicationTime();
    //		String title = item.getTitle();

    Vertex source = getOrCreateVertex(userId, vertexUserId);

    // handle mentions
    String[] mentions = item.getMentions();
    for (String userMention : mentions) {
      Edge edge;
      // handle retweets
      if (!item.isOriginal()) {
        String userRetweets = item.getReferencedUserId();
        Vertex destination = getOrCreateVertex(userRetweets, vertexUserId);
        edge = titanGraph.addEdge(null, source, destination, edgeReTweets);
        //				edge.setProperty("title", title);
      } else {
        Vertex destination = getOrCreateVertex(userMention, vertexUserId);
        edge = titanGraph.addEdge(null, source, destination, edgeMentions);
        //				edge.setProperty("title", title);
      }
      edge.setProperty(edgePropertyTweedId, tweetId);
      edge.setProperty(edgePropertyTimestamp, timestamp);
    }

    titanGraph.commit();
  }
Пример #9
0
 private void writeEdges(Writer writer, List<Edge> edges, Map<Vertex, Integer> ids)
     throws IOException {
   for (Edge e : edges) {
     writeEdgeProperties(
         writer, e, ids.get(e.getVertex(Direction.OUT)), ids.get(e.getVertex(Direction.IN)));
   }
 }
  private void verifyUpdatedEdges(Process newProcess) {
    Vertex processVertex = getEntityVertex(newProcess.getName(), RelationshipType.PROCESS_ENTITY);

    // cluster
    Edge edge =
        processVertex
            .getEdges(Direction.OUT, RelationshipLabel.PROCESS_CLUSTER_EDGE.getName())
            .iterator()
            .next();
    Assert.assertEquals(edge.getVertex(Direction.IN).getProperty("name"), anotherCluster.getName());

    // inputs
    edge =
        processVertex
            .getEdges(Direction.IN, RelationshipLabel.FEED_PROCESS_EDGE.getName())
            .iterator()
            .next();
    Assert.assertEquals(
        edge.getVertex(Direction.OUT).getProperty("name"),
        newProcess.getInputs().getInputs().get(0).getFeed());

    // outputs
    for (Edge e :
        processVertex.getEdges(Direction.OUT, RelationshipLabel.PROCESS_FEED_EDGE.getName())) {
      Assert.fail("there should not be any edges to output feeds" + e);
    }
  }
Пример #11
0
  public Edge addEdge(
      final Object id, final Vertex outVertex, final Vertex inVertex, final String label) {
    if (uniqueIds && null != id && null != getEdge(id)) {
      throw new IllegalArgumentException("Edge with given id already exists: " + id);
    }

    verifyNativeElement(outVertex);
    verifyNativeElement(inVertex);

    Edge base =
        baseGraph.addEdge(
            null,
            ((IdVertex) outVertex).getBaseVertex(),
            ((IdVertex) inVertex).getBaseVertex(),
            label);

    Object v = null == id ? edgeIdFactory.createId() : id;

    if (null == v) {
      base.removeProperty(ID);
    } else {
      base.setProperty(ID, v);
    }

    return new IdEdge(base);
  }
Пример #12
0
 public void addOutEdge(final Edge edge) {
   boolean adding = false;
   String label = edge.getLabel();
   // Set<String> outs = getOutEdges();
   Set<String> outs = getOutEdgesSet(label);
   synchronized (outs) {
     if (!outs.contains((String) edge.getId())) {
       adding = true;
       outs.add((String) edge.getId());
     }
   }
   if (adding) {
     getParent().startTransaction(this);
     Map map = getOutDirtyMap();
     synchronized (map) {
       map.put(label, true);
     }
     Set<Edge> outLabelObjs = getOutEdgeCache(label);
     synchronized (outLabelObjs) {
       outLabelObjs.add(edge);
     }
     // outDirty_ = true;
     // Set<Edge> outObjs = getOutEdgeObjects();
     // synchronized (outObjs) {
     // outObjs.add(edge);
     // }
   }
   // setProperty(DominoVertex.OUT_NAME, outEdges_);
 }
Пример #13
0
 private static void debugEdge(final Edge e) {
   System.out.println("edge " + e + ":");
   for (String key : e.getPropertyKeys()) {
     System.out.println("\t" + key + ":\t'" + e.getProperty(key) + "'");
   }
   System.out.println("\t[in vertex]: " + e.getVertex(Direction.IN));
   System.out.println("\t[out vertex]: " + e.getVertex(Direction.OUT));
 }
Пример #14
0
  public void removeEdge(final Edge edge) {
    getParent().startTransaction(this);
    String label = edge.getLabel();

    boolean inChanged = false;
    Set<String> ins = getInEdgesSet(label);
    if (ins != null) {
      //			System.out.println("Removing an in edge from " + label + " with id " + edge.getId() + "
      // from a vertex of type "
      //					+ getProperty("Form"));
      synchronized (ins) {
        inChanged = ins.remove(edge.getId());
      }
    } else {
      //			System.out.println("in edges were null from a vertex of type " + getProperty("Form") + ":
      // " + getId());
    }
    // Set<Edge> inObjs = getInEdgeObjects();
    // synchronized (inObjs) {
    // inObjs.remove(edge);
    // }
    if (inChanged) {
      //			System.out.println("Ins were changed so recording cache invalidation...");
      Set<Edge> inObjsLabel = getInEdgeCache(label);
      synchronized (inObjsLabel) {
        inObjsLabel.remove(edge);
      }
      Map<String, Boolean> inDirtyMap = getInDirtyMap();
      synchronized (inDirtyMap) {
        inDirtyMap.put(label, true);
      }
    }

    boolean outChanged = false;
    Set<String> outs = getOutEdgesSet(label);
    if (outs != null) {
      //			System.out.println("Removing an out edge from " + label + " with id " + edge.getId() + "
      // from a vertex of type "
      //					+ getProperty("Form"));
      synchronized (outs) {
        outChanged = outs.remove(edge.getId());
      }
    } else {
      //			System.out.println("out edges were null from a vertex of type " + getProperty("Form") +
      // ": " + getId());
    }
    if (outChanged) {
      //			System.out.println("Out were changed so recording cache invalidation...");
      Set<Edge> outObjsLabel = getOutEdgeCache(label);
      synchronized (outObjsLabel) {
        outObjsLabel.remove(edge);
      }
      Map<String, Boolean> outDirtyMap = getOutDirtyMap();
      synchronized (outDirtyMap) {
        outDirtyMap.put(label, true);
      }
    }
  }
Пример #15
0
 public static String edgeString(final Edge edge) {
   return "e["
       + edge.getLabel()
       + "], ["
       + edge.getVertex(Direction.OUT)
       + " -> "
       + edge.getLabel()
       + " -> "
       + edge.getVertex(Direction.IN)
       + "]";
 }
Пример #16
0
 static Edge addEdge(Graph graph, Edge edge) {
   Edge newEdge = graph.getEdge(edge.getId());
   if (null == newEdge) {
     Vertex outVertex = addNode(graph, edge.getVertex(Direction.OUT));
     Vertex inVertex = addNode(graph, edge.getVertex(Direction.IN));
     String label = edge.getLabel();
     newEdge = graph.addEdge(edge.getId(), outVertex, inVertex, label);
     copyProperties(edge, edge);
   }
   return newEdge;
 }
 private void verifyVertexForEdge(
     Vertex fromVertex,
     Direction direction,
     String label,
     String expectedName,
     String expectedType) {
   for (Edge edge : fromVertex.getEdges(direction, label)) {
     Vertex outVertex = edge.getVertex(Direction.IN);
     Assert.assertEquals(outVertex.getProperty(RelationshipProperty.NAME.getName()), expectedName);
     Assert.assertEquals(outVertex.getProperty(RelationshipProperty.TYPE.getName()), expectedType);
   }
 }
Пример #18
0
 public Edge removeRelation(String edgeId, boolean cascade) {
   LOG.debug("Removing edge with id {}", edgeId);
   final Edge edge = titanGraph.getEdge(edgeId);
   titanGraph.removeEdge(edge);
   LOG.info("Removed edge {}", edge);
   if (cascade) {
     Vertex referredVertex = edge.getVertex(Direction.IN);
     titanGraph.removeVertex(referredVertex);
     LOG.info("Removed vertex {}", referredVertex);
   }
   return edge;
 }
  private void verifyProcessEntityEdges() {
    Vertex processVertex = getEntityVertex(PROCESS_ENTITY_NAME, RelationshipType.PROCESS_ENTITY);

    // verify edge to cluster vertex
    verifyVertexForEdge(
        processVertex,
        Direction.OUT,
        RelationshipLabel.FEED_CLUSTER_EDGE.getName(),
        CLUSTER_ENTITY_NAME,
        RelationshipType.CLUSTER_ENTITY.getName());
    // verify edge to user vertex
    verifyVertexForEdge(
        processVertex,
        Direction.OUT,
        RelationshipLabel.USER.getName(),
        FALCON_USER,
        RelationshipType.USER.getName());
    // verify edge to tags vertex
    verifyVertexForEdge(
        processVertex, Direction.OUT, "classified-as", "Critical", RelationshipType.TAGS.getName());

    // verify edges to inputs
    List<String> actual = new ArrayList<String>();
    for (Edge edge :
        processVertex.getEdges(Direction.IN, RelationshipLabel.FEED_PROCESS_EDGE.getName())) {
      Vertex outVertex = edge.getVertex(Direction.OUT);
      Assert.assertEquals(
          RelationshipType.FEED_ENTITY.getName(),
          outVertex.getProperty(RelationshipProperty.TYPE.getName()));
      actual.add(outVertex.<String>getProperty(RelationshipProperty.NAME.getName()));
    }

    Assert.assertTrue(
        actual.containsAll(Arrays.asList("impression-feed", "clicks-feed")),
        "Actual does not contain expected: " + actual);

    actual.clear();
    // verify edges to outputs
    for (Edge edge :
        processVertex.getEdges(Direction.OUT, RelationshipLabel.PROCESS_FEED_EDGE.getName())) {
      Vertex outVertex = edge.getVertex(Direction.IN);
      Assert.assertEquals(
          RelationshipType.FEED_ENTITY.getName(),
          outVertex.getProperty(RelationshipProperty.TYPE.getName()));
      actual.add(outVertex.<String>getProperty(RelationshipProperty.NAME.getName()));
    }
    Assert.assertTrue(
        actual.containsAll(Arrays.asList("imp-click-join1", "imp-click-join2")),
        "Actual does not contain expected: " + actual);
  }
  protected void deleteEdge(Edge edge, boolean updateReverseAttribute, boolean force)
      throws AtlasException {
    // update reverse attribute
    if (updateReverseAttribute) {
      AttributeInfo attributeInfo = getAttributeForEdge(edge.getLabel());
      if (attributeInfo.reverseAttributeName != null) {
        deleteEdgeBetweenVertices(
            edge.getVertex(Direction.IN),
            edge.getVertex(Direction.OUT),
            attributeInfo.reverseAttributeName);
      }
    }

    deleteEdge(edge, force);
  }
Пример #21
0
  /*
   * (non-Javadoc)
   *
   * @see
   * com.tinkerpop.blueprints.Graph#removeEdge(com.tinkerpop.blueprints
   * .pgm.Edge)
   */
  @Override
  public void removeEdge(final Edge edge) {
    autoStartTransaction();

    assert edge instanceof DexEdge;
    getRawGraph().drop((Long) edge.getId());
  }
 /*
  * (non-Javadoc)
  *
  * @see org.sli.orient.importer.importers.BaseImporter#importCollection()
  */
 @Override
 public void importCollection() {
   DBCursor cursor = mongo.getCollection("studentProgramAssociation").find();
   while (cursor.hasNext()) {
     DBObject spa = cursor.next();
     Map<String, Object> body = (Map) spa.get("body");
     for (Vertex student : graph.getVertices("mongoid", body.get("studentId"))) {
       for (Vertex program : graph.getVertices("mongoid", body.get("programId"))) {
         Edge e = graph.addEdge(null, program, student, "studentProgram");
         e.setProperty("mongoid", spa.get("_id"));
         // This may not be safe.
         e.setProperty("endDate", body.get("endDate"));
       }
     }
   }
 }
Пример #23
0
 public Object processEdge(
     final Range annotation,
     final Method method,
     final Object[] arguments,
     final FramedGraph framedGraph,
     final Edge edge,
     final Direction direction) {
   return framedGraph.frame(edge.getVertex(direction.opposite()), method.getReturnType());
 }
Пример #24
0
 protected Map<Integer, ValueLoader> addEdgesLoaders() {
   Map<Integer, ValueLoader> returned = new TreeMap<Integer, ValueLoader>();
   for (Edge e : strategy.getOutEdgesFor(rootVertex, property)) {
     if (e.getProperty(Properties.collection_index.name()) != null) {
       returned.put(
           (Integer) e.getProperty(Properties.collection_index.name()),
           new LoadValueBehindEdge(e));
     } else {
       // These items are pushed to the latest element (after collectionSize) which has no value
       // set
       int index = Integer.MAX_VALUE - 1;
       while (returned.containsKey(index)) {
         index--;
       }
       returned.put(index, new LoadValueBehindEdge(e));
     }
   }
   return returned;
 }
Пример #25
0
  /**
   * Creates a Jackson ObjectNode from a graph element.
   *
   * @param element the graph element to convert to JSON.
   * @param propertyKeys The property keys at the root of the element to serialize. If null, then
   *     all keys are serialized.
   * @param showTypes Data types are written to the JSON explicitly if true.
   */
  public static ObjectNode createJSONElementAsObjectNode(
      final Element element, final List<String> propertyKeys, final boolean showTypes) {

    ObjectNode jsonElement =
        createJSONMap(createPropertyMap(element, propertyKeys), propertyKeys, showTypes);
    putObject(jsonElement, GraphSONTokens._ID, element.getId());

    if (element instanceof Vertex) {
      jsonElement.put(GraphSONTokens._TYPE, GraphSONTokens.VERTEX);
    } else if (element instanceof Edge) {
      final Edge edge = (Edge) element;
      jsonElement.put(GraphSONTokens._TYPE, GraphSONTokens.EDGE);
      putObject(jsonElement, GraphSONTokens._OUT_V, edge.getVertex(Direction.OUT).getId());
      putObject(jsonElement, GraphSONTokens._IN_V, edge.getVertex(Direction.IN).getId());
      jsonElement.put(GraphSONTokens._LABEL, edge.getLabel());
    }

    return jsonElement;
  }
  protected void deleteVertex(Vertex instanceVertex, boolean force) throws AtlasException {
    // Update external references(incoming edges) to this vertex
    LOG.debug(
        "Setting the external references to {} to null(removing edges)", string(instanceVertex));
    Iterator<Edge> edges = instanceVertex.getEdges(Direction.IN).iterator();

    while (edges.hasNext()) {
      Edge edge = edges.next();
      Id.EntityState edgeState = GraphHelper.getState(edge);
      if (edgeState == Id.EntityState.ACTIVE) {
        // Delete only the active edge references
        AttributeInfo attribute = getAttributeForEdge(edge.getLabel());
        // TODO use delete edge instead??
        deleteEdgeBetweenVertices(
            edge.getVertex(Direction.OUT), edge.getVertex(Direction.IN), attribute.name);
      }
    }
    _deleteVertex(instanceVertex, force);
  }
  public void ingestPairs(int vert) {
    StopWatch timer = new StopWatch();
    timer.start();
    for (int i = 0; i < vert; i++) {
      Vertex person = graph.addVertex("p" + i);
      person.setProperty("type", "person");
      person.setProperty("age", i);
      person.setProperty("firstname", "John" + i);
      person.setProperty("lastname", "Doe" + i);

      Vertex location = graph.addVertex("l" + i);
      location.setProperty("type", "location");
      location.setProperty("address", "address" + i);

      Edge edge = graph.addEdge(i, person, location, "e");
      edge.setProperty("type", "lived at");
      edge.setProperty("from", "199" + i);
      edge.setProperty("to", "201" + i);
    }
    System.out.println("Created graph\n");
  }
Пример #28
0
 private void writeEdgeProperties(Writer writer, Edge e) throws IOException {
   Object blueprintsId = e.getId();
   if (!useId) {
     writeKey(writer, edgeIdKey);
     if (blueprintsId instanceof Number) {
       writeNumberProperty(writer, (Number) blueprintsId);
     } else {
       writeStringProperty(writer, blueprintsId);
     }
   }
   writeProperties(writer, e);
 }
Пример #29
0
  /**
   * Reads an individual Edge from JSON. The edge must match the accepted GraphSON format.
   *
   * @param node a single edge in GraphSON format
   * @param factory the factory responsible for constructing graph elements
   * @param hasEmbeddedTypes the GraphSON has embedded types
   */
  public static Edge edgeFromJSON(
      final JsonNode node,
      final Vertex out,
      final Vertex in,
      final ElementFactory factory,
      final boolean hasEmbeddedTypes)
      throws IOException {

    final Map<String, Object> props = GraphSONFactory.readProperties(node, true, hasEmbeddedTypes);

    final Object edgeId = getTypedValueFromJsonNode(node.get(GraphSONTokens._ID));
    final String label = node.get(GraphSONTokens._LABEL).getValueAsText();

    final Edge e = factory.createEdge(edgeId, out, in, label);

    for (Map.Entry<String, Object> entry : props.entrySet()) {
      e.setProperty(entry.getKey(), entry.getValue());
    }

    return e;
  }
  @Test
  public void testReindexOnEdge() {
    ThunderGraph thunderGraph = new ThunderGraph(this.dbPath);
    try {

      Vertex v1 = thunderGraph.addVertex(null);
      Vertex v2 = thunderGraph.addVertex(null);
      Vertex v3 = thunderGraph.addVertex(null);
      Vertex v4 = thunderGraph.addVertex(null);

      Edge e1 = v1.addEdge("label1", v2);
      Edge e2 = v1.addEdge("label1", v3);
      Edge e3 = v1.addEdge("label1", v4);

      e1.setProperty("name1", 1);
      e2.setProperty("name1", 1);
      e3.setProperty("name1", 1);

      thunderGraph.commit();

      Assert.assertEquals(3, count(thunderGraph.getEdges("name1", 1)));
      thunderGraph.printDb(DbEnum.EDGE_INT_INDEX);

      thunderGraph.createKeyIndex("name1", Edge.class);
      Assert.assertEquals(3, count(thunderGraph.getEdges("name1", 1)));
      thunderGraph.printDb(DbEnum.EDGE_INT_INDEX);

    } finally {
      thunderGraph.shutdown();
    }
  }