| is.sorted {ff} | R Documentation |
Functions to mark an ff or ram object as 'is.sorted' and query this. Responsibility to maintain this attribute is with the user.
is.sorted(x) is.sorted(x) <- value
x |
an ff or ram object |
value |
NULL (to remove the 'is.sorted' attribute) or TRUE or FALSE |
Sorting is slow, see sort.
Checking whether an object is sorted can avoid unnessary sorting – see is.unsorted, intisasc – but still takes too much time with large objects stored on disk.
Thus it makes sense to maintain an attribute, that tells us whether sorting can be skipped.
Note that – though you change it yourself – is.sorted is a physical attribute of an object,
because it represents an attribute of the data, which is shared between different virtual views of the object.
TRUE (if set to TRUE) or FALSE (if set to NULL or FALSE)
ff will set is.sorted(x) <- FALSE if clone or length<-.ff have increased length.
Jens Oehlschlägel
is.ordered.ff for testing factor levels, is.unsorted for testing the data, intisasc for a quick version thereof, na.count for yet another physical attribute
x <- 1:12
is.sorted(x) <- !( is.na(is.unsorted(x)) || is.unsorted(x)) # actually calling is.unsorted twice is stupid
is.sorted(x)
x[1] <- 100L
cat("don't forget to maintain once it's no longer TRUE")
is.sorted(x) <- FALSE
cat("check whether as 'is.sorted' attribute is maintained\n")
!is.null(physical(x)$is.sorted)
cat("remove the 'is.sorted' attribute\n")
is.sorted(x) <- NULL
cat("NOTE that querying 'is.sorted' still returns FALSE\n")
is.sorted(x)