]>
git.proxmox.com Git - ceph.git/blob - ceph/src/arrow/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/Table.java
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 package org
.apache
.arrow
.adapter
.jdbc
;
20 import java
.math
.BigDecimal
;
21 import java
.nio
.charset
.StandardCharsets
;
23 import com
.fasterxml
.jackson
.annotation
.JsonIgnoreProperties
;
26 * POJO to handle the YAML data from the test YAML file.
28 @JsonIgnoreProperties(ignoreUnknown
= true)
32 private String vector
;
33 private String timezone
;
34 private String create
;
35 private String
[] data
;
38 private String
[] values
;
39 private String
[] vectors
;
45 public String
getName() {
49 public void setName(String name
) {
53 public String
getType() {
57 public void setType(String type
) {
61 public String
getVector() {
65 public void setVector(String vector
) {
69 public String
[] getValues() {
73 public void setValues(String
[] values
) {
77 public Long
[] getLongValues() {
78 Long
[] arr
= new Long
[values
.length
];
80 for (String str
: values
) {
81 arr
[i
++] = Long
.parseLong(str
);
86 public Integer
[] getIntValues() {
87 Integer
[] arr
= new Integer
[values
.length
];
89 for (String str
: values
) {
90 arr
[i
++] = Integer
.parseInt(str
);
95 public Boolean
[] getBoolValues() {
96 Boolean
[] arr
= new Boolean
[values
.length
];
98 for (String str
: values
) {
99 arr
[i
++] = Boolean
.parseBoolean(str
);
104 public BigDecimal
[] getBigDecimalValues() {
105 BigDecimal
[] arr
= new BigDecimal
[values
.length
];
107 for (String str
: values
) {
108 arr
[i
++] = new BigDecimal(str
);
113 public Double
[] getDoubleValues() {
114 Double
[] arr
= new Double
[values
.length
];
116 for (String str
: values
) {
117 arr
[i
++] = Double
.parseDouble(str
);
122 public Float
[] getFloatValues() {
123 Float
[] arr
= new Float
[values
.length
];
125 for (String str
: values
) {
126 arr
[i
++] = Float
.parseFloat(str
);
131 public byte[][] getBinaryValues() {
132 return getHexToByteArray(values
);
135 public byte[][] getVarCharValues() {
136 return getByteArray(values
);
139 public byte[][] getBlobValues() {
140 return getBinaryValues();
143 public byte[][] getClobValues() {
144 return getByteArray(values
);
147 public byte[][] getCharValues() {
148 return getByteArray(values
);
151 public String
getCreate() {
155 public void setCreate(String create
) {
156 this.create
= create
;
159 public String
[] getData() {
163 public void setData(String
[] data
) {
167 public String
getQuery() {
171 public void setQuery(String query
) {
175 public String
getDrop() {
179 public void setDrop(String drop
) {
183 public String
getTimezone() {
187 public void setTimezone(String timezone
) {
188 this.timezone
= timezone
;
191 public String
[] getVectors() {
195 public void setVectors(String
[] vectors
) {
196 this.vectors
= vectors
;
199 public int getRowCount() {
203 public void setRowCount(int rowCount
) {
204 this.rowCount
= rowCount
;
207 static byte[][] getByteArray(String
[] data
) {
208 byte[][] byteArr
= new byte[data
.length
][];
210 for (int i
= 0; i
< data
.length
; i
++) {
211 byteArr
[i
] = data
[i
].getBytes(StandardCharsets
.UTF_8
);
216 static byte[][] getHexToByteArray(String
[] data
) {
217 byte[][] byteArr
= new byte[data
.length
][];
219 for (int i
= 0; i
< data
.length
; i
++) {
220 byteArr
[i
] = hexStringToByteArray(data
[i
]);
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));