Пример #1
0
 private boolean isRanking(Graph graph, Column column) {
   if (column.isDynamic() && column.isNumber()) {
     ElementIterable<? extends Element> iterable =
         AttributeUtils.isNodeColumn(column) ? graph.getNodes() : graph.getEdges();
     for (Element el : iterable) {
       if (el.getAttribute(column, graph.getView()) != null) {
         iterable.doBreak();
         return true;
       }
     }
   } else if (!column.isDynamic() && column.isIndexed() && column.isNumber()) {
     Index index;
     if (AttributeUtils.isNodeColumn(column)) {
       index = localScale ? graphModel.getNodeIndex(graph.getView()) : graphModel.getNodeIndex();
     } else {
       index = localScale ? graphModel.getEdgeIndex(graph.getView()) : graphModel.getEdgeIndex();
     }
     if (index.countValues(column) > 0) {
       return true;
     }
   }
   return false;
 }
Пример #2
0
 private boolean isPartition(Graph graph, Column column) {
   if (column.isDynamic()) {
     Set<Object> set = new HashSet<Object>();
     boolean hasNullValue = false;
     int elements = 0;
     ElementIterable<? extends Element> iterable =
         AttributeUtils.isNodeColumn(column) ? graph.getNodes() : graph.getEdges();
     for (Element el : iterable) {
       TimeMap val = (TimeMap) el.getAttribute(column);
       if (val != null) {
         Object[] va = val.toValuesArray();
         for (Object v : va) {
           if (v != null) {
             set.add(v);
           } else {
             hasNullValue = true;
           }
           elements++;
         }
       }
     }
     double ratio = set.size() / (double) elements;
     return ratio <= 0.9;
   } else if (column.isIndexed()) {
     Index index;
     if (AttributeUtils.isNodeColumn(column)) {
       index = graphModel.getNodeIndex(graph.getView());
     } else {
       index = graphModel.getEdgeIndex(graph.getView());
     }
     int valueCount = index.countValues(column);
     int elementCount = index.countElements(column);
     double ratio = valueCount / (double) elementCount;
     return ratio <= 0.9;
   }
   return false;
 }
Пример #3
0
 @Override
 public Partition getEdgePartition(Graph graph, Column column) {
   synchronized (functionLock) {
     FunctionsModel m;
     if (graph.getView().isMainView()) {
       m = functionsMain;
     } else {
       m = functions.get(graph);
     }
     if (m != null) {
       return m.edgeFunctionsModel.getPartition(column);
     }
     return null;
   }
 }
Пример #4
0
  private FunctionsModel refreshFunctions(Graph graph) {
    synchronized (functionLock) {
      FunctionsModel m;
      if (graph.getView().isMainView()) {
        m = functionsMain;
      } else {
        m = functions.get(graph);
        if (m == null) {
          m = new FunctionsModel(graph);
          functions.put(graph, m);
        }
      }

      // Check and detroy old
      for (Iterator<Map.Entry<Graph, FunctionsModel>> it = functions.entrySet().iterator();
          it.hasNext(); ) {
        Map.Entry<Graph, FunctionsModel> entry = it.next();
        if (entry.getKey().getView().isDestroyed()) {
          it.remove();
        }
      }
      return m;
    }
  }
Пример #5
0
  public GraphObserverImpl createGraphObserver(Graph graph, boolean withDiff) {
    GraphViewImpl graphViewImpl = (GraphViewImpl) graph.getView();
    checkViewExist(graphViewImpl);

    return graphViewImpl.createGraphObserver(graph, withDiff);
  }