本文整理汇总了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);
}
}
示例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);
}
示例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);
}
示例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);
}
}
示例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();
}
}