]> git.proxmox.com Git - ceph.git/blob - ceph/src/arrow/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/Table.java
import quincy 17.2.0
[ceph.git] / ceph / src / arrow / java / adapter / jdbc / src / test / java / org / apache / arrow / adapter / jdbc / Table.java
1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 package org.apache.arrow.adapter.jdbc;
19
20 import java.math.BigDecimal;
21 import java.nio.charset.StandardCharsets;
22
23 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
24
25 /**
26 * POJO to handle the YAML data from the test YAML file.
27 */
28 @JsonIgnoreProperties(ignoreUnknown = true)
29 public class Table {
30 private String name;
31 private String type;
32 private String vector;
33 private String timezone;
34 private String create;
35 private String[] data;
36 private String query;
37 private String drop;
38 private String[] values;
39 private String[] vectors;
40 private int rowCount;
41
42 public Table() {
43 }
44
45 public String getName() {
46 return name;
47 }
48
49 public void setName(String name) {
50 this.name = name;
51 }
52
53 public String getType() {
54 return type;
55 }
56
57 public void setType(String type) {
58 this.type = type;
59 }
60
61 public String getVector() {
62 return vector;
63 }
64
65 public void setVector(String vector) {
66 this.vector = vector;
67 }
68
69 public String[] getValues() {
70 return values;
71 }
72
73 public void setValues(String[] values) {
74 this.values = values;
75 }
76
77 public Long[] getLongValues() {
78 Long[] arr = new Long[values.length];
79 int i = 0;
80 for (String str : values) {
81 arr[i++] = Long.parseLong(str);
82 }
83 return arr;
84 }
85
86 public Integer[] getIntValues() {
87 Integer[] arr = new Integer[values.length];
88 int i = 0;
89 for (String str : values) {
90 arr[i++] = Integer.parseInt(str);
91 }
92 return arr;
93 }
94
95 public Boolean[] getBoolValues() {
96 Boolean[] arr = new Boolean[values.length];
97 int i = 0;
98 for (String str : values) {
99 arr[i++] = Boolean.parseBoolean(str);
100 }
101 return arr;
102 }
103
104 public BigDecimal[] getBigDecimalValues() {
105 BigDecimal[] arr = new BigDecimal[values.length];
106 int i = 0;
107 for (String str : values) {
108 arr[i++] = new BigDecimal(str);
109 }
110 return arr;
111 }
112
113 public Double[] getDoubleValues() {
114 Double[] arr = new Double[values.length];
115 int i = 0;
116 for (String str : values) {
117 arr[i++] = Double.parseDouble(str);
118 }
119 return arr;
120 }
121
122 public Float[] getFloatValues() {
123 Float[] arr = new Float[values.length];
124 int i = 0;
125 for (String str : values) {
126 arr[i++] = Float.parseFloat(str);
127 }
128 return arr;
129 }
130
131 public byte[][] getBinaryValues() {
132 return getHexToByteArray(values);
133 }
134
135 public byte[][] getVarCharValues() {
136 return getByteArray(values);
137 }
138
139 public byte[][] getBlobValues() {
140 return getBinaryValues();
141 }
142
143 public byte[][] getClobValues() {
144 return getByteArray(values);
145 }
146
147 public byte[][] getCharValues() {
148 return getByteArray(values);
149 }
150
151 public String getCreate() {
152 return create;
153 }
154
155 public void setCreate(String create) {
156 this.create = create;
157 }
158
159 public String[] getData() {
160 return data;
161 }
162
163 public void setData(String[] data) {
164 this.data = data;
165 }
166
167 public String getQuery() {
168 return query;
169 }
170
171 public void setQuery(String query) {
172 this.query = query;
173 }
174
175 public String getDrop() {
176 return drop;
177 }
178
179 public void setDrop(String drop) {
180 this.drop = drop;
181 }
182
183 public String getTimezone() {
184 return timezone;
185 }
186
187 public void setTimezone(String timezone) {
188 this.timezone = timezone;
189 }
190
191 public String[] getVectors() {
192 return vectors;
193 }
194
195 public void setVectors(String[] vectors) {
196 this.vectors = vectors;
197 }
198
199 public int getRowCount() {
200 return rowCount;
201 }
202
203 public void setRowCount(int rowCount) {
204 this.rowCount = rowCount;
205 }
206
207 static byte[][] getByteArray(String[] data) {
208 byte[][] byteArr = new byte[data.length][];
209
210 for (int i = 0; i < data.length; i++) {
211 byteArr[i] = data[i].getBytes(StandardCharsets.UTF_8);
212 }
213 return byteArr;
214 }
215
216 static byte[][] getHexToByteArray(String[] data) {
217 byte[][] byteArr = new byte[data.length][];
218
219 for (int i = 0; i < data.length; i++) {
220 byteArr[i] = hexStringToByteArray(data[i]);
221 }
222 return byteArr;
223 }
224
225 static byte[] hexStringToByteArray(String s) {
226 int len = s.length();
227 byte[] data = new byte[len / 2];
228 for (int i = 0; i < len; i += 2) {
229 data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4) +
230 Character.digit(s.charAt(i + 1), 16));
231 }
232 return data;
233 }
234 }