Java Code Examples for org.apache.accumulo.core.data.Key#compareColumnFamily()
The following examples show how to use
org.apache.accumulo.core.data.Key#compareColumnFamily() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FileCount.java From accumulo-examples with Apache License 2.0 | 6 votes |
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; }
Example 2
Source File: FileCount.java From accumulo-examples with Apache License 2.0 | 4 votes |
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++; } }