Returns true if all data within this array is ASCII
(&self)
| 1142 | |
| 1143 | /// Returns true if all data within this array is ASCII |
| 1144 | pub fn is_ascii(&self) -> bool { |
| 1145 | // Alternative (but incorrect): directly check the underlying buffers |
| 1146 | // (1) Our string view might be sparse, i.e., a subset of the buffers, |
| 1147 | // so even if the buffer is not ascii, we can still be ascii. |
| 1148 | // (2) It is quite difficult to know the range of each buffer (unlike StringArray) |
| 1149 | // This means that this operation is quite expensive, shall we cache the result? |
| 1150 | // i.e. track `is_ascii` in the builder. |
| 1151 | self.iter().all(|v| match v { |
| 1152 | Some(v) => v.is_ascii(), |
| 1153 | None => true, |
| 1154 | }) |
| 1155 | } |
| 1156 | } |
| 1157 | |
| 1158 | impl From<Vec<&str>> for StringViewArray { |