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


Java SerialBinding类代码示例

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


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

示例1: getChildren

import com.sleepycat.bind.serial.SerialBinding; //导入依赖的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.SerialBinding; //导入依赖的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.SerialBinding; //导入依赖的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: run

import com.sleepycat.bind.serial.SerialBinding; //导入依赖的package包/类
private void run(String args[]) 
    throws DatabaseException {
    // Parse the arguments list
    parseArgs(args);
  
    myDbEnv.setup(myDbEnvPath, // path to the environment home
                  true);      // is this environment read-only?

    // Setup our bindings.
    inventoryBinding = new InventoryBinding();
    vendorBinding =
         new SerialBinding(myDbEnv.getClassCatalog(), 
                           Vendor.class);

    if (locateItem != null) {
        showItem();
    } else {
        showAllInventory();
    }
}
 
开发者ID:nologic,项目名称:nabs,代码行数:21,代码来源:ExampleInventoryRead.java

示例5: setUp

import com.sleepycat.bind.serial.SerialBinding; //导入依赖的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

示例6: setUp

import com.sleepycat.bind.serial.SerialBinding; //导入依赖的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

示例7: primitiveBindingTest

import com.sleepycat.bind.serial.SerialBinding; //导入依赖的package包/类
private void primitiveBindingTest(Object val) {

        Class cls = val.getClass();
        SerialBinding binding = new SerialBinding(catalog, cls);

        binding.objectToEntry(val, buffer);
        assertTrue(buffer.getSize() > 0);

        Object val2 = binding.entryToObject(buffer);
        assertSame(cls, val2.getClass());
        assertEquals(val, val2);

        Object valWithWrongCls = (cls == String.class)
                      ? ((Object) new Integer(0)) : ((Object) new String(""));
        try {
            binding.objectToEntry(valWithWrongCls, buffer);
        } catch (IllegalArgumentException expected) {}
    }
 
开发者ID:nologic,项目名称:nabs,代码行数:19,代码来源:SerialBindingTest.java

示例8: testSerialSerialBinding

import com.sleepycat.bind.serial.SerialBinding; //导入依赖的package包/类
public void testSerialSerialBinding() {

        SerialBinding keyBinding = new SerialBinding(catalog, String.class);
        SerialBinding valueBinding = new SerialBinding(catalog, String.class);
        EntityBinding binding = new MySerialSerialBinding(keyBinding,
                                                          valueBinding);

        String val = "key#value?indexKey";
        binding.objectToData(val, buffer);
        assertTrue(buffer.getSize() > 0);
        binding.objectToKey(val, keyBuffer);
        assertTrue(keyBuffer.getSize() > 0);

        Object result = binding.entryToObject(keyBuffer, buffer);
        assertEquals(val, result);
    }
 
开发者ID:nologic,项目名称:nabs,代码行数:17,代码来源:SerialBindingTest.java

示例9: testTupleSerialMarshalledBinding

import com.sleepycat.bind.serial.SerialBinding; //导入依赖的package包/类
public void testTupleSerialMarshalledBinding() {

        SerialBinding valueBinding = new SerialBinding(catalog,
                                                    MarshalledObject.class);
        EntityBinding binding =
            new TupleSerialMarshalledBinding(valueBinding);

        MarshalledObject val = new MarshalledObject("abc", "primary",
                                                    "index1", "index2");
        binding.objectToData(val, buffer);
        assertTrue(buffer.getSize() > 0);
        binding.objectToKey(val, keyBuffer);
        assertEquals(val.expectedKeyLength(), keyBuffer.getSize());

        Object result = binding.entryToObject(keyBuffer, buffer);
        assertTrue(result instanceof MarshalledObject);
        val = (MarshalledObject) result;
        assertEquals("abc", val.getData());
        assertEquals("primary", val.getPrimaryKey());
        assertEquals("index1", val.getIndexKey1());
        assertEquals("index2", val.getIndexKey2());
    }
 
开发者ID:nologic,项目名称:nabs,代码行数:23,代码来源:SerialBindingTest.java

示例10: testClassloaderOverride

import com.sleepycat.bind.serial.SerialBinding; //导入依赖的package包/类
/**
 * Tests that overriding SerialBinding.getClassLoader is possible.  This is
 * a crude test because to create a truly working class loader is a large
 * undertaking.
 */
public void testClassloaderOverride()
    throws Exception {

    DatabaseEntry entry = new DatabaseEntry();

    SerialBinding binding = new CustomLoaderBinding
        (catalog, null, new FailureClassLoader());

    try {
        binding.objectToEntry(new MyClass(), entry);
        binding.entryToObject(entry);
        fail();
    } catch (RuntimeException e) {
        assertTrue(e.getMessage().startsWith("expect failure"));
    }
}
 
开发者ID:nologic,项目名称:nabs,代码行数:22,代码来源:SerialBindingTest.java

示例11: run

import com.sleepycat.bind.serial.SerialBinding; //导入依赖的package包/类
private void run(String args[])
    throws DatabaseException {
    // Parse the arguments list
    parseArgs(args);

    myDbs.setup(myDbsPath);

    // Setup our bindings.
    inventoryBinding = new InventoryBinding();
    vendorBinding =
         new SerialBinding(myDbs.getClassCatalog(),
                           Vendor.class);

    if (locateItem != null) {
        showItem();
    } else {
        showAllInventory();
    }
}
 
开发者ID:nologic,项目名称:nabs,代码行数:20,代码来源:ExampleDatabaseRead.java

示例12: setUp

import com.sleepycat.bind.serial.SerialBinding; //导入依赖的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

示例13: setUp

import com.sleepycat.bind.serial.SerialBinding; //导入依赖的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

示例14: ClassCatalog

import com.sleepycat.bind.serial.SerialBinding; //导入依赖的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

示例15: putData

import com.sleepycat.bind.serial.SerialBinding; //导入依赖的package包/类
/**
 * 
 * Put key and value into file BD. If key is same the old value will be rewrited
 * 
 * @param key
 * @param value
 */
public void putData(String[] key, Object value) {
	String keyString = ConvertToKey(key);
	DataListRow valueListRow = new DataListRow();
	valueListRow.getKeys().addAll(Arrays.asList(key));
	valueListRow.getValue().add(value);
	
	StoredClassCatalog classCatalog = berkeleyDbEnv.getClassCatalog();
	EntryBinding<DataListRow> dataBinding = new SerialBinding<DataListRow>(classCatalog, DataListRow.class);
	TupleBinding<String> integerBinding = TupleBinding.getPrimitiveBinding(String.class);
	DatabaseEntry keyEntry = new DatabaseEntry();
	DatabaseEntry valueEntry = new DatabaseEntry();
	integerBinding.objectToEntry(keyString, keyEntry);
	dataBinding.objectToEntry(valueListRow, valueEntry);
	berkeleyDbEnv.getDataDB().put(null, keyEntry, valueEntry);
}
 
开发者ID:sizhaoliu,项目名称:MemoryManagementBenchmark,代码行数:23,代码来源:BerkeleyDBStoreOnDiskHandler.java


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