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


Java ScannerBase.close方法代码示例

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


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

示例1: streamingPropertyValueTableDatas

import org.apache.accumulo.core.client.ScannerBase; //导入方法依赖的package包/类
private Map<String, byte[]> streamingPropertyValueTableDatas(List<String> dataRowKeys) {
    try {
        if (dataRowKeys.size() == 0) {
            return Collections.emptyMap();
        }

        List<org.apache.accumulo.core.data.Range> ranges = dataRowKeys.stream()
                .map(RangeUtils::createRangeFromString)
                .collect(Collectors.toList());

        final long timerStartTime = System.currentTimeMillis();
        ScannerBase scanner = graph.createBatchScanner(graph.getDataTableName(), ranges, new org.apache.accumulo.core.security.Authorizations());

        graph.getGraphLogger().logStartIterator(scanner);
        Span trace = Trace.start("streamingPropertyValueTableData");
        trace.data("dataRowKeyCount", Integer.toString(dataRowKeys.size()));
        try {
            Map<String, byte[]> results = new HashMap<>();
            for (Map.Entry<Key, Value> col : scanner) {
                results.put(col.getKey().getRow().toString(), col.getValue().get());
            }
            return results;
        } finally {
            scanner.close();
            trace.stop();
            graph.getGraphLogger().logEndIterator(System.currentTimeMillis() - timerStartTime);
        }
    } catch (Exception ex) {
        throw new VertexiumException(ex);
    }
}
 
开发者ID:visallo,项目名称:vertexium,代码行数:32,代码来源:OverflowIntoHdfsStreamingPropertyValueStorageStrategy.java

示例2: initIterator

import org.apache.accumulo.core.client.ScannerBase; //导入方法依赖的package包/类
@Override
protected Iterator initIterator(
		final AdapterStore adapterStore,
		final ScannerBase scanner ) {
	if (isAggregation()) {
		// aggregate the stats to a single value here

		try {
			final Iterator<Entry<Key, Value>> it = scanner.iterator();
			Mergeable mergedAggregationResult = null;
			if (!it.hasNext()) {
				return Iterators.emptyIterator();
			}
			else {
				while (it.hasNext()) {
					final Entry<Key, Value> input = it.next();
					if (input.getValue() != null) {
						if (mergedAggregationResult == null) {
							mergedAggregationResult = (Mergeable) AccumuloUtils.fromBinary(input.getValue().get());
						}
						else {
							mergedAggregationResult.merge((Mergeable) AccumuloUtils.fromBinary(input
									.getValue()
									.get()));
						}
					}
				}
			}
			return Iterators.singletonIterator(mergedAggregationResult);
		}
		finally {
			scanner.close();
		}
	}
	else {
		return super.initIterator(
				adapterStore,
				scanner);
	}
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:41,代码来源:AccumuloConstraintsQuery.java

示例3: initCloseableIterator

import org.apache.accumulo.core.client.ScannerBase; //导入方法依赖的package包/类
@Override
protected CloseableIterator<T> initCloseableIterator(
		ScannerBase scanner,
		Iterator it ) {
	return new CloseableIteratorWrapper(
			new Closeable() {
				boolean closed = false;

				@Override
				public void close()
						throws IOException {
					if (!closed) {
						if (scanner instanceof BatchDeleter) {
							try {
								((BatchDeleter) scanner).delete();
							}
							catch (MutationsRejectedException | TableNotFoundException e) {
								LOGGER.warn(
										"Unable to delete rows by query constraints",
										e);
							}
						}
						scanner.close();
					}
					closed = true;
				}
			},
			it);
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:30,代码来源:AccumuloRowPrefixDelete.java

示例4: initCloseableIterator

import org.apache.accumulo.core.client.ScannerBase; //导入方法依赖的package包/类
@Override
protected CloseableIterator<Object> initCloseableIterator(
		ScannerBase scanner,
		Iterator it ) {
	return new CloseableIteratorWrapper(
			new Closeable() {
				boolean closed = false;

				@Override
				public void close()
						throws IOException {
					if (!closed) {
						if (scanner instanceof BatchDeleter) {
							try {
								((BatchDeleter) scanner).delete();
							}
							catch (MutationsRejectedException | TableNotFoundException e) {
								LOGGER.warn(
										"Unable to delete rows by query constraints",
										e);
							}
						}
						scanner.close();
					}
					closed = true;
				}
			},
			it);
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:30,代码来源:AccumuloRowIdsDelete.java

示例5: streamingPropertyValueTableData

import org.apache.accumulo.core.client.ScannerBase; //导入方法依赖的package包/类
public byte[] streamingPropertyValueTableData(String dataRowKey, Long timestamp) {
    try {
        List<Range> ranges = Lists.newArrayList(RangeUtils.createRangeFromString(dataRowKey));

        long timerStartTime = System.currentTimeMillis();
        ScannerBase scanner = graph.createBatchScanner(graph.getDataTableName(), ranges, new org.apache.accumulo.core.security.Authorizations());
        if (timestamp != null && !DataTableRowKey.isLegacy(dataRowKey)) {
            IteratorSetting iteratorSetting = new IteratorSetting(
                    80,
                    TimestampFilter.class.getSimpleName(),
                    TimestampFilter.class
            );
            TimestampFilter.setStart(iteratorSetting, timestamp, true);
            TimestampFilter.setEnd(iteratorSetting, timestamp, true);
            scanner.addScanIterator(iteratorSetting);
        }

        GRAPH_LOGGER.logStartIterator(scanner);
        Span trace = Trace.start("streamingPropertyValueTableData");
        trace.data("dataRowKeyCount", Integer.toString(1));
        try {
            byte[] result = null;
            for (Map.Entry<Key, Value> col : scanner) {
                String foundKey = col.getKey().getRow().toString();
                byte[] value = col.getValue().get();
                if (foundKey.equals(dataRowKey)) {
                    result = value;
                }
            }
            if (result == null) {
                throw new VertexiumException("Could not find data with key: " + dataRowKey);
            }
            return result;
        } finally {
            scanner.close();
            trace.stop();
            GRAPH_LOGGER.logEndIterator(System.currentTimeMillis() - timerStartTime);
        }
    } catch (Exception ex) {
        throw new VertexiumException(ex);
    }
}
 
开发者ID:visallo,项目名称:vertexium,代码行数:43,代码来源:StreamingPropertyValueTable.java

示例6: getConnectedVertexIds

import org.apache.accumulo.core.client.ScannerBase; //导入方法依赖的package包/类
private Map<String, Set<String>> getConnectedVertexIds(Set<String> vertexIds) {
    Span trace = Trace.start("getConnectedVertexIds");
    try {
        if (LOGGER.isTraceEnabled()) {
            LOGGER.trace("getConnectedVertexIds:\n  %s", IterableUtils.join(vertexIds, "\n  "));
        }

        if (vertexIds.size() == 0) {
            return new HashMap<>();
        }

        List<org.apache.accumulo.core.data.Range> ranges = new ArrayList<>();
        for (String vertexId : vertexIds) {
            ranges.add(RangeUtils.createRangeFromString(vertexId));
        }

        int maxVersions = 1;
        Long startTime = null;
        Long endTime = null;
        ScannerBase scanner = graph.createElementScanner(
                FetchHint.EDGE_REFS,
                ElementType.VERTEX,
                maxVersions,
                startTime,
                endTime,
                ranges,
                false,
                authorizations
        );

        IteratorSetting connectedVertexIdsIteratorSettings = new IteratorSetting(
                1000,
                ConnectedVertexIdsIterator.class.getSimpleName(),
                ConnectedVertexIdsIterator.class
        );
        ConnectedVertexIdsIterator.setLabels(connectedVertexIdsIteratorSettings, options.getLabels());
        ConnectedVertexIdsIterator.setExcludedLabels(connectedVertexIdsIteratorSettings, options.getExcludedLabels());
        scanner.addScanIterator(connectedVertexIdsIteratorSettings);

        final long timerStartTime = System.currentTimeMillis();
        try {
            Map<String, Set<String>> results = new HashMap<>();
            for (Map.Entry<Key, Value> row : scanner) {
                try {
                    Map<String, Boolean> verticesExist = graph.doVerticesExist(ConnectedVertexIdsIterator.decodeValue(row.getValue()), authorizations);
                    Set<String> rowVertexIds =  stream(verticesExist.keySet())
                            .filter(key -> verticesExist.getOrDefault(key, false))
                            .collect(Collectors.toSet());
                    results.put(row.getKey().getRow().toString(), rowVertexIds);
                } catch (IOException e) {
                    throw new VertexiumException("Could not decode vertex ids for row: " + row.getKey().toString(), e);
                }
            }
            return results;
        } finally {
            scanner.close();
            AccumuloGraph.GRAPH_LOGGER.logEndIterator(System.currentTimeMillis() - timerStartTime);
        }
    } finally {
        trace.stop();
    }
}
 
开发者ID:visallo,项目名称:vertexium,代码行数:63,代码来源:AccumuloFindPathStrategy.java


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