fstpackage / fsttable

An interface to fast on-disk data tables stored with the fst format
GNU Affero General Public License v3.0
27 stars 4 forks source link

Code completion with fsttable interface in RStudio #10

Open MarcusKlik opened 6 years ago

MarcusKlik commented 6 years ago

In RStudio, list and data.frame objects have code completion, when you do:

image

you get a nice popup showing the list element names. However, when you select a name from the menu, the following happens:

image

so we get brackets around the column name, as you would expect for a list or data.frame.

If we want to get auto-completion on a fsttable object the data.table-way, that object should have a data.table class and a fsttable class name:

# create a print generic
print.myclass <- function(dt){
  print("This is an override")
}

# define a data.table object
dt <- data.table::data.table(ColA = 1:100, ColBB = LETTERS)

# add a myclass class to the list of class names (at position 1)
class(dt) <- c("myclass", class(dt))

# check that custom print method is called
print(dt)
#> [1] "This is an override"

the auto-completion will now work as intended.

It would be nice to use the data.table class name in the fsttable object. That would require that overrides exist in the fsttable package for every possible generic that is defined in the data.table package. Otherwise, the data.table generic would be called for that particular method...

MarcusKlik commented 6 years ago

To keep good performance, there should be a limit to the number of columns simulated in the fsttable object. Perhaps 50 columns to start with.