]>
git.proxmox.com Git - ceph.git/blob - ceph/src/arrow/java/adapter/jdbc/src/main/java/org/apache/arrow/adapter/jdbc/consumer/BlobConsumer.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
.consumer
;
20 import java
.io
.IOException
;
22 import java
.sql
.ResultSet
;
23 import java
.sql
.SQLException
;
25 import org
.apache
.arrow
.vector
.VarBinaryVector
;
28 * Consumer which consume blob type values from {@link ResultSet}.
29 * Write the data to {@link VarBinaryVector}.
31 public class BlobConsumer
extends BaseConsumer
<VarBinaryVector
> {
33 private BinaryConsumer delegate
;
35 private final boolean nullable
;
38 * Creates a consumer for {@link VarBinaryVector}.
40 public static BlobConsumer
createConsumer(
41 BinaryConsumer delegate
, int index
, boolean nullable
) {
42 return new BlobConsumer(delegate
, index
, nullable
);
46 * Instantiate a BlobConsumer.
48 public BlobConsumer(BinaryConsumer delegate
, int index
, boolean nullable
) {
50 this.delegate
= delegate
;
51 this.nullable
= nullable
;
55 public void consume(ResultSet resultSet
) throws SQLException
, IOException
{
56 Blob blob
= resultSet
.getBlob(columnIndexInResultSet
);
58 delegate
.consume(blob
.getBinaryStream());
60 delegate
.moveWriterPosition();
64 public void close() throws Exception
{
69 public void resetValueVector(VarBinaryVector vector
) {
70 delegate
= BinaryConsumer
.createConsumer(vector
, columnIndexInResultSet
, nullable
);