Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between using df.as[T] and df.asInstanceOf[Dataset[T]]?

As mentioned in the title, what is the main difference between using df.as[T] and df.asInstanceOf[Dataset[T]]?

like image 793
dadadima Avatar asked May 06 '21 17:05

dadadima


People also ask

What is the difference between “Du” and “DF”?

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:

What does df report in Linux?

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).

How does df report disk space usage?

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.

What is the difference between DF-H and DF-L?

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.


Video Answer


1 Answers

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.

like image 111
Luis Miguel Mejía Suárez Avatar answered Nov 10 '22 21:11

Luis Miguel Mejía Suárez