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


Java StoredClassCatalog类代码示例

本文整理汇总了Java中com.sleepycat.bind.serial.StoredClassCatalog的典型用法代码示例。如果您正苦于以下问题:Java StoredClassCatalog类的具体用法?Java StoredClassCatalog怎么用?Java StoredClassCatalog使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getChildren

import com.sleepycat.bind.serial.StoredClassCatalog; //导入依赖的package包/类
public Set<String> getChildren(String parentHash)
{
    try
    {
        // Instantiate class catalog
        StoredClassCatalog neighborCatalog = new StoredClassCatalog(neighborDatabase);
        // Create the binding
        EntryBinding<Neighbors> neighborBinding = new SerialBinding<>(neighborCatalog, Neighbors.class);
        // Create DatabaseEntry for the key
        DatabaseEntry key = new DatabaseEntry(parentHash.getBytes("UTF-8"));
        // Create the DatabaseEntry for the data.
        DatabaseEntry data = new DatabaseEntry();
        // query database to get the key-value
        OperationStatus operationStatus = scaffoldDatabase.get(null, key, data, LockMode.DEFAULT);
        if(operationStatus != OperationStatus.NOTFOUND)
        {
            Neighbors neighbors = neighborBinding.entryToObject(data);
            return neighbors.children;
        }
    }
    catch (UnsupportedEncodingException ex)
    {
        Logger.getLogger(Scaffold.class.getName()).log(Level.SEVERE, "Scaffold entry insertion error!", ex);
    }
    return null;
}
 
开发者ID:ashish-gehani,项目名称:SPADE,代码行数:27,代码来源:Scaffold.java

示例2: getParents

import com.sleepycat.bind.serial.StoredClassCatalog; //导入依赖的package包/类
public Set<String> getParents(String childHash)
{
    try
    {
        // Instantiate class catalog
        StoredClassCatalog neighborCatalog = new StoredClassCatalog(neighborDatabase);
        // Create the binding
        EntryBinding<Neighbors> neighborBinding = new SerialBinding<>(neighborCatalog, Neighbors.class);
        // Create DatabaseEntry for the key
        DatabaseEntry key = new DatabaseEntry(childHash.getBytes("UTF-8"));
        // Create the DatabaseEntry for the data.
        DatabaseEntry data = new DatabaseEntry();
        // query database to get the key-value
        OperationStatus operationStatus = scaffoldDatabase.get(null, key, data, LockMode.DEFAULT);
        if(operationStatus != OperationStatus.NOTFOUND)
        {
            Neighbors neighbors = neighborBinding.entryToObject(data);
            return neighbors.parents;
        }
    }
    catch (UnsupportedEncodingException ex)
    {
        Logger.getLogger(Scaffold.class.getName()).log(Level.SEVERE, "Scaffold entry insertion error!", ex);
    }
    return null;
}
 
开发者ID:ashish-gehani,项目名称:SPADE,代码行数:27,代码来源:Scaffold.java

示例3: getVertex

import com.sleepycat.bind.serial.StoredClassCatalog; //导入依赖的package包/类
@Override
public AbstractVertex getVertex(String vertexHash) {
	AbstractVertex vertex = null;
	Integer vertexID = hashToID.get(vertexHash);
	try
	{
		// Instantiate class catalog
		StoredClassCatalog vertexCatalog = new StoredClassCatalog(annotationsDatabase);
		// Create the binding
		EntryBinding vertexBinding = new SerialBinding<>(vertexCatalog, AbstractVertex.class);
		// Create DatabaseEntry for the key
		DatabaseEntry key = new DatabaseEntry(vertexID.toString().getBytes("UTF-8"));
		// Create the DatabaseEntry for the data.
		DatabaseEntry data = new DatabaseEntry();
		annotationsDatabase.get(null, key, data, LockMode.DEFAULT);
		// Recreate the MyData object from the retrieved DatabaseEntry using
		// the EntryBinding created above
		vertex = (AbstractVertex) vertexBinding.entryToObject(data);
	}
	catch (UnsupportedEncodingException ex)
	{
		Logger.getLogger(BerkeleyDB.class.getName()).log(Level.WARNING, null, ex);
	}

	return vertex;
}
 
开发者ID:ashish-gehani,项目名称:SPADE,代码行数:27,代码来源:CompressedStorage.java

示例4: connection

import com.sleepycat.bind.serial.StoredClassCatalog; //导入依赖的package包/类
/**
 * Returns a {@link BerkeleyDB} instance with given parameter
 */
public BerkeleyDB connection(String databaseName, DatabaseConfig databaseConfig, Transaction transaction) {
    _dbName = databaseName; _database = this.getEnv().openDatabase(transaction,
            checkNotNull(databaseName), databaseConfig = firstNonNull(databaseConfig, defaultDatabaseConfig()));
    if (log.isDebugEnabled()) {
        log.debug("Database initialized with name: " + databaseName);
        log.debug("DatabaseConfig initialized: " + databaseConfig.toString());
        log.debug("Transaction initialized: " + (null != transaction ? transaction.toString() : null));
    }
    
    storedClassCatalog = new StoredClassCatalog(delegate());
    if (log.isDebugEnabled()) {
        log.debug("StoredClassCatalog initialized with database: " + delegate().getDatabaseName());
    }
    return this;
}
 
开发者ID:jronrun,项目名称:benayn,代码行数:19,代码来源:Berkeley.java

示例5: AbstractFrontier

import com.sleepycat.bind.serial.StoredClassCatalog; //导入依赖的package包/类
public AbstractFrontier(String homeDirectory) {
  EnvironmentConfig envConfig = new EnvironmentConfig();
  envConfig.setTransactional(true);
  envConfig.setAllowCreate(true);
  env = new Environment(new File(homeDirectory), envConfig);
  // 设置databaseconfig
  DatabaseConfig dbConfig = new DatabaseConfig();
  dbConfig.setTransactional(true);
  dbConfig.setAllowCreate(true);
  // 打开
  catalogdatabase = env.openDatabase(null, CLASS_CATALOG, dbConfig);
  javaCatalog = new StoredClassCatalog(catalogdatabase);
  // 设置databaseconfig
  DatabaseConfig dbConfig0 = new DatabaseConfig();
  dbConfig0.setTransactional(true);
  dbConfig0.setAllowCreate(true);
  database = env.openDatabase(null, "URL", dbConfig0);
}
 
开发者ID:classtag,项目名称:scratch_crawler,代码行数:19,代码来源:AbstractFrontier.java

示例6: getData

import com.sleepycat.bind.serial.StoredClassCatalog; //导入依赖的package包/类
/**
 * 
 * Get the value which key is keyArray
 * 
 * @param keyArray
 * @return null if can not find a value by the keyArray
 */
public List<Object> getData(String[] keyArray) {
    String keyString = ConvertToKey(keyArray);
    StoredClassCatalog classCatalog = berkeleyDbEnv.getClassCatalog();
    EntryBinding<DataListRow> dataBinding = new SerialBinding<DataListRow>(classCatalog, DataListRow.class);
    TupleBinding<String> stringBinding = TupleBinding.getPrimitiveBinding(String.class);
    DatabaseEntry keyEntry = new DatabaseEntry();
    DatabaseEntry valueEntry = new DatabaseEntry();
    stringBinding.objectToEntry(keyString, keyEntry);
    if(berkeleyDbEnv.getDataDB().get(null, keyEntry, valueEntry, LockMode.DEFAULT)==OperationStatus.SUCCESS){
    	DataListRow valueListRow = dataBinding.entryToObject(valueEntry);
    	return valueListRow.getValue();
    }else{
    	return null;
    }
}
 
开发者ID:sizhaoliu,项目名称:MemoryManagementBenchmark,代码行数:23,代码来源:BerkeleyDBStoreOnDiskHandler.java

示例7: testReadOnlyEmptyCatalog

import com.sleepycat.bind.serial.StoredClassCatalog; //导入依赖的package包/类
public void testReadOnlyEmptyCatalog()
    throws Exception {

    String file = "catalog.db";

    /* Create an empty database. */
    DatabaseConfig config = new DatabaseConfig();
    config.setAllowCreate(true);
    DbCompat.setTypeBtree(config);
    Database db = DbCompat.openDatabase(env, null, file, null, config);
    db.close();

    /* Open the empty database read-only. */
    config.setAllowCreate(false);
    config.setReadOnly(true);
    db = DbCompat.openDatabase(env, null, file, null, config);

    /* Expect exception when creating the catalog. */
    try {
        new StoredClassCatalog(db);
        fail();
    } catch (IllegalStateException e) { }
    db.close();
}
 
开发者ID:nologic,项目名称:nabs,代码行数:25,代码来源:CatalogCornerCaseTest.java

示例8: setUp

import com.sleepycat.bind.serial.StoredClassCatalog; //导入依赖的package包/类
public void setUp()
    throws Exception {

    DbTestUtil.printTestName(getName());
    env = testEnv.open(StoredClassCatalogTest.makeTestName(testEnv));
    runner = new TransactionRunner(env);

    catalog = new StoredClassCatalog(openDb(CATALOG_FILE));

    SerialBinding keyBinding = new SerialBinding(catalog, String.class);
    SerialBinding valueBinding =
 new SerialBinding(catalog, TestSerial.class);
    store = openDb(STORE_FILE);

    map = new StoredMap(store, keyBinding, valueBinding, true);
}
 
开发者ID:nologic,项目名称:nabs,代码行数:17,代码来源:StoredClassCatalogTestInit.java

示例9: setUp

import com.sleepycat.bind.serial.StoredClassCatalog; //导入依赖的package包/类
public void setUp()
    throws Exception {

    DbTestUtil.printTestName(getName());
    env = testEnv.open(makeTestName(testEnv), false);
    runner = new TransactionRunner(env);

    catalog = new StoredClassCatalog(openDb(CATALOG_FILE, false));
    catalog2 = new StoredClassCatalog(openDb("catalog2.db", true));

    SerialBinding keyBinding = new SerialBinding(catalog,
                                              String.class);
    SerialBinding valueBinding = new SerialBinding(catalog,
                                                TestSerial.class);
    store = openDb(STORE_FILE, false);

    map = new StoredMap(store, keyBinding, valueBinding, true);
}
 
开发者ID:nologic,项目名称:nabs,代码行数:19,代码来源:StoredClassCatalogTest.java

示例10: setUp

import com.sleepycat.bind.serial.StoredClassCatalog; //导入依赖的package包/类
public void setUp()
    throws Exception {

    SharedTestUtils.printTestName(getName());
    env = testEnv.open(makeTestName(testEnv), false);
    runner = new TransactionRunner(env);

    catalog = new StoredClassCatalog(openDb(CATALOG_FILE, false));
    catalog2 = new StoredClassCatalog(openDb("catalog2.db", true));

    SerialBinding keyBinding = new SerialBinding(catalog,
                                              String.class);
    SerialBinding valueBinding = new SerialBinding(catalog,
                                                TestSerial.class);
    store = openDb(STORE_FILE, false);

    map = new StoredMap(store, keyBinding, valueBinding, true);
}
 
开发者ID:nologic,项目名称:nabs,代码行数:19,代码来源:StoredClassCatalogTest.java

示例11: testReadOnlyEmptyCatalog

import com.sleepycat.bind.serial.StoredClassCatalog; //导入依赖的package包/类
public void testReadOnlyEmptyCatalog()
    throws Exception {

    String file = "catalog.db";

    /* Create an empty database. */
    DatabaseConfig config = new DatabaseConfig();
    config.setAllowCreate(true);
    DbCompat.setTypeBtree(config);
    Database db =
        DbCompat.testOpenDatabase(env, null, file, null, config);
    db.close();

    /* Open the empty database read-only. */
    config.setAllowCreate(false);
    config.setReadOnly(true);
    db = DbCompat.testOpenDatabase(env, null, file, null, config);

    /* Expect exception when creating the catalog. */
    try {
        new StoredClassCatalog(db);
        fail();
    } catch (IllegalStateException e) { }
    db.close();
}
 
开发者ID:nologic,项目名称:nabs,代码行数:26,代码来源:CatalogCornerCaseTest.java

示例12: setUp

import com.sleepycat.bind.serial.StoredClassCatalog; //导入依赖的package包/类
public void setUp()
    throws Exception {

    SharedTestUtils.printTestName(getName());
    env = testEnv.open(StoredClassCatalogTest.makeTestName(testEnv));
    runner = new TransactionRunner(env);

    catalog = new StoredClassCatalog(openDb(CATALOG_FILE));

    SerialBinding keyBinding = new SerialBinding(catalog, String.class);
    SerialBinding valueBinding =
 new SerialBinding(catalog, TestSerial.class);
    store = openDb(STORE_FILE);

    map = new StoredMap(store, keyBinding, valueBinding, true);
}
 
开发者ID:nologic,项目名称:nabs,代码行数:17,代码来源:StoredClassCatalogTestInit.java

示例13: ClassCatalog

import com.sleepycat.bind.serial.StoredClassCatalog; //导入依赖的package包/类
ClassCatalog(String directory, EnvironmentConfig environmentConfig, DatabaseConfig dbConfig) {
	// This should be main database directory
	dirClassLoader = new DirClassLoader(directory);
	
    // Open the environment in subdirectory of the above
	String classesDir = directory + java.io.File.separator + "classes";
	RelDatabase.mkdir(classesDir);
    environment = new Environment(new File(classesDir), environmentConfig);
    
    // Open the class catalog db. This is used to optimize class serialization.
    classCatalogDb = environment.openDatabase(null, "_ClassCatalog", dbConfig);

    // Create our class catalog
    classCatalog = new StoredClassCatalog(classCatalogDb);
    
    // Need a serial binding for metadata
    relvarMetadataBinding = new SerialBinding<RelvarMetadata>(classCatalog, RelvarMetadata.class);
    
    // Need serial binding for data
    tupleBinding = new SerialBinding<ValueTuple>(classCatalog, ValueTuple.class) {
    	public ClassLoader getClassLoader() {
    		return dirClassLoader;
    	}
    };   	
}
 
开发者ID:DaveVoorhis,项目名称:Rel,代码行数:26,代码来源:ClassCatalog.java

示例14: BdbPersistentQueue

import com.sleepycat.bind.serial.StoredClassCatalog; //导入依赖的package包/类
/**
 * 构造函数,传入BDB数据库
 * @param db 数据库
 * @param valueClass 值的类型
 * @param classCatalog StoredClassCatalog
 */
public BdbPersistentQueue(Database db, Class<E> valueClass, StoredClassCatalog classCatalog) {
    this.queueDb = db;
    this.dbName = db.getDatabaseName();
    headIndex = new AtomicLong(0);
    tailIndex = new AtomicLong(0);
    bindDatabase(queueDb, valueClass, classCatalog);
}
 
开发者ID:brucezee,项目名称:jspider,代码行数:14,代码来源:BdbPersistentQueue.java

示例15: bindDatabase

import com.sleepycat.bind.serial.StoredClassCatalog; //导入依赖的package包/类
/**
 * 绑定数据库
 * @param db 数据库
 * @param valueClass 值类型
 * @param classCatalog StoredClassCatalog
 */
public void bindDatabase(Database db, Class<E> valueClass, StoredClassCatalog classCatalog) {
    EntryBinding<E> valueBinding = TupleBinding.getPrimitiveBinding(valueClass);
    if(valueBinding == null) {
        valueBinding = new SerialBinding<E>(classCatalog, valueClass);   // 序列化绑定
    }
    queueDb = db;
    queueMap = new StoredSortedMap<Long,E>(
            db,                                             // db
            TupleBinding.getPrimitiveBinding(Long.class),   //Key
            valueBinding,                                   // Value
            true);                                          // allow write
}
 
开发者ID:brucezee,项目名称:jspider,代码行数:19,代码来源:BdbPersistentQueue.java


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