HBASE-1930 Put.setTimeStamp misleading (doesn't change timestamp on existing KeyValues, not copied in copy constructor)
git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@829197 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
98aee5440f
commit
a4c81cdd30
|
@ -4,6 +4,9 @@ Release 0.21.0 - Unreleased
|
|||
HBASE-1822 Remove the deprecated APIs
|
||||
HBASE-1848 Fixup shell for HBASE-1822
|
||||
HBASE-1854 Remove the Region Historian
|
||||
HBASE-1930 Put.setTimeStamp misleading (doesn't change timestamp on
|
||||
existing KeyValues, not copied in copy constructor)
|
||||
(Dave Latham via Stack)
|
||||
|
||||
BUG FIXES
|
||||
HBASE-1791 Timeout in IndexRecordWriter (Bradford Stephens via Andrew
|
||||
|
|
|
@ -78,10 +78,21 @@ public class Put implements HeapSize, Writable, Row, Comparable<Row> {
|
|||
* @param rowLock previously acquired row lock, or null
|
||||
*/
|
||||
public Put(byte [] row, RowLock rowLock) {
|
||||
this(row, HConstants.LATEST_TIMESTAMP, rowLock);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a Put operation for the specified row, using a given timestamp, and an existing row lock.
|
||||
* @param row row key
|
||||
* @param ts timestamp
|
||||
* @param rowLock previously acquired row lock, or null
|
||||
*/
|
||||
public Put(byte [] row, long ts, RowLock rowLock) {
|
||||
if(row == null || row.length > HConstants.MAX_ROW_LENGTH) {
|
||||
throw new IllegalArgumentException("Row key is invalid");
|
||||
}
|
||||
this.row = Arrays.copyOf(row, row.length);
|
||||
this.timestamp = ts;
|
||||
if(rowLock != null) {
|
||||
this.lockId = rowLock.getLockId();
|
||||
}
|
||||
|
@ -92,13 +103,14 @@ public class Put implements HeapSize, Writable, Row, Comparable<Row> {
|
|||
* @param putToCopy put to copy
|
||||
*/
|
||||
public Put(Put putToCopy) {
|
||||
this(putToCopy.getRow(), putToCopy.getRowLock());
|
||||
this(putToCopy.getRow(), putToCopy.timestamp, putToCopy.getRowLock());
|
||||
this.familyMap =
|
||||
new TreeMap<byte [], List<KeyValue>>(Bytes.BYTES_COMPARATOR);
|
||||
for(Map.Entry<byte [], List<KeyValue>> entry :
|
||||
putToCopy.getFamilyMap().entrySet()) {
|
||||
this.familyMap.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
this.writeToWAL = putToCopy.writeToWAL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -205,15 +217,6 @@ public class Put implements HeapSize, Writable, Row, Comparable<Row> {
|
|||
return this.timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method for setting the timestamp
|
||||
* @param timestamp
|
||||
*/
|
||||
public Put setTimeStamp(long timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the number of different families included in this put
|
||||
*/
|
||||
|
|
|
@ -441,8 +441,7 @@ public class ThriftServer {
|
|||
HTable table = null;
|
||||
try {
|
||||
table = getTable(tableName);
|
||||
Put put = new Put(row);
|
||||
put.setTimeStamp(timestamp);
|
||||
Put put = new Put(row, timestamp, null);
|
||||
|
||||
Delete delete = new Delete(row);
|
||||
|
||||
|
@ -488,8 +487,7 @@ public class ThriftServer {
|
|||
byte[] row = batch.row;
|
||||
List<Mutation> mutations = batch.mutations;
|
||||
Delete delete = new Delete(row);
|
||||
Put put = new Put(row);
|
||||
put.setTimeStamp(timestamp);
|
||||
Put put = new Put(row, timestamp, null);
|
||||
for (Mutation m : mutations) {
|
||||
byte[][] famAndQf = KeyValue.parseColumn(m.column);
|
||||
if (m.isDelete) {
|
||||
|
|
|
@ -300,9 +300,11 @@ public abstract class HBaseTestCase extends TestCase {
|
|||
break EXIT;
|
||||
}
|
||||
try {
|
||||
Put put = new Put(t);
|
||||
Put put;
|
||||
if(ts != -1) {
|
||||
put.setTimeStamp(ts);
|
||||
put = new Put(t, ts, null);
|
||||
} else {
|
||||
put = new Put(t);
|
||||
}
|
||||
try {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
|
|
@ -71,8 +71,7 @@ public class TestScanMultipleVersions extends HBaseClusterTestCase {
|
|||
HRegion.createHRegion(this.INFOS[i], this.testDir, this.conf);
|
||||
// Insert data
|
||||
for (int j = 0; j < TIMESTAMPS.length; j++) {
|
||||
Put put = new Put(ROWS[i]);
|
||||
put.setTimeStamp(TIMESTAMPS[j]);
|
||||
Put put = new Put(ROWS[i], TIMESTAMPS[j], null);
|
||||
put.add(HConstants.CATALOG_FAMILY, null, TIMESTAMPS[j],
|
||||
Bytes.toBytes(TIMESTAMPS[j]));
|
||||
REGIONS[i].put(put);
|
||||
|
|
|
@ -241,10 +241,7 @@ public class TimestampTestBase extends HBaseTestCase {
|
|||
public static void put(final Incommon loader, final byte [] bytes,
|
||||
final long ts)
|
||||
throws IOException {
|
||||
Put put = new Put(ROW);
|
||||
if(ts != HConstants.LATEST_TIMESTAMP) {
|
||||
put.setTimeStamp(ts);
|
||||
}
|
||||
Put put = new Put(ROW, ts, null);
|
||||
put.add(FAMILY_NAME, QUALIFIER_NAME, bytes);
|
||||
loader.put(put);
|
||||
}
|
||||
|
|
|
@ -58,8 +58,7 @@ public class TestGetRowVersions extends HBaseClusterTestCase {
|
|||
|
||||
/** @throws Exception */
|
||||
public void testGetRowMultipleVersions() throws Exception {
|
||||
Put put = new Put(ROW);
|
||||
put.setTimeStamp(TIMESTAMP1);
|
||||
Put put = new Put(ROW, TIMESTAMP1, null);
|
||||
put.add(CONTENTS, CONTENTS, VALUE1);
|
||||
this.table.put(put);
|
||||
// Shut down and restart the HBase cluster
|
||||
|
@ -70,8 +69,7 @@ public class TestGetRowVersions extends HBaseClusterTestCase {
|
|||
// Make a new connection
|
||||
this.table = new HTable(conf, TABLE_NAME);
|
||||
// Overwrite previous value
|
||||
put = new Put(ROW);
|
||||
put.setTimeStamp(TIMESTAMP2);
|
||||
put = new Put(ROW, TIMESTAMP2, null);
|
||||
put.add(CONTENTS, CONTENTS, VALUE2);
|
||||
this.table.put(put);
|
||||
// Now verify that getRow(row, column, latest) works
|
||||
|
|
|
@ -205,8 +205,7 @@ public class TestScanner extends HBaseTestCase {
|
|||
|
||||
// Write information to the meta table
|
||||
|
||||
Put put = new Put(ROW_KEY);
|
||||
put.setTimeStamp(System.currentTimeMillis());
|
||||
Put put = new Put(ROW_KEY, System.currentTimeMillis(), null);
|
||||
|
||||
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
|
||||
DataOutputStream s = new DataOutputStream(byteStream);
|
||||
|
@ -236,8 +235,7 @@ public class TestScanner extends HBaseTestCase {
|
|||
|
||||
HServerAddress address = new HServerAddress("foo.bar.com:1234");
|
||||
|
||||
put = new Put(ROW_KEY);
|
||||
put.setTimeStamp(System.currentTimeMillis());
|
||||
put = new Put(ROW_KEY, System.currentTimeMillis(), null);
|
||||
put.add(HConstants.CATALOG_FAMILY, HConstants.SERVER_QUALIFIER,
|
||||
Bytes.toBytes(address.toString()));
|
||||
|
||||
|
@ -275,8 +273,7 @@ public class TestScanner extends HBaseTestCase {
|
|||
|
||||
address = new HServerAddress("bar.foo.com:4321");
|
||||
|
||||
put = new Put(ROW_KEY);
|
||||
put.setTimeStamp(System.currentTimeMillis());
|
||||
put = new Put(ROW_KEY, System.currentTimeMillis(), null);
|
||||
|
||||
put.add(HConstants.CATALOG_FAMILY, HConstants.SERVER_QUALIFIER,
|
||||
Bytes.toBytes(address.toString()));
|
||||
|
|
Loading…
Reference in New Issue