Retrieves the statistics key for the element/attribute name. @param ii index info @param type index type @return key, or null if statistics are not available
(final IndexInfo ii, final IndexType type)
| 257 | * @return key, or {@code null} if statistics are not available |
| 258 | */ |
| 259 | private Stats key(final IndexInfo ii, final IndexType type) { |
| 260 | // statistics are not up-to-date |
| 261 | final Data data = ii.db.data(); |
| 262 | if(data == null || !data.meta.uptodate || !data.nspaces.isEmpty() || |
| 263 | !(expr instanceof final AxisPath path)) return null; |
| 264 | |
| 265 | NameTest test = ii.test; |
| 266 | if(test == null) { |
| 267 | final Step step; |
| 268 | final int st = path.steps.length - 1; |
| 269 | if(type == IndexType.TEXT) { |
| 270 | step = st == 0 ? ii.step : path.step(st - 1); |
| 271 | } else { |
| 272 | step = path.step(st); |
| 273 | if(step.axis != Axis.ATTRIBUTE || step.exprs.length > 0) return null; |
| 274 | } |
| 275 | if(!(step.test instanceof final NameTest nt) || nt.name == null) return null; |
| 276 | test = nt; |
| 277 | } |
| 278 | |
| 279 | final Names names = type == IndexType.TEXT ? data.elemNames : data.attrNames; |
| 280 | final Stats stats = names.stats(names.index(test.qname.local())); |
| 281 | return stats != null && StatsType.isNumeric(stats.type) ? stats : null; |
| 282 | } |
| 283 | |
| 284 | @Override |
| 285 | public Expr copy(final CompileContext cc, final IntObjectMap<Var> vm) { |
no test coverage detected