Skip to content
This repository has been archived by the owner on Feb 8, 2023. It is now read-only.

Commit

Permalink
适配SimpleHbaseCellResult的改动。
Browse files Browse the repository at this point in the history
调整配置文件中bean的名字。
调整包结构。
新增DisplayOnlyStringRowKey。
  • Loading branch information
xinzhi.zhang committed Mar 25, 2014
1 parent 97cc8f1 commit 259603c
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 16 deletions.
2 changes: 1 addition & 1 deletion config/consumerecord.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<SimpleHbase>

<HBaseTableSchema tableName="T_CONSUME_RECORD" defaultFamily="CONSUME" rowKeyHandlerName="com.alipay.hbaseviewer.ext.ConsumeRecordRowKeyHandler" >
<HBaseTableSchema tableName="T_CONSUME_RECORD" defaultFamily="CONSUME" rowKeyHandlerName="com.alipay.hbaseviewer.ext.consumerecord.ConsumeRecordRowKeyHandler" >

<HBaseColumnSchema qualifier="OWNER_CARD_NO" typeName="string" />
<HBaseColumnSchema qualifier="OWNER_CUSTOMER_ID" typeName="string" />
Expand Down
20 changes: 16 additions & 4 deletions hbaseviewer/WEB-INF/spring/simplehbase.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,23 @@
</property>
</bean>

<bean id="test_hbaseTableConfig" class="com.alipay.simplehbase.config.HBaseTableConfig"


<bean id="myRecord_hbaseTableConfig" class="com.alipay.simplehbase.config.HBaseTableConfig"
init-method="init">
<property name="configResource" value="file:config\myRecord.xml">
</property>
</bean>

<bean id="test_simpleHbaseClient" class="com.alipay.simplehbase.client.SimpleHbaseClientImpl">
<property name="hbaseTableConfig" ref="test_hbaseTableConfig" />
<bean id="myRecord_simpleHbaseClient" class="com.alipay.simplehbase.client.SimpleHbaseClientImpl">
<property name="hbaseTableConfig" ref="myRecord_hbaseTableConfig" />
<property name="hbaseDataSource" ref="test_hbaseDataSource" />
</bean>





<bean id="consumerecord_hbaseTableConfig" class="com.alipay.simplehbase.config.HBaseTableConfig"
init-method="init">
<property name="configResource" value="file:config\consumerecord.xml">
Expand All @@ -41,6 +46,10 @@
<property name="hbaseDataSource" ref="test_hbaseDataSource" />
</bean>





<bean id="billCategory_hbaseTableConfig" class="com.alipay.simplehbase.config.HBaseTableConfig"
init-method="init">
<property name="configResource" value="file:config\billCategory.xml">
Expand All @@ -64,11 +73,14 @@
</list>
</property>
</bean>




<bean id="hbaseClientManager" class="com.alipay.hbaseviewer.home.HbaseClientManager">
<property name="list">
<list>
<ref bean="test_simpleHbaseClient" />
<ref bean="myRecord_simpleHbaseClient" />
<ref bean="consumerecord_simpleHbaseClient" />
<ref bean="billCategory_simpleHbaseClient" />
</list>
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<groupId>allen</groupId>
<artifactId>simplehbaseviewer</artifactId>
<packaging>jar</packaging>
<version>0.6</version>
<version>0.7</version>
<name>simplehbaseviewer</name>

<properties>
Expand Down Expand Up @@ -98,7 +98,7 @@
<dependency>
<groupId>allen</groupId>
<artifactId>simplehbase</artifactId>
<version>0.6</version>
<version>0.7</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.alipay.hbaseviewer.ext;

import com.alipay.simplehbase.client.RowKey;
import com.alipay.simplehbase.exception.SimpleHBaseException;

public class DisplayOnlyStringRowKey implements RowKey {

private String rowkey;

public DisplayOnlyStringRowKey(String rowkey) {
this.rowkey = rowkey;
}

@Override
public byte[] toBytes() {
throw new SimpleHBaseException("Not support.");
}

@Override
public String toString() {
return rowkey;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

import org.apache.hadoop.hbase.util.Bytes;

import com.alipay.hbaseviewer.ext.DisplayOnlyStringRowKey;
import com.alipay.simplehbase.client.RowKey;
import com.alipay.simplehbase.client.rowkey.handler.RowKeyHandler;
import com.alipay.simplehbase.util.BytesUtil;
import com.alipay.simplehbase.util.StringUtil;

public class BillCategoryRowKeyHandler implements RowKeyHandler {
public Object convert(byte[] key) {
public RowKey convert(byte[] key) {
StringBuilder sb = new StringBuilder();
String reverseUserId = Bytes.toString(BytesUtil.subBytes(key, 5, 16));
String userId = StringUtil.reverse(reverseUserId);
Expand All @@ -16,6 +18,6 @@ public Object convert(byte[] key) {
String reverseCycle = Bytes.toString(BytesUtil.subBytes(key, 22, 8));
int cycle = 100000000 - Integer.parseInt(reverseCycle);
sb.append(cycle);
return sb.toString();
return new DisplayOnlyStringRowKey(sb.toString());
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.alipay.hbaseviewer.ext;
package com.alipay.hbaseviewer.ext.consumerecord;

import java.util.Date;
import java.util.List;

import org.apache.hadoop.hbase.util.Bytes;

import com.alipay.hbaseviewer.ext.DisplayOnlyStringRowKey;
import com.alipay.simplehbase.client.RowKey;
import com.alipay.simplehbase.client.rowkey.handler.RowKeyHandler;
import com.alipay.simplehbase.util.BytesUtil;
import com.alipay.simplehbase.util.DateUtil;
Expand All @@ -14,7 +16,7 @@
public class ConsumeRecordRowKeyHandler implements RowKeyHandler {

@Override
public Object convert(byte[] row) {
public RowKey convert(byte[] row) {
StringBuilder sb = new StringBuilder();
List<byte[]> list = BytesUtil.split(row, BytesUtil.ZERO);
Util.check(list.size() == 4);
Expand All @@ -30,7 +32,8 @@ public Object convert(byte[] row) {
sb.append(" ");

sb.append(Bytes.toString(list.get(3)));
return sb;

return new DisplayOnlyStringRowKey(sb.toString());

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.alipay.simplehbase.client.RowKey;
import com.alipay.simplehbase.client.SimpleHbaseCellResult;
import com.alipay.simplehbase.config.SimpleHbaseConstants;
import com.alipay.simplehbase.util.DateUtil;
Expand Down Expand Up @@ -51,7 +52,7 @@ public static List<CellListWrapper> convertCellListWrapper(
for (SimpleHbaseCellResult cell : cellList) {
if (cell.getTsDate().equals(ts)) {
cellListWrapper.addCell(cell);
cellListWrapper.setRowkey(cell.getRowObject());
cellListWrapper.setRowkey(cell.getRowKey());
}
}
}
Expand All @@ -60,7 +61,7 @@ public static List<CellListWrapper> convertCellListWrapper(

private List<SimpleHbaseCellResult> cellList = new ArrayList<SimpleHbaseCellResult>();
private Date ts;
private Object rowkey;
private RowKey rowkey;

public CellListWrapper() {
}
Expand Down Expand Up @@ -98,11 +99,11 @@ public void setTs(Date ts) {
this.ts = ts;
}

public Object getRowkey() {
public RowKey getRowkey() {
return rowkey;
}

public void setRowkey(Object rowkey) {
public void setRowkey(RowKey rowkey) {
this.rowkey = rowkey;
}
}

0 comments on commit 259603c

Please sign in to comment.