当前位置: 首页>>代码示例>>Java>>正文


Java SortedKeyValueIterator.getTopKey方法代码示例

本文整理汇总了Java中org.apache.accumulo.core.iterators.SortedKeyValueIterator.getTopKey方法的典型用法代码示例。如果您正苦于以下问题:Java SortedKeyValueIterator.getTopKey方法的具体用法?Java SortedKeyValueIterator.getTopKey怎么用?Java SortedKeyValueIterator.getTopKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.accumulo.core.iterators.SortedKeyValueIterator的用法示例。


在下文中一共展示了SortedKeyValueIterator.getTopKey方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: KeyValueIterator

import org.apache.accumulo.core.iterators.SortedKeyValueIterator; //导入方法依赖的package包/类
/**
 * Constructs an iterator over {@link Value}s whose {@link Key}s are
 * versions of the current topKey of the source
 * {@link SortedKeyValueIterator}.
 *
 * @param source           The {@link SortedKeyValueIterator} of {@link Key},
 *                         {@link Value} pairs from which to read data.
 * @param group            the element group
 * @param elementConverter the elementConverter to use
 * @param schema           the schema
 * @param groupBy          the groupBy properties
 */
public KeyValueIterator(final SortedKeyValueIterator<Key, Value> source,
                        final String group, final AccumuloElementConverter elementConverter,
                        final Schema schema,
                        final Set<String> groupBy) {
    this.source = source;
    this.group = group;
    this.elementConverter = elementConverter;

    final Key unsafeRef = source.getTopKey();
    topKey = new Key(unsafeRef.getRow().getBytes(),
            unsafeRef.getColumnFamily().getBytes(),
            unsafeRef.getColumnQualifier().getBytes(),
            unsafeRef.getColumnVisibility().getBytes(),
            unsafeRef.getTimestamp(),
            unsafeRef.isDeleted(), true);

    schemaGroupBy = schema.getElement(this.group).getGroupBy();
    this.groupBy = groupBy;
    hasNext = _hasNext();
}
 
开发者ID:gchq,项目名称:Gaffer,代码行数:33,代码来源:CoreKeyGroupByCombiner.java

示例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;
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:17,代码来源:BaseFilterIterator.java

示例3: runQuery

import org.apache.accumulo.core.iterators.SortedKeyValueIterator; //导入方法依赖的package包/类
private Map<Set<Tag>, Aggregation> runQuery(SortedKeyValueIterator<Key, Value> iter,
        SortedMap<Key, Value> testData, long period) throws Exception {
    IteratorSetting is = new IteratorSetting(100, AggregationIterator.class);
    AggregationIterator.setAggregationOptions(is, Collections.singletonMap("host", ".*"), Avg.class.getName());
    SortedKeyValueIterator<Key, Value> source = new SortedMapIterator(testData);
    iter.init(source, is.getOptions(), null);
    iter.seek(new Range(), Collections.emptyList(), true);
    assertTrue(iter.hasTop());
    Key key = iter.getTopKey();
    assertEquals(testData.lastKey(), key);
    Map<Set<Tag>, Aggregation> samples = AggregationIterator.decodeValue(iter.getTopValue());
    return samples;
}
 
开发者ID:NationalSecurityAgency,项目名称:timely,代码行数:14,代码来源:AggregationIteratorTest.java

示例4: runQuery

import org.apache.accumulo.core.iterators.SortedKeyValueIterator; //导入方法依赖的package包/类
private Map<Set<Tag>, Downsample> runQuery(SortedKeyValueIterator<Key, Value> iter, SortedMap<Key, Value> testData,
        long period) throws Exception {
    IteratorSetting is = new IteratorSetting(100, DownsampleIterator.class);
    DownsampleIterator.setDownsampleOptions(is, 0, 1000, period, Avg.class.getName());
    SortedKeyValueIterator<Key, Value> source = new SortedMapIterator(testData);
    iter.init(source, is.getOptions(), null);
    iter.seek(new Range(), Collections.emptyList(), true);
    assertTrue(iter.hasTop());
    Key key = iter.getTopKey();
    assertEquals(testData.lastKey(), key);
    Map<Set<Tag>, Downsample> samples = DownsampleIterator.decodeValue(iter.getTopValue());
    return samples;
}
 
开发者ID:NationalSecurityAgency,项目名称:timely,代码行数:14,代码来源:DownsampleIteratorTest.java

示例5: 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);
  }
}
 
开发者ID:apache,项目名称:accumulo-wikisearch,代码行数:34,代码来源:BooleanLogicTreeNode.java

示例6: 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);
		}
	}
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:29,代码来源:QueryFilterIterator.java

示例7: 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;
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:35,代码来源:SecondaryIndexQueryFilterIterator.java

示例8: 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);
        }
    }
 
开发者ID:calrissian,项目名称:accumulo-recipes,代码行数:34,代码来源:BooleanLogicTreeNode.java

示例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);
  }
  
}
 
开发者ID:apache,项目名称:accumulo-wikisearch,代码行数:42,代码来源:BooleanLogicTreeNode.java

示例10: 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)));
	}
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:58,代码来源:MergingVisibilityCombiner.java

示例11: 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();
	}
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:77,代码来源:AttributeSubsettingIterator.java

示例12: 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);
        }

    }
 
开发者ID:calrissian,项目名称:accumulo-recipes,代码行数:42,代码来源:BooleanLogicTreeNode.java


注:本文中的org.apache.accumulo.core.iterators.SortedKeyValueIterator.getTopKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。