is.sorted: Getting and setting 'is.sorted' physical attribute

Description Usage Arguments Details Value Note Author(s) See Also Examples

Description

Functions to mark an ff or ram object as 'is.sorted' and query this. Responsibility to maintain this attribute is with the user.

Usage

1
2
3
4
## Default S3 method:
is.sorted(x, ...)
## Default S3 replacement method:
is.sorted(x, ...) <- value

Arguments

x

an ff or ram object

...

ignored

value

NULL (to remove the 'is.sorted' attribute) or TRUE or FALSE

Details

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.

Value

TRUE (if set to TRUE) or FALSE (if set to NULL or FALSE)

Note

ff will set is.sorted(x) <- FALSE if clone or length<-.ff have increased length.

Author(s)

Jens Oehlschl<c3><a4>gel

See Also

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
  x <- 1:12
  is.sorted(x) <- !( is.na(is.unsorted(x)) || is.unsorted(x))
  is.sorted(x)
  x[1] <- 100L
  message("don't forget to maintain once it's no longer TRUE")
  is.sorted(x) <- FALSE
  message("check whether as 'is.sorted' attribute is maintained")
  !is.null(physical(x)$is.sorted)
  message("remove the 'is.sorted' attribute")
  is.sorted(x) <- NULL
  message("NOTE that querying 'is.sorted' still returns FALSE")
  is.sorted(x)

kindlychung/ff documentation built on May 20, 2019, 9:58 a.m.