|
8 | 8 | import org.apache.arrow.vector.VectorSchemaRoot; |
9 | 9 |
|
10 | 10 | public interface Array extends AutoCloseable { |
| 11 | + /** |
| 12 | + * Returns the number of elements in this array. |
| 13 | + * |
| 14 | + * @return the length of the array |
| 15 | + */ |
11 | 16 | long getLen(); |
12 | 17 |
|
| 18 | + /** |
| 19 | + * Returns the total size in bytes of this array including all buffers. |
| 20 | + * |
| 21 | + * @return the size in bytes |
| 22 | + */ |
13 | 23 | long nbytes(); |
14 | 24 |
|
15 | 25 | /** |
16 | 26 | * Export to an ArrowVector. The data will now be owned by the VectorSchemaRoot after this operation. |
17 | 27 | */ |
18 | 28 | VectorSchemaRoot exportToArrow(BufferAllocator allocator, VectorSchemaRoot reuse); |
19 | 29 |
|
| 30 | + /** |
| 31 | + * Returns the data type of this array. |
| 32 | + * |
| 33 | + * @return the DType describing the logical type of this array |
| 34 | + */ |
20 | 35 | DType getDataType(); |
21 | 36 |
|
| 37 | + /** |
| 38 | + * Returns a child array at the given field index. |
| 39 | + * |
| 40 | + * <p>This is used for accessing fields in struct arrays or elements in list arrays.</p> |
| 41 | + * |
| 42 | + * @param index the field index |
| 43 | + * @return the child array at the specified index |
| 44 | + * @throws IndexOutOfBoundsException if index is out of bounds |
| 45 | + */ |
22 | 46 | Array getField(int index); |
23 | 47 |
|
| 48 | + /** |
| 49 | + * Returns a slice of this array from start (inclusive) to stop (exclusive). |
| 50 | + * |
| 51 | + * @param start the starting index (inclusive) |
| 52 | + * @param stop the ending index (exclusive) |
| 53 | + * @return a new Array containing the sliced elements |
| 54 | + * @throws IndexOutOfBoundsException if start or stop are out of bounds |
| 55 | + */ |
24 | 56 | Array slice(int start, int stop); |
25 | 57 |
|
| 58 | + /** |
| 59 | + * Returns true if the value at the given index is null. |
| 60 | + * |
| 61 | + * @param index the element index |
| 62 | + * @return true if the value is null, false otherwise |
| 63 | + * @throws IndexOutOfBoundsException if index is out of bounds |
| 64 | + */ |
26 | 65 | boolean getNull(int index); |
27 | 66 |
|
| 67 | + /** |
| 68 | + * Returns the total number of null values in this array. |
| 69 | + * |
| 70 | + * @return the null count |
| 71 | + */ |
28 | 72 | int getNullCount(); |
29 | 73 |
|
| 74 | + /** |
| 75 | + * Returns the byte value at the given index. |
| 76 | + * |
| 77 | + * @param index the element index |
| 78 | + * @return the byte value |
| 79 | + * @throws IndexOutOfBoundsException if index is out of bounds |
| 80 | + * @throws ClassCastException if the array type is not compatible with byte |
| 81 | + */ |
30 | 82 | byte getByte(int index); |
31 | 83 |
|
| 84 | + /** |
| 85 | + * Returns the short value at the given index. |
| 86 | + * |
| 87 | + * @param index the element index |
| 88 | + * @return the short value |
| 89 | + * @throws IndexOutOfBoundsException if index is out of bounds |
| 90 | + * @throws ClassCastException if the array type is not compatible with short |
| 91 | + */ |
32 | 92 | short getShort(int index); |
33 | 93 |
|
| 94 | + /** |
| 95 | + * Returns the int value at the given index. |
| 96 | + * |
| 97 | + * @param index the element index |
| 98 | + * @return the int value |
| 99 | + * @throws IndexOutOfBoundsException if index is out of bounds |
| 100 | + * @throws ClassCastException if the array type is not compatible with int |
| 101 | + */ |
34 | 102 | int getInt(int index); |
35 | 103 |
|
| 104 | + /** |
| 105 | + * Returns the long value at the given index. |
| 106 | + * |
| 107 | + * @param index the element index |
| 108 | + * @return the long value |
| 109 | + * @throws IndexOutOfBoundsException if index is out of bounds |
| 110 | + * @throws ClassCastException if the array type is not compatible with long |
| 111 | + */ |
36 | 112 | long getLong(int index); |
37 | 113 |
|
| 114 | + /** |
| 115 | + * Returns the boolean value at the given index. |
| 116 | + * |
| 117 | + * @param index the element index |
| 118 | + * @return the boolean value |
| 119 | + * @throws IndexOutOfBoundsException if index is out of bounds |
| 120 | + * @throws ClassCastException if the array type is not compatible with boolean |
| 121 | + */ |
38 | 122 | boolean getBool(int index); |
39 | 123 |
|
| 124 | + /** |
| 125 | + * Returns the float value at the given index. |
| 126 | + * |
| 127 | + * @param index the element index |
| 128 | + * @return the float value |
| 129 | + * @throws IndexOutOfBoundsException if index is out of bounds |
| 130 | + * @throws ClassCastException if the array type is not compatible with float |
| 131 | + */ |
40 | 132 | float getFloat(int index); |
41 | 133 |
|
| 134 | + /** |
| 135 | + * Returns the double value at the given index. |
| 136 | + * |
| 137 | + * @param index the element index |
| 138 | + * @return the double value |
| 139 | + * @throws IndexOutOfBoundsException if index is out of bounds |
| 140 | + * @throws ClassCastException if the array type is not compatible with double |
| 141 | + */ |
42 | 142 | double getDouble(int index); |
43 | 143 |
|
| 144 | + /** |
| 145 | + * Returns the BigDecimal value at the given index. |
| 146 | + * |
| 147 | + * @param index the element index |
| 148 | + * @return the BigDecimal value |
| 149 | + * @throws IndexOutOfBoundsException if index is out of bounds |
| 150 | + * @throws ClassCastException if the array type is not compatible with decimal |
| 151 | + */ |
44 | 152 | BigDecimal getBigDecimal(int index); |
45 | 153 |
|
| 154 | + /** |
| 155 | + * Returns the UTF-8 string value at the given index. |
| 156 | + * |
| 157 | + * @param index the element index |
| 158 | + * @return the string value |
| 159 | + * @throws IndexOutOfBoundsException if index is out of bounds |
| 160 | + * @throws ClassCastException if the array type is not compatible with string |
| 161 | + */ |
46 | 162 | String getUTF8(int index); |
47 | 163 |
|
| 164 | + /** |
| 165 | + * Returns the UTF-8 string value at the given index as a pointer and length. |
| 166 | + * |
| 167 | + * <p>This is a low-level method that provides direct access to the underlying |
| 168 | + * string data without copying. The pointer and length are written to the |
| 169 | + * provided arrays.</p> |
| 170 | + * |
| 171 | + * @param index the element index |
| 172 | + * @param ptr array to store the pointer (first element will be set) |
| 173 | + * @param len array to store the length (first element will be set) |
| 174 | + * @throws IndexOutOfBoundsException if index is out of bounds |
| 175 | + * @throws ClassCastException if the array type is not compatible with string |
| 176 | + */ |
48 | 177 | void getUTF8_ptr_len(int index, long[] ptr, int[] len); |
49 | 178 |
|
| 179 | + /** |
| 180 | + * Returns the binary value at the given index as a byte array. |
| 181 | + * |
| 182 | + * @param index the element index |
| 183 | + * @return the binary value as a byte array |
| 184 | + * @throws IndexOutOfBoundsException if index is out of bounds |
| 185 | + * @throws ClassCastException if the array type is not compatible with binary |
| 186 | + */ |
50 | 187 | byte[] getBinary(int index); |
51 | 188 |
|
52 | 189 | @Override |
|
0 commit comments