本文整理汇总了Java中org.neo4j.kernel.EmbeddedGraphDatabase类的典型用法代码示例。如果您正苦于以下问题:Java EmbeddedGraphDatabase类的具体用法?Java EmbeddedGraphDatabase怎么用?Java EmbeddedGraphDatabase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EmbeddedGraphDatabase类属于org.neo4j.kernel包,在下文中一共展示了EmbeddedGraphDatabase类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: initDB
import org.neo4j.kernel.EmbeddedGraphDatabase; //导入依赖的package包/类
private void initDB() {
String dbFullPath = getDBFullPath();
if (!reuseDB) {
deleteFileOrDirectory(new File(dbFullPath));
} else {
if(!new File(dbFullPath).exists()) {
throw new RuntimeException("Database directory " + dbFullPath + " does not exist.");
}
}
graphDb = new EmbeddedGraphDatabase(dbFullPath);
indexNodesById = graphDb.index().forNodes("nodes");
indexRelationship = graphDb.index().forRelationships("relationships");
createNewCutIndex();
createNewPartitionIndex();
registerShutdownHook();
}
开发者ID:rrocharoberto,项目名称:GraphPartitionFramework,代码行数:19,代码来源:GraphDB.java
示例2: shutdownDatabase
import org.neo4j.kernel.EmbeddedGraphDatabase; //导入依赖的package包/类
@Override
public void shutdownDatabase(String name, ParcelableError err) throws RemoteException {
if (name.isEmpty()) {
String message = "given database name is empty.";
err.setError(Errors.MISSING_DATABASE_NAME, message);
Log.e(TAG, message);
return;
}
mDatabaseLock.lock();
try {
WeakReference<EmbeddedGraphDatabase> dbRef = mDatabases.get(name);
if (dbRef != null) {
if (dbRef.get() != null) {
EmbeddedGraphDatabase db = dbRef.get();
db.shutdown();
}
mDatabases.remove(name);
} else {
Log.w(TAG, "no database found with name '" + name + "'. available databases '" + mDatabases.keySet() + "'.");
}
} finally {
mDatabaseLock.unlock();
}
}
开发者ID:neo4j-contrib,项目名称:neo4j-mobile-android,代码行数:26,代码来源:Neo4jServiceImpl.java
示例3: initDB
import org.neo4j.kernel.EmbeddedGraphDatabase; //导入依赖的package包/类
public void initDB() {
String dbFullPath = databaseName;
deleteFileOrDirectory(new File(dbFullPath));
graphDb = new EmbeddedGraphDatabase(dbFullPath);
indexName = graphDb.index().forNodes("nodes");
indexRelationship = graphDb.index().forRelationships("relationships");
registerShutdownHook();
}
开发者ID:rrocharoberto,项目名称:GraphPartitionFramework,代码行数:10,代码来源:GrafoNeoDB.java
示例4: setUp
import org.neo4j.kernel.EmbeddedGraphDatabase; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
String dir = System.getProperty("java.io.tmpdir") + "/neo4jtest";
FileUtils.deleteDirectory(new File(dir));
GraphDatabaseService db = new EmbeddedGraphDatabase(dir);
ReflectionTestUtils.setField(dao, "db", db);
ReflectionTestUtils.setField(dao, "index", new LuceneIndexService(db));
ReflectionTestUtils.setField(dao, "template", new Neo4jTemplate(new DelegatingGraphDatabase(db)));
}
开发者ID:Glamdring,项目名称:welshare,代码行数:12,代码来源:ViralLinkTest.java
示例5: setUp
import org.neo4j.kernel.EmbeddedGraphDatabase; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
String dir = System.getProperty("java.io.tmpdir") + "/neo4jtest";
System.out.println(dir);
//FileUtils.deleteDirectory(new File(dir));
db = new EmbeddedGraphDatabase(dir);
index = new LuceneIndexService(db);
template = new Neo4jTemplate(new DelegatingGraphDatabase(db));
ReflectionTestUtils.setField(dao, "template", template);
ReflectionTestUtils.setField(dao, "index", index);
}
开发者ID:Glamdring,项目名称:welshare,代码行数:13,代码来源:FollowingTest.java
示例6: createEmbeddedDB
import org.neo4j.kernel.EmbeddedGraphDatabase; //导入依赖的package包/类
private void createEmbeddedDB() {
storeDir = RECORD_DB_DIR + "gds" + runningNum;
try {
FileUtils.deleteRecursively(new File(storeDir));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
runningNum++;
GDS = new EmbeddedGraphDatabase(storeDir);
registerShutdownHook(GDS);
}
开发者ID:sapirgolan,项目名称:MFIBlocking,代码行数:13,代码来源:GDS_NG.java
示例7: createEmbeddedDB
import org.neo4j.kernel.EmbeddedGraphDatabase; //导入依赖的package包/类
private void createEmbeddedDB(){
storeDir = RECORD_DB_DIR + "gds" + runningNum;
try {
FileUtils.deleteRecursively(new File(storeDir));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
runningNum++;
GDS = new EmbeddedGraphDatabase(storeDir);
registerShutdownHook(GDS);
}
开发者ID:sapirgolan,项目名称:MFIBlocking,代码行数:13,代码来源:GDS_NG.java
示例8: run
import org.neo4j.kernel.EmbeddedGraphDatabase; //导入依赖的package包/类
private void run( String legacyStoreDirectory, String targetStoreDirectory ) throws IOException
{
LegacyStore legacyStore = new LegacyStore( new File( new File( legacyStoreDirectory ), NeoStore.DEFAULT_NAME ).getPath() );
HashMap config = new HashMap();
config.put( IdGeneratorFactory.class, CommonFactories.defaultIdGeneratorFactory() );
config.put( FileSystemAbstraction.class, CommonFactories.defaultFileSystemAbstraction() );
File targetStoreDirectoryFile = new File( targetStoreDirectory );
if ( targetStoreDirectoryFile.exists() )
{
throw new IllegalStateException( "Cannot migrate to a directory that already exists, please delete first and re-run" );
}
boolean success = targetStoreDirectoryFile.mkdirs();
if ( !success )
{
throw new IllegalStateException( "Failed to create directory" );
}
File targetStoreFile = new File( targetStoreDirectory, NeoStore.DEFAULT_NAME );
config.put( "neo_store", targetStoreFile.getPath() );
NeoStore.createStore( targetStoreFile.getPath(), config );
NeoStore neoStore = new NeoStore( config );
long startTime = System.currentTimeMillis();
new StoreMigrator( new VisibleMigrationProgressMonitor( System.out ) ) .migrate( legacyStore, neoStore );
long duration = System.currentTimeMillis() - startTime;
System.out.printf( "Migration completed in %d s%n", duration / 1000 );
neoStore.close();
EmbeddedGraphDatabase database = new EmbeddedGraphDatabase( null, targetStoreDirectoryFile.getPath() );
database.shutdown();
}
开发者ID:neo4j-contrib,项目名称:neo4j-mobile-android,代码行数:37,代码来源:StoreMigrationTool.java
示例9: rejectAutoUpgrade
import org.neo4j.kernel.EmbeddedGraphDatabase; //导入依赖的package包/类
private void rejectAutoUpgrade( Map<String, String> stringParams )
{
if ( parseBoolean( stringParams.get( ALLOW_STORE_UPGRADE ) ) )
{
throw new IllegalArgumentException( "Batch inserter is not allowed to do upgrade of a store" +
", use " + EmbeddedGraphDatabase.class.getSimpleName() + " instead" );
}
}
开发者ID:neo4j-contrib,项目名称:neo4j-mobile-android,代码行数:9,代码来源:BatchInserterImpl.java
示例10: deleteDatabase
import org.neo4j.kernel.EmbeddedGraphDatabase; //导入依赖的package包/类
@Override
public boolean deleteDatabase(String name, ParcelableError err) throws RemoteException {
if (name.isEmpty()) {
String message = "given database name is empty.";
err.setError(Errors.MISSING_DATABASE_NAME, message);
Log.e(TAG, message);
return false;
}
boolean doDelete = false;
// check if DB is loaded, if it is, terminate it
mDatabaseLock.lock();
try {
WeakReference<EmbeddedGraphDatabase> dbRef = mDatabases.get(name);
if (dbRef == null) {
doDelete = true;
} else {
if (dbRef.get() != null) {
// DB is still in memory and strongly referenced?
Log.w(TAG, "Delete requested for database that is still being referenced (HINT: misbehaving clients?)");
} else {
// object has been cleared, remove the mapping and
// delete the DB
mDatabases.remove(name);
doDelete = true;
}
}
if (doDelete) {
deleteDatabaseDir(name); // I/O in a lock, not good, but
// it's not critical here
}
return doDelete;
} finally {
mDatabaseLock.unlock();
}
}
开发者ID:neo4j-contrib,项目名称:neo4j-mobile-android,代码行数:40,代码来源:Neo4jServiceImpl.java
示例11: exportDatabase
import org.neo4j.kernel.EmbeddedGraphDatabase; //导入依赖的package包/类
@Override
public boolean exportDatabase(String name, ParcelableError err) throws RemoteException {
if (name.isEmpty()) {
String message = "given database name is empty.";
err.setError(Errors.MISSING_DATABASE_NAME, message);
Log.e(TAG, message);
return false;
}
boolean doExport = false;
// check if DB is loaded, if it is, terminate it
mDatabaseLock.lock();
try {
WeakReference<EmbeddedGraphDatabase> dbRef = mDatabases.get(name);
if (dbRef == null) {
doExport = true;
} else {
if (dbRef.get() != null) {
// DB is still in memory and strongly referenced?
Log.w(TAG, "Export requested for database that is still being referenced (HINT: misbehaving clients?)");
} else {
// object has been cleared, remove the mapping and
// delete the DB
mDatabases.remove(name);
doExport = true;
}
}
if (doExport) {
exportDatabaseDir(name); // I/O in a lock, not good, but
// it's not critical here
}
return doExport;
} finally {
mDatabaseLock.unlock();
}
}
开发者ID:neo4j-contrib,项目名称:neo4j-mobile-android,代码行数:40,代码来源:Neo4jServiceImpl.java
示例12: DataAccess
import org.neo4j.kernel.EmbeddedGraphDatabase; //导入依赖的package包/类
public DataAccess(String databaseLocation) {
graphDatabaseService = new EmbeddedGraphDatabase(databaseLocation);
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
graphDatabaseService.shutdown();
}
});
}
开发者ID:tuwiendsg,项目名称:MELA,代码行数:11,代码来源:DataAccess.java
示例13: persistCostElementEntities
import org.neo4j.kernel.EmbeddedGraphDatabase; //导入依赖的package包/类
/**
* Actually persists only CostElement and Properties
*
* @param entityToPersist
* @param database connection to DB
*/
public static void persistCostElementEntities(List<CostElement> resourcesToPersist, EmbeddedGraphDatabase database) {
boolean transactionAllreadyRunning = false;
try {
transactionAllreadyRunning = (database.getTxManager().getStatus() == Status.STATUS_ACTIVE);
} catch (SystemException ex) {
log.error(ex.getMessage(), ex);
}
Transaction tx = (transactionAllreadyRunning) ? null : database.beginTx();
try {
for (CostElement entityToPersist : resourcesToPersist) {
Node resourceNode = database.createNode();
resourceNode.setProperty(KEY, entityToPersist.getName());
resourceNode.setProperty(COST_METRIC_NAME, entityToPersist.getCostMetric().getName());
resourceNode.setProperty(COST_METRIC_TYPE, entityToPersist.getCostMetric().getType().toString());
resourceNode.setProperty(COST_METRIC_UNIT, entityToPersist.getCostMetric().getMeasurementUnit());
resourceNode.setProperty(TYPE, entityToPersist.getType());
resourceNode.setProperty(UUID, entityToPersist.getUuid().toString());
resourceNode.addLabel(LABEL);
//
// for (Map.Entry<MetricValue, Double> entry : entityToPersist.getCostIntervalFunction().entrySet()) {
// MetricValue metricValue = entry.getKey();
// String propertyKey = metricValue.getValueRepresentation();
// resourceNode.setProperty(propertyKey, entry.getValue());
// }
}
if (!transactionAllreadyRunning) {
tx.success();
}
} catch (Exception e) {
log.error(e.getMessage(), e);
e.printStackTrace();
} finally {
if (!transactionAllreadyRunning) {
tx.finish();
}
}
}
开发者ID:tuwiendsg,项目名称:MELA,代码行数:46,代码来源:CostElementDAO.java
示例14: persistQualityEntity
import org.neo4j.kernel.EmbeddedGraphDatabase; //导入依赖的package包/类
/**
* Actually persists only Quality and Properties
*
* @param resourceToPersist
* @param database connection to DB
*/
public static Node persistQualityEntity(Quality resourceToPersist, EmbeddedGraphDatabase database) {
Node resourceNode = null;
boolean transactionAllreadyRunning = false;
try {
transactionAllreadyRunning = (database.getTxManager().getStatus() == Status.STATUS_ACTIVE);
} catch (SystemException ex) {
log.error(ex.getMessage(), ex);
}
Transaction tx = (transactionAllreadyRunning) ? null : database.beginTx();
try {
resourceNode = database.createNode();
resourceNode.setProperty(KEY, resourceToPersist.getName());
resourceNode.setProperty (UUID, resourceToPersist.getUuid().toString());
resourceNode.addLabel(LABEL);
// for (Map.Entry<Metric, MetricValue> entry : resourceToPersist.getProperties().entrySet()) {
// Metric metric = entry.getKey();
// String propertyKey = metric.getName() + PROPERTY_SEPARATOR + metric.getMeasurementUnit();
// resourceNode.setProperty(propertyKey, entry.getValue().getValue());
// }
if (!transactionAllreadyRunning) {
tx.success();
}
} catch (Exception e) {
log.error(e.getMessage(), e);
e.printStackTrace();
} finally {
if (!transactionAllreadyRunning) {
tx.finish();
}
}
return resourceNode;
}
开发者ID:tuwiendsg,项目名称:MELA,代码行数:43,代码来源:QualityDAO.java
示例15: persistQualityEntities
import org.neo4j.kernel.EmbeddedGraphDatabase; //导入依赖的package包/类
/**
* Actually persists only Quality and Properties
*
* @param resourceToPersist
* @param database connection to DB
*/
public static void persistQualityEntities(List<Quality> resourcesToPersist, EmbeddedGraphDatabase database) {
boolean transactionAllreadyRunning = false;
try {
transactionAllreadyRunning = (database.getTxManager().getStatus() == Status.STATUS_ACTIVE);
} catch (SystemException ex) {
log.error(ex.getMessage(), ex);
}
Transaction tx = (transactionAllreadyRunning) ? null : database.beginTx();
try {
for (Quality resourceToPersist : resourcesToPersist) {
Node resourceNode = database.createNode();
resourceNode.setProperty(KEY, resourceToPersist.getName());
resourceNode.setProperty (UUID, resourceToPersist.getUuid().toString());
resourceNode.addLabel(LABEL);
// for (Map.Entry<Metric, MetricValue> entry : resourceToPersist.getProperties().entrySet()) {
// Metric metric = entry.getKey();
// String propertyKey = metric.getName() + PROPERTY_SEPARATOR + metric.getMeasurementUnit();
// resourceNode.setProperty(propertyKey, entry.getValue().getValue());
// }
}
if (!transactionAllreadyRunning) {
tx.success();
}
} catch (Exception e) {
log.error(e.getMessage(), e);
e.printStackTrace();
} finally {
if (!transactionAllreadyRunning) {
tx.finish();
}
}
}
开发者ID:tuwiendsg,项目名称:MELA,代码行数:42,代码来源:QualityDAO.java
示例16: loadProperties
import org.neo4j.kernel.EmbeddedGraphDatabase; //导入依赖的package包/类
public static Map<String,String> loadProperties( String file )
{
return EmbeddedGraphDatabase.loadConfigurations( file );
}
开发者ID:neo4j-contrib,项目名称:neo4j-mobile-android,代码行数:5,代码来源:BatchInserterImpl.java
示例17: DbWrapper
import org.neo4j.kernel.EmbeddedGraphDatabase; //导入依赖的package包/类
public DbWrapper(EmbeddedGraphDatabase db, TrxManager mgr, Context context) {
mDb = db;
mTrxManager = mgr;
mContext = context;
}
开发者ID:neo4j-contrib,项目名称:neo4j-mobile-android,代码行数:6,代码来源:DbWrapper.java
示例18: getGraphDatabaseService
import org.neo4j.kernel.EmbeddedGraphDatabase; //导入依赖的package包/类
public EmbeddedGraphDatabase getGraphDatabaseService() {
return graphDatabaseService;
}
开发者ID:tuwiendsg,项目名称:MELA,代码行数:4,代码来源:DataAccess.java
示例19: TransactionManager
import org.neo4j.kernel.EmbeddedGraphDatabase; //导入依赖的package包/类
public TransactionManager(EmbeddedGraphDatabase database) {
this.database = database;
}
开发者ID:tuwiendsg,项目名称:MELA,代码行数:4,代码来源:TransactionManager.java
示例20: persistCostElementEntity
import org.neo4j.kernel.EmbeddedGraphDatabase; //导入依赖的package包/类
/**
* Actually persists only CostElement and Properties
*
* @param entityToPersist
* @param database connection to DB
*/
public static Node persistCostElementEntity(CostElement entityToPersist, EmbeddedGraphDatabase database) {
Node resourceNode = null;
boolean transactionAllreadyRunning = false;
try {
transactionAllreadyRunning = (database.getTxManager().getStatus() == Status.STATUS_ACTIVE);
} catch (SystemException ex) {
log.error(ex.getMessage(), ex);
}
Transaction tx = (transactionAllreadyRunning) ? null : database.beginTx();
try {
resourceNode = database.createNode();
resourceNode.setProperty(KEY, entityToPersist.getName());
resourceNode.setProperty(COST_METRIC_NAME, entityToPersist.getCostMetric().getName());
resourceNode.setProperty(COST_METRIC_TYPE, entityToPersist.getCostMetric().getType().toString());
resourceNode.setProperty(COST_METRIC_UNIT, entityToPersist.getCostMetric().getMeasurementUnit());
resourceNode.setProperty(TYPE, entityToPersist.getType());
resourceNode.setProperty(UUID, entityToPersist.getUuid().toString());
resourceNode.addLabel(LABEL);
// for (Map.Entry<MetricValue, Double> entry : entityToPersist.getCostIntervalFunction().entrySet()) {
// MetricValue metricValue = entry.getKey();
// String propertyKey = metricValue.getValueRepresentation();
// resourceNode.setProperty(propertyKey, entry.getValue());
// }
if (!transactionAllreadyRunning) {
tx.success();
}
} catch (Exception e) {
log.error(e.getMessage(), e);
e.printStackTrace();
} finally {
if (!transactionAllreadyRunning) {
tx.finish();
}
}
return resourceNode;
}
开发者ID:tuwiendsg,项目名称:MELA,代码行数:47,代码来源:CostElementDAO.java
注:本文中的org.neo4j.kernel.EmbeddedGraphDatabase类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论