How to calculate the size of dataframe in bytes in Spark?

Usingspark.sessionState.executePlan(df.queryExecution.logical).optimizedPlan.stats(spark.sessionState.conf).sizeInBytes we can get the size of actual Dataframe once its loaded into memory. Check the below code. scala> val df = spark.read.format(“orc”).load(“/tmp/srinivas/”) df: org.apache.spark.sql.DataFrame = [channelGrouping: string, clientId: string … 75 more fields] scala> import org.apache.commons.io.FileUtils import org.apache.commons.io.FileUtils scala> val bytes = spark.sessionState.executePlan(df.queryExecution.logical).optimizedPlan.stats(spark.sessionState.conf).sizeInBytes bytes: BigInt = 763275709 scala> FileUtils.byteCountToDisplaySize(bytes.toLong) res5: String = 727 MB … Read more

Maximum and minimum value of C types integers from Python

According to: [Python 3 docs]: Numeric Types – int, float, complex: Integers have unlimited precision. Translated to code: >>> i = 10 ** 100 >>> i 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 >>> len(str(i)) 101 >>> i.bit_length() 333 On the other hand, each C type has a fixed size (depending on platform / architecture), as clearly shown in [CPPReference]: Fundamental … Read more

How to change legend fontsize with matplotlib.pyplot

You can set an individual font size for the legend by adjusting the prop keyword. plot.legend(loc=2, prop={‘size’: 6}) This takes a dictionary of keywords corresponding to matplotlib.font_manager.FontProperties properties. See the documentation for legend: Keyword arguments: prop: [ None | FontProperties | dict ] A matplotlib.font_manager.FontProperties instance. If prop is a dictionary, a new instance will … Read more

std::string length() and size() member functions

As per the documentation, these are just synonyms. size() is there to be consistent with other STL containers (like vector, map, etc.) and length() is to be consistent with most peoples’ intuitive notion of character strings. People usually talk about a word, sentence or paragraph’s length, not its size, so length() is there to make … Read more

Get size of POST-request in PHP

As simple as: $size = (int) $_SERVER[‘CONTENT_LENGTH’]; Note that $_SERVER[‘CONTENT_LENGTH’] is only set when the HTTP request method is POST (not GET). This is the raw value of the Content-Length header, as specified in RFC 7230. In the case of file uploads, if you want to get the total size of uploaded files, you should … Read more

Size of font in CSS with slash

This actually sets two properties and is equivalent to: font-size: 100%; line-height: 120%; To quote the official documentation: The syntax of this property is based on a traditional typographical shorthand notation to set multiple properties related to fonts. As David M said in the comments, it mirrors the typesetting tradition of specifying typeface sizes as … Read more