MCPcopy Create free account
hub / github.com/crate/crate / ArrayBucket

Class ArrayBucket

libs/dex/src/main/java/io/crate/data/ArrayBucket.java:27–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25import java.util.Iterator;
26
27public class ArrayBucket implements Bucket {
28
29 private final Object[][] rows;
30 private final int numColumns;
31
32 /**
33 * Constructs a new ArrayBucket with rows of the given size, regardless of what length the row arrays is.
34 *
35 * @param rows the backing array of this bucket
36 * @param numColumns the size of rows emitted from this bucket
37 */
38 public ArrayBucket(Object[][] rows, int numColumns) {
39 this.rows = rows;
40 this.numColumns = numColumns;
41 }
42
43 public ArrayBucket(Object[][] rows) {
44 this.rows = rows;
45 if (rows.length > 0) {
46 numColumns = rows[0].length;
47 } else {
48 numColumns = -1;
49 }
50 }
51
52 @Override
53 public int size() {
54 return rows.length;
55 }
56
57 @Override
58 public Iterator<Row> iterator() {
59 return new Iterator<Row>() {
60 int pos = 0;
61 final RowN row = new RowN(numColumns);
62
63 @Override
64 public boolean hasNext() {
65 return pos < rows.length;
66 }
67
68 @Override
69 public Row next() {
70 row.cells(rows[pos++]);
71 return row;
72 }
73
74 @Override
75 public void remove() {
76
77 }
78 };
79 }
80
81 @Override
82 public String toString() {
83 return "ArrayBucket{numRows=" + rows.length + ", numColumns=" + numColumns + '}';
84 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected