本文整理汇总了Java中com.sleepycat.bind.tuple.StringBinding类的典型用法代码示例。如果您正苦于以下问题:Java StringBinding类的具体用法?Java StringBinding怎么用?Java StringBinding使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StringBinding类属于com.sleepycat.bind.tuple包,在下文中一共展示了StringBinding类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例3: display
import com.sleepycat.bind.tuple.StringBinding; //导入依赖的package包/类
@Override
protected void display() {
out.print(" VLSN=" + currentEntryHeader.getVLSN());
DatabaseEntry key = new DatabaseEntry(targetEntry.getKey());
LN ln = targetEntry.getLN();
if (ln.isDeleted()) {
outStream.print("<deleted>");
} else {
DatabaseEntry data = new DatabaseEntry(ln.getData());
String keyVal = StringBinding.entryToString(key);
TupleBinding<?> binding = null;
if (keyVal.equals(RepGroupDB.GROUP_KEY)) {
outStream.print(" GroupInfo: ");
binding = new GroupBinding();
} else {
outStream.print(" NodeInfo: " + keyVal);
binding = new NodeBinding();
}
outStream.print(binding.entryToObject(data));
}
}
示例4: addNewMapEntry
import com.sleepycat.bind.tuple.StringBinding; //导入依赖的package包/类
private void addNewMapEntry(Transaction txn,
DatabaseEntry key,
DatabaseEntry data,
boolean isDelete) {
String dataSetName = StringBinding.entryToString(key);
/* Only do it if it's a CHANGE_SET information. */
if (DataType.getDataType(dataSetName) == DataType.CHANGE_SET) {
Map<String, StartInfo> syncStartInfos =
txnIdToSyncStarts.get(txn.getId());
if (syncStartInfos == null) {
syncStartInfos =
new ConcurrentHashMap<String, StartInfo>();
txnIdToSyncStarts.put(txn.getId(), syncStartInfos);
}
LogChangeSetBinding binding = new LogChangeSetBinding();
LogChangeSet set = binding.entryToObject(data);
StartInfo startInfo =
new StartInfo(set.getNextSyncStart(), isDelete);
syncStartInfos.put(dataSetName, startInfo);
}
}
示例5: LabelDatabase
import com.sleepycat.bind.tuple.StringBinding; //导入依赖的package包/类
/**
* Creates or connects to a database, whose name and type will be {@link WDatabase.DatabaseType#label}.
* This will index label statistics according to their raw, unprocessed texts.
*
* @param env the WEnvironment surrounding this database
*/
public LabelDatabase(WEnvironment env) {
super(
env,
DatabaseType.label,
new StringBinding(),
new RecordBinding<DbLabel>() {
public DbLabel createRecordInstance() {
return new DbLabel() ;
}
}
) ;
textProcessor = null ;
}
示例6: getId
import com.sleepycat.bind.tuple.StringBinding; //导入依赖的package包/类
/**
* 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;
}
}
示例7: buildTitleDatabase
import com.sleepycat.bind.tuple.StringBinding; //导入依赖的package包/类
public WDatabase<String, Integer> buildTitleDatabase(DatabaseType type) {
if (type != DatabaseType.articlesByTitle && type != DatabaseType.categoriesByTitle)
throw new IllegalArgumentException("type must be either DatabaseType.articlesByTitle or DatabaseType.categoriesByTitle") ;
return new WDatabase<String, Integer>(
env,
type,
new StringBinding(),
new IntegerBinding()
);
}
示例8: createBinding
import com.sleepycat.bind.tuple.StringBinding; //导入依赖的package包/类
private EntryBinding createBinding(final Type type) throws UnsupportedOperationException {
if (ReflectionUtils.isString(type)) {
return new StringBinding();
}
if (ReflectionUtils.isInteger(type)) {
return new IntegerBinding();
}
if (ReflectionUtils.isLong(type)) {
return new LongBinding();
}
if (ReflectionUtils.isBoolean(type)) {
return new BooleanBinding();
}
if (ReflectionUtils.isShort(type)) {
return new ShortBinding();
}
if (ReflectionUtils.isByte(type)) {
return new ByteBinding();
}
if (ReflectionUtils.isDouble(type)) {
return new DoubleBinding();
}
if (ReflectionUtils.isFloat(type)) {
return new FloatBinding();
}
if (ReflectionUtils.isCharacter(type)) {
return new CharacterBinding();
}
if (ReflectionUtils.isByteArray(type)) {
return new ByteArrayBinding();
}
throw new UnsupportedOperationException("Cannot provide collection of type " + type);
}
示例9: 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;
}
示例10: createBinding
import com.sleepycat.bind.tuple.StringBinding; //导入依赖的package包/类
private EntryBinding createBinding(Type type)
throws UnsupportedOperationException {
if (ReflectionUtils.isString(type)) {
return new StringBinding();
}
if (ReflectionUtils.isInteger(type)) {
return new IntegerBinding();
}
if (ReflectionUtils.isLong(type)) {
return new LongBinding();
}
if (ReflectionUtils.isBoolean(type)) {
return new BooleanBinding();
}
if (ReflectionUtils.isShort(type)) {
return new ShortBinding();
}
if (ReflectionUtils.isByte(type)) {
return new ByteBinding();
}
if (ReflectionUtils.isDouble(type)) {
return new DoubleBinding();
}
if (ReflectionUtils.isFloat(type)) {
return new FloatBinding();
}
if (ReflectionUtils.isCharacter(type)) {
return new CharacterBinding();
}
if (ReflectionUtils.isByteArray(type)) {
return new ByteArrayBinding();
}
throw new UnsupportedOperationException(
"Cannot provide collection of type " + type);
}
示例11: 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();
}
}
}
示例12: readDataForType
import com.sleepycat.bind.tuple.StringBinding; //导入依赖的package包/类
public Map<String, DatabaseEntry> readDataForType(DataType dataType,
Environment env) {
if (dbImpl == null) {
return null;
}
Locker locker = null;
boolean operationOK = false;
Map<String, DatabaseEntry> readData =
new HashMap<String, DatabaseEntry>();
try {
locker = LockerFactory.getReadableLocker
(env, null, dbImpl.isTransactional(), false);
Cursor cursor = makeCursor(locker);
DatabaseEntry key = new DatabaseEntry();
DatabaseEntry data = new DatabaseEntry();
while (OperationStatus.SUCCESS ==
cursor.getNext(key, data, null)) {
String keyName = StringBinding.entryToString(key);
if (DataType.getDataType(keyName).equals(dataType)) {
readData.put(keyName, data);
}
data = new DatabaseEntry();
}
operationOK = true;
} finally {
if (locker != null) {
locker.operationEnd(operationOK);
}
}
return readData;
}
示例13: 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;
}
}
示例14: 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
}
示例15: dumpiidToIdDB
import com.sleepycat.bind.tuple.StringBinding; //导入依赖的package包/类
/**
* 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();
}