Java Code Examples for org.apache.accumulo.core.data.Key

The following are top voted examples for showing how to use org.apache.accumulo.core.data.Key. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to product more good examples.

Example 1
Project: fluo   File: FluoFormatter.java View source code 6 votes vote down vote up
public static String toString(Entry<Key, Value> entry) {
  Key key = entry.getKey();

  long ts = key.getTimestamp();
  String type = "";

  if ((ts & ColumnConstants.PREFIX_MASK) == ColumnConstants.TX_DONE_PREFIX) {
    type = "TX_DONE";
  }
  if ((ts & ColumnConstants.PREFIX_MASK) == ColumnConstants.DEL_LOCK_PREFIX) {
    type = "DEL_LOCK";
  }
  if ((ts & ColumnConstants.PREFIX_MASK) == ColumnConstants.LOCK_PREFIX) {
    type = "LOCK";
  }
  if ((ts & ColumnConstants.PREFIX_MASK) == ColumnConstants.DATA_PREFIX) {
    type = "DATA";
  }
  if ((ts & ColumnConstants.PREFIX_MASK) == ColumnConstants.WRITE_PREFIX) {
    type = "WRITE";
  }
  if ((ts & ColumnConstants.PREFIX_MASK) == ColumnConstants.ACK_PREFIX) {
    type = "ACK";
  }

  String val;
  if (type.equals("WRITE")) {
    val = new WriteValue(entry.getValue().get()).toString();
  } else if (type.equals("DEL_LOCK")) {
    val = new DelLockValue(entry.getValue().get()).toString();
  } else if (type.equals("LOCK")) {
    // TODO can Value be made to extend Bytes w/o breaking API?
    val = new LockValue(entry.getValue().get()).toString();
  } else {
    val = entry.getValue().toString();
  }

  return key.getRow() + " " + key.getColumnFamily() + ":" + key.getColumnQualifier() + " ["
      + key.getColumnVisibility() + "] " + (ts & ColumnConstants.TIMESTAMP_MASK) + "-" + type
      + "\t" + val;
}
 
Example 2
Project: accumulo-wikisearch   File: OptimizedQueryIterator.java View source code 6 votes vote down vote up
public void next() throws IOException {
  if (log.isDebugEnabled()) {
    log.debug("next");
  }
  if (key != null) {
    key = null;
    value = null;
  }
  
  if (eventSpecificRange) {
    // Then this will probably return nothing
    event.next();
    if (event.hasTop()) {
      key = event.getTopKey();
      value = event.getTopValue();
    }
  } else {
    
    do {
      index.next();
      // If the index has a match, then seek the event to the key
      if (index.hasTop()) {
        Key eventKey = index.getTopKey();
        Key endKey = eventKey.followingKey(PartialKey.ROW_COLFAM);
        Key startKey = new Key(eventKey.getRow(), eventKey.getColumnFamily());
        Range eventRange = new Range(startKey, endKey);
        HashSet<ByteSequence> cf = new HashSet<ByteSequence>();
        cf.add(eventKey.getColumnFamilyData());
        event.seek(eventRange, cf, true);
        if (event.hasTop()) {
          key = event.getTopKey();
          value = event.getTopValue();
        }
      }
    } while (key == null && index.hasTop());
  }
  // Sanity check. Make sure both returnValue and returnKey are null or both are not null
  if (!((key == null && value == null) || (key != null && value != null))) {
    log.warn("Key: " + ((key == null) ? "null" : key.toString()));
    log.warn("Value: " + ((value == null) ? "null" : value.toString()));
    throw new IOException("Return values are inconsistent");
  }
  
}
 
Example 3
Project: accumulo-wikisearch   File: BooleanLogicTreeNode.java View source code 6 votes vote down vote up
public Key getMinUniqueID() {
  Iterator<Key> iter = uids.iterator();
  Key min = null;
  while (iter.hasNext()) {
    Key t = (Key) iter.next();
    if (log.isDebugEnabled()) {
      log.debug("OR set member: " + t);
    }
    if (t != null) {
      if (min == null) {
        min = t;
      } else if (t.compareTo(min) < 0) {
        min = t;
      }
    }
  }
  return min;
}