/** * Returns the value row by two steps: * 1) looking up the key row with the same id (skipped if the key row is cached) * 2) retrieve the value row by reusing the metadata from step 1) * In most times, 1) is skipped because `getKeyRow(id)` is often called before `getValueRow(id)`. */ @Override public UnsafeRow getValueFromKey(int rowId) { 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; valueRow.pointTo(base, offset + klen, vlen + 4); return valueRow; }
public static RowBasedKeyValueBatch allocate(StructType keySchema, StructType valueSchema, TaskMemoryManager manager, int maxRows) { boolean allFixedLength = true; // checking if there is any variable length fields // there is probably a more succinct impl of this for (String name : keySchema.fieldNames()) { allFixedLength = allFixedLength && UnsafeRow.isFixedLength(keySchema.apply(name).dataType()); } for (String name : valueSchema.fieldNames()) { allFixedLength = allFixedLength && UnsafeRow.isFixedLength(valueSchema.apply(name).dataType()); } if (allFixedLength) { return new FixedLengthRowBasedKeyValueBatch(keySchema, valueSchema, maxRows, manager); } else { return new VariableLengthRowBasedKeyValueBatch(keySchema, valueSchema, maxRows, manager); } }
public static RowBasedKeyValueBatch allocate(StructType keySchema, StructType valueSchema, TaskMemoryManager manager, int maxRows) { boolean allFixedLength = true; // checking if there is any variable length fields // there is probably a more succinct impl of this for (String name : keySchema.fieldNames()) { allFixedLength = allFixedLength && UnsafeRow.isFixedLength(keySchema.apply(name).dataType()); } for (String name : valueSchema.fieldNames()) { allFixedLength = allFixedLength && UnsafeRow.isFixedLength(valueSchema.apply(name).dataType()); } if (allFixedLength) { return new FixedLengthRowBasedKeyValueBatch(keySchema, valueSchema, maxRows, manager); } else { return new VariableLengthRowBasedKeyValueBatch(keySchema, valueSchema, maxRows, manager); } }
/** * Returns the value row by two steps: * 1) looking up the key row with the same id (skipped if the key row is cached) * 2) retrieve the value row by reusing the metadata from step 1) * In most times, 1) is skipped because `getKeyRow(id)` is often called before `getValueRow(id)`. */ @Override public UnsafeRow getValueFromKey(int rowId) { 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; valueRow.pointTo(base, offset + klen, vlen); return valueRow; }
public static RowBasedKeyValueBatch allocate(StructType keySchema, StructType valueSchema, TaskMemoryManager manager, int maxRows) { boolean allFixedLength = true; // checking if there is any variable length fields // there is probably a more succinct impl of this for (String name : keySchema.fieldNames()) { allFixedLength = allFixedLength && UnsafeRow.isFixedLength(keySchema.apply(name).dataType()); } for (String name : valueSchema.fieldNames()) { allFixedLength = allFixedLength && UnsafeRow.isFixedLength(valueSchema.apply(name).dataType()); } if (allFixedLength) { return new FixedLengthRowBasedKeyValueBatch(keySchema, valueSchema, maxRows, manager); } else { return new VariableLengthRowBasedKeyValueBatch(keySchema, valueSchema, maxRows, manager); } }
/** * Returns the value row by two steps: * 1) looking up the key row with the same id (skipped if the key row is cached) * 2) retrieve the value row by reusing the metadata from step 1) * In most times, 1) is skipped because `getKeyRow(id)` is often called before `getValueRow(id)`. */ @Override public UnsafeRow getValueFromKey(int rowId) { 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; valueRow.pointTo(base, offset + klen, vlen); return valueRow; }