本文整理汇总了Java中org.apache.accumulo.core.data.Key.getRow方法的典型用法代码示例。如果您正苦于以下问题:Java Key.getRow方法的具体用法?Java Key.getRow怎么用?Java Key.getRow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.accumulo.core.data.Key
的用法示例。
在下文中一共展示了Key.getRow方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findCount
import org.apache.accumulo.core.data.Key; //导入方法依赖的package包/类
private Entry<Key,Value> findCount(Entry<Key,Value> entry, Iterator<Entry<Key,Value>> iterator, CountValue cv) {
Key key = entry.getKey();
Text currentRow = key.getRow();
if (key.compareColumnQualifier(QueryUtil.COUNTS_COLQ) == 0)
cv.set(entry.getValue());
while (iterator.hasNext()) {
entry = iterator.next();
entriesScanned++;
key = entry.getKey();
if (key.compareRow(currentRow) != 0)
return entry;
if (key.compareColumnFamily(QueryUtil.DIR_COLF) == 0 && key.compareColumnQualifier(QueryUtil.COUNTS_COLQ) == 0) {
cv.set(entry.getValue());
}
}
return null;
}
示例2: test
import org.apache.accumulo.core.data.Key; //导入方法依赖的package包/类
@Test
public void test() throws Exception {
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()), k.getTimestamp(), e.getValue());
bw.addMutation(m);
}
bw.close();
assertEquals(0, CIFTester.main(tableName, CIFTester.TestMapper.class.getName()));
assertEquals(1, assertionErrors.get(tableName).size());
}
示例3: testErrorOnNextWithoutClose
import org.apache.accumulo.core.data.Key; //导入方法依赖的package包/类
@Test
public void testErrorOnNextWithoutClose() throws Exception {
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()), k.getTimestamp(), e.getValue());
bw.addMutation(m);
}
bw.close();
assertEquals(1, CIFTester.main(tableName, CIFTester.TestNoClose.class.getName()));
assertEquals(1, assertionErrors.get(tableName).size());
// this should actually exist, in addition to the dummy entry
assertEquals(2, assertionErrors.get(tableName + "_map_ioexception").size());
}
示例4: buildKey
import org.apache.accumulo.core.data.Key; //导入方法依赖的package包/类
public static Key buildKey(Key key) {
if (key == null) {
log.error("Problem in BooleanLogicTreeNodeJexl.buildKey");
return null;
}
// Build Key(Text row, Text colfam) where colFam is dataype\0uid
String[] cq = key.getColumnQualifier().toString().split("\0");
Text uuid = new Text(cq[cq.length - 2] + "\0" + cq[cq.length - 1]);
Text row = key.getRow();
if (log.isDebugEnabled()) {
log.debug("Key-> r:" + row + " fam:" + uuid);
}
// System.out.println("Key-> r:"+row+" fam:"+uuid);
Key k = new Key(row, uuid);
// System.out.println("Key: "+k);
return k;
}
示例5: consumeRow
import org.apache.accumulo.core.data.Key; //导入方法依赖的package包/类
private Entry<Key,Value> consumeRow(Entry<Key,Value> entry, Iterator<Entry<Key,Value>> iterator) {
Key key = entry.getKey();
Text currentRow = key.getRow();
while (iterator.hasNext()) {
entry = iterator.next();
entriesScanned++;
key = entry.getKey();
if (key.compareRow(currentRow) != 0)
return entry;
}
return null;
}
示例6: map
import org.apache.accumulo.core.data.Key; //导入方法依赖的package包/类
@Override
public void map(Key row, Value data, Context context) throws IOException, InterruptedException {
Mutation m = new Mutation(row.getRow());
m.put(new Text("cf-HASHTYPE"), new Text("cq-MD5BASE64"), new Value(Base64.getEncoder().encode(MD5Hash.digest(data.toString()).getDigest())));
context.write(null, m);
context.progress();
}
示例7: testInfoWithoutChunks
import org.apache.accumulo.core.data.Key; //导入方法依赖的package包/类
@Test
public void testInfoWithoutChunks() throws Exception {
conn.tableOperations().create(tableName);
BatchWriter bw = conn.createBatchWriter(tableName, new BatchWriterConfig());
for (Entry<Key,Value> e : baddata) {
Key k = e.getKey();
Mutation m = new Mutation(k.getRow());
m.put(k.getColumnFamily(), k.getColumnQualifier(), new ColumnVisibility(k.getColumnVisibility()), k.getTimestamp(), e.getValue());
bw.addMutation(m);
}
bw.close();
assertEquals(0, CIFTester.main(tableName, CIFTester.TestBadData.class.getName()));
assertEquals(1, assertionErrors.get(tableName).size());
}
示例8: advanceNegatives
import org.apache.accumulo.core.data.Key; //导入方法依赖的package包/类
private void advanceNegatives(Key k) throws IOException {
if (log.isDebugEnabled()) {
log.debug("advancingNegatives for Key: " + k);
}
Text rowID = k.getRow();
Text colFam = k.getColumnFamily();
for (BooleanLogicTreeNode neg : negatives) {
Key startKey = new Key(rowID, neg.getFieldName(), new Text(neg.getFieldValue() + "\0" + colFam));
Key endKey = new Key(rowID, neg.getFieldName(), new Text(neg.getFieldValue() + "\0" + colFam + "\1"));
Range range = new Range(startKey, true, endKey, false);
if (log.isDebugEnabled()) {
log.debug("range: " + range);
}
neg.seek(range, EMPTY_COL_FAMS, false);
if (neg.hasTop()) {
neg.setValid(false);
}
if (log.isDebugEnabled()) {
if (neg.hasTop()) {
log.debug("neg top key: " + neg.getTopKey());
} else {
log.debug("neg has no top");
}
}
}
}
示例9: isKeyAccepted
import org.apache.accumulo.core.data.Key; //导入方法依赖的package包/类
/**
* Don't accept this key if the colf starts with 'fi'
*/
@Override
public boolean isKeyAccepted(Key key) throws IOException {
if (key.getColumnFamily().toString().startsWith("fi")) {
Key copy = new Key(key.getRow(), new Text("fi\01"));
Collection<ByteSequence> columnFamilies = Collections.emptyList();
this.iterator.seek(new Range(copy, copy), columnFamilies, true);
if (this.iterator.hasTop())
return isKeyAccepted(this.iterator.getTopKey());
return true;
}
return true;
}
示例10: calculateCounts
import org.apache.accumulo.core.data.Key; //导入方法依赖的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++;
}
}
示例11: testWithAccumulo
import org.apache.accumulo.core.data.Key; //导入方法依赖的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());
}
示例12: getPartition
import org.apache.accumulo.core.data.Key; //导入方法依赖的package包/类
protected Text getPartition(Key key) {
return key.getRow();
}
示例13: next
import org.apache.accumulo.core.data.Key; //导入方法依赖的package包/类
public void next() throws IOException {
if (log.isDebugEnabled()) {
log.debug("next");
}
if (key != null) {
key = null;
value = null;
}
if (eventSpecificRange) {
// Then this will probably return nothing
event.next();
if (event.hasTop()) {
key = event.getTopKey();
value = event.getTopValue();
}
} else {
do {
index.next();
// If the index has a match, then seek the event to the key
if (index.hasTop()) {
Key eventKey = index.getTopKey();
Key endKey = eventKey.followingKey(PartialKey.ROW_COLFAM);
Key startKey = new Key(eventKey.getRow(), eventKey.getColumnFamily());
Range eventRange = new Range(startKey, endKey);
HashSet<ByteSequence> cf = new HashSet<ByteSequence>();
cf.add(eventKey.getColumnFamilyData());
event.seek(eventRange, cf, true);
if (event.hasTop()) {
key = event.getTopKey();
value = event.getTopValue();
}
}
} while (key == null && index.hasTop());
}
// Sanity check. Make sure both returnValue and returnKey are null or both are not null
if (!((key == null && value == null) || (key != null && value != null))) {
log.warn("Key: " + ((key == null) ? "null" : key.toString()));
log.warn("Value: " + ((value == null) ? "null" : value.toString()));
throw new IOException("Return values are inconsistent");
}
}
示例14: seek
import org.apache.accumulo.core.data.Key; //导入方法依赖的package包/类
public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive) throws IOException {
if (log.isDebugEnabled()) {
log.debug("seek, range:" + range);
}
// Test the range to see if it is event specific.
if (null != range.getEndKey() && range.getEndKey().getColumnFamily() != null && range.getEndKey().getColumnFamily().getLength() != 0) {
if (log.isDebugEnabled()) {
log.debug("Jumping straight to the event");
}
// Then this range is for a specific event. We don't need to use the index iterator to find it, we can just
// seek to it with the event iterator and evaluate it.
eventSpecificRange = true;
event.seek(range, columnFamilies, inclusive);
if (event.hasTop()) {
key = event.getTopKey();
value = event.getTopValue();
}
} else {
if (log.isDebugEnabled()) {
log.debug("Using BooleanLogicIteratorJexl");
}
// Seek the boolean logic iterator
index.seek(range, columnFamilies, inclusive);
// If the index has a match, then seek the event to the key
if (index.hasTop()) {
Key eventKey = index.getTopKey();
// Range eventRange = new Range(eventKey, eventKey);
Range eventRange = new Range(eventKey.getRow());
HashSet<ByteSequence> cf = new HashSet<ByteSequence>();
cf.add(eventKey.getColumnFamilyData());
event.seek(eventRange, cf, true);
if (event.hasTop()) {
key = event.getTopKey();
value = event.getTopValue();
} else {
next();
}
}
}
}
示例15: next
import org.apache.accumulo.core.data.Key; //导入方法依赖的package包/类
@Override
public void next() throws IOException {
if (log.isDebugEnabled()) {
log.debug("next()");
}
if (this.hasTop()) {
currentRow = topKey.getRow();
}
getSource().next();
while (true) {
log.debug("next(), Range: " + range);
if (getSource().hasTop()) {
Key k = getSource().getTopKey();
if (range.contains(k)) {
if (matches(k)) {
topKey = k;
topValue = getSource().getTopValue();
return;
} else {
getSource().next();
}
} else {
if (parentEndRow != null) { // need to check it
if (k.getRow().equals(currentRow)) {
currentRow = getNextRow();
} else if (currentRow == null || k.getRow().compareTo(currentRow) > 0) {
currentRow = k.getRow();
}
if (currentRow == null || parentEndRow.compareTo(currentRow) < 0) {
// you're done
topKey = null;
topValue = null;
return;
}
} else { // we can go to end of the tablet
if (k.getRow().equals(currentRow)) {
currentRow = getNextRow();
if (currentRow == null) {
topKey = null;
topValue = null;
return;
}
} else if (currentRow == null || (k.getRow().compareTo(currentRow) > 0)) {
currentRow = k.getRow();
}
}
// construct new range and seek the source
range = buildRange(currentRow);
if (log.isDebugEnabled()) {
log.debug("next, range: " + range);
}
getSource().seek(range, EMPTY_COL_FAMS, false);
}
} else {
topKey = null;
topValue = null;
return;
}
}
}