コード例 #1
0
  public <T extends Element> Index<T> createManualIndex(
      final String indexName, final Class<T> indexClass, final Parameter... indexParameters) {
    final Neo4jBatchIndex<T> index;

    final Map<String, String> map = generateParameterMap(indexParameters);
    if (indexParameters.length == 0) {
      map.put(Neo4jBatchTokens.TYPE, Neo4jBatchTokens.EXACT);
    }
    map.put(Neo4jBatchTokens.BLUEPRINTS_TYPE, Index.Type.MANUAL.toString());

    if (Vertex.class.isAssignableFrom(indexClass)) {
      index =
          new Neo4jBatchIndex<T>(
              this, indexProvider.nodeIndex(indexName, map), indexName, indexClass);
    } else {
      index =
          new Neo4jBatchIndex<T>(
              this, indexProvider.relationshipIndex(indexName, map), indexName, indexClass);
    }
    this.indices.put(indexName, index);
    return index;
  }
コード例 #2
0
  public <T extends Element> AutomaticIndex<T> createAutomaticIndex(
      final String indexName,
      final Class<T> indexClass,
      final Set<String> indexKeys,
      final Parameter... indexParameters) {
    final Neo4jBatchAutomaticIndex<T> index;

    final Map<String, String> map = generateParameterMap(indexParameters);
    if (indexParameters.length == 0) {
      map.put(Neo4jBatchTokens.TYPE, Neo4jBatchTokens.EXACT);
    }
    map.put(Neo4jBatchTokens.BLUEPRINTS_TYPE, Index.Type.AUTOMATIC.toString());
    map.put(Neo4jBatchTokens.BLUEPRINTS_AUTOKEYS, makeAutoIndexKeys(indexKeys));

    if (indexClass.equals(Vertex.class)) {
      index =
          new Neo4jBatchAutomaticIndex<T>(
              this, indexProvider.nodeIndex(indexName, map), indexName, indexClass, indexKeys);
    } else {
      index =
          new Neo4jBatchAutomaticIndex<T>(
              this,
              indexProvider.relationshipIndex(indexName, map),
              indexName,
              indexClass,
              indexKeys);
    }
    this.indices.put(indexName, index);
    if (Vertex.class.isAssignableFrom(indexClass)) {
      this.automaticVertexIndices.put(
          indexName, (Neo4jBatchAutomaticIndex<Neo4jBatchVertex>) index);
    } else {
      this.automaticEdgeIndices.put(indexName, (Neo4jBatchAutomaticIndex<Neo4jBatchEdge>) index);
    }
    return index;
  }