This file is indexed.

/usr/lib/R/site-library/dplyr/include/dplyr/SubsetVectorVisitorImpl.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
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
#ifndef dplyr_SubsetVectorVisitor_Impl_H
#define dplyr_SubsetVectorVisitor_Impl_H

#include <tools/collapse.h>
#include <tools/utils.h>

#include <dplyr/VectorVisitorImpl.h>
#include <dplyr/SubsetVectorVisitor.h>

namespace dplyr {

/**
 * Implementations
 */
template <int RTYPE>
class SubsetVectorVisitorImpl : public SubsetVectorVisitor {
public:
  typedef Rcpp::Vector<RTYPE> VECTOR;

  /**
   * The type of data : int, double, SEXP, Rcomplex
   */
  typedef typename Rcpp::traits::storage_type<RTYPE>::type STORAGE;

  SubsetVectorVisitorImpl(const VECTOR& vec_) : vec(vec_) {}

  inline SEXP subset(const Rcpp::IntegerVector& index) const {
    return subset_int_index(index);
  }

  inline SEXP subset(const std::vector<int>& index) const {
    return subset_int_index(index);
  }

  inline SEXP subset(const SlicingIndex& index) const {
    return subset_int_index(index);
  }

  inline SEXP subset(const ChunkIndexMap& map) const {
    int n = output_size(map);
    VECTOR out = Rcpp::no_init(n);
    ChunkIndexMap::const_iterator it = map.begin();
    for (int i = 0; i < n; i++, ++it)
      out[i] = vec[ it->first ];
    copy_most_attributes(out, vec);
    return out;
  }

  inline SEXP subset(EmptySubset) const {
    VECTOR out(0);
    copy_most_attributes(out, vec);
    return out;
  }

  inline std::string get_r_type() const {
    return VectorVisitorType<RTYPE>();
  }

  inline int size() const {
    return vec.size();
  }

  inline bool is_compatible(SubsetVectorVisitor* other, std::stringstream&, const SymbolString&) const {
    return is_same_typeid(other);
  }

protected:
  VECTOR vec;

  template <typename Container>
  inline SEXP subset_int_index(const Container& index) const {
    int n = output_size(index);
    VECTOR out = Rcpp::no_init(n);
    for (int i = 0; i < n; i++) {
      if (index[i] < 0) {
        out[i] = VECTOR::get_na();
      } else {
        out[i] = vec[ index[i] ];
      }
    }
    copy_most_attributes(out, vec);
    return out;
  }

};

template <>
template <typename Container>
SEXP SubsetVectorVisitorImpl<VECSXP>::subset_int_index(const Container& index) const {
  int n = output_size(index);
  List out(n);
  for (int i = 0; i < n; i++)
    out[i] = (index[i] < 0) ? R_NilValue : vec[ index[i] ];
  copy_most_attributes(out, vec);
  return out;
}

class SubsetFactorVisitor : public SubsetVectorVisitorImpl<INTSXP> {
public:
  typedef SubsetVectorVisitorImpl<INTSXP> Parent;

  SubsetFactorVisitor(const IntegerVector& vec_) : Parent(vec_) {
    levels = get_levels(vec);
    levels_ptr = Rcpp::internal::r_vector_start<STRSXP>(levels);
  }

  inline SEXP subset(const Rcpp::IntegerVector& index) const {
    return promote(Parent::subset(index));
  }

  inline SEXP subset(const SlicingIndex& index) const {
    return promote(Parent::subset(index));
  }

  inline SEXP subset(const std::vector<int>& index) const {
    return promote(Parent::subset(index));
  }

  inline SEXP subset(const ChunkIndexMap& map) const {
    return promote(Parent::subset(map));
  }

  inline SEXP subset(EmptySubset empty) const {
    return promote(Parent::subset(empty));
  }

  inline std::string get_r_type() const {
    return get_single_class(Parent::vec);
  }

  inline bool is_same_type(SubsetVectorVisitor* other, std::stringstream& ss, const SymbolString& name) const {
    return is_same_typeid(other) && same_levels(dynamic_cast<SubsetFactorVisitor*>(other), ss, name);
  }

  inline bool is_compatible(SubsetVectorVisitor* other, std::stringstream&, const SymbolString&) const {
    return is_same_typeid(other) || (typeid(*other) == typeid(SubsetVectorVisitorImpl<STRSXP>));
  }

private:
  inline bool same_levels(SubsetFactorVisitor* other, std::stringstream& ss, const SymbolString& name) const {
    CharacterVector levels_other = other->levels;

    if (!character_vector_equal(levels, levels_other)) {
      ss << "Factor levels not equal for column `" << name.get_utf8_cstring() << "`";
      return false;
    }
    return true;
  }

  inline SEXP promote(IntegerVector x) const {
    copy_most_attributes(x, vec);
    return x;
  }

  CharacterVector levels;
  SEXP* levels_ptr;

};

class DateSubsetVectorVisitor : public SubsetVectorVisitor {
public:

  DateSubsetVectorVisitor(SEXP data) : impl(0) {
    if (TYPEOF(data) == INTSXP) {
      impl  = new SubsetVectorVisitorImpl<INTSXP>(data);
    } else if (TYPEOF(data) == REALSXP) {
      impl = new SubsetVectorVisitorImpl<REALSXP>(data);
    } else {
      stop("Unreachable");
    }
  }

  ~DateSubsetVectorVisitor() {
    delete impl;
  }

  virtual SEXP subset(const Rcpp::IntegerVector& index) const {
    return impl->subset(index);
  }

  virtual SEXP subset(const SlicingIndex& index) const {
    return impl->subset(index);
  }

  virtual SEXP subset(const std::vector<int>& index) const {
    return impl->subset(index);
  }

  virtual SEXP subset(const ChunkIndexMap& index) const {
    return impl->subset(index);
  }

  virtual SEXP subset(EmptySubset index) const {
    return impl->subset(index);
  }

  virtual int size() const {
    return impl->size();
  }

  virtual std::string get_r_type() const {
    return impl->get_r_type();
  }

  bool is_compatible(SubsetVectorVisitor* other, std::stringstream&, const SymbolString&) const {
    return is_same_typeid(other);
  }

private:
  SubsetVectorVisitor* impl;
  DateSubsetVectorVisitor(const DateSubsetVectorVisitor&);

};

template <>
inline bool SubsetVectorVisitorImpl<INTSXP>::is_compatible(SubsetVectorVisitor* other, std::stringstream&,
    const SymbolString&) const {
  return is_same_typeid(other) || typeid(*other) == typeid(SubsetVectorVisitorImpl<REALSXP>);
}

template <>
inline bool SubsetVectorVisitorImpl<REALSXP>::is_compatible(SubsetVectorVisitor* other, std::stringstream&,
    const SymbolString&) const {
  return is_same_typeid(other) || typeid(*other) == typeid(SubsetVectorVisitorImpl<INTSXP>);
}

template <>
inline bool SubsetVectorVisitorImpl<STRSXP>::is_compatible(SubsetVectorVisitor* other, std::stringstream&,
    const SymbolString&) const {
  return is_same_typeid(other) || typeid(*other) == typeid(SubsetFactorVisitor);
}

}

#endif