]> git.proxmox.com Git - ceph.git/blob - ceph/src/arrow/java/vector/src/main/java/org/apache/arrow/vector/ZeroVector.java
import quincy 17.2.0
[ceph.git] / ceph / src / arrow / java / vector / src / main / java / org / apache / arrow / vector / ZeroVector.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.vector;
19
20 import org.apache.arrow.memory.BufferAllocator;
21 import org.apache.arrow.memory.util.ArrowBufPointer;
22 import org.apache.arrow.memory.util.hash.ArrowBufHasher;
23 import org.apache.arrow.vector.types.pojo.Field;
24 import org.apache.arrow.vector.types.pojo.FieldType;
25 import org.apache.arrow.vector.util.CallBack;
26 import org.apache.arrow.vector.util.TransferPair;
27
28 /**
29 * A zero length vector of any type.
30 */
31 public final class ZeroVector extends NullVector {
32 public static final ZeroVector INSTANCE = new ZeroVector();
33
34 /**
35 * Instantiate a ZeroVector.
36 *
37 * @param name name of the vector
38 */
39 public ZeroVector(String name) {
40 super(name);
41 }
42
43 /**
44 * Instantiate a ZeroVector.
45 *
46 * @param name name of the vector
47 * @param fieldType type of Field materialized by this vector.
48 */
49 public ZeroVector(String name, FieldType fieldType) {
50 super(name, fieldType);
51 }
52
53 /**
54 * Instantiate a ZeroVector.
55 *
56 * @param field field materialized by this vector.
57 */
58 public ZeroVector(Field field) {
59 super(field);
60 }
61
62 @Deprecated
63 public ZeroVector() {
64 }
65
66 @Override
67 public int getValueCount() {
68 return 0;
69 }
70
71 @Override
72 public void setValueCount(int valueCount) {
73 }
74
75 @Override
76 public int getNullCount() {
77 return 0;
78 }
79
80 @Override
81 public boolean isNull(int index) {
82 throw new IndexOutOfBoundsException();
83 }
84
85 @Override
86 public int hashCode(int index) {
87 return 0;
88 }
89
90 @Override
91 public int hashCode(int index, ArrowBufHasher hasher) {
92 return ArrowBufPointer.NULL_HASH_CODE;
93 }
94
95 @Override
96 public int getValueCapacity() {
97 return 0;
98 }
99
100 @Override
101 public TransferPair getTransferPair(BufferAllocator allocator) {
102 return defaultPair;
103 }
104
105 @Override
106 public TransferPair getTransferPair(String ref, BufferAllocator allocator) {
107 return defaultPair;
108 }
109
110 @Override
111 public TransferPair getTransferPair(String ref, BufferAllocator allocator, CallBack callBack) {
112 return defaultPair;
113 }
114
115 @Override
116 public TransferPair makeTransferPair(ValueVector target) {
117 return defaultPair;
118 }
119
120 private final TransferPair defaultPair = new TransferPair() {
121 @Override
122 public void transfer() {
123 }
124
125 @Override
126 public void splitAndTransfer(int startIndex, int length) {
127 }
128
129 @Override
130 public ValueVector getTo() {
131 return ZeroVector.this;
132 }
133
134 @Override
135 public void copyValueSafe(int from, int to) {
136 }
137 };
138 }