本文整理汇总了Java中org.apache.accumulo.core.iterators.SortedKeyValueIterator.hasTop方法的典型用法代码示例。如果您正苦于以下问题:Java SortedKeyValueIterator.hasTop方法的具体用法?Java SortedKeyValueIterator.hasTop怎么用?Java SortedKeyValueIterator.hasTop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.accumulo.core.iterators.SortedKeyValueIterator
的用法示例。
在下文中一共展示了SortedKeyValueIterator.hasTop方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: runTest
import org.apache.accumulo.core.iterators.SortedKeyValueIterator; //导入方法依赖的package包/类
private void runTest(boolean reseek, TreeMap<Key,Value> source, TreeMap<Key,Value> result, Collection<ByteSequence> cols) throws IOException {
MapIterator src = new MapIterator(source);
SortedKeyValueIterator<Key,Value> iter = new ChunkCombiner();
iter.init(src, null, null);
iter = iter.deepCopy(null);
iter.seek(new Range(), cols, true);
TreeMap<Key,Value> seen = new TreeMap<>();
while (iter.hasTop()) {
assertFalse("already contains " + iter.getTopKey(), seen.containsKey(iter.getTopKey()));
seen.put(new Key(iter.getTopKey()), new Value(iter.getTopValue()));
if (reseek)
iter.seek(new Range(iter.getTopKey().followingKey(PartialKey.ROW_COLFAM_COLQUAL), true, null, true), cols, true);
else
iter.next();
}
assertEquals(result, seen);
}
示例2: accept
import org.apache.accumulo.core.iterators.SortedKeyValueIterator; //导入方法依赖的package包/类
private boolean accept(SortedKeyValueIterator<Key,Value> rowItem) {
while(rowItem.hasTop()) {
Key key = rowItem.getTopKey();
if (this.columnFilter.contains(key)) {
byte[] value;
if (this.valueIn.equals(AccumuloMetadataProcessor.ValueIn.VALUE)) {
value = rowItem.getTopValue().get();
}
else {
value = key.getColumnQualifier().getBytes();
}
return accept(value);
}
}
return true;
}
示例3: TestData
import org.apache.accumulo.core.iterators.SortedKeyValueIterator; //导入方法依赖的package包/类
TestData(SortedKeyValueIterator<Key, Value> iter, Range range, boolean reseek) {
try {
iter.seek(range, new HashSet<ByteSequence>(), false);
while (iter.hasTop()) {
data.put(iter.getTopKey(), iter.getTopValue());
if (reseek) {
iter.seek(
new Range(iter.getTopKey(), false, range.getEndKey(), range.isEndKeyInclusive()),
new HashSet<ByteSequence>(), false);
} else {
iter.next();
}
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
示例4: seek
import org.apache.accumulo.core.iterators.SortedKeyValueIterator; //导入方法依赖的package包/类
public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive) throws IOException {
// always start fresh
this.setTopKey(null);
this.setDone(false);
// get my user object which should be an iterator
SortedKeyValueIterator<?,?> iter = (SortedKeyValueIterator<?,?>) this.getUserObject();
if (iter != null) {
iter.seek(range, columnFamilies, inclusive);
if (iter.hasTop()) {
Key key = (Key) iter.getTopKey();
key = buildKey(key);
this.setTopKey(key);
if (log.isDebugEnabled()) {
log.debug("BLTNODE.seek() -> found: " + this.getTopKey());
}
} else {
if (log.isDebugEnabled()) {
log.debug("BLTNODE.seek() -> hasTop::false");
}
this.setDone(true);
}
} else {
if (log.isDebugEnabled()) {
log.debug("BLTNODE.seek(), The iterator was null!");
}
this.setTopKey(null);
}
}
示例5: findTopEnhanced
import org.apache.accumulo.core.iterators.SortedKeyValueIterator; //导入方法依赖的package包/类
protected static void findTopEnhanced(
final SortedKeyValueIterator<Key, Value> source,
final Filter filter ) {
Key key;
if (source.hasTop()) {
key = source.getTopKey();
}
else {
return;
}
while (!key.isDeleted() && !filter.accept(
key,
source.getTopValue())) {
try {
source.next();
if (source.hasTop()) {
key = source.getTopKey();
}
else {
return;
}
}
catch (final IOException e) {
throw new RuntimeException(
e);
}
}
}
示例6: acceptRow
import org.apache.accumulo.core.iterators.SortedKeyValueIterator; //导入方法依赖的package包/类
@Override
public boolean acceptRow(
final SortedKeyValueIterator<Key, Value> rowIterator )
throws IOException {
if (filter != null) {
while (rowIterator.hasTop()) {
final Key key = rowIterator.getTopKey();
final Value value = rowIterator.getTopValue();
final String cq = StringUtils.stringFromBinary(key.getColumnQualifierData().getBackingArray());
if (!cq.equals(primaryIndexId)) {
final IndexedPersistenceEncoding<ByteArrayId> persistenceEncoding = new IndexedPersistenceEncoding<ByteArrayId>(
null, // not needed
null, // not needed
null, // not needed
0, // not needed
new PersistentDataset<ByteArrayId>(
new PersistentValue<ByteArrayId>(
new ByteArrayId(
key.getColumnQualifierData().getBackingArray()),
new ByteArrayId(
value.get()))),
null);
if (filter.accept(
null,
persistenceEncoding)) return true;
}
rowIterator.next();
}
return false;
}
// should not happen but if the filter is not sent to this iterator, it
// will accept everything
return true;
}
示例7: seek
import org.apache.accumulo.core.iterators.SortedKeyValueIterator; //导入方法依赖的package包/类
public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive) throws IOException {
// always start fresh
this.setTopKey(null);
this.setDone(false);
// get my user object which should be an iterator
SortedKeyValueIterator<?, ?> iter = (SortedKeyValueIterator<?, ?>) this.getUserObject();
if (iter != null) {
iter.seek(range, columnFamilies, inclusive);
if (iter.hasTop()) {
Key key = (Key) iter.getTopKey();
key = buildKey(key);
this.setTopKey(key);
if (log.isDebugEnabled()) {
log.debug("BLTNODE.seek() -> found: " + this.getTopKey());
}
} else {
if (log.isDebugEnabled()) {
log.debug("BLTNODE.seek() -> hasTop::false");
}
this.setDone(true);
}
} else {
if (log.isDebugEnabled()) {
log.debug("BLTNODE.seek(), The iterator was null!");
}
this.setTopKey(null);
}
}
示例8: stringTopKey
import org.apache.accumulo.core.iterators.SortedKeyValueIterator; //导入方法依赖的package包/类
public static String stringTopKey(SortedKeyValueIterator<Key,Value> iter) {
if (iter.hasTop()) {
return iter.getTopKey().toString();
}
return "";
}
示例9: next
import org.apache.accumulo.core.iterators.SortedKeyValueIterator; //导入方法依赖的package包/类
public void next() throws IOException {
// always start fresh
this.setTopKey(null);
if (log.isDebugEnabled()) {
TreeNode[] path = this.getPath();
log.debug("BLTNODE.next() path-> " + this.buildTreePathString(path));
}
// have I been marked as done?
if (this.isDone()) {
if (log.isDebugEnabled()) {
log.debug("I've been marked as done, returning");
}
return;
}
SortedKeyValueIterator<?,?> iter = (SortedKeyValueIterator<?,?>) this.getUserObject();
iter.next();
if (iter.hasTop()) {
Key key = (Key) iter.getTopKey();
// I have a valid topKey, pull out the piece I want
key = buildKey(key);
this.setTopKey(key);
if (log.isDebugEnabled()) {
log.debug("BLTNODE.next() -> found: " + this.getTopKey());
}
} else {
// no top value has been returned, I'm done.
if (log.isDebugEnabled()) {
log.debug("BLTNODE.next() -> Nothing found");
}
this.setTopKey(null);
this.setDone(true);
}
}
示例10: stringTopKey
import org.apache.accumulo.core.iterators.SortedKeyValueIterator; //导入方法依赖的package包/类
public static String stringTopKey(SortedKeyValueIterator<Key,Value> iter) {
if (iter.hasTop())
return iter.getTopKey().toString();
return "";
}
示例11: stringTopKey
import org.apache.accumulo.core.iterators.SortedKeyValueIterator; //导入方法依赖的package包/类
public static String stringTopKey(final SortedKeyValueIterator<Key, Value> iter) {
if (iter.hasTop()) {
return iter.getTopKey().toString();
}
return "";
}
示例12: transformRange
import org.apache.accumulo.core.iterators.SortedKeyValueIterator; //导入方法依赖的package包/类
@Override
protected void transformRange(
final SortedKeyValueIterator<Key, Value> input,
final KVBuffer output )
throws IOException {
Mergeable currentMergeable = null;
Key outputKey = null;
while (input.hasTop()) {
final Value val = input.getTopValue();
// the SortedKeyValueIterator uses the same instance of topKey to
// hold keys (a wrapper)
final Key currentKey = new Key(
input.getTopKey());
if (outputKey == null) {
outputKey = currentKey;
}
else if ((currentMergeable != null) && !outputKey.getRowData().equals(
currentKey.getRowData())) {
output.append(
outputKey,
new Value(
AccumuloUtils.toBinary(currentMergeable)));
currentMergeable = null;
outputKey = currentKey;
continue;
}
else {
final Text combinedVisibility = new Text(
combineVisibilities(
currentKey.getColumnVisibility().getBytes(),
outputKey.getColumnVisibility().getBytes()));
outputKey = replaceColumnVisibility(
outputKey,
combinedVisibility);
}
final Mergeable mergeable = getMergeable(
currentKey,
val.get());
// hopefully its never the case that null mergeables are stored,
// but just in case, check
if (mergeable != null) {
if (currentMergeable == null) {
currentMergeable = mergeable;
}
else {
currentMergeable.merge(mergeable);
}
}
input.next();
}
if (currentMergeable != null) {
output.append(
outputKey,
new Value(
getBinary(currentMergeable)));
}
}
示例13: transformRange
import org.apache.accumulo.core.iterators.SortedKeyValueIterator; //导入方法依赖的package包/类
@Override
protected void transformRange(
final SortedKeyValueIterator<Key, Value> input,
final KVBuffer output )
throws IOException {
while (input.hasTop()) {
final Key wholeRowKey = input.getTopKey();
final Value wholeRowVal = input.getTopValue();
final SortedMap<Key, Value> rowMapping;
if (wholeRowEncoded) {
rowMapping = WholeRowIterator.decodeRow(
wholeRowKey,
wholeRowVal);
}
else {
rowMapping = new TreeMap<Key, Value>();
rowMapping.put(
wholeRowKey,
wholeRowVal);
}
final List<Key> keyList = new ArrayList<>();
final List<Value> valList = new ArrayList<>();
Text adapterId = null;
for (final Entry<Key, Value> row : rowMapping.entrySet()) {
final Key currKey = row.getKey();
final Value currVal = row.getValue();
if (adapterId == null) {
adapterId = currKey.getColumnFamily();
}
final byte[] originalBitmask = currKey.getColumnQualifierData().getBackingArray();
final byte[] newBitmask = BitmaskUtils.generateANDBitmask(
originalBitmask,
fieldSubsetBitmask);
if (BitmaskUtils.isAnyBitSet(newBitmask)) {
if (!Arrays.equals(
newBitmask,
originalBitmask)) {
keyList.add(replaceColumnQualifier(
currKey,
new Text(
newBitmask)));
valList.add(constructNewValue(
currVal,
originalBitmask,
newBitmask));
}
else {
// pass along unmodified
keyList.add(currKey);
valList.add(currVal);
}
}
}
if (!keyList.isEmpty() && !valList.isEmpty()) {
final Value outputVal;
final Key outputKey;
if (wholeRowEncoded) {
outputKey = new Key(
wholeRowKey.getRow(),
adapterId);
outputVal = WholeRowIterator.encodeRow(
keyList,
valList);
}
else {
outputKey = keyList.get(0);
outputVal = valList.get(0);
}
output.append(
outputKey,
outputVal);
}
input.next();
}
}
示例14: stringTopKey
import org.apache.accumulo.core.iterators.SortedKeyValueIterator; //导入方法依赖的package包/类
public static String stringTopKey(SortedKeyValueIterator<Key, Value> iter) {
if (iter.hasTop()) {
return iter.getTopKey().toString();
}
return "";
}
示例15: next
import org.apache.accumulo.core.iterators.SortedKeyValueIterator; //导入方法依赖的package包/类
public void next() throws IOException {
// always start fresh
this.setTopKey(null);
if (log.isDebugEnabled()) {
TreeNode[] path = this.getPath();
log.debug("BLTNODE.next() path-> " + this.buildTreePathString(path));
}
// have I been marked as done?
if (this.isDone()) {
if (log.isDebugEnabled()) {
log.debug("I've been marked as done, returning");
}
return;
}
SortedKeyValueIterator<?, ?> iter = (SortedKeyValueIterator<?, ?>) this.getUserObject();
iter.next();
if (iter.hasTop()) {
Key key = (Key) iter.getTopKey();
// I have a valid topKey, pull out the piece I want
key = buildKey(key);
this.setTopKey(key);
if (log.isDebugEnabled()) {
log.debug("BLTNODE.next() -> found: " + this.getTopKey());
}
} else {
// no top value has been returned, I'm done.
if (log.isDebugEnabled()) {
log.debug("BLTNODE.next() -> Nothing found");
}
this.setTopKey(null);
this.setDone(true);
}
}