As mentioned in the title, what is the main difference between using df.as[T]
and df.asInstanceOf[Dataset[T]]
?
Normally the difference between “du” and “df” is caused by deleted files that are still in use. Files that have been deleted but are still in use by a process, are not listed but are consuming spaces. This can be verified using the “lsof” command. If the “lsof” command is not working, a list of files marked as “deleted” can be obtained using:
First of, df reports file system disk space usage. That is, it displays the total size, the used and available space for each of your mounted partitions. is the default behavior, without arguments. Sizes are given in 1K-blocks (that is, 1024 bytes).
First of, df reports file system disk space usage. That is, it displays the total size, the used and available space for each of your mounted partitions. is the default behavior, without arguments.
df - disk space shown in 1K blocks. df -h - disk space shown in human readable form (KB, MB, GB) df -l - limit listing to local file systems. This info can be found in man pages. Try man df.
First, asInstanceOf
is just telling the compiler to shut up and believe you that df
is an instance of the Dataset
class (the T part is irrelevant due to type-erasure). In runtime, if the value is not an instance of that class you will get an exception; and in this case it will never be.
On the other hand, as
is a method defined in the Dataset class, which asks for an implicit Encoder so it can safely cast the data; note that since the data is processed in runtime, the conversion may still fail.
So the difference is big and you should not use the former.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With