Java Code Examples for com.sleepycat.bind.tuple.StringBinding#entryToString()

The following examples show how to use com.sleepycat.bind.tuple.StringBinding#entryToString() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
private List<String> loadVersions()
{
    final List<String> versions = new ArrayList<>();
    CursorOperation configuredObjectsCursor = new CursorOperation()
    {
        @Override
        public void processEntry(Database sourceDatabase, Database targetDatabase, Transaction transaction,
                                 DatabaseEntry key, DatabaseEntry value)
        {
            String version = StringBinding.entryToString(key);
            versions.add(version);
        }
    };
    new DatabaseTemplate(_environment, PREFERENCES_VERSION_DB_NAME, null).run(configuredObjectsCursor);
    return versions;
}
 
Example 2
/**
 * Returns the id of the vector which was assigned the given internal id or null if the internal id does
 * not exist. Accesses the BDB store!
 * 
 * @param iid
 *            The internal id of the vector
 * @return The id mapped to the given internal id or null if the internal id does not exist
 */
public String getId(int iid) {
	if (iid < 0 || iid > loadCounter) {
		System.out.println("Internal id " + iid + " is out of range!");
		return null;
	}
	DatabaseEntry key = new DatabaseEntry();
	IntegerBinding.intToEntry(iid, key);
	DatabaseEntry data = new DatabaseEntry();
	if ((iidToIdDB.get(null, key, data, null) == OperationStatus.SUCCESS)) {
		return StringBinding.entryToString(data);
	} else {
		System.out.println("Internal id " + iid + " is in range but id was not found..");
		System.out.println("Index is probably corrupted");
		System.exit(0);
		return null;
	}
}
 
Example 3
Source Project: qpid-broker-j   File: BDBLinkStore.java    License: Apache License 2.0 5 votes vote down vote up
private ModelVersion getStoredVersion() throws RuntimeException
{
    try(Cursor cursor = getLinksVersionDb().openCursor(null, null))
    {
        DatabaseEntry key = new DatabaseEntry();
        DatabaseEntry value = new DatabaseEntry();

        ModelVersion storedVersion = null;
        while (cursor.getNext(key, value, LockMode.READ_UNCOMMITTED) == OperationStatus.SUCCESS)
        {
            String versionString = StringBinding.entryToString(key);
            ModelVersion version = ModelVersion.fromString(versionString);
            if (storedVersion == null || storedVersion.lessThan(version))
            {
                storedVersion = version;
            }
        }
        if (storedVersion == null)
        {
            throw new StoreException("No link version information.");
        }
        return storedVersion;
    }
    catch (RuntimeException e)
    {
        throw getEnvironmentFacade().handleDatabaseException("Cannot visit link version", e);
    }
}
 
Example 4
ModelVersion getStoredVersion()
{
    try(Cursor cursor = getPreferencesVersionDb().openCursor(null, null))
    {
        DatabaseEntry key = new DatabaseEntry();
        DatabaseEntry value = new DatabaseEntry();

        ModelVersion storedVersion = null;
        while (cursor.getNext(key, value, LockMode.READ_UNCOMMITTED) == OperationStatus.SUCCESS)
        {
            String versionString = StringBinding.entryToString(key);
            ModelVersion version = ModelVersion.fromString(versionString);
            if (storedVersion == null || storedVersion.lessThan(version))
            {
                storedVersion = version;
            }
        }
        if (storedVersion == null)
        {
            throw new StoreException("No preference version information.");
        }
        return storedVersion;
    }
    catch (RuntimeException e)
    {
        throw getEnvironmentFacade().handleDatabaseException("Cannot visit preference version", e);
    }
}
 
Example 5
/**
 * This is a utility method that can be used to dump the contents of the iidToIdDB to a txt file.
 * 
 * @param dumpFilename
 *            Full path to the file where the dump will be written.
 * @throws Exception
 */
public void dumpiidToIdDB(String dumpFilename) throws Exception {
	DatabaseEntry foundKey = new DatabaseEntry();
	DatabaseEntry foundData = new DatabaseEntry();

	ForwardCursor cursor = iidToIdDB.openCursor(null, null);
	BufferedWriter out = new BufferedWriter(new FileWriter(new File(dumpFilename)));
	while (cursor.getNext(foundKey, foundData, LockMode.DEFAULT) == OperationStatus.SUCCESS) {
		int iid = IntegerBinding.entryToInt(foundKey);
		String id = StringBinding.entryToString(foundData);
		out.write(iid + " " + id + "\n");
	}
	cursor.close();
	out.close();
}
 
Example 6
/**
 * This is a utility method that can be used to dump the contents of the idToIidDB to a txt file.
 * 
 * @param dumpFilename
 *            Full path to the file where the dump will be written.
 * @throws Exception
 */
public void dumpidToIidDB(String dumpFilename) throws Exception {
	DatabaseEntry foundKey = new DatabaseEntry();
	DatabaseEntry foundData = new DatabaseEntry();

	ForwardCursor cursor = idToIidDB.openCursor(null, null);
	BufferedWriter out = new BufferedWriter(new FileWriter(new File(dumpFilename)));
	while (cursor.getNext(foundKey, foundData, LockMode.DEFAULT) == OperationStatus.SUCCESS) {
		int iid = IntegerBinding.entryToInt(foundData);
		String id = StringBinding.entryToString(foundKey);
		out.write(id + " " + iid + "\n");
	}
	cursor.close();
	out.close();
}