Java源码示例:org.neo4j.unsafe.batchinsert.BatchInserters

示例1
@Test
public void testBatchIndexToAutoIndex() throws IOException {
  BatchInserter inserter = BatchInserters.inserter(new File(path));
  BatchInserterIndexProvider indexProvider = new LuceneBatchInserterIndexProvider(inserter);
  BatchInserterIndex index =
      indexProvider.nodeIndex("node_auto_index", MapUtil.stringMap("type", "exact"));
  long node = inserter.createNode(MapUtil.map("foo", "bar"));
  index.add(node, MapUtil.map("foo", "bar"));
  index.flush();
  assertThat("Batch indexed node can be retrieved", index.get("foo", "bar").next(), is(node));
  indexProvider.shutdown();
  inserter.shutdown();
  graphDb = getGraphDb();
  try (Transaction tx = graphDb.beginTx()) {
    assertThat("AutoIndex is not enabled after reopening the graph", graphDb.index()
        .getNodeAutoIndexer().isEnabled(), is(false));
    assertThat("AutoIndexed properties are not maintained after closing the graph", graphDb
        .index().getNodeAutoIndexer().getAutoIndexedProperties(), is(empty()));
    assertThat("Batch index properties are in the index", graphDb.index().getNodeAutoIndexer()
        .getAutoIndex().query("foo", "bar").size(), is(1));
    tx.success();
  }
}
 
示例2
public static void main(String[] args) {
	//GraphDatabaseService njgraph = new GraphDatabaseFactory().newEmbeddedDatabaseBuilder(NEO_STORE).loadPropertiesFromFile("neo4j.properties").newGraphDatabase();
	BatchInserter db = BatchInserters.inserter(NEO_STORE);
	Course_Test.write(db);
	//Course_Test.getJob(njgraph);
	//Course_Test.search(njgraph);
	//Course_Test.insertData(njgraph);
	//njgraph.shutdown();
	db.shutdown();
	log.info("Connection closed");
}
 
示例3
@Provides
@Singleton
BatchInserter getInserter() throws IOException {
  File location = new File(config.getGraphConfiguration().getLocation());
  logger.info("Getting BatchInserter for " + location);
  return BatchInserters.inserter(new File(location.toString()), config.getGraphConfiguration()
      .getNeo4jConfig());
}
 
示例4
@Override
protected GraphBatchImpl createInstance() throws IOException {
  String path = folder.newFolder().getAbsolutePath();
  BatchInserter inserter = BatchInserters.inserter(new File(path));
  return new GraphBatchImpl(inserter, CommonProperties.IRI, newHashSet("prop1", "prop2"),
          newHashSet("prop1"), new IdMap(), new RelationshipMap());
}
 
示例5
@Before
public void setup() throws IOException {
  path = folder.newFolder().getAbsolutePath();
  BatchInserter inserter = BatchInserters.inserter(new File(path));
  graph =
      new GraphBatchImpl(inserter, CommonProperties.IRI, newHashSet("prop1", "prop2"),
          newHashSet("prop1"), new IdMap(), new RelationshipMap());
  foo = graph.createNode("http://example.org/foo");
}
 
示例6
@Override
public void createGraphForMassiveLoad()
{
    Map<String, String> config = new HashMap<String, String>();
    config.put("cache_type", "none");
    config.put("use_memory_mapped_buffers", "true");
    config.put("neostore.nodestore.db.mapped_memory", "200M");
    config.put("neostore.relationshipstore.db.mapped_memory", "1000M");
    config.put("neostore.propertystore.db.mapped_memory", "250M");
    config.put("neostore.propertystore.db.strings.mapped_memory", "250M");

    inserter = BatchInserters.inserter(dbStorageDirectory.getAbsolutePath(), config);
    createDeferredSchema();
}
 
示例7
Graph getBatchGraph() throws IOException {
  BatchInserter inserter = BatchInserters.inserter(new File(path));
  return new GraphBatchImpl(inserter, "uri", Collections.<String>emptySet(), Collections.<String>emptySet(),
      new IdMap(maker), new RelationshipMap(maker));
}
 
示例8
@Override
protected GraphBatchImpl createInstance() throws Exception {
  BatchInserter inserter = BatchInserters.inserter(new File(path));
  return new GraphBatchImpl(inserter, CommonProperties.IRI, Collections.<String>emptySet(),
      Collections.<String>emptySet(), new IdMap(), new RelationshipMap());
}