public static Pair<byte[], byte[]> getMinMaxRowIds(Connector connector, AccumuloTable table, Authorizations auths) throws TableNotFoundException { Scanner scanner = connector.createScanner(table.getMetricsTableName(), auths); scanner.setRange(new Range(new Text(Indexer.METRICS_TABLE_ROW_ID.array()))); Text family = new Text(Indexer.METRICS_TABLE_ROWS_CF.array()); Text firstRowQualifier = new Text(Indexer.METRICS_TABLE_FIRST_ROW_CQ.array()); Text lastRowQualifier = new Text(Indexer.METRICS_TABLE_LAST_ROW_CQ.array()); scanner.fetchColumn(family, firstRowQualifier); scanner.fetchColumn(family, lastRowQualifier); byte[] firstRow = null; byte[] lastRow = null; for (Entry<Key, Value> entry : scanner) { if (entry.getKey().compareColumnQualifier(firstRowQualifier) == 0) { firstRow = entry.getValue().get(); } if (entry.getKey().compareColumnQualifier(lastRowQualifier) == 0) { lastRow = entry.getValue().get(); } } scanner.close(); return Pair.of(firstRow, lastRow); }
public boolean equals(ColHashKey ohk) { if (columnFamily == null) return key.compareColumnFamily(ohk.columnFamily) == 0 && key.compareColumnQualifier(ohk.columnQualifier) == 0; return ohk.key.compareColumnFamily(columnFamily) == 0 && ohk.key.compareColumnQualifier(columnQualifier) == 0; } }
public boolean hasColumns(Key key) { return key.compareColumnFamily(colf) == 0 && key.compareColumnQualifier(colq) == 0; }
private PartialKey isKeyInSlice(Key k) { if (cso.minCf.getLength() > 0) { int minCfComp = k.compareColumnFamily(cso.minCf); if (minCfComp < 0 || (minCfComp == 0 && !cso.minInclusive)) { return PartialKey.ROW; } } if (cso.maxCf.getLength() > 0) { int maxCfComp = k.compareColumnFamily(cso.maxCf); if (maxCfComp > 0 || (maxCfComp == 0 && !cso.maxInclusive)) { return PartialKey.ROW; } } // k.colfam is in the "slice". if (cso.minCq.getLength() > 0) { int minCqComp = k.compareColumnQualifier(cso.minCq); if (minCqComp < 0 || (minCqComp == 0 && !cso.minInclusive)) { return PartialKey.ROW_COLFAM; } } if (cso.maxCq.getLength() > 0) { int maxCqComp = k.compareColumnQualifier(cso.maxCq); if (maxCqComp > 0 || (maxCqComp == 0 && !cso.maxInclusive)) { return PartialKey.ROW_COLFAM; } } // k.colqual is in the slice. return PartialKey.ROW_COLFAM_COLQUAL; }
int minCqCmp = k.compareColumnQualifier(cso.minCq); if (minCqCmp < 0) { return SKIP_TO_HINT; // hint will be the min CQ in this CF in this row. int maxCqCmp = k.compareColumnQualifier(cso.maxCq); if (maxCqCmp > 0 || (maxCqCmp == 0 && !cso.maxInclusive)) { return SKIP_TO_NEXT_CF;
@Override public int compareTo(TermSource o) { // NOTE: If your implementation can have more than one row in a tablet, // you must compare row key here first, then column qualifier. // NOTE2: A null check is not needed because things are only added to the // sorted after they have been determined to be valid. return this.iter.getTopKey().compareColumnQualifier(o.iter.getTopKey().getColumnQualifier()); }
@Override public Key getNextKeyHint(Key k, Value v) throws IllegalArgumentException { if (cso.minCf.getLength() > 0) { int minCfCmp = k.compareColumnFamily(cso.minCf); if (minCfCmp < 0) { Key hint = new Key(k.getRow(), cso.minCf); return cso.minInclusive ? hint : hint.followingKey(PartialKey.ROW_COLFAM); } } if (cso.minCq.getLength() > 0) { int minCqCmp = k.compareColumnQualifier(cso.minCq); if (minCqCmp < 0) { Key hint = new Key(k.getRow(), k.getColumnFamily(), cso.minCq); return cso.minInclusive ? hint : hint.followingKey(PartialKey.ROW_COLFAM_COLQUAL); } } // If we get here it means that we were asked to provide a hint for a key that we // didn't return USE_HINT for. throw new IllegalArgumentException("Don't know how to provide hint for key " + k); }
public boolean equals(ColHashKey ohk) { if (columnFamily == null) return key.compareColumnFamily(ohk.columnFamily) == 0 && key.compareColumnQualifier(ohk.columnQualifier) == 0; return ohk.key.compareColumnFamily(columnFamily) == 0 && ohk.key.compareColumnQualifier(columnQualifier) == 0; } }
public boolean hasColumns(Key key) { return key.compareColumnFamily(colf) == 0 && key.compareColumnQualifier(colq) == 0; }
private PartialKey isKeyInSlice(Key k) { if (cso.minCf.getLength() > 0) { int minCfComp = k.compareColumnFamily(cso.minCf); if (minCfComp < 0 || (minCfComp == 0 && !cso.minInclusive)) { return PartialKey.ROW; } } if (cso.maxCf.getLength() > 0) { int maxCfComp = k.compareColumnFamily(cso.maxCf); if (maxCfComp > 0 || (maxCfComp == 0 && !cso.maxInclusive)) { return PartialKey.ROW; } } // k.colfam is in the "slice". if (cso.minCq.getLength() > 0) { int minCqComp = k.compareColumnQualifier(cso.minCq); if (minCqComp < 0 || (minCqComp == 0 && !cso.minInclusive)) { return PartialKey.ROW_COLFAM; } } if (cso.maxCq.getLength() > 0) { int maxCqComp = k.compareColumnQualifier(cso.maxCq); if (maxCqComp > 0 || (maxCqComp == 0 && !cso.maxInclusive)) { return PartialKey.ROW_COLFAM; } } // k.colqual is in the slice. return PartialKey.ROW_COLFAM_COLQUAL; }
int minCqCmp = k.compareColumnQualifier(cso.minCq); if (minCqCmp < 0) { return SKIP_TO_HINT; // hint will be the min CQ in this CF in this row. int maxCqCmp = k.compareColumnQualifier(cso.maxCq); if (maxCqCmp > 0 || (maxCqCmp == 0 && !cso.maxInclusive)) { return SKIP_TO_NEXT_CF;
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; }
@Override public int compareTo(TermSource o) { // NOTE: If your implementation can have more than one row in a tablet, // you must compare row key here first, then column qualifier. // NOTE2: A null check is not needed because things are only added to the // sorted after they have been determined to be valid. return this.iter.getTopKey().compareColumnQualifier(o.iter.getTopKey().getColumnQualifier()); }
@Override public Key getNextKeyHint(Key k, Value v) throws IllegalArgumentException { if (cso.minCf.getLength() > 0) { int minCfCmp = k.compareColumnFamily(cso.minCf); if (minCfCmp < 0) { Key hint = new Key(k.getRow(), cso.minCf); return cso.minInclusive ? hint : hint.followingKey(PartialKey.ROW_COLFAM); } } if (cso.minCq.getLength() > 0) { int minCqCmp = k.compareColumnQualifier(cso.minCq); if (minCqCmp < 0) { Key hint = new Key(k.getRow(), k.getColumnFamily(), cso.minCq); return cso.minInclusive ? hint : hint.followingKey(PartialKey.ROW_COLFAM_COLQUAL); } } // If we get here it means that we were asked to provide a hint for a key that we // didn't return USE_HINT for. throw new IllegalArgumentException("Don't know how to provide hint for key " + k); }
if (!nowEqual && next.getKey().compareColumnQualifier(row) < 0) { nowEqual = true; if (!nowGreat && next.getKey().compareColumnQualifier(row) == 0) continue; else