|
10 | 10 | import org.apache.arrow.c.ArrowArray; |
11 | 11 | import org.apache.arrow.c.ArrowSchema; |
12 | 12 | import org.apache.arrow.c.Data; |
| 13 | +import org.apache.logging.log4j.LogManager; |
| 14 | +import org.apache.logging.log4j.Logger; |
13 | 15 |
|
14 | 16 | import java.util.concurrent.atomic.AtomicReference; |
15 | 17 | import java.util.concurrent.locks.ReadWriteLock; |
|
23 | 25 | */ |
24 | 26 | public class ManagedVSR implements AutoCloseable { |
25 | 27 |
|
| 28 | + private static final Logger logger = LogManager.getLogger(ManagedVSR.class); |
| 29 | + |
26 | 30 | private final String id; |
27 | 31 | private final VectorSchemaRoot vsr; |
28 | 32 | private final BufferAllocator allocator; |
@@ -109,9 +113,7 @@ public FieldVector getVector(String fieldName) { |
109 | 113 | public void setState(VSRState newState) { |
110 | 114 | VSRState oldState = state.getAndSet(newState); |
111 | 115 |
|
112 | | - System.out.println(String.format( |
113 | | - "[VSR] State transition: %s -> %s for VSR %s", |
114 | | - oldState, newState, id)); |
| 116 | + logger.debug("State transition: {} -> {} for VSR {}", oldState, newState, id); |
115 | 117 | } |
116 | 118 |
|
117 | 119 | /** |
@@ -226,34 +228,4 @@ public String toString() { |
226 | 228 | return String.format("ManagedVSR{id='%s', state=%s, rows=%d, immutable=%s}", |
227 | 229 | id, state.get(), getRowCount(), isImmutable()); |
228 | 230 | } |
229 | | - |
230 | | - public static void main(String[] args) { |
231 | | - RootAllocator allocator = new RootAllocator(); |
232 | | - BigIntVector vector = new BigIntVector("vector", allocator); |
233 | | - vector.allocateNew(10); |
234 | | - vector.set(0, 100); // Set position 0 |
235 | | -// vector.setNull(1); |
236 | | - vector.set(2, 300); // Set position 2 |
237 | | -// Position 1 is not set! |
238 | | - vector.setValueCount(3); // Claims vector has 3 elements |
239 | | - |
240 | | -// Position 1 now contains undefined data |
241 | | -// long value = vector.get(1); // Could be any value! |
242 | | - System.out.println(readBit(vector.getValidityBuffer(), 0)); |
243 | | - System.out.println(readBit(vector.getValidityBuffer(), 1)); |
244 | | - System.out.println(readBit(vector.getValidityBuffer(), 2)); |
245 | | - System.out.println(readBit(vector.getValidityBuffer(), 3)); |
246 | | - } |
247 | | - |
248 | | - public static byte readBit(ArrowBuf validityBuffer, long index) { |
249 | | - // it can be observed that some logic is duplicate of the logic in setValidityBit. |
250 | | - // this is because JIT cannot always remove the if branch in setValidityBit, |
251 | | - // so we give a dedicated implementation for setting bits. |
252 | | - final long byteIndex = byteIndex(index); |
253 | | - |
254 | | - // the byte is promoted to an int, because according to Java specification, |
255 | | - // bytes will be promoted to ints automatically, upon expression evaluation. |
256 | | - // by promoting it manually, we avoid the unnecessary conversions. |
257 | | - return validityBuffer.getByte(byteIndex); |
258 | | - } |
259 | 231 | } |
0 commit comments