本文整理汇总了Java中org.apache.accumulo.core.data.Key.followingKey方法的典型用法代码示例。如果您正苦于以下问题:Java Key.followingKey方法的具体用法?Java Key.followingKey怎么用?Java Key.followingKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.accumulo.core.data.Key
的用法示例。
在下文中一共展示了Key.followingKey方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: lookup
import org.apache.accumulo.core.data.Key; //导入方法依赖的package包/类
@Override
public SearchLookupResponse lookup(SearchLookupRequest msg) throws TimelyException {
long startMillis = System.currentTimeMillis();
SearchLookupResponse result = new SearchLookupResponse();
result.setType("LOOKUP");
result.setMetric(msg.getQuery());
Map<String, String> tags = new TreeMap<>();
for (Tag tag : msg.getTags()) {
tags.put(tag.getKey(), tag.getValue());
}
result.setTags(tags);
result.setLimit(msg.getLimit());
Map<String, Pattern> tagPatterns = new HashMap<>();
tags.forEach((k, v) -> {
tagPatterns.put(k, Pattern.compile(v));
});
try {
List<Result> resultField = new ArrayList<>();
Scanner scanner = connector.createScanner(metaTable, Authorizations.EMPTY);
Key start = new Key(Meta.VALUE_PREFIX + msg.getQuery());
Key end = start.followingKey(PartialKey.ROW);
Range range = new Range(start, end);
scanner.setRange(range);
tags.keySet().forEach(k -> scanner.fetchColumnFamily(new Text(k)));
int total = 0;
for (Entry<Key, Value> entry : scanner) {
Meta metaEntry = Meta.parse(entry.getKey(), entry.getValue());
if (matches(metaEntry.getTagKey(), metaEntry.getTagValue(), tagPatterns)) {
if (resultField.size() < msg.getLimit()) {
Result r = new Result();
r.putTag(metaEntry.getTagKey(), metaEntry.getTagValue());
resultField.add(r);
}
total++;
}
}
result.setResults(resultField);
result.setTotalResults(total);
result.setTime((int) (System.currentTimeMillis() - startMillis));
} catch (Exception ex) {
LOG.error("Error during lookup: " + ex.getMessage(), ex);
throw new TimelyException(HttpResponseStatus.INTERNAL_SERVER_ERROR.code(), "Error during lookup: "
+ ex.getMessage(), ex.getMessage(), ex);
}
return result;
}
示例2: doSeek
import org.apache.accumulo.core.data.Key; //导入方法依赖的package包/类
private void doSeek(Range range) throws IOException {
overallRange = new Range(range);
if (range.getEndKey() != null && range.getEndKey().getRow() != null) {
this.parentEndRow = range.getEndKey().getRow();
}
// seek each of the sources to the right column family within the row given by key
for (int i = 0; i < sourcesCount; i++) {
Key sourceKey;
Text dataLocation = (sources[i].dataLocation == null) ? nullText : sources[i].dataLocation;
if (range.getStartKey() != null) {
// Build a key with the DocID if one is given
if (range.getStartKey().getColumnFamily() != null) {
sourceKey = buildKey(getPartition(range.getStartKey()), dataLocation,
(sources[i].term == null) ? nullText : new Text(sources[i].term + "\0" + range.getStartKey().getColumnFamily()));
} // Build a key with just the term.
else {
sourceKey = buildKey(getPartition(range.getStartKey()), dataLocation,
(sources[i].term == null) ? nullText : sources[i].term);
}
if (!range.isStartKeyInclusive())
sourceKey = sourceKey.followingKey(PartialKey.ROW_COLFAM_COLQUAL);
sources[i].iter.seek(new Range(sourceKey, true, null, false), sources[i].seekColumnFamilies, SEEK_INCLUSIVE);
} else {
sources[i].iter.seek(range, sources[i].seekColumnFamilies, SEEK_INCLUSIVE);
}
}
advanceToIntersection();
if (hasTop()) {
if (overallRange != null && !overallRange.contains(topKey)) {
topKey = null;
if (log.isDebugEnabled()) {
log.debug("doSeek, topKey is outside of overall range: " + overallRange);
}
}
}
}
示例3: next
import org.apache.accumulo.core.data.Key; //导入方法依赖的package包/类
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");
}
}
示例4: buildFollowingPartitionKey
import org.apache.accumulo.core.data.Key; //导入方法依赖的package包/类
/**
* Return the key that directly follows the given key
*
* @param key
* The key who will be directly before the returned key
* @return The key directly following the given key.
*/
protected Key buildFollowingPartitionKey(Key key) {
return key.followingKey(PartialKey.ROW);
}