Tag: hbase

Hbase Java API:检索与部分行键匹配的所有行

在Python模块happybase中 ,我可以检索具有以给定字符串开头的行键的所有行(即,使用部分行键进行搜索)。 假设我有一个格式为(ID | TYPE | DATE)的rowkey,我可以通过以下方式找到ID为1且TYPE为A的所有行: import happybase connection = happybase.Connection(‘hmaster-host.com’) table = connection.table(‘table_name’) for key, data in table.scan(row_prefix=”1|A|”): print key, data 到目前为止,这是一个完全客户端的Java程序,适用于任何尝试使用Java HBase API进行基础操作的人,但我只能使用完整的行键搜索一行: import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; import org.apache.hadoop.hbase.client.Get; import org.apache.hadoop.hbase.client.HTable; import org.apache.hadoop.hbase.client.Result; import org.apache.hadoop.hbase.util.Bytes; //class foo { public static void main(String[] args) { Configuration conf = new Configuration(); conf.addResource(new Path(“C:\\core-site.xml”)); conf.addResource(new […]

Hadoop – 直接从Mapper写入HBase

我有一个haddop作业,它的输出应写入HBase。 我真的不需要reducer,我想插入的那种行在Mapper中确定。 我如何使用TableOutputFormat来实现这一目标? 从我看到的所有示例中,我们假设reducer是创建Put的那个,而TableMapper只是用于从HBase表中读取。 在我的情况下,输入是HDFS,输出是Put到特定的表,我在TableMapReduceUtil中找不到任何可以帮助我的东西。 有什么例子可以帮助我吗? 顺便说一下,我正在使用新的Hadoop API

增加Hadoop 2中的Hive映射器数量

我从Hive创建了一个HBase表,我正在尝试对它进行简单的聚合。 这是我的Hive查询: from my_hbase_table select col1, count(1) group by col1; 地图减少作业只产生2个映射器,我想增加它。 使用普通地图缩小作业,我将配置纱线和映射器内存以增加映射器的数量。 我在Hive中尝试了以下操作,但它不起作用: set yarn.nodemanager.resource.cpu-vcores=16; set yarn.nodemanager.resource.memory-mb=32768; set mapreduce.map.cpu.vcores=1; set mapreduce.map.memory.mb=2048; 注意: 我的测试集群只有2个节点 HBase表有超过5M的记录 Hive日志显示HiveInputFormat和一些splits = 2

Hbase客户端ConnectionLoss for / hbase错误

我疯了: 安装好的Hadoop / Hbase都在运行; /opt/jdk1.6.0_24/bin/jps 23261 ThriftServer 22582 QuorumPeerMain 21969 NameNode 23500 Jps 23021 HRegionServer 22211 TaskTracker 22891 HMaster 22117 SecondaryNameNode 21779 DataNode 22370 Main 22704 JobTracker 伪分布式环境。 hbase shell 正在运行并提出运行’list’的正确结果; hbase shell HBase Shell; enter ‘help’ for list of supported commands. Type “exit” to leave the HBase Shell Version 0.90.1-cdh3u0, r, Fri Mar 25 […]

无法使用Java连接到HBase

我正在尝试使用Java连接HBase。 只有一个节点,这是我自己的机器。 好像我无法成功连接。 这是我的Java代码: public class Test { public static void main(String[] args) throws MasterNotRunningException, ZooKeeperConnectionException, IOException, ServiceException { SparkConf conf = new SparkConf().setAppName(“Test”).setMaster(“spark://10.239.58.111:7077”); JavaSparkContext sc = new JavaSparkContext(conf); sc.addJar(“/home/cloudera/workspace/Test/target/Test-0.0.1-SNAPSHOT.jar”); Configuration hbaseConf = HBaseConfiguration.create(); hbaseConf.addResource(new Path(“/usr/lib/hbase/conf/hbase-site.xml”)); HTable table = new HTable(hbaseConf, “rdga_by_id”); } } 我试着在这样的代码中设置环境, hbaseConf.set(“hbase.master”, “localhost”); hbaseConf.set(“hbase.master.port”, “60000”); hbaseConf.set(“hbase.zookeeper.property.clientPort”, “2181”); hbaseConf.set(“hbase.zookeeper.quorum”, “quickstart.cloudera”); hbaseConf.set(“hbase.zookeeper.quorum”, “localhost”); […]

在HBase中获取一组行的网络效率最高的方法是什么?

假设我有一组行键(作为Set)。 为这组行获取特定列族的网络效率最高的方法是什么?

HBase – java中的java.lang.NoClassDefFoundError

我只是想尝试使用Java与Hbase进行交互 import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.*; import org.apache.hadoop.hbase.client.*; import org.apache.hadoop.hbase.util.*; import org.apache.hadoop.hbase.HBaseConfiguration; public class TestHBase { public static void main(String[] args) throws Exception { Configuration conf = HBaseConfiguration.create(); HBaseAdmin admin = new HBaseAdmin(conf); try { HTable table = new HTable(conf, “test-table”); Put put = new Put(Bytes.toBytes(“test-key”)); put.add(Bytes.toBytes(“cf”), Bytes.toBytes(“q”), Bytes.toBytes(“value”)); table.put(put); } finally { admin.close(); } } […]

java.lang.NoSuchFieldError:IBM_JAVA,用于Eclipse中的简单hbase Java客户端

标题是。我的源代码是: package hbase; import java.io.IOException; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.HColumnDescriptor; import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.client.HBaseAdmin; import org.apache.hadoop.hbase.util.Bytes; public class HbaseExampleClient { public static void main(String[] args) throws IOException { Configuration config = HBaseConfiguration.create(); config.set(“hbase.zookeeper.quorum”, “192.168.10.17”); config.set(“hbase.zookeeper.property.clientPort”, “2222”); HBaseAdmin admin = new HBaseAdmin(config);//reports an IBM_JAVA NoSuchFieldError HTableDescriptor htd = new HTableDescriptor(“test1111”); HColumnDescriptor hcd = new HColumnDescriptor(“data”); […]

如何在HBase上使用带有SingleColumnValueFilter的自定义比较器?

我试图使用两个SingleColumnValueFilter对象来过滤HBase表中的行,以返回属于该列的长值范围内的所有记录。 根据SingleColumnValueFilter的文档,它会对列值进行字典比较,除非您将其传递给自己的比较器。 api显示SingleColumnValueFilter将WritableByteArrayComparable作为实现此目的的方法。 我写了一个扩展WritableByteArrayComparable并覆盖compare方法的类。 public class LongWritableComparable extends WritableByteArrayComparable { public LongWritableComparable() { super(); } public LongWritableComparable(byte[] value) { super(value); } public LongWritableComparable(Long value) { super(Bytes.toBytes(value)); } @Override public int compareTo(byte[] otherValue) { byte[] thisValue = this.getValue(); long thisLong = Bytes.toLong(thisValue); long otherLong = Bytes.toLong(otherValue); if (thisLong == otherLong) { return 0; } if (thisLong […]

引起:java.lang.ClassNotFoundException:org.apache.zookeeper.KeeperException

当我在Eclipse IDE下运行JAVA程序(不能使用新的HTable)时,我遇到以下错误: Exception in thread “main” java.lang.NoClassDefFoundError: org/apache/zookeeperKeeperException at org.apache.hadoop.hbase.client.HConnectionManager.getConnection(HConnectionManager.java:185) at org.apache.hadoop.hbase.client.HTable.(HTable.java:154) at org.apache.hadoop.hbase.client.HTable.(HTable.java:132) at HBaseConnector.main(HBaseConnector.java:27) Caused by: java.lang.ClassNotFoundException: org.apache.zookeeper.KeeperException at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) … 4 more import java.io.IOException; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.client.Get; import org.apache.hadoop.hbase.client.HTable; import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.client.Result; import org.apache.hadoop.hbase.client.ResultScanner; import […]