コード例 #1
0
ファイル: RepQuoteExample.java プロジェクト: gildafnai82/craq
  /*
   * void return type since error conditions are propogated
   * via exceptions.
   */
  private void printStocks(Database db) throws DeadlockException, DatabaseException {
    Cursor dbc = db.openCursor(null, null);

    System.out.println("\tSymbol\tPrice");
    System.out.println("\t======\t=====");

    DatabaseEntry key = new DatabaseEntry();
    DatabaseEntry data = new DatabaseEntry();
    OperationStatus ret;
    for (ret = dbc.getFirst(key, data, LockMode.DEFAULT);
        ret == OperationStatus.SUCCESS;
        ret = dbc.getNext(key, data, LockMode.DEFAULT)) {
      String keystr = new String(key.getData(), key.getOffset(), key.getSize());
      String datastr = new String(data.getData(), data.getOffset(), data.getSize());
      System.out.println("\t" + keystr + "\t" + datastr);
    }
    dbc.close();
  }
コード例 #2
0
ファイル: UtilI.java プロジェクト: alexmnazarenko/ice
  //
  // A DatabaseEntry object won't always have a ByteBuffer. In fact, the entry only
  // keeps a ByteBuffer if it's a direct buffer, otherwise the entry keeps a reference
  // to the buffer's backing array and discards the buffer.
  //
  public static ByteBuffer getBuffer(com.sleepycat.db.DatabaseEntry entry) {
    ByteBuffer b = entry.getDataNIO();
    if (b == null) {
      byte[] arr = entry.getData();
      if (arr != null) {
        b = ByteBuffer.wrap(arr, entry.getOffset(), entry.getSize());
      }
    }

    return b;
  }
コード例 #3
0
  /* used in freetext index stuff since the row data is not just a pkey. it also has a
   * pos index after it e.g. 42-pkey:pos
   */
  public void moveWithPartialData(DatabaseEntry newkey, DatabaseEntry partial_data)
      throws DatabaseException {
    key = newkey;
    data = partial_data;
    DatabaseEntry original_data = IteratorUtil.cloneDatabaseEntry(partial_data);
    int s = original_data.getSize();

    last_opstat = index_cursor.getSearchBothRange(key, data, LockMode.DEFAULT);

    if (IteratorUtil.compareDatabaseEntries(original_data, 0, s, data, 0, s) != 0)
      last_opstat = OperationStatus.NOTFOUND;

    //	if(isValid())
    //		System.out.println("\t\tMOVE OK "+new String(key.getData())+" |
    // "+LongBinding.entryToLong(newdata));
    //	else
    //		System.out.println("\t\tFAILED MOVE "+new String(key.getData())+" |
    // "+LongBinding.entryToLong(newdata));
  }