Java Code Examples for org.apache.hadoop.hbase.client.Get#getRow()

The following examples show how to use org.apache.hadoop.hbase.client.Get#getRow() . 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: MockHTable.java    From metron with Apache License 2.0 6 votes vote down vote up
@Override
public boolean exists(Get get) throws IOException {
  if(get.getFamilyMap() == null || get.getFamilyMap().size() == 0) {
    return data.containsKey(get.getRow());
  } else {
    byte[] row = get.getRow();
    if(!data.containsKey(row)) {
      return false;
    }
    for(byte[] family : get.getFamilyMap().keySet()) {
      if(!data.get(row).containsKey(family)) {
        return false;
      } else {
        return true;
      }
    }
    return true;
  }
}
 
Example 2
Source File: CatalogJanitor.java    From hbase with Apache License 2.0 6 votes vote down vote up
/**
 * For testing against a cluster.
 * Doesn't have a MasterServices context so does not report on good vs bad servers.
 */
public static void main(String [] args) throws IOException {
  checkLog4jProperties();
  ReportMakingVisitor visitor = new ReportMakingVisitor(null);
  Configuration configuration = HBaseConfiguration.create();
  configuration.setBoolean("hbase.defaults.for.version.skip", true);
  try (Connection connection = ConnectionFactory.createConnection(configuration)) {
    /* Used to generate an overlap.
    */
    Get g = new Get(Bytes.toBytes("t2,40,1564119846424.1db8c57d64e0733e0f027aaeae7a0bf0."));
    g.addColumn(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER);
    try (Table t = connection.getTable(TableName.META_TABLE_NAME)) {
      Result r = t.get(g);
      byte [] row = g.getRow();
      row[row.length - 2] <<= row[row.length - 2];
      Put p = new Put(g.getRow());
      p.addColumn(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER,
          r.getValue(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER));
      t.put(p);
    }
    MetaTableAccessor.scanMetaForTableRegions(connection, visitor, null);
    Report report = visitor.getReport();
    LOG.info(report != null? report.toString(): "empty");
  }
}
 
Example 3
Source File: BigtableMocker.java    From styx with Apache License 2.0 5 votes vote down vote up
private Result resultOfGet(List<Cell> cells, Get get) {
  final byte[] row = get.getRow();

  return cells.stream()
      .filter(cell -> Bytes.equals(cell.getRowArray(), row))
      .findFirst()
      .map(cell -> Result.create(new Cell[] {cell}))
      .orElseGet(() -> Result.create(Collections.emptyList()));
}
 
Example 4
Source File: RegionObserverDemo.java    From bigdata-tutorial with Apache License 2.0 5 votes vote down vote up
@Override
public void preGetOp(ObserverContext<RegionCoprocessorEnvironment> e, Get get, List<Cell> results) throws IOException {
	LOG.debug("Got preGetOp for row: " + Bytes.toStringBinary(get.getRow()));

	if (Bytes.equals(get.getRow(), ROW_GETDMEO)) {
		KeyValue kv = new KeyValue(get.getRow(), FAMILY, ROW_GETDMEO, Bytes.toBytes("hello,micmiu.com"));
		LOG.debug("coprocess match the row kv: " + kv);
		results.add(kv);
	}
}
 
Example 5
Source File: RemoteHTable.java    From hbase with Apache License 2.0 5 votes vote down vote up
@Override
public Result[] get(List<Get> gets) throws IOException {
  byte[][] rows = new byte[gets.size()][];
  int maxVersions = 1;
  int count = 0;

  for (Get g : gets) {

    if (count == 0) {
      maxVersions = g.getMaxVersions();
    } else if (g.getMaxVersions() != maxVersions) {
      LOG.warn(
        "MaxVersions on Gets do not match, using the first in the list (" + maxVersions + ")");
    }

    if (g.getFilter() != null) {
      LOG.warn("filters not supported on gets");
    }

    rows[count] = g.getRow();
    count++;
  }

  String spec = buildMultiRowSpec(rows, maxVersions);

  return getResults(spec);
}