コード例 #1
0
  public List<Person> all() {
    try {
      // Java Scan
      ScanPolicy policy = new ScanPolicy();
      policy.concurrentNodes = true;
      policy.priority = Priority.LOW;
      policy.includeBinData = true;
      final List<Person> persons = new ArrayList<Person>();
      client.scanAll(
          policy,
          "test",
          "demo",
          new ScanCallback() {

            @Override
            public void scanCallback(Key key, Record record) throws AerospikeException {

              persons.add(getPerson(key, record));
            }
          });
      return persons;
    } catch (AerospikeException e) {
      System.out.println("EXCEPTION - Message: " + e.getMessage());
      return new ArrayList<Person>();
    }
  } //
コード例 #2
0
  public void scanAllTweetsForAllUsers() {
    try {
      // Java Scan
      ScanPolicy policy = new ScanPolicy();
      policy.concurrentNodes = true;
      policy.priority = Priority.LOW;
      policy.includeBinData = true;

      client.scanAll(
          policy,
          "test",
          "tweets",
          new ScanCallback() {

            public void scanCallback(Key key, Record record) throws AerospikeException {
              console.printf(record.getValue("tweet") + "\n");
            }
          },
          "tweet");
    } catch (AerospikeException e) {
      System.out.println("EXCEPTION - Message: " + e.getMessage());
      System.out.println("EXCEPTION - StackTrace: " + UtilityService.printStackTrace(e));
    }
  } // scanAllTweetsForAllUsers