/usr/lib/R/site-library/dplyr/include/dplyr/Result/LazySubsets.h is in r-cran-dplyr 0.7.4-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | #ifndef dplyr_LazySubsets_H
#define dplyr_LazySubsets_H
#include <tools/SymbolMap.h>
#include <tools/SlicingIndex.h>
#include <dplyr/Result/ILazySubsets.h>
namespace dplyr {
class LazySubsets : public ILazySubsets {
public:
LazySubsets(const DataFrame& df) : nr(df.nrows()) {
int nvars = df.size();
if (nvars) {
CharacterVector names = df.names();
for (int i = 0; i < nvars; i++) {
SEXP column = df[i];
if (Rf_inherits(column, "matrix")) {
stop("matrix as column is not supported");
}
symbol_map.insert(names[i]);
data.push_back(df[i]);
}
}
}
virtual ~LazySubsets() {}
public:
virtual const SymbolVector get_variable_names() const {
return symbol_map.get_names();
}
virtual SEXP get_variable(const SymbolString& symbol) const {
return data[ symbol_map.get(symbol) ];
}
virtual SEXP get(const SymbolString& symbol, const SlicingIndex& indices) const {
const int pos = symbol_map.get(symbol);
SEXP col = data[pos];
if (!indices.is_identity(col) && Rf_length(col) != 1)
stop("Attempt to query lazy column with non-natural slicing index");
return col;
}
virtual bool is_summary(const SymbolString& symbol) const {
return summary_map.has(symbol);
}
virtual bool has_variable(const SymbolString& symbol) const {
return symbol_map.has(symbol);
}
virtual void input(const SymbolString& symbol, SEXP x) {
SymbolMapIndex index = symbol_map.insert(symbol);
if (index.origin == NEW) {
data.push_back(x);
} else {
data[index.pos] = x;
}
}
virtual int size() const {
return data.size();
}
virtual int nrows() const {
return nr;
}
void input_summarised(const SymbolString& symbol, SummarisedVariable x) {
input(symbol, x);
summary_map.insert(symbol);
}
public:
void clear() {}
inline SEXP& operator[](const SymbolString& symbol) {
return data[symbol_map.get(symbol)];
}
private:
SymbolMap symbol_map, summary_map;
std::vector<SEXP> data;
int nr;
};
}
#endif
|