@@ -0,0 +1,1851 @@
+package org.CMPT732A3;%0A%0Aimport java.io.BufferedReader;%0Aimport java.io.FileReader;%0Aimport java.io.IOException;%0Aimport java.util.List;%0A%0Aimport org.apache.hadoop.conf.Configuration;%0Aimport org.apache.hadoop.hbase.*;%0Aimport org.apache.hadoop.hbase.client.*;%0Aimport org.apache.hadoop.hbase.util.*;%0A%0Apublic class ExtractMovieInfo %7B%0A%0A%09public static void main(String%5B%5D args) throws IOException %7B%0A%09%09// TODO Auto-generated method stub%0A%09%09%0A%09%09Configuration config = HBaseConfiguration.create();%0A%09%09// Create table%0A%09%09HBaseAdmin admin = new HBaseAdmin(config);%0A%09%09%0A%09%09%0A%09%09HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(%22weipuz_movieInfo%22));%0A%09%09HColumnDescriptor hcd = new HColumnDescriptor(%22data%22);%0A%09%09htd.addFamily(hcd);%0A%09%09admin.createTable(htd);%0A%09%09byte %5B%5D tablename = htd.getName();%0A%09%09HTableDescriptor %5B%5D tables = admin.listTables();%0A%09%09if (tables.length != 1 && Bytes.equals(tablename, tables%5B0%5D.getName())) %7B%0A%09%09%09throw new IOException(%22Failed create of table%22);%0A%09%09%7D%0A%09%09%0A%09%09// Run some operations -- a put, and a get%0A%09%09HTable table = new HTable(config, tablename);%0A%09%09String filename = %22movies.dat%22;%0A%09%09BufferedReader br = new BufferedReader(new FileReader(filename));%0A%09%09String line;%0A%09%09int row_index = 0;%0A%09%09while ((line = br.readLine()) != null) %7B%0A%09%09   // process the line.%0A%09%09%09String aline%5B%5D = line.split(%22::%22);%0A%09%09%09String row = Integer.toString(row_index);%0A%09%09%09row_index++;%0A%09%09%09%0A%09%09%09byte %5B%5D row1 = Bytes.toBytes(row);%0A%09%09%09Put p1 = new Put(row1);%0A%09%09%09byte %5B%5D databytes = Bytes.toBytes(%22data%22);%0A%09%09%09%0A%09%09%09p1.add(databytes, Bytes.toBytes(%22ID%22), Bytes.toBytes(aline%5B0%5D));%0A%09%09%09p1.add(databytes, Bytes.toBytes(%22Title%22), Bytes.toBytes(aline%5B1%5D));%0A%09%09%09p1.add(databytes, Bytes.toBytes(%22Genres%22), Bytes.toBytes(aline%5B2%5D));%0A%09%09%09%09%0A%09%09%09table.put(p1);%09%09%0A%09%09%09%0A%09%09%09%0A%09%09%09%0A%09%09%7D%0A%09%09br.close();%0A%09%09%0A%09%09// Drop the table%0A%09%09admin.disableTable(tablename);%0A%09%09admin.deleteTable(tablename);%0A%09%09%09%0A%09%09%0A%0A%09%7D%0A%0A%7D%0A

question1 extract movieinfo into Hbase