Пример #1
0
  public void destroyView(GraphView view) {
    graphStore.autoWriteLock();
    try {
      checkNonNullViewObject(view);

      TimestampIndexStore nodeTimestampStore = graphStore.timestampStore.nodeIndexStore;
      if (nodeTimestampStore != null) {
        nodeTimestampStore.deleteViewIndex(((GraphViewImpl) view).getDirectedGraph());
      }

      TimestampIndexStore edgeTimestampStore = graphStore.timestampStore.edgeIndexStore;
      if (edgeTimestampStore != null) {
        edgeTimestampStore.deleteViewIndex(((GraphViewImpl) view).getDirectedGraph());
      }

      IndexStore<Node> nodeIndexStore = graphStore.nodeColumnStore.indexStore;
      if (nodeIndexStore != null) {
        nodeIndexStore.deleteViewIndex(((GraphViewImpl) view).getDirectedGraph());
      }

      IndexStore<Edge> edgeIndexStore = graphStore.edgeColumnStore.indexStore;
      if (edgeIndexStore != null) {
        edgeIndexStore.deleteViewIndex(((GraphViewImpl) view).getDirectedGraph());
      }

      removeView((GraphViewImpl) view);
    } finally {
      graphStore.autoWriteUnlock();
    }
  }
Пример #2
0
 @Test
 public void testGetTable() {
   GraphStore graphStore = GraphGenerator.generateTinyGraphStore();
   for (Node n : graphStore.getNodes()) {
     Assert.assertSame(n.getTable(), graphStore.getModel().getNodeTable());
   }
 }
Пример #3
0
 public GraphViewImpl createView() {
   graphStore.autoWriteLock();
   try {
     GraphViewImpl graphView = new GraphViewImpl(graphStore, true, true);
     addView(graphView);
     return graphView;
   } finally {
     graphStore.autoWriteUnlock();
   }
 }
Пример #4
0
 public GraphViewImpl createView(boolean nodes, boolean edges) {
   graphStore.autoWriteLock();
   try {
     GraphViewImpl graphView = new GraphViewImpl(graphStore, nodes, edges);
     addView(graphView);
     return graphView;
   } finally {
     graphStore.autoWriteUnlock();
   }
 }
Пример #5
0
  @Test(expectedExceptions = IllegalArgumentException.class)
  public void testRemoveAttributeWithIntervalByStringUnknown() {
    GraphStore store = getIntervalGraphStore();
    Column column = generateIntervalColumn(store);

    NodeImpl node = new NodeImpl("0", store);
    node.setAttribute(column, 15, new Interval(1.0, 2.0));
    store.addNode(node);

    node.removeAttribute("foo", new Interval(1.0, 2.0));
  }
Пример #6
0
  @Test(expectedExceptions = IllegalArgumentException.class)
  public void testRemoveAttributeWithTimestampByStringUnknown() {
    GraphStore store = new GraphStore();
    Column column = generateTimestampColumn(store);

    NodeImpl node = new NodeImpl("0", store);
    node.setAttribute(column, 15, 1.0);
    store.addNode(node);

    node.removeAttribute("foo", 1.0);
  }
Пример #7
0
  public void setTimeInterval(GraphView view, Interval interval) {
    checkNonNullViewObject(view);
    checkViewExist((GraphViewImpl) view);

    graphStore.autoWriteLock();
    try {
      GraphViewImpl graphView = (GraphViewImpl) view;
      graphView.setTimeInterval(interval);
    } finally {
      graphStore.autoWriteUnlock();
    }
  }
Пример #8
0
  @Test
  public void testRemoveTimestampAttribute() {
    GraphStore store = new GraphStore();
    Column column = generateTimestampColumn(store);

    NodeImpl node = new NodeImpl("0", store);
    node.setAttribute(column, 15, 1.0);
    store.addNode(node);

    Assert.assertNotNull(node.removeAttribute(column));
    Assert.assertNull(node.getAttribute(column, 1.0));
  }
Пример #9
0
  @Test
  public void testRemoveAttributeWithIntervalByString() {
    GraphStore store = getIntervalGraphStore();
    Column column = generateIntervalColumn(store);

    NodeImpl node = new NodeImpl("0", store);
    node.setAttribute(column, 15, new Interval(1.0, 2.0));
    store.addNode(node);

    Assert.assertEquals(node.removeAttribute("age", new Interval(1.0, 2.0)), 15);
    Assert.assertNull(node.getAttribute(column, new Interval(1.0, 2.0)));
  }
Пример #10
0
  @Test
  public void testRemoveAttributeWithTimestampByString() {
    GraphStore store = new GraphStore();
    Column column = generateTimestampColumn(store);

    NodeImpl node = new NodeImpl("0", store);
    node.setAttribute(column, 15, 1.0);
    store.addNode(node);

    Assert.assertEquals(node.removeAttribute("age", 1.0), 15);
    Assert.assertNull(node.getAttribute(column, 1.0));
  }
Пример #11
0
  public GraphViewImpl createView(GraphView view, boolean nodes, boolean edges) {
    checkNonNullViewObject(view);
    checkViewExist((GraphViewImpl) view);

    graphStore.autoWriteLock();
    try {
      GraphViewImpl graphView = new GraphViewImpl((GraphViewImpl) view, nodes, edges);
      addView(graphView);
      return graphView;
    } finally {
      graphStore.autoWriteUnlock();
    }
  }
Пример #12
0
  @Test
  public void testRemoveAttributeBoolean() {
    GraphStore store = new GraphStore();
    Column column = generateBasicBooleanColumn(store);

    NodeImpl node = new NodeImpl("0", store);
    node.setAttribute(column, true);
    store.addNode(node);

    Object r = node.removeAttribute(column);
    Assert.assertEquals(r, true);

    Assert.assertNull(node.getAttribute(column));
  }
Пример #13
0
  @Test
  public void testRemoveAttributeByString() {
    GraphStore store = new GraphStore();
    Column column = generateBasicColumn(store);

    NodeImpl node = new NodeImpl("0", store);
    node.setAttribute(column, 14);
    store.addNode(node);

    Object r = node.removeAttribute("age");
    Assert.assertEquals(r, 14);

    Assert.assertNull(node.getAttribute("age"));
  }
Пример #14
0
 public boolean contains(GraphView view) {
   graphStore.autoReadLock();
   try {
     checkNonNullViewObject(view);
     GraphViewImpl viewImpl = (GraphViewImpl) view;
     int id = viewImpl.storeId;
     if (id != NULL_VIEW && id < length && views[id] == view) {
       return true;
     }
     return false;
   } finally {
     graphStore.autoReadUnlock();
   }
 }
Пример #15
0
  @Test
  public void testRemoveAttributeOnNewColumnWithoutSettingValue() {
    GraphStore store = new GraphStore();
    NodeImpl node = new NodeImpl("0", store);
    store.addNode(node);

    Column column = generateBasicColumn(store);

    Assert.assertNull(node.getAttribute(column));
    Assert.assertNull(node.removeAttribute(column));
    Assert.assertNull(node.getAttribute(column));

    node.setAttribute(column, 14);
    Assert.assertEquals(node.getAttribute(column), 14);
  }
Пример #16
0
  public Subgraph getGraph(GraphView view) {
    checkNonNullViewObject(view);

    if (graphStore.isUndirected()) {
      if (view.isMainView()) {
        return graphStore.undirectedDecorator;
      }
      return ((GraphViewImpl) view).getUndirectedGraph();
    } else {
      if (view.isMainView()) {
        return graphStore;
      }
      return ((GraphViewImpl) view).getDirectedGraph();
    }
  }
Пример #17
0
 private void checkDirectedAllowed() {
   if (graphStore.isUndirected()) {
     throw new RuntimeException("Can't get a directed subgraph from an undirected graph");
   }
 }