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


Java Scanner.close方法代码示例

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


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

示例1: main

import org.apache.accumulo.core.client.Scanner; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {

        try (ConfigurableApplicationContext ctx = new SpringApplicationBuilder(SpringBootstrap.class)
                .bannerMode(Mode.OFF).web(false).run(args)) {
            Configuration conf = ctx.getBean(Configuration.class);

            final BaseConfiguration apacheConf = new BaseConfiguration();
            Configuration.Accumulo accumuloConf = conf.getAccumulo();
            apacheConf.setProperty("instance.name", accumuloConf.getInstanceName());
            apacheConf.setProperty("instance.zookeeper.host", accumuloConf.getZookeepers());
            final ClientConfiguration aconf = new ClientConfiguration(Collections.singletonList(apacheConf));
            final Instance instance = new ZooKeeperInstance(aconf);
            Connector con = instance.getConnector(accumuloConf.getUsername(),
                    new PasswordToken(accumuloConf.getPassword()));
            Scanner s = con.createScanner(conf.getMetaTable(),
                    con.securityOperations().getUserAuthorizations(con.whoami()));
            try {
                s.setRange(new Range(Meta.METRIC_PREFIX, true, Meta.TAG_PREFIX, false));
                for (Entry<Key, Value> e : s) {
                    System.out.println(e.getKey().getRow().toString().substring(Meta.METRIC_PREFIX.length()));
                }
            } finally {
                s.close();
            }
        }
    }
 
开发者ID:NationalSecurityAgency,项目名称:timely,代码行数:27,代码来源:GetMetricTableSplitPoints.java

示例2: benchmark

import org.apache.accumulo.core.client.Scanner; //导入方法依赖的package包/类
/**
 * Benchmark creating the scanner, reading the entries, and closing the scanner.
 */
@Benchmark
public void benchmark() throws Exception {
  Scanner scanner = getSignedScanner(configFile, TEST_TABLE);
  Iterator<Entry<Key,Value>> iterator = scanner.iterator();
  while (iterator.hasNext()) {
    iterator.next();
  }
  scanner.close();
}
 
开发者ID:mit-ll,项目名称:PACE,代码行数:13,代码来源:SignatureReadBenchmark.java

示例3: getRowCountFromTable

import org.apache.accumulo.core.client.Scanner; //导入方法依赖的package包/类
private long getRowCountFromTable(String tableName, Text signalColumn, Authorizations authorizations) {
    try {
        LOGGER.debug("BEGIN getRowCountFromTable(%s)", tableName);
        Scanner scanner = createScanner(tableName, null, authorizations);
        try {
            scanner.fetchColumnFamily(signalColumn);

            IteratorSetting countingIterator = new IteratorSetting(
                    100,
                    CountingIterator.class.getSimpleName(),
                    CountingIterator.class
            );
            scanner.addScanIterator(countingIterator);

            GRAPH_LOGGER.logStartIterator(scanner);

            long count = 0;
            for (Map.Entry<Key, Value> entry : scanner) {
                Long countForKey = LongCombiner.FIXED_LEN_ENCODER.decode(entry.getValue().get());
                LOGGER.debug("getRowCountFromTable(%s): %s: %d", tableName, entry.getKey().getRow(), countForKey);
                count += countForKey;
            }
            LOGGER.debug("getRowCountFromTable(%s): TOTAL: %d", tableName, count);
            return count;
        } finally {
            scanner.close();
        }
    } catch (TableNotFoundException ex) {
        throw new VertexiumException("Could not get count from table: " + tableName, ex);
    }
}
 
开发者ID:visallo,项目名称:vertexium,代码行数:32,代码来源:AccumuloGraph.java

示例4: isInitialized

import org.apache.accumulo.core.client.Scanner; //导入方法依赖的package包/类
@Override
public boolean isInitialized() throws RyaDetailsRepositoryException {
    Scanner scanner = null;
    try {
        scanner = connector.createScanner(detailsTableName, new Authorizations());
        scanner.fetchColumn(COL_FAMILY, COL_QUALIFIER);
        return scanner.iterator().hasNext();
    } catch (final TableNotFoundException e) {
        return false;
    } finally {
        if(scanner != null) {
            scanner.close();
        }
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:16,代码来源:AccumuloRyaInstanceDetailsRepository.java

示例5: getRyaInstanceDetails

import org.apache.accumulo.core.client.Scanner; //导入方法依赖的package包/类
@Override
public RyaDetails getRyaInstanceDetails() throws NotInitializedException, RyaDetailsRepositoryException {
    // Preconditions.
    if(!isInitialized()) {
        throw new NotInitializedException("Could not fetch the details for the Rya instanced named '" +
                instanceName + "' because it has not been initialized yet.");
    }

    // Read it from the table.
    Scanner scanner = null;
    try {
        // Fetch the value from the table.
        scanner = connector.createScanner(detailsTableName, new Authorizations());
        scanner.fetchColumn(COL_FAMILY, COL_QUALIFIER);
        final Entry<Key, Value> entry = scanner.iterator().next();

        // Deserialize it.
        final byte[] bytes = entry.getValue().get();
        return serializer.deserialize( bytes );

    } catch (final TableNotFoundException e) {
        throw new RyaDetailsRepositoryException("Could not get the details from the table.", e);
    } finally {
        if(scanner != null) {
            scanner.close();
        }
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:29,代码来源:AccumuloRyaInstanceDetailsRepository.java

示例6: validate

import org.apache.accumulo.core.client.Scanner; //导入方法依赖的package包/类
private void validate(int expected, Scanner scanner) {
  int count = 0;
  for (Entry<Key,Value> entry : scanner) {
    validate(entry);
    count++;
  }
  Assert.assertEquals(expected, count);
  scanner.close();
}
 
开发者ID:JHUAPL,项目名称:accumulo-proxy-instance,代码行数:10,代码来源:ScannerTest.java

示例7: execute

import org.apache.accumulo.core.client.Scanner; //导入方法依赖的package包/类
public void execute(Options options, Authorizations authorizations) {
    try {
        org.apache.accumulo.core.security.Authorizations accumuloAuthorizations = graph.toAccumuloAuthorizations(authorizations);
        Scanner scanner = graph.getConnector().createScanner(graph.getDataTableName(), accumuloAuthorizations);
        BatchWriter writer = graph.getConnector().createBatchWriter(
                graph.getDataTableName(),
                graph.getConfiguration().createBatchWriterConfig()
        );
        String lastRowIdPrefix = null;
        List<Key> rowsToDelete = new ArrayList<>();
        try {
            int rowCount = 0;
            for (Map.Entry<Key, Value> row : scanner) {
                if (rowCount % 10000 == 0) {
                    writer.flush();
                    LOGGER.debug("looking at row: %s (row count: %d)", row.getKey().getRow().toString(), rowCount);
                }
                rowCount++;
                if (!EMPTY_TEXT.equals(row.getKey().getColumnFamily())) {
                    continue;
                }
                if (!EMPTY_TEXT.equals(row.getKey().getColumnQualifier())) {
                    continue;
                }

                String rowId = row.getKey().getRow().toString();
                String[] rowIdParts = rowId.split("" + DataTableRowKey.VALUE_SEPARATOR);
                if (rowIdParts.length < 3) {
                    continue;
                }

                if (lastRowIdPrefix == null || !isSameProperty(lastRowIdPrefix, rowId)) {
                    deleteRows(writer, rowsToDelete, options);
                    rowsToDelete.clear();
                    lastRowIdPrefix = rowIdParts[0]
                            + DataTableRowKey.VALUE_SEPARATOR
                            + rowIdParts[1]
                            + DataTableRowKey.VALUE_SEPARATOR
                            + rowIdParts[2];
                }
                rowsToDelete.add(row.getKey());
            }
            deleteRows(writer, rowsToDelete, options);
        } finally {
            writer.flush();
            scanner.close();
        }
    } catch (Exception ex) {
        throw new VertexiumException("Could not delete old SPV data", ex);
    }
}
 
开发者ID:visallo,项目名称:vertexium,代码行数:52,代码来源:DeleteHistoricalLegacyStreamingPropertyValueData.java

示例8: getPcjMetadata

import org.apache.accumulo.core.client.Scanner; //导入方法依赖的package包/类
/**
 * Fetch the {@link PCJMetadata} from an Accumulo table.
 * <p>
 * This method assumes the PCJ table has already been created.
 *
 * @param accumuloConn - A connection to the Accumulo that hosts the PCJ table. (not null)
 * @param pcjTableName - The name of the table that will be search. (not null)
 * @return The PCJ Metadata that has been stolred in the in the PCJ Table.
 * @throws PCJStorageException The PCJ Table does not exist.
 */
public PcjMetadata getPcjMetadata(
        final Connector accumuloConn,
        final String pcjTableName) throws PCJStorageException {
    checkNotNull(accumuloConn);
    checkNotNull(pcjTableName);

    Scanner scanner = null;
    try {
        // Create an Accumulo scanner that iterates through the metadata entries.
        scanner = accumuloConn.createScanner(pcjTableName, new Authorizations());
        final Iterator<Entry<Key, Value>> entries = scanner.iterator();

        // No metadata has been stored in the table yet.
        if(!entries.hasNext()) {
            throw new PCJStorageException("Could not find any PCJ metadata in the table named: " + pcjTableName);
        }

        // Fetch the metadata from the entries. Assuming they all have the same cardinality and sparql query.
        String sparql = null;
        Long cardinality = null;
        final Set<VariableOrder> varOrders = new HashSet<>();

        while(entries.hasNext()) {
            final Entry<Key, Value> entry = entries.next();
            final Text columnQualifier = entry.getKey().getColumnQualifier();
            final byte[] value = entry.getValue().get();

            if(columnQualifier.equals(PCJ_METADATA_SPARQL_QUERY)) {
                sparql = stringLexicoder.decode(value);
            } else if(columnQualifier.equals(PCJ_METADATA_CARDINALITY)) {
                cardinality = longLexicoder.decode(value);
            } else if(columnQualifier.equals(PCJ_METADATA_VARIABLE_ORDERS)) {
                for(final String varOrderStr : listLexicoder.decode(value)) {
                    varOrders.add( new VariableOrder(varOrderStr) );
                }
            }
        }

        return new PcjMetadata(sparql, cardinality, varOrders);

    } catch (final TableNotFoundException e) {
        throw new PCJStorageException("Could not add results to a PCJ because the PCJ table does not exist.", e);
    } finally {
        if(scanner != null) {
            scanner.close();
        }
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:59,代码来源:PcjTables.java


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