com.sleepycat.je.Cursor.getSearchKeyRange()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(227)

本文整理了Java中com.sleepycat.je.Cursor.getSearchKeyRange()方法的一些代码示例,展示了Cursor.getSearchKeyRange()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Cursor.getSearchKeyRange()方法的具体详情如下:
包路径:com.sleepycat.je.Cursor
类名称:Cursor
方法名:getSearchKeyRange

Cursor.getSearchKeyRange介绍

[英]Moves the cursor to the closest matching key of the database, and returns the data item associated with the matching key. If the matching key has duplicate values, the first data item in the set of duplicates is returned.

Calling this method is equivalent to calling #get(DatabaseEntry,DatabaseEntry,Get,ReadOptions) with Get#SEARCH_GTE.

The returned key/data pair is for the smallest key greater than or equal to the specified key (as determined by the key comparison function), permitting partial key matches and range searches.
[中]将光标移动到数据库中最近的匹配键,并返回与匹配键关联的数据项。如果匹配项具有重复值,则返回重复项集中的第一个数据项。
调用此方法相当于使用get#SEARCH#GTE调用#get(DatabaseEntry,DatabaseEntry,get,ReadOptions)。
返回的密钥/数据对用于大于或等于指定密钥(由密钥比较函数确定)的最小密钥,允许部分密钥匹配和范围搜索。

代码示例

代码示例来源:origin: internetarchive/heritrix3

try {
  cursor = pendingUrisDB.openCursor(null, null);
  OperationStatus result = cursor.getSearchKeyRange(headKey,
      value, null);

代码示例来源:origin: thinkaurelius/titan

OperationStatus status = cursor.getSearchKeyRange(foundKey, foundData, getLockMode(txh));

代码示例来源:origin: internetarchive/heritrix3

long forgottenCount = 0l;
for (OperationStatus status = cursor.getSearchKeyRange(key, value, null);
    status == OperationStatus.SUCCESS;
    status = cursor.getNext(key, value, null)) {

代码示例来源:origin: voldemort/voldemort

positioned = true;
keyEntry.setData(StoreBinaryFormat.makePartitionKey(partition));
status = cursor.getSearchKeyRange(keyEntry,
                 valueEntry,
                 LockMode.READ_UNCOMMITTED);

代码示例来源:origin: voldemort/voldemort

positioned = true;
keyEntry.setData(StoreBinaryFormat.makePartitionKey(partition));
status = cursor.getSearchKeyRange(keyEntry,
                 valueEntry,
                 LockMode.READ_UNCOMMITTED);

代码示例来源:origin: opensourceBIM/BIMserver

private Record getFirstNext(byte[] startSearchingAt) throws BimserverLockConflictException {
  this.nextStartSearchingAt = null;
  DatabaseEntry key = new DatabaseEntry(startSearchingAt);
  DatabaseEntry value = new DatabaseEntry();
  if (onlyKeys) {
    value.setPartial(0, 0, true);
  }
  try {
    OperationStatus next = cursor.getSearchKeyRange(key, value, LockMode.DEFAULT);
    if (next == OperationStatus.SUCCESS) {
      byte[] firstBytes = new byte[mustStartWith.length];
      System.arraycopy(key.getData(), 0, firstBytes, 0, mustStartWith.length);
      if (Arrays.equals(firstBytes, mustStartWith)) {
        return new BerkeleyRecord(key, value);
      }
    }
  } catch (LockConflictException e) {
    throw new BimserverLockConflictException(e);
  } catch (DatabaseException e) {
    LOGGER.error("", e);
  }
  return null;
}

代码示例来源:origin: com.amazon.carbonado/carbonado-sleepycat-je

@Override
protected boolean cursor_getSearchKeyRange() throws Exception {
  return cursor().getSearchKeyRange(mSearchKey, mData, mLockMode) == SUCCESS;
}

代码示例来源:origin: org.reddwarfserver.server/sgs-server

/** {@inheritDoc} */
public boolean findNext(byte[] key) {
DatabaseEntry searchEntry = new DatabaseEntry(key);
try {
  OperationStatus status =
  cursor.getSearchKeyRange(searchEntry, valueEntry, null);
  if (status == SUCCESS) {
  keyEntry = searchEntry;
  isCurrent = true;
  return true;
  } else if (status == NOTFOUND) {
  return false;
  } else {
  throw new DbDatabaseException("Operation failed: " + status);
  }
} catch (DatabaseException e) {
  throw JeEnvironment.convertException(e, true);
}
}

代码示例来源:origin: com.projectdarkstar.server/sgs-server

/** {@inheritDoc} */
public boolean findNext(byte[] key) {
DatabaseEntry searchEntry = new DatabaseEntry(key);
try {
  OperationStatus status =
  cursor.getSearchKeyRange(searchEntry, valueEntry, null);
  if (status == SUCCESS) {
  keyEntry = searchEntry;
  isCurrent = true;
  return true;
  } else if (status == NOTFOUND) {
  return false;
  } else {
  throw new DbDatabaseException("Operation failed: " + status);
  }
} catch (DatabaseException e) {
  throw JeEnvironment.convertException(e, true);
}
}

代码示例来源:origin: dworkin/reddwarf

/** {@inheritDoc} */
public boolean findNext(byte[] key) {
DatabaseEntry searchEntry = new DatabaseEntry(key);
try {
  OperationStatus status =
  cursor.getSearchKeyRange(searchEntry, valueEntry, null);
  if (status == SUCCESS) {
  keyEntry = searchEntry;
  isCurrent = true;
  return true;
  } else if (status == NOTFOUND) {
  return false;
  } else {
  throw new DbDatabaseException("Operation failed: " + status);
  }
} catch (DatabaseException e) {
  throw JeEnvironment.convertException(e, true);
}
}

代码示例来源:origin: co.paralleluniverse/galaxy

@Override
public short findAllocation(long ref) {
  final DatabaseEntry key = new DatabaseEntry();
  final DatabaseEntry data = new DatabaseEntry();
  try (Cursor cursor = allocationDirectory.openCursor(null, CursorConfig.DEFAULT)) {
    OperationStatus retVal = cursor.getSearchKeyRange(key, data, null);
    if (retVal == OperationStatus.SUCCESS) {
      ownerDirectory.put(null, key, SERVER);
      return Shorts.fromByteArray(data.getData());
    } else if (retVal == OperationStatus.NOTFOUND)
      return (short) -1;
    throw new AssertionError();
  }
}

代码示例来源:origin: iipc/openwayback

private void initialize(Cursor cursor,String search, boolean backward)
throws DatabaseException {
  this.cursor = cursor;
  this.backward = backward;
  key = new DatabaseEntry();
  value = new DatabaseEntry();
  key.setData(search.getBytes());
  key.setPartial(false);
  OperationStatus status = cursor.getSearchKeyRange(key, value,
      LockMode.DEFAULT);
  if(backward && (status == OperationStatus.SUCCESS)) {
    // if we are in reverse, immediately back up one record:
    status = cursor.getPrev(key, value, LockMode.DEFAULT);
  }
  if(status == OperationStatus.SUCCESS) {
    gotNext = true;
  }
  record = new BDBRecord(key,value);
}

代码示例来源:origin: org.netpreserve.openwayback/openwayback-core

private void initialize(Cursor cursor,String search, boolean backward)
throws DatabaseException {
  this.cursor = cursor;
  this.backward = backward;
  key = new DatabaseEntry();
  value = new DatabaseEntry();
  key.setData(search.getBytes());
  key.setPartial(false);
  OperationStatus status = cursor.getSearchKeyRange(key, value,
      LockMode.DEFAULT);
  if(backward && (status == OperationStatus.SUCCESS)) {
    // if we are in reverse, immediately back up one record:
    status = cursor.getPrev(key, value, LockMode.DEFAULT);
  }
  if(status == OperationStatus.SUCCESS) {
    gotNext = true;
  }
  record = new BDBRecord(key,value);
}

代码示例来源:origin: org.deephacks/graphene-core

public Map<byte[], byte[]> listAll() {
 Map<byte[], byte[]> map = new HashMap<>();
 try (Cursor cursor = db.get().openCursor(tm.getInternalTx(), null)) {
  DatabaseEntry firstKey = new DatabaseEntry(RowKey.getMinId().getKey());
  DatabaseEntry entry = new DatabaseEntry();
  if (cursor.getSearchKeyRange(firstKey, entry, LockMode.RMW) == OperationStatus.SUCCESS) {
   map.put(firstKey.getData(), entry.getData());
  }
  while (cursor.getNextNoDup(firstKey, entry, LockMode.RMW) == OperationStatus.SUCCESS) {
   map.put(firstKey.getData(), entry.getData());
  }
 }
 return map;
}

代码示例来源:origin: HuygensING/timbuctoo

public List<String> dump(String prefix, int start, int count, LockMode lockMode) {
 EntryBinding<String> binder = TupleBinding.getPrimitiveBinding(String.class);
 DatabaseEntry key = new DatabaseEntry();
 binder.objectToEntry(prefix, key);
 DatabaseEntry value = new DatabaseEntry();
 Cursor cursor = database.openCursor(null, null);
 OperationStatus status = cursor.getSearchKeyRange(key, value, LockMode.READ_UNCOMMITTED);
 List<String> result = new ArrayList<>();
 int index = 0;
 while (status == OperationStatus.SUCCESS && index < (start + count)) {
  if (index >= start) {
   result.add(
    binder.entryToObject(key) + " -> " + binder.entryToObject(value)
   );
  }
  index++;
  status = cursor.getNext(key, value, LockMode.READ_UNCOMMITTED);
 }
 cursor.close();
 return result;
}

代码示例来源:origin: addthis/hydra

try {
  cursor = bdb.openCursor(null, CursorConfig.READ_UNCOMMITTED);
  OperationStatus status = cursor.getSearchKeyRange(dk, dvs, lockMode);

代码示例来源:origin: addthis/hydra

try {
  cursor = bdb.openCursor(null, CursorConfig.READ_UNCOMMITTED);
  OperationStatus status = cursor.getSearchKeyRange(dk, dvs, lockMode);

代码示例来源:origin: org.deephacks/graphene-core

public ByteIteratorWrapper(Iterator<byte[][]> iterator, Serializer serializer) {
 this.iterator = iterator;
 this.serializer = serializer;
}

代码示例来源:origin: org.deephacks/graphene-core

public void deleteAll() {
  try (Cursor cursor = db.get().openCursor(tm.getInternalTx(), null)) {
   DatabaseEntry firstKey = new DatabaseEntry(RowKey.getMinId().getKey());

   if (cursor.getSearchKeyRange(firstKey, new DatabaseEntry(), LockMode.RMW) == OperationStatus.SUCCESS) {
    cursor.delete();
   }

   while (cursor.getNextNoDup(firstKey, new DatabaseEntry(), LockMode.RMW) == OperationStatus.SUCCESS) {
    cursor.delete();
   }
  }
 }
}

代码示例来源:origin: org.deephacks/graphene-core

public ByteIteratorWrapper(Iterator<byte[][]> iterator, Serializer serializer) {
  this.iterator = iterator;
  this.serializer = serializer;
}

相关文章