当前位置: 首页>>代码示例>>Java>>正文


Java IoCore类代码示例

本文整理汇总了Java中org.apache.tinkerpop.gremlin.structure.io.IoCore的典型用法代码示例。如果您正苦于以下问题:Java IoCore类的具体用法?Java IoCore怎么用?Java IoCore使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IoCore类属于org.apache.tinkerpop.gremlin.structure.io包,在下文中一共展示了IoCore类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadGraph

import org.apache.tinkerpop.gremlin.structure.io.IoCore; //导入依赖的package包/类
private void loadGraph() {
    final File f = new File(graphLocation);
    if (f.exists() && f.isFile()) {
        try {
            if (graphFormat.equals("graphml")) {
                io(IoCore.graphml()).readGraph(graphLocation);
            } else if (graphFormat.equals("graphson")) {
                io(IoCore.graphson()).readGraph(graphLocation);
            } else if (graphFormat.equals("gryo")) {
                io(IoCore.gryo()).readGraph(graphLocation);
            } else {
                io(IoCore.createIoBuilder(graphFormat)).readGraph(graphLocation);
            }
        } catch (Exception ex) {
            throw new RuntimeException(String.format("Could not load graph at %s with %s", graphLocation, graphFormat), ex);
        }
    }
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:19,代码来源:TinkerGraph.java

示例2: loadGraph

import org.apache.tinkerpop.gremlin.structure.io.IoCore; //导入依赖的package包/类
public boolean loadGraph(String name)
{
  tg = TinkerGraph.open() ;
  
  try
  {
    tg.io(IoCore.graphml()).readGraph(name);
  }
  catch( IOException e )
  {
    System.out.println("GraphStats - GraphML file not found");
    return false;
  }
  g = tg.traversal();
  return true;
}
 
开发者ID:krlawrence,项目名称:graph,代码行数:17,代码来源:GraphSearch3.java

示例3: loadGraph

import org.apache.tinkerpop.gremlin.structure.io.IoCore; //导入依赖的package包/类
public boolean loadGraph(String name)
{
  tg = TinkerGraph.open() ;
  
  try
  {
    tg.io(IoCore.graphml()).readGraph(name);
  }
  catch( IOException e )
  {
    System.out.println("GraphStats - Air routes GraphML file not found");
    return false;
  }
  g = tg.traversal();
  return true;
}
 
开发者ID:krlawrence,项目名称:graph,代码行数:17,代码来源:GraphSearch.java

示例4: saveGraph

import org.apache.tinkerpop.gremlin.structure.io.IoCore; //导入依赖的package包/类
private void saveGraph() {
    final File f = new File(graphLocation);
    if (f.exists()) {
        f.delete();
    } else {
        final File parent = f.getParentFile();
        if (!parent.exists()) {
            parent.mkdirs();
        }
    }

    try {
        if (graphFormat.equals("graphml")) {
            io(IoCore.graphml()).writeGraph(graphLocation);
        } else if (graphFormat.equals("graphson")) {
            io(IoCore.graphson()).writeGraph(graphLocation);
        } else if (graphFormat.equals("gryo")) {
            io(IoCore.gryo()).writeGraph(graphLocation);
        } else {
            io(IoCore.createIoBuilder(graphFormat)).writeGraph(graphLocation);
        }
    } catch (Exception ex) {
        throw new RuntimeException(String.format("Could not save graph at %s with %s", graphLocation, graphFormat), ex);
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:26,代码来源:TinkerGraph.java

示例5: loadGraph

import org.apache.tinkerpop.gremlin.structure.io.IoCore; //导入依赖的package包/类
private void loadGraph() {
	final File f = new File(graphLocation);
    if (f.exists() && f.isFile()) {
        try {
            if (graphFormat.equals("graphml")) {
                io(IoCore.graphml()).readGraph(graphLocation);
            } else if (graphFormat.equals("graphson")) {
                io(IoCore.graphson()).readGraph(graphLocation);
            } else if (graphFormat.equals("gryo")) {
                io(IoCore.gryo()).readGraph(graphLocation);
            } else {
                io(IoCore.createIoBuilder(graphFormat)).readGraph(graphLocation);
            }
        } catch (Exception ex) {
            throw new RuntimeException(String.format("Could not load graph at %s with %s", graphLocation, graphFormat), ex);
        }
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:19,代码来源:LiteGraph.java

示例6: saveGraph

import org.apache.tinkerpop.gremlin.structure.io.IoCore; //导入依赖的package包/类
private void saveGraph() {
	
	final File f = new File(graphLocation);
    if (f.exists()) {
        f.delete();
    } else {
        final File parent = f.getParentFile();
        if (!parent.exists()) {
            parent.mkdirs();
        }
    }

    try {
        if (graphFormat.equals("graphml")) {
            io(IoCore.graphml()).writeGraph(graphLocation);
        } else if (graphFormat.equals("graphson")) {
            io(IoCore.graphson()).writeGraph(graphLocation);
        } else if (graphFormat.equals("gryo")) {
            io(IoCore.gryo()).writeGraph(graphLocation);
        } else {
            io(IoCore.createIoBuilder(graphFormat)).writeGraph(graphLocation);
        }
    } catch (Exception ex) {
        throw new RuntimeException(String.format("Could not save graph at %s with %s", graphLocation, graphFormat), ex);
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:27,代码来源:LiteGraph.java

示例7: persistModel

import org.apache.tinkerpop.gremlin.structure.io.IoCore; //导入依赖的package包/类
@Override
public void persistModel() throws IOException, XMLStreamException, ClassNotFoundException, IllegalAccessException,
		InstantiationException {
	final TinkerGraphFormat format = gc.getGraphFormat();
	Builder<?> builder = null;
	switch (format) {
	case GRAPHML:
		builder = IoCore.graphml();
		break;
	case GRAPHSON:
		builder = IoCore.graphson();
		break;
	case GRYO:
		builder = IoCore.gryo();
		break;
	default:
		throw new UnsupportedOperationException("Format " + format + " is not supported.");
	}

	final String postfix = "-tinkerpop." + format.toString().toLowerCase();
	final String fileName = gc.getConfigBase().getModelPathWithoutExtension() + postfix;
	graph.io(builder).writeGraph(fileName);
	graph.close();
}
 
开发者ID:FTSRG,项目名称:trainbenchmark,代码行数:25,代码来源:TinkerGraphSerializer.java

示例8: writeGraph

import org.apache.tinkerpop.gremlin.structure.io.IoCore; //导入依赖的package包/类
public String writeGraph() {
  java.io.OutputStream output = new java.io.OutputStream() {
    private StringBuilder stringBuilder = new StringBuilder();
    @Override
    public void write(int chr) throws java.io.IOException {
      stringBuilder.append((char) chr );
    }

    @Override
    public String toString() {
      return stringBuilder.toString();
    }
  };
  try {
    graph.io(IoCore.graphson()).writer().create().writeGraph(output, graph);
  } catch (java.io.IOException e) {
    e.printStackTrace();
  }

  String wellformedJson = "[" + String.join(",\n", (CharSequence[]) output.toString().split("\n")) + "]";
  com.google.gson.Gson gson = new GsonBuilder().setPrettyPrinting().create();
  com.google.gson.JsonParser jp = new JsonParser();
  com.google.gson.JsonElement je = jp.parse(wellformedJson);
  return gson.toJson(je);
}
 
开发者ID:HuygensING,项目名称:timbuctoo,代码行数:26,代码来源:TestableTinkerPopGraphManager.java

示例9: saveGraph

import org.apache.tinkerpop.gremlin.structure.io.IoCore; //导入依赖的package包/类
private void saveGraph() {
    final File f = new File(graphLocation);
    if (f.exists()) {
        f.delete();
    } else {
        final File parent = f.getParentFile();

        // the parent would be null in the case of an relative path if the graphLocation was simply: "f.gryo"
        if (parent != null && !parent.exists()) {
            parent.mkdirs();
        }
    }

    try {
        if (graphFormat.equals("graphml")) {
            io(IoCore.graphml()).writeGraph(graphLocation);
        } else if (graphFormat.equals("graphson")) {
            io(IoCore.graphson()).writeGraph(graphLocation);
        } else if (graphFormat.equals("gryo")) {
            io(IoCore.gryo()).writeGraph(graphLocation);
        } else {
            io(IoCore.createIoBuilder(graphFormat)).writeGraph(graphLocation);
        }
    } catch (Exception ex) {
        throw new RuntimeException(String.format("Could not save graph at %s with %s", graphLocation, graphFormat), ex);
    }
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:28,代码来源:TinkerGraph.java

示例10: shouldSerializeTinkerGraphToGryo

import org.apache.tinkerpop.gremlin.structure.io.IoCore; //导入依赖的package包/类
@Test
public void shouldSerializeTinkerGraphToGryo() throws Exception {
    final TinkerGraph graph = TinkerFactory.createModern();
    try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) {
        graph.io(IoCore.gryo()).writer().create().writeObject(out, graph);
        final byte[] b = out.toByteArray();
        try (final ByteArrayInputStream inputStream = new ByteArrayInputStream(b)) {
            final TinkerGraph target = graph.io(IoCore.gryo()).reader().create().readObject(inputStream, TinkerGraph.class);
            IoTest.assertModernGraph(target, true, false);
        }
    }
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:13,代码来源:TinkerGraphTest.java

示例11: shouldSerializeTinkerGraphWithMultiPropertiesToGryo

import org.apache.tinkerpop.gremlin.structure.io.IoCore; //导入依赖的package包/类
@Test
public void shouldSerializeTinkerGraphWithMultiPropertiesToGryo() throws Exception {
    final TinkerGraph graph = TinkerFactory.createTheCrew();
    try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) {
        graph.io(IoCore.gryo()).writer().create().writeObject(out, graph);
        final byte[] b = out.toByteArray();
        try (final ByteArrayInputStream inputStream = new ByteArrayInputStream(b)) {
            final TinkerGraph target = graph.io(IoCore.gryo()).reader().create().readObject(inputStream, TinkerGraph.class);
            IoTest.assertCrewGraph(target, false);
        }
    }
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:13,代码来源:TinkerGraphTest.java

示例12: shouldSerializeTinkerGraphToGraphSON

import org.apache.tinkerpop.gremlin.structure.io.IoCore; //导入依赖的package包/类
@Test
public void shouldSerializeTinkerGraphToGraphSON() throws Exception {
    final TinkerGraph graph = TinkerFactory.createModern();
    try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) {
        graph.io(IoCore.graphson()).writer().create().writeObject(out, graph);
        try (final ByteArrayInputStream inputStream = new ByteArrayInputStream(out.toByteArray())) {
            final TinkerGraph target = graph.io(IoCore.graphson()).reader().create().readObject(inputStream, TinkerGraph.class);
            IoTest.assertModernGraph(target, true, false);
        }
    }
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:12,代码来源:TinkerGraphTest.java

示例13: shouldSerializeTinkerGraphWithMultiPropertiesToGraphSON

import org.apache.tinkerpop.gremlin.structure.io.IoCore; //导入依赖的package包/类
@Test
public void shouldSerializeTinkerGraphWithMultiPropertiesToGraphSON() throws Exception {
    final TinkerGraph graph = TinkerFactory.createTheCrew();
    try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) {
        graph.io(IoCore.graphson()).writer().create().writeObject(out, graph);
        try (final ByteArrayInputStream inputStream = new ByteArrayInputStream(out.toByteArray())) {
            final TinkerGraph target = graph.io(IoCore.graphson()).reader().create().readObject(inputStream, TinkerGraph.class);
            IoTest.assertCrewGraph(target, false);
        }
    }
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:12,代码来源:TinkerGraphTest.java

示例14: shouldSerializeTinkerGraphToGraphSONWithTypes

import org.apache.tinkerpop.gremlin.structure.io.IoCore; //导入依赖的package包/类
@Test
public void shouldSerializeTinkerGraphToGraphSONWithTypes() throws Exception {
    final TinkerGraph graph = TinkerFactory.createModern();
    final Mapper<ObjectMapper> mapper = graph.io(IoCore.graphson()).mapper().typeInfo(TypeInfo.PARTIAL_TYPES).create();
    try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) {
        final GraphWriter writer = GraphSONWriter.build().mapper(mapper).create();
        writer.writeObject(out, graph);
        try (final ByteArrayInputStream inputStream = new ByteArrayInputStream(out.toByteArray())) {
            final GraphReader reader = GraphSONReader.build().mapper(mapper).create();
            final TinkerGraph target = reader.readObject(inputStream, TinkerGraph.class);
            IoTest.assertModernGraph(target, true, false);
        }
    }
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:15,代码来源:TinkerGraphTest.java

示例15: setup

import org.apache.tinkerpop.gremlin.structure.io.IoCore; //导入依赖的package包/类
@Override
public void setup(final Map<String,Object> config) {
    logger.info("Initializing authentication with the {}", SimpleAuthenticator.class.getName());

    if (null == config) {
        throw new IllegalArgumentException(String.format(
                "Could not configure a %s - provide a 'config' in the 'authentication' settings",
                SimpleAuthenticator.class.getName()));
    }

    if (!config.containsKey(CONFIG_CREDENTIALS_DB)) {
        throw new IllegalStateException(String.format(
                "Credentials configuration missing the %s key that points to a graph config file", CONFIG_CREDENTIALS_DB));
    }

    final Graph graph = GraphFactory.open((String) config.get(CONFIG_CREDENTIALS_DB));

    if (graph instanceof TinkerGraph) {
        // have to create the indices because they are not stored in gryo
        final TinkerGraph tinkerGraph = (TinkerGraph) graph;
        tinkerGraph.createIndex(PROPERTY_USERNAME, Vertex.class);

        // we deprecated credentialsLocation, but we still need to support it.  if it is present as a key, we can
        // load the data as we always did.
        if (config.containsKey(CONFIG_CREDENTIALS_LOCATION)) {
            logger.warn("Using {} configuration option which is deprecated - prefer including the location of the credentials graph data in the TinkerGraph config file.");
            final String location = (String) config.get(CONFIG_CREDENTIALS_LOCATION);
            try {
                tinkerGraph.io(IoCore.gryo()).readGraph(location);
            } catch (IOException e) {
                logger.warn("Could not read credentials graph from {} - authentication is enabled, but with an empty user database", location);
            }
        }
    }

    credentialStore = CredentialGraph.credentials(graph);
    logger.info("CredentialGraph initialized at {}", credentialStore);
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:39,代码来源:SimpleAuthenticator.java


注:本文中的org.apache.tinkerpop.gremlin.structure.io.IoCore类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。