Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
reuse valueRow too
  • Loading branch information
yaooqinn committed Sep 22, 2016
commit 0f60e107904fa4d0e92185bd9fae214ee70a1a11
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ public UnsafeRow getKeyRow(int rowId) {
keyRow.pointTo(base, offset, klen);
// set keyRowId so we can check if desired row is cached
keyRowId = rowId;
isValueCached = false;
} else {
isValueCached = true;
}
return keyRow;
}
Expand All @@ -91,10 +94,12 @@ public UnsafeRow getKeyRow(int rowId) {
*/
@Override
protected UnsafeRow getValueFromKey(int rowId) {
if (keyRowId != rowId) {
assert(rowId >= 0);
if (keyRowId == rowId && isValueCached) {
return valueRow;
} else if (keyRowId != rowId) {
getKeyRow(rowId);
}
assert(rowId >= 0);
valueRow.pointTo(base, keyRow.getBaseOffset() + klen, vlen + 4);
return valueRow;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ public abstract class RowBasedKeyValueBatch extends MemoryConsumer {
protected final UnsafeRow keyRow;
protected final UnsafeRow valueRow;

// mark valueRow as cached after calling getKeyRow if rowId == keyRowId
protected boolean isValueCached = false;

protected MemoryBlock page = null;
protected Object base = null;
protected final long recordStartOffset;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ public UnsafeRow getKeyRow(int rowId) {
keyRow.pointTo(base, offset, klen);
// set keyRowId so we can check if desired row is cached
keyRowId = rowId;
isValueCached = false;
} else {
isValueCached = true;
}
return keyRow;
}
Expand All @@ -95,10 +98,12 @@ public UnsafeRow getKeyRow(int rowId) {
*/
@Override
public UnsafeRow getValueFromKey(int rowId) {
if (keyRowId != rowId) {
assert(rowId >= 0);
if (keyRowId == rowId && isValueCached) {
return valueRow;
} else if (keyRowId != rowId) {
getKeyRow(rowId);
}
assert(rowId >= 0);
long offset = keyRow.getBaseOffset();
int klen = keyRow.getSizeInBytes();
int vlen = Platform.getInt(base, offset - 8) - klen - 4;
Expand Down