Advertisement
Guest User

Random HBase Gets

a guest
Jun 28th, 2012
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.35 KB | None | 0 0
  1.             HTable table = new HTable(config, "test3");
  2.            
  3.             for (int iteration = 0; iteration < 10; iteration++)
  4.             {
  5.                
  6.                 final int linesToRead = 1000;
  7.                 System.out.println(new java.util.Date () + " Processing iteration " + iteration + "... ");
  8.                 Vector<Get> gets = new Vector<Get>(linesToRead);
  9.    
  10.                 for (long l = 0; l < linesToRead; l++)
  11.                 {
  12.                     byte[] array1 = new byte[24];
  13.                     for (int i = 0; i < array1.length; i++)
  14.                         array1[i] = (byte)Math.floor(Math.random() * 256);
  15.                     Get g = new Get (array1);
  16.                     gets.addElement(g);            
  17.    
  18.                     processed++;
  19.                 }
  20.                 Object[] results = new Object[gets.size()];
  21.                
  22.                 long timeBefore = System.currentTimeMillis();
  23.                 table.batch(gets, results);
  24.                 long timeAfter = System.currentTimeMillis();
  25.    
  26.                 float duration = timeAfter - timeBefore;
  27.                 System.out.println ("Time to read " + gets.size() + " lines : " + duration + " mseconds (" + Math.round(((float)linesToRead / (duration / 1000))) + " lines/seconds)");        
  28.                
  29.    
  30.                 for (int i = 0; i < results.length; i++)
  31.                 {
  32.                     if (results[i] instanceof KeyValue)
  33.                         if (!((KeyValue)results[i]).isEmptyColumn())
  34.                             System.out.println("Result[" + i + "]: " + results[i]); // co BatchExample-9-Dump Print all results.
  35.                 }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement