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


Java StringBinding.stringToEntry方法代码示例

本文整理汇总了Java中com.sleepycat.bind.tuple.StringBinding.stringToEntry方法的典型用法代码示例。如果您正苦于以下问题:Java StringBinding.stringToEntry方法的具体用法?Java StringBinding.stringToEntry怎么用?Java StringBinding.stringToEntry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sleepycat.bind.tuple.StringBinding的用法示例。


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

示例1: getSequence

import com.sleepycat.bind.tuple.StringBinding; //导入方法依赖的package包/类
public synchronized Sequence getSequence(String name)
    throws DatabaseException {

    checkOpen();

    if (storeConfig.getReadOnly()) {
        throw new IllegalStateException("Store is read-only");
    }

    Sequence seq = sequenceMap.get(name);
    if (seq == null) {
        if (sequenceDb == null) {
            String dbName = storePrefix + SEQUENCE_DB;
            DatabaseConfig dbConfig = new DatabaseConfig();
            dbConfig.setTransactional(storeConfig.getTransactional());
            dbConfig.setAllowCreate(true);
            sequenceDb = env.openDatabase(null, dbName, dbConfig);
        }
        DatabaseEntry entry = new DatabaseEntry();
        StringBinding.stringToEntry(name, entry);
        seq = sequenceDb.openSequence(null, entry, getSequenceConfig(name));
        sequenceMap.put(name, seq);
    }
    return seq;
}
 
开发者ID:nologic,项目名称:nabs,代码行数:26,代码来源:Store.java

示例2: getSequence

import com.sleepycat.bind.tuple.StringBinding; //导入方法依赖的package包/类
public synchronized Sequence getSequence(String name)
    throws DatabaseException {

    checkOpen();

    if (storeConfig.getReadOnly()) {
        throw new IllegalStateException("Store is read-only");
    }
    
    Sequence seq = sequenceMap.get(name);
    if (seq == null) {
        if (sequenceDb == null) {
            String dbName = storePrefix + SEQUENCE_DB;
            DatabaseConfig dbConfig = new DatabaseConfig();
            dbConfig.setTransactional(storeConfig.getTransactional());
            dbConfig.setAllowCreate(true);
            sequenceDb = env.openDatabase(null, dbName, dbConfig);
        }
        DatabaseEntry entry = new DatabaseEntry();
        StringBinding.stringToEntry(name, entry);
        seq = sequenceDb.openSequence(null, entry, getSequenceConfig(name));
        sequenceMap.put(name, seq);
    }
    return seq;
}
 
开发者ID:nologic,项目名称:nabs,代码行数:26,代码来源:Store.java

示例3: getSequence

import com.sleepycat.bind.tuple.StringBinding; //导入方法依赖的package包/类
public synchronized Sequence getSequence(String name)
    throws DatabaseException {

    checkOpen();

    if (storeConfig.getReadOnly()) {
        throw new IllegalStateException("Store is read-only");
    }

    Sequence seq = sequenceMap.get(name);
    if (seq == null) {
        if (sequenceDb == null) {
            String[] fileAndDbNames =
                parseDbName(storePrefix + SEQUENCE_DB);
            DatabaseConfig dbConfig = new DatabaseConfig();
            dbConfig.setTransactional(storeConfig.getTransactional());
            dbConfig.setAllowCreate(true);
            DbCompat.setTypeBtree(dbConfig);
            try {
                sequenceDb = DbCompat.openDatabase
                    (env, null/*txn*/, fileAndDbNames[0],
                     fileAndDbNames[1], dbConfig);
            } catch (FileNotFoundException e) {
                throw new DatabaseException(e);
            }
        }
        DatabaseEntry entry = new DatabaseEntry();
        StringBinding.stringToEntry(name, entry);
        seq = sequenceDb.openSequence(null, entry, getSequenceConfig(name));
        sequenceMap.put(name, seq);
    }
    return seq;
}
 
开发者ID:nologic,项目名称:nabs,代码行数:34,代码来源:Store.java

示例4: saveNodeObject

import com.sleepycat.bind.tuple.StringBinding; //导入方法依赖的package包/类
private void saveNodeObject(Txn txn,
                            RepNodeImpl node,
                            DatabaseImpl groupDbImpl)
    throws DatabaseException {

    DatabaseEntry nodeNameKey = new DatabaseEntry();
    StringBinding.stringToEntry(node.getName(), nodeNameKey);

    final RepGroupDB.NodeBinding nodeBinding =
        new RepGroupDB.NodeBinding();
    DatabaseEntry memberInfoEntry = new DatabaseEntry();
    nodeBinding.objectToEntry(node, memberInfoEntry);

    Cursor cursor = null;
    try {
        cursor = makeCursor(groupDbImpl, txn, CursorConfig.DEFAULT);

        OperationStatus status =  cursor.put(nodeNameKey, memberInfoEntry);
        if (status != OperationStatus.SUCCESS) {
            throw EnvironmentFailureException.unexpectedState
                ("Group entry save failed");
        }
    } finally {
        if (cursor != null) {
            cursor.close();
        }
    }
}
 
开发者ID:prat0318,项目名称:dbms,代码行数:29,代码来源:RepGroupDB.java

示例5: getInternalId

import com.sleepycat.bind.tuple.StringBinding; //导入方法依赖的package包/类
/**
 * Returns the internal id assigned to the vector with the given id or -1 if the id is not found. Accesses
 * the BDB store!
 * 
 * @param id
 *            The id of the vector
 * @return The internal id assigned to this vector or -1 if the id is not found.
 */
public int getInternalId(String id) {
	DatabaseEntry key = new DatabaseEntry();
	StringBinding.stringToEntry(id, key);
	DatabaseEntry data = new DatabaseEntry();
	// check if the id already exists in id to iid database
	if ((idToIidDB.get(null, key, data, null) == OperationStatus.SUCCESS)) {
		return IntegerBinding.entryToInt(data);
	} else {
		return -1;
	}
}
 
开发者ID:MKLab-ITI,项目名称:multimedia-indexing,代码行数:20,代码来源:AbstractSearchStructure.java

示例6: createMapping

import com.sleepycat.bind.tuple.StringBinding; //导入方法依赖的package包/类
/**
 * This method is used to create a persistent mapping between the given id and an internal id (equal to
 * the current value of {@link #loadCounter}). Should be called every time that a new vector is indexed.
 * 
 * @param id
 *            The id
 */
protected void createMapping(String id) {
	DatabaseEntry key = new DatabaseEntry();
	DatabaseEntry data = new DatabaseEntry();
	IntegerBinding.intToEntry(loadCounter, key);
	StringBinding.stringToEntry(id, data);
	iidToIdDB.put(null, key, data); // required during name look-up
	idToIidDB.put(null, data, key); // required during indexing
}
 
开发者ID:MKLab-ITI,项目名称:multimedia-indexing,代码行数:16,代码来源:AbstractSearchStructure.java

示例7: recursive

import com.sleepycat.bind.tuple.StringBinding; //导入方法依赖的package包/类
private int recursive(
	Transaction txn,
	final String endProt,
	Stack<String> path,
	int bestDepth,
	final int maxDepth
	)
{
DatabaseEntry key=new DatabaseEntry();
DatabaseEntry data=new DatabaseEntry();
StringBinding.stringToEntry(path.lastElement(), key);
if(this.database.get(txn,key,data,null)==OperationStatus.SUCCESS)
	{
	Set<String> partners=this.bindingSet.entryToObject(data);
	for(String prot2:partners)
		{
		int depth=-1;
		if(prot2.equals(endProt))
			{
			depth=path.size()-1;
			}
		else if(path.size()<maxDepth && !path.contains(prot2))
			{
			path.push(prot2);
			depth=recursive(txn,endProt,path,bestDepth,maxDepth);
			path.pop();
			}
		
		if(depth!=-1 && (bestDepth==-1 || bestDepth>depth))
			{
			bestDepth=depth;
			}
		}
	}
return bestDepth;
}
 
开发者ID:lindenb,项目名称:jvarkit,代码行数:37,代码来源:Biostar92368.java

示例8: put

import com.sleepycat.bind.tuple.StringBinding; //导入方法依赖的package包/类
private void put(File f,String xml)
  	{
  	LOG.info("insert "+f);
DatabaseEntry key=new DatabaseEntry();
DatabaseEntry data=new DatabaseEntry();
StringBinding.stringToEntry(f.getAbsolutePath(), key);
StringBinding.stringToEntry(xml,data);
this.database.put(this.txn, key, data);
  	}
 
开发者ID:lindenb,项目名称:jvarkit,代码行数:10,代码来源:NgsFilesScanner.java

示例9: getAuthorByOrcid

import com.sleepycat.bind.tuple.StringBinding; //导入方法依赖的package包/类
private Author getAuthorByOrcid(final String orcid) {
final DatabaseEntry key=new DatabaseEntry();
final DatabaseEntry data=new DatabaseEntry();
StringBinding.stringToEntry(orcid, key);
if(this.authorDatabase.get(txn, key, data, LockMode.DEFAULT)==OperationStatus.SUCCESS) 
	{
	return this.authorBinding.entryToObject(data);
	}
else
	{
	return null;
	}
}
 
开发者ID:lindenb,项目名称:jvarkit,代码行数:14,代码来源:PubmedOrcidGraph.java

示例10: insertAuthor

import com.sleepycat.bind.tuple.StringBinding; //导入方法依赖的package包/类
private Author insertAuthor(final Author au) {
final DatabaseEntry key=new DatabaseEntry();
final DatabaseEntry data=new DatabaseEntry();
StringBinding.stringToEntry(au.orcid, key);
this.authorBinding.objectToEntry(au, data);
if(this.authorDatabase.put(txn, key, data)!=OperationStatus.SUCCESS) {
	throw new JvarkitException.BerkeleyDbError("Cannot update author");
	}
return au;
}
 
开发者ID:lindenb,项目名称:jvarkit,代码行数:11,代码来源:PubmedOrcidGraph.java

示例11: testSR13034

import com.sleepycat.bind.tuple.StringBinding; //导入方法依赖的package包/类
public void testSR13034()
throws DatabaseException {

       open();

       DatabaseEntry key = new DatabaseEntry();
       DatabaseEntry data = new DatabaseEntry();
       OperationStatus status;
       Transaction txn;

       /*
        * Insert {A, C}, then delete it.  No dup tree has been created, so
        * this logs a deleted LN with no data.
        */
       txn = env.beginTransaction(null, null);
       StringBinding.stringToEntry("A", key);
       StringBinding.stringToEntry("C", data);
       status = db.putNoOverwrite(txn, key, data);
       assertEquals(OperationStatus.SUCCESS, status);
       status = db.delete(txn, key);
       assertEquals(OperationStatus.SUCCESS, status);
       txn.commit();

       /*
        * Insert {A, A}, {A, B}, which creates a dup tree.  Then abort to set
        * KnownDeleted on these entries.
        */
       txn = env.beginTransaction(null, null);
       StringBinding.stringToEntry("A", key);
       StringBinding.stringToEntry("A", data);
       status = db.putNoDupData(txn, key, data);
       StringBinding.stringToEntry("A", key);
       StringBinding.stringToEntry("B", data);
       status = db.putNoDupData(txn, key, data);
       assertEquals(OperationStatus.SUCCESS, status);
       txn.abort();

       /*
        * Close without a checkpoint and recover.  Before the bug fix, the
        * recovery would throw DatabaseException "attempt to fetch a deleted
        * entry".
        */
       db.close();
       DbInternal.envGetEnvironmentImpl(env).close(false);
       open();

       close();
   }
 
开发者ID:nologic,项目名称:nabs,代码行数:49,代码来源:SR13034Test.java

示例12: ensureMember

import com.sleepycat.bind.tuple.StringBinding; //导入方法依赖的package包/类
void ensureMember(RepNodeImpl ensureNode)
    throws DatabaseException {

    DatabaseImpl groupDbImpl;
    try {
        groupDbImpl = repImpl.getGroupDb();
    } catch (DatabaseNotFoundException e) {
        /* Should never happen. */
        throw EnvironmentFailureException.unexpectedException(e);
    }

    DatabaseEntry nodeNameKey = new DatabaseEntry();
    StringBinding.stringToEntry(ensureNode.getName(), nodeNameKey);

    DatabaseEntry value = new DatabaseEntry();
    final RepGroupDB.NodeBinding mib = new RepGroupDB.NodeBinding();

    Txn txn = null;
    Cursor cursor = null;
    try {
        txn = new ReadonlyTxn(repImpl, NO_ACK);
        CursorConfig config = new CursorConfig();
        config.setReadCommitted(true);
        cursor = makeCursor(groupDbImpl, txn, config);

        OperationStatus status =
            cursor.getSearchKey(nodeNameKey, value, null);
        if (status == OperationStatus.SUCCESS) {
            /* Let's see if the entry needs updating. */
            RepNodeImpl miInDb = mib.entryToObject(value);
            if (miInDb.equivalent(ensureNode)) {
                if (miInDb.isQuorumAck()) {
                    /* Present, matched and acknowledged. */
                    return;
                }
                ensureNode.getNameIdPair().update(miInDb.getNameIdPair());
                /* Not acknowledged, retry the update. */
            } else {
                /* Present but not equivalent. */
                LoggerUtils.warning(logger, repImpl,
                                    "Incompatible node descriptions. " +
                                    "Membership database definition: " +
                                    miInDb.toString() +
                                    " Transient definition: " +
                                    ensureNode.toString());
                throw EnvironmentFailureException.unexpectedState
                    ("Incompatible node descriptions for node ID: " +
                     ensureNode.getNodeId());
            }
            LoggerUtils.info(logger, repImpl,
                             "Present but not ack'd node: " +
                             ensureNode.getNodeId() +
                             " ack status: " + miInDb.isQuorumAck());
        }
        cursor.close();
        cursor = null;
        txn.commit();
        txn = null;
    } finally {
        if (cursor != null) {
            cursor.close();
        }

        if (txn != null) {
            txn.abort();
        }

    }
    createMember(ensureNode);

    /* Refresh group and Fire an ADD GroupChangeEvent. */
    refreshGroupAndNotifyGroupChange
        (ensureNode.getName(), GroupChangeType.ADD);
}
 
开发者ID:prat0318,项目名称:dbms,代码行数:75,代码来源:RepGroupDB.java

示例13: load

import com.sleepycat.bind.tuple.StringBinding; //导入方法依赖的package包/类
private void load(Transaction txn,LineIterator r)
{
long nLines=0L;
DatabaseEntry key=new DatabaseEntry();
DatabaseEntry data=new DatabaseEntry();
Pattern tab=Pattern.compile("[\t ]");
Cursor c=this.database.openCursor(txn, null);
while(r.hasNext())
	{
	if(nLines++ % 10000 ==0)
		{
		LOG.info("Lines : "+nLines);
		}
	String line=r.next();
	if(line.isEmpty() || line.startsWith("#")) continue;
	String tokens[]=tab.split(line);
	for(int i=0;i< 2;++i)
		{
		String a=tokens[i==0?0:1];
		String b=tokens[i==0?1:0];
		StringBinding.stringToEntry(a, key);
		OperationStatus status=c.getSearchKey(key, data, LockMode.DEFAULT);
		Set<String> partners; 
		if(status==OperationStatus.SUCCESS)
			{
			partners=bindingSet.entryToObject(data);
			
			}
		else
			{
			partners=new HashSet<String>(1);
			}
		partners.add(b);
		bindingSet.objectToEntry(partners,data);
		if(status==OperationStatus.SUCCESS)
			{
			status=c.putCurrent(data);
			}
		else
			{
			status=c.put(key, data);
			}
		if(status!=OperationStatus.SUCCESS)
			{
			throw new RuntimeException("Cannot insert data in bdb "+a+"/"+b);
			}
		if(a.equals(b)) break;//self-self
		}
	}
CloserUtil.close(c);
}
 
开发者ID:lindenb,项目名称:jvarkit,代码行数:52,代码来源:Biostar92368.java

示例14: isIndexed

import com.sleepycat.bind.tuple.StringBinding; //导入方法依赖的package包/类
/**
 * <b>{@link #getInternalId(String)} can always be called instead of this method at the same cost!</b>
 * <br>
 * Checks if the vector with the given id is already indexed. This method is useful to avoid re-indexing
 * the same vector. Its convention is that if the given name is already in idToIidBDB, then the vector is
 * indexed in all other structures e.g. iidToIdBDB. The rest of the checks are avoided for efficiency.
 * Accesses the BDB store!
 * 
 * @param id
 *            The id the vector
 * @return true if the vector is indexed, false otherwise
 */
public boolean isIndexed(String id) {
	DatabaseEntry key = new DatabaseEntry();
	StringBinding.stringToEntry(id, key);
	DatabaseEntry data = new DatabaseEntry();
	if ((idToIidDB.get(null, key, data, null) == OperationStatus.SUCCESS)) {
		return true;
	} else {
		return false;
	}
}
 
开发者ID:MKLab-ITI,项目名称:multimedia-indexing,代码行数:23,代码来源:AbstractSearchStructure.java


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