hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From llpind <sonny_h...@hotmail.com>
Subject Re: Adding/Removing regionservers
Date Thu, 02 Jul 2009 18:51:23 GMT

Assume a schema like so:  

TableA======================
Row Key:  TYPE|VALUE|ID
Column:  link:ID  (irrelevant)
TableB======================
Row Key: ID
Column: typeval:TYPE|VALUE
===========================



I need to iterate over the TableA using a Scanner to get all IDs based on
TYPE|VALUE, then for each ID I need to get from TableB what TYPE|VALUE’s
it’s tied to (a many to many).
Assume I have a list of TYPE|VALUES in a List, and need to process through
this data.  Done something like this:



for (String typeVal : list){

  Scan tblAScan = new Scan(Bytes.toBytes(typeVal  + “|”),
Bytes.toBytes(typeVal  + “|A”));	//give me all IDs for matching TYPE|VAL
  ResultScanner s1 = tblA.getScanner(tblAScan);

  for (Result tblBRowResult = s1.next(); tblBRowResult != null;
tblBRowResult = s1.next()){

	  Scan tblBScan = new Scan(Bytes.toBytes(tblBRowResult.getValue() ),
Bytes.toBytes(typeVal  + “ ”));  //IDs are all numeric
	  ResultScanner s2 = tblA.getScanner(tblAScan);
	  List results = s2.next().list();  //only care about column data here,
since ID is row key

	  for (KeyValue kv : results){
			//do stuff
			kv.getValue();
	  }

  }

}

-- 
View this message in context: http://www.nabble.com/Adding-Removing-regionservers-tp24309642p24312147.html
Sent from the HBase User mailing list archive at Nabble.com.


Mime
View raw message