本文整理汇总了Java中org.apache.accumulo.core.client.Scanner.fetchColumn方法的典型用法代码示例。如果您正苦于以下问题:Java Scanner.fetchColumn方法的具体用法?Java Scanner.fetchColumn怎么用?Java Scanner.fetchColumn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.accumulo.core.client.Scanner
的用法示例。
在下文中一共展示了Scanner.fetchColumn方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test
import org.apache.accumulo.core.client.Scanner; //导入方法依赖的package包/类
@Test
public void test() throws Exception {
Scanner scanner = conn.createScanner(tableName, new Authorizations());
scanner.fetchColumn(new Text("dir"), new Text("counts"));
assertFalse(scanner.iterator().hasNext());
ScannerOpts scanOpts = new ScannerOpts();
BatchWriterOpts bwOpts = new BatchWriterOpts();
FileCount fc = new FileCount(conn, tableName, Authorizations.EMPTY, new ColumnVisibility(), scanOpts, bwOpts);
fc.run();
ArrayList<Pair<String,String>> expected = new ArrayList<>();
expected.add(new Pair<>(QueryUtil.getRow("").toString(), "1,0,3,3"));
expected.add(new Pair<>(QueryUtil.getRow("/local").toString(), "2,1,2,3"));
expected.add(new Pair<>(QueryUtil.getRow("/local/user1").toString(), "0,2,0,2"));
expected.add(new Pair<>(QueryUtil.getRow("/local/user2").toString(), "0,0,0,0"));
int i = 0;
for (Entry<Key,Value> e : scanner) {
assertEquals(e.getKey().getRow().toString(), expected.get(i).getFirst());
assertEquals(e.getValue().toString(), expected.get(i).getSecond());
i++;
}
assertEquals(i, expected.size());
}
示例2: getCommittedWindowId
import org.apache.accumulo.core.client.Scanner; //导入方法依赖的package包/类
@Override
public long getCommittedWindowId(String appId, int operatorId)
{
byte[] value = null;
Authorizations auths = new Authorizations();
Scanner scan = null;
String columnKey = appId + "_" + operatorId + "_" + lastWindowColumnName;
lastWindowColumnBytes = columnKey.getBytes();
try {
scan = connector.createScanner(tableName, auths);
} catch (TableNotFoundException e) {
logger.error("error getting committed window id", e);
DTThrowable.rethrow(e);
}
scan.setRange(new Range(new Text(rowBytes)));
scan.fetchColumn(new Text(columnFamilyBytes), new Text(lastWindowColumnBytes));
for (Entry<Key, Value> entry : scan) {
value = entry.getValue().get();
}
if (value != null) {
long longval = toLong(value);
return longval;
}
return -1;
}
示例3: getAccumuloTuple
import org.apache.accumulo.core.client.Scanner; //导入方法依赖的package包/类
public static AccumuloTuple getAccumuloTuple(String row, String colFam,
String colName)
{
Authorizations auths = new Authorizations();
Scanner scan = null;
try {
scan = con.createScanner("tab1", auths);
} catch (TableNotFoundException e) {
logger.error("error in test helper");
DTThrowable.rethrow(e);
}
scan.setRange(new Range(new Text(row)));
scan.fetchColumn(new Text(colFam), new Text(colName));
// assuming only one row
for (Entry<Key, Value> entry : scan) {
AccumuloTuple tuple = new AccumuloTuple();
tuple.setRow(entry.getKey().getRow().toString());
tuple.setColFamily(entry.getKey().getColumnFamily().toString());
tuple.setColName(entry.getKey().getColumnQualifier().toString());
tuple.setColValue(entry.getValue().toString());
return tuple;
}
return null;
}
示例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;
}
示例5: queryIntervalEquals
import org.apache.accumulo.core.client.Scanner; //导入方法依赖的package包/类
/**
* Get intervals stored in the repository matching the given interval.
* Indexing Intervals will probably change or be removed.
* Currently predicate and subject constraints are filtered on the client.
*/
@Override
public CloseableIteration<Statement, QueryEvaluationException> queryIntervalEquals(
final TemporalInterval query, final StatementConstraints contraints)
throws QueryEvaluationException {
final Scanner scanner = getScanner();
if (scanner != null) {
// get rows where the start and end match.
final Range range = Range.prefix(new Text(query.getAsKeyBeginning()));
scanner.setRange(range);
if (contraints.hasContext()) {
scanner.fetchColumn(new Text(contraints.getContext().toString()), new Text(KeyParts.CQ_BEGIN));
} else {
scanner.fetchColumn(new Text(""), new Text(KeyParts.CQ_BEGIN));
}
}
// Iterator<Entry<Key, Value>> iter = scanner.iterator();
// while (iter.hasNext()) {
// System.out.println("queryIntervalEquals results:"+iter.next());
// }
//return getConstrainedIteratorWrapper(scanner, contraints);
return getIteratorWrapper(scanner);
}
示例6: queryIntervalBefore
import org.apache.accumulo.core.client.Scanner; //导入方法依赖的package包/类
/**
* find intervals stored in the repository before the given Interval. Find interval endings that are
* before the given beginning.
* Indexing Intervals will probably change or be removed.
* Currently predicate and subject constraints are filtered on the client.
*/
@Override
public CloseableIteration<Statement, QueryEvaluationException> queryIntervalBefore(
final TemporalInterval queryInterval, final StatementConstraints constraints) throws QueryEvaluationException
{
final Scanner scanner = getScanner();
if (scanner != null) {
// get rows where the end date is less than the queryInterval.getBefore()
final Range range = new Range(null, false, new Key(new Text(queryInterval.getHasBeginning().getAsKeyBytes())), false);
scanner.setRange(range);
if (constraints.hasContext()) {
scanner.fetchColumn(new Text(constraints.getContext().toString()), new Text(KeyParts.CQ_END));
} else {
scanner.fetchColumn(new Text(""), new Text(KeyParts.CQ_END));
}
}
return getIteratorWrapper(scanner);
}
示例7: queryIntervalAfter
import org.apache.accumulo.core.client.Scanner; //导入方法依赖的package包/类
/**
* Interval after given interval. Find intervals that begin after the endings of the given interval.
* Use the special following prefix mechanism to avoid matching the beginning date.
* Indexing Intervals will probably change or be removed.
* Currently predicate and subject and context constraints are filtered on the client.
*/
@Override
public CloseableIteration<Statement, QueryEvaluationException> queryIntervalAfter(
final TemporalInterval queryInterval, final StatementConstraints constraints)
throws QueryEvaluationException {
final Scanner scanner = getScanner();
if (scanner != null) {
// get rows where the start date is greater than the queryInterval.getEnd()
final Range range = new Range(new Key(Range.followingPrefix(new Text(queryInterval.getHasEnd().getAsKeyBytes()))), false, null, true);
scanner.setRange(range);
if (constraints.hasContext()) {
scanner.fetchColumn(new Text(constraints.getContext().toString()), new Text(KeyParts.CQ_BEGIN));
} else {
scanner.fetchColumn(new Text(""), new Text(KeyParts.CQ_BEGIN));
}
}
// TODO currently predicate, subject and context constraints are filtered on the clients
return getIteratorWrapper(scanner);
}
示例8: setFetchColumns
import org.apache.accumulo.core.client.Scanner; //导入方法依赖的package包/类
private void setFetchColumns(Scanner scanner, String fields[]) {
fields = getFieldsToQuery(fields);
for (String field : fields) {
Pair<Text,Text> col = mapping.fieldMap.get(field);
if (col != null) {
if (col.getSecond() == null) {
scanner.fetchColumnFamily(col.getFirst());
} else {
scanner.fetchColumn(col.getFirst(), col.getSecond());
}
} else {
LOG.error("Mapping not found for field: " + field);
}
}
}
示例9: 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();
}
}
}
示例10: 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();
}
}
}
示例11: 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;
}