Arrays
import org.apache.spark.sql.functions;
List<String> ficheros = new ArrayList<>();
int limit = 100; // Máximo de elementos
Dataset<Row> filenamesWithIndex = filenames
.withColumn("index", functions.monotonically_increasing_id());
for (int i = 0; i < limit; i++) {
String[] row = (String[]) filenamesWithIndex
.filter(functions.col("index").equalTo(i)) // Filtra por índice
.select("value") // Asume que la columna se llama "value" en Dataset<String>
.head();
if (row.length > 0) {
ficheros.add(row[0]);
} else {
break; // No hay más datos
}
}




