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


Java Scanner.iterator方法代码示例

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


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

示例1: runTest

import org.apache.accumulo.core.client.Scanner; //导入方法依赖的package包/类
/**
 * Run a specific test for a given version and configuration.
 *
 * @param dataScanner
 *          Scanner for the unsigned data.
 * @param signedScanner
 *          Scanner for the signed data.
 * @param verifier
 *          Verifier for the signed data.
 * @param signatureConfig
 *          Configuration for the verifier.
 */
private void runTest(Scanner dataScanner, Scanner signedScanner, EntrySigner verifier, SignatureConfig signatureConfig) {
  Iterator<Entry<Key,Value>> iterator = signedScanner.iterator();
  for (Entry<Key,Value> entry : dataScanner) {
    assertThat("should have more entries", iterator.hasNext(), is(true));
    Entry<Key,Value> signedEntry = iterator.next();

    Entry<Key,Value> verifiedEntry;
    if (signatureConfig.isSignatureInSeparateTable()) {
      assertThat("keys should match", signedEntry.getKey(), equalTo(entry.getKey()));
      assertThat("values should not match", signedEntry.getValue().get(), not(equalTo(entry.getValue().get())));
      verifiedEntry = verifier.verify(entry, signedEntry);
    } else {
      verifiedEntry = verifier.verify(signedEntry);
    }

    assertThat("entries should match", verifiedEntry, Matchers.equalTo(entry));
  }

  assertThat("should have no more entries", iterator.hasNext(), is(false));
}
 
开发者ID:mit-ll,项目名称:PACE,代码行数:33,代码来源:VersioningIT.java

示例2: check

import org.apache.accumulo.core.client.Scanner; //导入方法依赖的package包/类
public void check(SignatureConfig config) throws Exception {
  Scanner scanner = AccumuloInstance.getConnector(USER).createScanner(UNSIGNED_TEST_TABLE, AccumuloInstance.getUser(USER).authorizations);
  Scanner signedScanner;

  if (!config.isSignatureInSeparateTable()) {
    signedScanner = new SignedScanner(AccumuloInstance.getConnector(USER), SIGNED_TEST_TABLE, AccumuloInstance.getUser(USER).authorizations, config,
        AccumuloInstance.getUser(USER).signatureKeys.get(config.getAlgorithm()));
  } else {
    signedScanner = new SignedScanner(AccumuloInstance.getConnector(USER), UNSIGNED_TEST_TABLE, AccumuloInstance.getUser(USER).authorizations, config,
        AccumuloInstance.getUser(USER).signatureKeys.get(config.getAlgorithm()));
  }

  Iterator<Entry<Key,Value>> iterator = signedScanner.iterator();
  for (Entry<Key,Value> entry : scanner) {
    assertThat("should have an entry that matches", iterator.hasNext(), is(true));
    assertThat("entries match", iterator.next(), equalTo(entry));
  }

  assertThat("should have no more entries", iterator.hasNext(), is(false));
}
 
开发者ID:mit-ll,项目名称:PACE,代码行数:21,代码来源:BatchWriteReadIT.java

示例3: printAccumuloTable

import org.apache.accumulo.core.client.Scanner; //导入方法依赖的package包/类
/**
 * Prints specified Accumulo table (accessible using Accumulo connector parameter)
 *
 * @param conn Accumulo connector of to instance with table to print
 * @param accumuloTable Accumulo table to print
 */
public static void printAccumuloTable(Connector conn, String accumuloTable) {
  Scanner scanner = null;
  try {
    scanner = conn.createScanner(accumuloTable, Authorizations.EMPTY);
  } catch (TableNotFoundException e) {
    throw new IllegalStateException(e);
  }
  Iterator<Map.Entry<Key, Value>> iterator = scanner.iterator();

  System.out.println("== accumulo start ==");
  while (iterator.hasNext()) {
    Map.Entry<Key, Value> entry = iterator.next();
    System.out.println(entry.getKey() + " " + entry.getValue());
  }
  System.out.println("== accumulo end ==");
}
 
开发者ID:apache,项目名称:fluo-recipes,代码行数:23,代码来源:FluoITHelper.java

示例4: getNamespace

import org.apache.accumulo.core.client.Scanner; //导入方法依赖的package包/类
@Override
public String getNamespace(final String pfx) throws RyaDAOException {
    try {
        final Scanner scanner = connector.createScanner(tableLayoutStrategy.getNs(),
                ALL_AUTHORIZATIONS);
        scanner.fetchColumn(INFO_NAMESPACE_TXT, EMPTY_TEXT);
        scanner.setRange(new Range(new Text(pfx)));
        final Iterator<Map.Entry<Key, Value>> iterator = scanner
                .iterator();

        if (iterator.hasNext()) {
            return new String(iterator.next().getValue().get(), StandardCharsets.UTF_8);
        }
    } catch (final Exception e) {
        throw new RyaDAOException(e);
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:19,代码来源:AccumuloRyaDAO.java

示例5: printTable

import org.apache.accumulo.core.client.Scanner; //导入方法依赖的package包/类
/**
 * Prints the table with the specified config and additional settings.
 * @param tableName the name of the table to print.
 * @param config the {@link AccumuloRdfConfiguration}.
 * @param shouldAddCommonIterators {@code true} to add the common iterators to the table scanner.
 * {@code false} otherwise.
 * @param settings the additional {@link IteratorSetting}s to add besides the common ones.
 * @throws IOException
 */
public static void printTable(final String tableName, final AccumuloRdfConfiguration config, final boolean shouldAddCommonIterators, final IteratorSetting... settings) throws IOException {
    final Scanner scanner = AccumuloRyaUtils.getScanner(tableName, config, shouldAddCommonIterators);
    for (final IteratorSetting setting : settings) {
        scanner.addScanIterator(setting);
    }

    final Iterator<Entry<Key, Value>> iterator = scanner.iterator();

    final String instance = config.get(MRUtils.AC_INSTANCE_PROP);
    log.info("==================");
    log.info("TABLE: " + tableName + " INSTANCE: " + instance);
    log.info("------------------");
    while (iterator.hasNext()) {
        final Entry<Key, Value> entry = iterator.next();
        final Key key = entry.getKey();
        final Value value = entry.getValue();
        final String keyString = getFormattedKeyString(key);
        log.info(keyString + " - " + value);
    }
    log.info("==================");
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:31,代码来源:AccumuloRyaUtils.java

示例6: 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

示例7: AccumuloResult

import org.apache.accumulo.core.client.Scanner; //导入方法依赖的package包/类
/**
 * @param dataStore
 * @param query
 * @param scanner
 */
public AccumuloResult(DataStore<K,T> dataStore, Query<K,T> query, Scanner scanner) {
  super(dataStore, query);
  
  // TODO set batch size based on limit, and construct iterator later
  iterator = new RowIterator(scanner.iterator());
}
 
开发者ID:jianglibo,项目名称:gora-boot,代码行数:12,代码来源:AccumuloResult.java

示例8: iterateNamespace

import org.apache.accumulo.core.client.Scanner; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public CloseableIteration<Namespace, RyaDAOException> iterateNamespace() throws RyaDAOException {
    try {
        final Scanner scanner = connector.createScanner(tableLayoutStrategy.getNs(),
                ALL_AUTHORIZATIONS);
        scanner.fetchColumnFamily(INFO_NAMESPACE_TXT);
        final Iterator<Map.Entry<Key, Value>> result = scanner.iterator();
        return new AccumuloNamespaceTableIterator(result);
    } catch (final Exception e) {
        throw new RyaDAOException(e);
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:14,代码来源:AccumuloRyaDAO.java

示例9: PCJKeyToCrossProductBindingSetIterator

import org.apache.accumulo.core.client.Scanner; //导入方法依赖的package包/类
public PCJKeyToCrossProductBindingSetIterator(Scanner scanner,
		List<BindingSet> crossProductBs,
		Map<String, Value> constantConstraints, Set<String> unAssuredVariables,
		Map<String, String> pcjVarMap) {
	this.crossProductBs = crossProductBs;
	this.scanner = scanner;
	this.iterator = scanner.iterator();
	this.pcjVarMap = HashBiMap.create(pcjVarMap).inverse();
	this.constantConstraints = constantConstraints;
	this.crossProductBsExist = crossProductBs.size() > 0;
	this.constantConstraintsExist = constantConstraints.size() > 0;
	this.unAssuredVariables = unAssuredVariables;
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:14,代码来源:PCJKeyToCrossProductBindingSetIterator.java

示例10: getTableSize

import org.apache.accumulo.core.client.Scanner; //导入方法依赖的package包/类
public int getTableSize(RdfCloudTripleStoreConfiguration conf) throws TableNotFoundException {

      Authorizations authorizations = getAuths(conf);
    

    if (joinMap.containsKey("subjectpredicateobject" + DELIM + "FullTableCardinality")) {
      FullTableCardinality = joinMap.get("subjectpredicateobject" + DELIM + "FullTableCardinality").intValue();
      return FullTableCardinality;
    }

    if (FullTableCardinality == 0) {
      Scanner joinScanner = connector.createScanner(tableLayoutStrategy.getSelectivity(), authorizations);
      joinScanner.setRange(Range.prefix(new Text("subjectpredicateobject" + DELIM + "FullTableCardinality")));
      Iterator<Map.Entry<Key,Value>> iterator = joinScanner.iterator();
      if (iterator.hasNext()) {
        Map.Entry<Key,Value> entry = iterator.next();
        if (entry.getKey().getColumnFamily().toString().equals("FullTableCardinality")) {
          String Count = entry.getKey().getColumnQualifier().toString();
          FullTableCardinality = Integer.parseInt(Count);
        }
      }
      if (FullTableCardinality == 0) {
        throw new RuntimeException("Table does not contain full cardinality");
      }

    }

    return FullTableCardinality;

  }
 
开发者ID:apache,项目名称:incubator-rya,代码行数:31,代码来源:AccumuloSelectivityEvalDAO.java

示例11: calculateCounts

import org.apache.accumulo.core.client.Scanner; //导入方法依赖的package包/类
private void calculateCounts(Scanner scanner, int depth, BatchWriter batchWriter) throws Exception {

    scanner.setRange(new Range(String.format("%03d", depth), true, String.format("%03d", depth + 1), false));

    CountValue countVal = new CountValue();

    Iterator<Entry<Key,Value>> iterator = scanner.iterator();

    String currentDir = null;

    Entry<Key,Value> entry = null;
    if (iterator.hasNext()) {
      entry = iterator.next();
      entriesScanned++;
    }

    while (entry != null) {
      Key key = entry.getKey();

      String dir = extractDir(key);

      if (currentDir == null) {
        currentDir = dir;
      } else if (!currentDir.equals(dir)) {
        batchWriter.addMutation(createMutation(depth - 1, currentDir, countVal));
        inserts++;
        currentDir = dir;
        countVal.clear();
      }

      // process a whole row
      if (key.compareColumnFamily(QueryUtil.DIR_COLF) == 0) {
        CountValue tmpCount = new CountValue();
        entry = findCount(entry, iterator, tmpCount);

        if (tmpCount.dirCount == 0 && tmpCount.fileCount == 0) {
          // in this case the higher depth will not insert anything if the
          // dir has no children, so insert something here
          Mutation m = new Mutation(key.getRow());
          m.put(QueryUtil.DIR_COLF, QueryUtil.COUNTS_COLQ, visibility, tmpCount.toValue());
          batchWriter.addMutation(m);
          inserts++;
        }

        countVal.incrementRecursive(tmpCount);
        countVal.incrementDirs();
      } else {
        entry = consumeRow(entry, iterator);
        countVal.incrementFiles();
      }
    }

    if (currentDir != null) {
      batchWriter.addMutation(createMutation(depth - 1, currentDir, countVal));
      inserts++;
    }
  }
 
开发者ID:apache,项目名称:accumulo-examples,代码行数:58,代码来源:FileCount.java

示例12: main

import org.apache.accumulo.core.client.Scanner; //导入方法依赖的package包/类
public static void main(String[] args) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
  Opts opts = new Opts();
  opts.parseArgs(VerifyIngest.class.getName(), args);

  Connector connector = opts.getConnector();
  Scanner scanner = connector.createScanner(opts.getTableName(), opts.auths);

  scanner.setRange(new Range(new Text(String.format("row_%010d", opts.startRow)), null));

  Iterator<Entry<Key,Value>> si = scanner.iterator();

  boolean ok = true;

  for (int i = opts.startRow; i < opts.numRows; i++) {

    if (si.hasNext()) {
      Entry<Key,Value> entry = si.next();

      if (!entry.getKey().getRow().toString().equals(String.format("row_%010d", i))) {
        log.error("unexpected row key " + entry.getKey().getRow().toString() + " expected " + String.format("row_%010d", i));
        ok = false;
      }

      if (!entry.getValue().toString().equals(String.format("value_%010d", i))) {
        log.error("unexpected value " + entry.getValue().toString() + " expected " + String.format("value_%010d", i));
        ok = false;
      }

    } else {
      log.error("no more rows, expected " + String.format("row_%010d", i));
      ok = false;
      break;
    }

  }

  if (ok) {
    System.out.println("OK");
    System.exit(0);
  } else {
    System.exit(1);
  }
}
 
开发者ID:apache,项目名称:accumulo-examples,代码行数:44,代码来源:VerifyIngest.java

示例13: testWithAccumulo

import org.apache.accumulo.core.client.Scanner; //导入方法依赖的package包/类
@Test
public void testWithAccumulo() throws AccumuloException, AccumuloSecurityException, TableExistsException, TableNotFoundException, IOException {
  conn.tableOperations().create(tableName);
  BatchWriter bw = conn.createBatchWriter(tableName, new BatchWriterConfig());

  for (Entry<Key,Value> e : data) {
    Key k = e.getKey();
    Mutation m = new Mutation(k.getRow());
    m.put(k.getColumnFamily(), k.getColumnQualifier(), new ColumnVisibility(k.getColumnVisibility()), e.getValue());
    bw.addMutation(m);
  }
  bw.close();

  Scanner scan = conn.createScanner(tableName, AUTHS);

  ChunkInputStream cis = new ChunkInputStream();
  byte[] b = new byte[20];
  int read;
  PeekingIterator<Entry<Key,Value>> pi = new PeekingIterator<>(scan.iterator());

  cis.setSource(pi);
  assertEquals(read = cis.read(b), 8);
  assertEquals(new String(b, 0, read), "asdfjkl;");
  assertEquals(read = cis.read(b), -1);

  cis.setSource(pi);
  assertEquals(read = cis.read(b), 10);
  assertEquals(new String(b, 0, read), "qwertyuiop");
  assertEquals(read = cis.read(b), -1);
  assertEquals(cis.getVisibilities().toString(), "[A&B, B&C, D]");
  cis.close();

  cis.setSource(pi);
  assertEquals(read = cis.read(b), 16);
  assertEquals(new String(b, 0, read), "asdfjkl;asdfjkl;");
  assertEquals(read = cis.read(b), -1);
  assertEquals(cis.getVisibilities().toString(), "[A&B]");
  cis.close();

  cis.setSource(pi);
  assertEquals(read = cis.read(b), -1);
  cis.close();

  cis.setSource(pi);
  assertEquals(read = cis.read(b), 8);
  assertEquals(new String(b, 0, read), "asdfjkl;");
  assertEquals(read = cis.read(b), -1);
  cis.close();

  assertFalse(pi.hasNext());
}
 
开发者ID:apache,项目名称:accumulo-examples,代码行数:52,代码来源:ChunkInputStreamIT.java

示例14: verifyAccumuloTable

import org.apache.accumulo.core.client.Scanner; //导入方法依赖的package包/类
/**
 * Verifies that actual data in Accumulo table matches expected data
 *
 * @param conn Connector to Accumulo instance with actual data
 * @param accumuloTable Accumulo table with actual data
 * @param expected RowColumnValue list containing expected data
 * @return True if actual data matches expected data
 */
public static boolean verifyAccumuloTable(Connector conn, String accumuloTable,
    Collection<RowColumnValue> expected) {

  expected = sort(expected);

  Scanner scanner;
  try {
    scanner = conn.createScanner(accumuloTable, Authorizations.EMPTY);
  } catch (TableNotFoundException e) {
    throw new IllegalStateException(e);
  }
  Iterator<Map.Entry<Key, Value>> scanIter = scanner.iterator();
  Iterator<RowColumnValue> rcvIter = expected.iterator();

  while (scanIter.hasNext() && rcvIter.hasNext()) {
    RowColumnValue rcv = rcvIter.next();
    Map.Entry<Key, Value> kvEntry = scanIter.next();
    Key key = kvEntry.getKey();
    Column col = rcv.getColumn();

    boolean retval = diff("row", rcv.getRow().toString(), key.getRow().toString());
    retval |= diff("fam", col.getFamily().toString(), key.getColumnFamily().toString());
    retval |= diff("qual", col.getQualifier().toString(), key.getColumnQualifier().toString());
    retval |= diff("val", rcv.getValue().toString(), kvEntry.getValue().toString());

    if (retval) {
      log.error("Difference found - row {} cf {} cq {} val {}", rcv.getRow().toString(),
          col.getFamily().toString(), col.getQualifier().toString(), rcv.getValue().toString());
      return false;
    }
    log.debug("Verified row {} cf {} cq {} val {}", rcv.getRow().toString(),
        col.getFamily().toString(), col.getQualifier().toString(), rcv.getValue().toString());
  }

  if (scanIter.hasNext() || rcvIter.hasNext()) {
    log.error("An iterator still has more data");
    return false;
  }

  log.debug("Actual data matched expected data");
  return true;
}
 
开发者ID:apache,项目名称:fluo-recipes,代码行数:51,代码来源:FluoITHelper.java

示例15: getCardinality

import org.apache.accumulo.core.client.Scanner; //导入方法依赖的package包/类
@Override
    public double getCardinality(final AccumuloRdfConfiguration conf,
            final RdfEvalStatsDAO.CARDINALITY_OF card, final List<Value> val,
            final Resource context) throws RdfDAOException {
        try {
            final Authorizations authorizations = conf.getAuthorizations();
            final Scanner scanner = connector.createScanner(tableLayoutStrategy.getEval(), authorizations);
            Text cfTxt = null;
            if (CARDINALITY_OF.SUBJECT.equals(card)) {
                cfTxt = SUBJECT_CF_TXT;
            } else if (CARDINALITY_OF.PREDICATE.equals(card)) {
                cfTxt = PRED_CF_TXT;
            } else if (CARDINALITY_OF.OBJECT.equals(card)) {
//                cfTxt = OBJ_CF_TXT;     //TODO: How do we do object cardinality
                return Double.MAX_VALUE;
            } else if (CARDINALITY_OF.SUBJECTOBJECT.equals(card)) {
                cfTxt = SUBJECTOBJECT_CF_TXT;
            } else if (CARDINALITY_OF.SUBJECTPREDICATE.equals(card)) {
                cfTxt = SUBJECTPRED_CF_TXT;
            } else if (CARDINALITY_OF.PREDICATEOBJECT.equals(card)) {
                cfTxt = PREDOBJECT_CF_TXT;
            } else {
                throw new IllegalArgumentException("Not right Cardinality[" + card + "]");
            }
            Text cq = EMPTY_TEXT;
            if (context != null) {
                cq = new Text(context.stringValue().getBytes(StandardCharsets.UTF_8));
            }
            scanner.fetchColumn(cfTxt, cq);
            final Iterator<Value> vals = val.iterator();
            String compositeIndex = vals.next().stringValue();
            while (vals.hasNext()){
                compositeIndex += DELIM + vals.next().stringValue();
            }
            scanner.setRange(new Range(new Text(compositeIndex.getBytes(StandardCharsets.UTF_8))));
            final Iterator<Map.Entry<Key, org.apache.accumulo.core.data.Value>> iter = scanner.iterator();
            if (iter.hasNext()) {
                return Double.parseDouble(new String(iter.next().getValue().get(), StandardCharsets.UTF_8));
            }
        } catch (final Exception e) {
            throw new RdfDAOException(e);
        }

        //default
        return -1;
    }
 
开发者ID:apache,项目名称:incubator-rya,代码行数:47,代码来源:AccumuloRdfEvalStatsDAO.java


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