HBASE-1824 [stargate] default timestamp should be LATEST_TIMESTAMP; minor additional changes

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@813579 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andrew Kyle Purtell 2009-09-10 20:46:37 +00:00
parent 9d1d24095c
commit 9bbcc4a06f
1 changed files with 4 additions and 11 deletions

View File

@ -39,6 +39,7 @@ import javax.ws.rs.core.Response.ResponseBuilder;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.client.Delete; import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.HTableInterface; import org.apache.hadoop.hbase.client.HTableInterface;
@ -147,11 +148,7 @@ public class RowResource implements Constants {
Put put = new Put(row.getKey()); Put put = new Put(row.getKey());
for (CellModel cell: row.getCells()) { for (CellModel cell: row.getCells()) {
byte [][] parts = KeyValue.parseColumn(cell.getColumn()); byte [][] parts = KeyValue.parseColumn(cell.getColumn());
if (cell.hasUserTimestamp()) { put.add(parts[0], parts[1], cell.getTimestamp(), cell.getValue());
put.add(parts[0], parts[1], cell.getTimestamp(), cell.getValue());
} else {
put.add(parts[0], parts[1], cell.getValue());
}
} }
table.put(put); table.put(put);
if (LOG.isDebugEnabled()) { if (LOG.isDebugEnabled()) {
@ -188,7 +185,7 @@ public class RowResource implements Constants {
if (columns != null) { if (columns != null) {
column = columns[0]; column = columns[0];
} }
long timestamp = -1; long timestamp = HConstants.LATEST_TIMESTAMP;
List<String> vals = headers.getRequestHeader("X-Row"); List<String> vals = headers.getRequestHeader("X-Row");
if (vals != null && !vals.isEmpty()) { if (vals != null && !vals.isEmpty()) {
row = Bytes.toBytes(vals.get(0)); row = Bytes.toBytes(vals.get(0));
@ -206,11 +203,7 @@ public class RowResource implements Constants {
} }
Put put = new Put(row); Put put = new Put(row);
byte parts[][] = KeyValue.parseColumn(column); byte parts[][] = KeyValue.parseColumn(column);
if (timestamp >= 0) { put.add(parts[0], parts[1], timestamp, message);
put.add(parts[0], parts[1], timestamp, message);
} else {
put.add(parts[0], parts[1], message);
}
table = pool.getTable(this.table); table = pool.getTable(this.table);
table.put(put); table.put(put);
if (LOG.isDebugEnabled()) { if (LOG.isDebugEnabled()) {