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); } }
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); } }