Skip to content

Commit e6905ef

Browse files
lw-linjacques-n
authored andcommitted
ARROW-9: Replace straggler references to Drill
- Renaming drill to arrow for TestBaseAllocator - Fix ArrowBuffer as ArrowBuf - Replace Drill with Arrow for ValueHolder This closes #2.
1 parent e9cc8ce commit e6905ef

17 files changed

+198
-198
lines changed

java/memory/src/main/java/io/netty/buffer/ArrowBuf.java

+18-18
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public final class ArrowBuf extends AbstractByteBuf implements AutoCloseable {
5656
private final boolean isEmpty;
5757
private volatile int length;
5858
private final HistoricalLog historicalLog = BaseAllocator.DEBUG ?
59-
new HistoricalLog(BaseAllocator.DEBUG_LOG_LENGTH, "DrillBuf[%d]", id) : null;
59+
new HistoricalLog(BaseAllocator.DEBUG_LOG_LENGTH, "ArrowBuf[%d]", id) : null;
6060

6161
public ArrowBuf(
6262
final AtomicInteger refCnt,
@@ -155,18 +155,18 @@ private void ensure(int width) {
155155
}
156156

157157
/**
158-
* Create a new DrillBuf that is associated with an alternative allocator for the purposes of memory ownership and
159-
* accounting. This has no impact on the reference counting for the current DrillBuf except in the situation where the
158+
* Create a new ArrowBuf that is associated with an alternative allocator for the purposes of memory ownership and
159+
* accounting. This has no impact on the reference counting for the current ArrowBuf except in the situation where the
160160
* passed in Allocator is the same as the current buffer.
161161
*
162-
* This operation has no impact on the reference count of this DrillBuf. The newly created DrillBuf with either have a
162+
* This operation has no impact on the reference count of this ArrowBuf. The newly created ArrowBuf with either have a
163163
* reference count of 1 (in the case that this is the first time this memory is being associated with the new
164164
* allocator) or the current value of the reference count + 1 for the other AllocationManager/BufferLedger combination
165165
* in the case that the provided allocator already had an association to this underlying memory.
166166
*
167167
* @param target
168168
* The target allocator to create an association with.
169-
* @return A new DrillBuf which shares the same underlying memory as this DrillBuf.
169+
* @return A new ArrowBuf which shares the same underlying memory as this ArrowBuf.
170170
*/
171171
public ArrowBuf retain(BufferAllocator target) {
172172

@@ -178,17 +178,17 @@ public ArrowBuf retain(BufferAllocator target) {
178178
historicalLog.recordEvent("retain(%s)", target.getName());
179179
}
180180
final BufferLedger otherLedger = this.ledger.getLedgerForAllocator(target);
181-
return otherLedger.newDrillBuf(offset, length, null);
181+
return otherLedger.newArrowBuf(offset, length, null);
182182
}
183183

184184
/**
185-
* Transfer the memory accounting ownership of this DrillBuf to another allocator. This will generate a new DrillBuf
186-
* that carries an association with the underlying memory of this DrillBuf. If this DrillBuf is connected to the
185+
* Transfer the memory accounting ownership of this ArrowBuf to another allocator. This will generate a new ArrowBuf
186+
* that carries an association with the underlying memory of this ArrowBuf. If this ArrowBuf is connected to the
187187
* owning BufferLedger of this memory, that memory ownership/accounting will be transferred to the taret allocator. If
188-
* this DrillBuf does not currently own the memory underlying it (and is only associated with it), this does not
189-
* transfer any ownership to the newly created DrillBuf.
188+
* this ArrowBuf does not currently own the memory underlying it (and is only associated with it), this does not
189+
* transfer any ownership to the newly created ArrowBuf.
190190
*
191-
* This operation has no impact on the reference count of this DrillBuf. The newly created DrillBuf with either have a
191+
* This operation has no impact on the reference count of this ArrowBuf. The newly created ArrowBuf with either have a
192192
* reference count of 1 (in the case that this is the first time this memory is being associated with the new
193193
* allocator) or the current value of the reference count for the other AllocationManager/BufferLedger combination in
194194
* the case that the provided allocator already had an association to this underlying memory.
@@ -203,7 +203,7 @@ public ArrowBuf retain(BufferAllocator target) {
203203
* @param target
204204
* The allocator to transfer ownership to.
205205
* @return A new transfer result with the impact of the transfer (whether it was overlimit) as well as the newly
206-
* created DrillBuf.
206+
* created ArrowBuf.
207207
*/
208208
public TransferResult transferOwnership(BufferAllocator target) {
209209

@@ -212,7 +212,7 @@ public TransferResult transferOwnership(BufferAllocator target) {
212212
}
213213

214214
final BufferLedger otherLedger = this.ledger.getLedgerForAllocator(target);
215-
final ArrowBuf newBuf = otherLedger.newDrillBuf(offset, length, null);
215+
final ArrowBuf newBuf = otherLedger.newArrowBuf(offset, length, null);
216216
final boolean allocationFit = this.ledger.transferBalance(otherLedger);
217217
return new TransferResult(allocationFit, newBuf);
218218
}
@@ -267,7 +267,7 @@ public boolean release(int decrement) {
267267

268268
if (refCnt < 0) {
269269
throw new IllegalStateException(
270-
String.format("DrillBuf[%d] refCnt has gone negative. Buffer Info: %s", id, toVerboseString()));
270+
String.format("ArrowBuf[%d] refCnt has gone negative. Buffer Info: %s", id, toVerboseString()));
271271
}
272272

273273
return refCnt == 0;
@@ -370,7 +370,7 @@ public ArrowBuf slice(int index, int length) {
370370
* Re the behavior of reference counting, see http://netty.io/wiki/reference-counted-objects.html#wiki-h3-5, which
371371
* explains that derived buffers share their reference count with their parent
372372
*/
373-
final ArrowBuf newBuf = ledger.newDrillBuf(offset + index, length);
373+
final ArrowBuf newBuf = ledger.newArrowBuf(offset + index, length);
374374
newBuf.writerIndex(length);
375375
return newBuf;
376376
}
@@ -437,7 +437,7 @@ public long memoryAddress() {
437437

438438
@Override
439439
public String toString() {
440-
return String.format("DrillBuf[%d], udle: [%d %d..%d]", id, udle.id, offset, offset + capacity());
440+
return String.format("ArrowBuf[%d], udle: [%d %d..%d]", id, udle.id, offset, offset + capacity());
441441
}
442442

443443
@Override
@@ -782,7 +782,7 @@ public void close() {
782782
}
783783

784784
/**
785-
* Returns the possible memory consumed by this DrillBuf in the worse case scenario. (not shared, connected to larger
785+
* Returns the possible memory consumed by this ArrowBuf in the worse case scenario. (not shared, connected to larger
786786
* underlying buffer of allocated memory)
787787
*
788788
* @return Size in bytes.
@@ -833,7 +833,7 @@ public String toHexString(final int start, final int length) {
833833
}
834834

835835
/**
836-
* Get the integer id assigned to this DrillBuf for debugging purposes.
836+
* Get the integer id assigned to this ArrowBuf for debugging purposes.
837837
*
838838
* @return integer id
839839
*/

java/memory/src/main/java/io/netty/buffer/ExpandableByteBuf.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import org.apache.arrow.memory.BufferAllocator;
2121

2222
/**
23-
* Allows us to decorate DrillBuf to make it expandable so that we can use them in the context of the Netty framework
23+
* Allows us to decorate ArrowBuf to make it expandable so that we can use them in the context of the Netty framework
2424
* (thus supporting RPC level memory accounting).
2525
*/
2626
public class ExpandableByteBuf extends MutableWrappedByteBuf {

java/memory/src/main/java/io/netty/buffer/PooledByteBufAllocatorL.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
import com.codahale.metrics.MetricRegistry;
3333

3434
/**
35-
* The base allocator that we use for all of Drill's memory management. Returns UnsafeDirectLittleEndian buffers.
35+
* The base allocator that we use for all of Arrow's memory management. Returns UnsafeDirectLittleEndian buffers.
3636
*/
3737
public class PooledByteBufAllocatorL {
3838
private static final org.slf4j.Logger memoryLogger = org.slf4j.LoggerFactory.getLogger("drill.allocator");
@@ -184,7 +184,7 @@ private UnsafeDirectLittleEndian newDirectBufferL(int initialCapacity, int maxCa
184184

185185
private UnsupportedOperationException fail() {
186186
return new UnsupportedOperationException(
187-
"Drill requries that the JVM used supports access sun.misc.Unsafe. This platform didn't provide that functionality.");
187+
"Arrow requries that the JVM used supports access sun.misc.Unsafe. This platform didn't provide that functionality.");
188188
}
189189

190190
public UnsafeDirectLittleEndian directBuffer(int initialCapacity, int maxCapacity) {
@@ -197,7 +197,7 @@ public UnsafeDirectLittleEndian directBuffer(int initialCapacity, int maxCapacit
197197

198198
@Override
199199
public ByteBuf heapBuffer(int initialCapacity, int maxCapacity) {
200-
throw new UnsupportedOperationException("Drill doesn't support using heap buffers.");
200+
throw new UnsupportedOperationException("Arrow doesn't support using heap buffers.");
201201
}
202202

203203

java/memory/src/main/java/io/netty/buffer/UnsafeDirectLittleEndian.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import java.util.concurrent.atomic.AtomicLong;
2525

2626
/**
27-
* The underlying class we use for little-endian access to memory. Is used underneath DrillBufs to abstract away the
27+
* The underlying class we use for little-endian access to memory. Is used underneath ArrowBufs to abstract away the
2828
* Netty classes and underlying Netty memory management.
2929
*/
3030
public final class UnsafeDirectLittleEndian extends WrappedByteBuf {
@@ -55,7 +55,7 @@ public final class UnsafeDirectLittleEndian extends WrappedByteBuf {
5555
private UnsafeDirectLittleEndian(AbstractByteBuf buf, boolean fake, AtomicLong bufferCount, AtomicLong bufferSize) {
5656
super(buf);
5757
if (!NATIVE_ORDER || buf.order() != ByteOrder.BIG_ENDIAN) {
58-
throw new IllegalStateException("Drill only runs on LittleEndian systems.");
58+
throw new IllegalStateException("Arrow only runs on LittleEndian systems.");
5959
}
6060

6161
this.bufferCount = bufferCount;

java/memory/src/main/java/org/apache/arrow/memory/AllocationManager.java

+17-17
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
* This class is also responsible for managing when memory is allocated and returned to the Netty-based
4242
* PooledByteBufAllocatorL.
4343
*
44-
* The only reason that this isn't package private is we're forced to put DrillBuf in Netty's package which need access
44+
* The only reason that this isn't package private is we're forced to put ArrowBuf in Netty's package which need access
4545
* to these objects or methods.
4646
*
4747
* Threading: AllocationManager manages thread-safety internally. Operations within the context of a single BufferLedger
@@ -185,8 +185,8 @@ public void release() {
185185

186186
/**
187187
* The reference manager that binds an allocator manager to a particular BaseAllocator. Also responsible for creating
188-
* a set of DrillBufs that share a common fate and set of reference counts.
189-
* As with AllocationManager, the only reason this is public is due to DrillBuf being in io.netty.buffer package.
188+
* a set of ArrowBufs that share a common fate and set of reference counts.
189+
* As with AllocationManager, the only reason this is public is due to ArrowBuf being in io.netty.buffer package.
190190
*/
191191
public class BufferLedger {
192192

@@ -322,7 +322,7 @@ public int decrement(int decrement) {
322322
/**
323323
* Returns the ledger associated with a particular BufferAllocator. If the BufferAllocator doesn't currently have a
324324
* ledger associated with this AllocationManager, a new one is created. This is placed on BufferLedger rather than
325-
* AllocationManager directly because DrillBufs don't have access to AllocationManager and they are the ones
325+
* AllocationManager directly because ArrowBufs don't have access to AllocationManager and they are the ones
326326
* responsible for exposing the ability to associate multiple allocators with a particular piece of underlying
327327
* memory. Note that this will increment the reference count of this ledger by one to ensure the ledger isn't
328328
* destroyed before use.
@@ -335,32 +335,32 @@ public BufferLedger getLedgerForAllocator(BufferAllocator allocator) {
335335
}
336336

337337
/**
338-
* Create a new DrillBuf associated with this AllocationManager and memory. Does not impact reference count.
338+
* Create a new ArrowBuf associated with this AllocationManager and memory. Does not impact reference count.
339339
* Typically used for slicing.
340340
* @param offset
341-
* The offset in bytes to start this new DrillBuf.
341+
* The offset in bytes to start this new ArrowBuf.
342342
* @param length
343-
* The length in bytes that this DrillBuf will provide access to.
344-
* @return A new DrillBuf that shares references with all DrillBufs associated with this BufferLedger
343+
* The length in bytes that this ArrowBuf will provide access to.
344+
* @return A new ArrowBuf that shares references with all ArrowBufs associated with this BufferLedger
345345
*/
346-
public ArrowBuf newDrillBuf(int offset, int length) {
346+
public ArrowBuf newArrowBuf(int offset, int length) {
347347
allocator.assertOpen();
348-
return newDrillBuf(offset, length, null);
348+
return newArrowBuf(offset, length, null);
349349
}
350350

351351
/**
352-
* Create a new DrillBuf associated with this AllocationManager and memory.
352+
* Create a new ArrowBuf associated with this AllocationManager and memory.
353353
* @param offset
354-
* The offset in bytes to start this new DrillBuf.
354+
* The offset in bytes to start this new ArrowBuf.
355355
* @param length
356-
* The length in bytes that this DrillBuf will provide access to.
356+
* The length in bytes that this ArrowBuf will provide access to.
357357
* @param manager
358-
* An optional BufferManager argument that can be used to manage expansion of this DrillBuf
358+
* An optional BufferManager argument that can be used to manage expansion of this ArrowBuf
359359
* @param retain
360360
* Whether or not the newly created buffer should get an additional reference count added to it.
361-
* @return A new DrillBuf that shares references with all DrillBufs associated with this BufferLedger
361+
* @return A new ArrowBuf that shares references with all ArrowBufs associated with this BufferLedger
362362
*/
363-
public ArrowBuf newDrillBuf(int offset, int length, BufferManager manager) {
363+
public ArrowBuf newArrowBuf(int offset, int length, BufferManager manager) {
364364
allocator.assertOpen();
365365

366366
final ArrowBuf buf = new ArrowBuf(
@@ -375,7 +375,7 @@ public ArrowBuf newDrillBuf(int offset, int length, BufferManager manager) {
375375

376376
if (BaseAllocator.DEBUG) {
377377
historicalLog.recordEvent(
378-
"DrillBuf(BufferLedger, BufferAllocator[%s], UnsafeDirectLittleEndian[identityHashCode == "
378+
"ArrowBuf(BufferLedger, BufferAllocator[%s], UnsafeDirectLittleEndian[identityHashCode == "
379379
+ "%d](%s)) => ledger hc == %d",
380380
allocator.name, System.identityHashCode(buf), buf.toString(),
381381
System.identityHashCode(this));

java/memory/src/main/java/org/apache/arrow/memory/DrillByteBufAllocator.java java/memory/src/main/java/org/apache/arrow/memory/ArrowByteBufAllocator.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,19 @@
2323
import io.netty.buffer.ExpandableByteBuf;
2424

2525
/**
26-
* An implementation of ByteBufAllocator that wraps a Drill BufferAllocator. This allows the RPC layer to be accounted
27-
* and managed using Drill's BufferAllocator infrastructure. The only thin different from a typical BufferAllocator is
26+
* An implementation of ByteBufAllocator that wraps a Arrow BufferAllocator. This allows the RPC layer to be accounted
27+
* and managed using Arrow's BufferAllocator infrastructure. The only thin different from a typical BufferAllocator is
2828
* the signature and the fact that this Allocator returns ExpandableByteBufs which enable otherwise non-expandable
29-
* DrillBufs to be expandable.
29+
* ArrowBufs to be expandable.
3030
*/
31-
public class DrillByteBufAllocator implements ByteBufAllocator {
31+
public class ArrowByteBufAllocator implements ByteBufAllocator {
3232

3333
private static final int DEFAULT_BUFFER_SIZE = 4096;
3434
private static final int DEFAULT_MAX_COMPOSITE_COMPONENTS = 16;
3535

3636
private final BufferAllocator allocator;
3737

38-
public DrillByteBufAllocator(BufferAllocator allocator) {
38+
public ArrowByteBufAllocator(BufferAllocator allocator) {
3939
this.allocator = allocator;
4040
}
4141

java/memory/src/main/java/org/apache/arrow/memory/BaseAllocator.java

+11-11
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ protected BaseAllocator(
8282
this.parentAllocator = parentAllocator;
8383
this.name = name;
8484

85-
this.thisAsByteBufAllocator = new DrillByteBufAllocator(this);
85+
this.thisAsByteBufAllocator = new ArrowByteBufAllocator(this);
8686

8787
if (DEBUG) {
8888
childAllocators = new IdentityHashMap<>();
@@ -236,7 +236,7 @@ private ArrowBuf bufferWithoutReservation(final int size, BufferManager bufferMa
236236

237237
final AllocationManager manager = new AllocationManager(this, size);
238238
final BufferLedger ledger = manager.associate(this); // +1 ref cnt (required)
239-
final ArrowBuf buffer = ledger.newDrillBuf(0, size, bufferManager);
239+
final ArrowBuf buffer = ledger.newArrowBuf(0, size, bufferManager);
240240

241241
// make sure that our allocation is equal to what we expected.
242242
Preconditions.checkArgument(buffer.capacity() == size,
@@ -314,9 +314,9 @@ public ArrowBuf allocateBuffer() {
314314
Preconditions.checkState(!closed, "Attempt to allocate after closed");
315315
Preconditions.checkState(!used, "Attempt to allocate more than once");
316316

317-
final ArrowBuf drillBuf = allocate(nBytes);
317+
final ArrowBuf arrowBuf = allocate(nBytes);
318318
used = true;
319-
return drillBuf;
319+
return arrowBuf;
320320
}
321321

322322
public int getSize() {
@@ -397,13 +397,13 @@ private ArrowBuf allocate(int nBytes) {
397397
* as well, so we need to return the same number back to avoid double-counting them.
398398
*/
399399
try {
400-
final ArrowBuf drillBuf = BaseAllocator.this.bufferWithoutReservation(nBytes, null);
400+
final ArrowBuf arrowBuf = BaseAllocator.this.bufferWithoutReservation(nBytes, null);
401401

402402
if (DEBUG) {
403-
historicalLog.recordEvent("allocate() => %s", String.format("DrillBuf[%d]", drillBuf.getId()));
403+
historicalLog.recordEvent("allocate() => %s", String.format("ArrowBuf[%d]", arrowBuf.getId()));
404404
}
405405
success = true;
406-
return drillBuf;
406+
return arrowBuf;
407407
} finally {
408408
if (!success) {
409409
releaseBytes(nBytes);
@@ -565,7 +565,7 @@ void verifyAllocator() {
565565
* Verifies the accounting state of the allocator. Only works for DEBUG.
566566
*
567567
* <p>
568-
* This overload is used for recursive calls, allowing for checking that DrillBufs are unique across all allocators
568+
* This overload is used for recursive calls, allowing for checking that ArrowBufs are unique across all allocators
569569
* that are checked.
570570
* </p>
571571
*
@@ -594,7 +594,7 @@ private void verifyAllocator(final IdentityHashMap<UnsafeDirectLittleEndian, Bas
594594
* Verify my relationships with my descendants.
595595
*
596596
* The sum of direct child allocators' owned memory must be <= my allocated memory; my allocated memory also
597-
* includes DrillBuf's directly allocated by me.
597+
* includes ArrowBuf's directly allocated by me.
598598
*/
599599
long childTotal = 0;
600600
for (final BaseAllocator childAllocator : childSet) {
@@ -623,11 +623,11 @@ private void verifyAllocator(final IdentityHashMap<UnsafeDirectLittleEndian, Bas
623623

624624
final UnsafeDirectLittleEndian udle = ledger.getUnderlying();
625625
/*
626-
* Even when shared, DrillBufs are rewrapped, so we should never see the same instance twice.
626+
* Even when shared, ArrowBufs are rewrapped, so we should never see the same instance twice.
627627
*/
628628
final BaseAllocator otherOwner = buffersSeen.get(udle);
629629
if (otherOwner != null) {
630-
throw new IllegalStateException("This allocator's drillBuf already owned by another allocator");
630+
throw new IllegalStateException("This allocator's ArrowBuf already owned by another allocator");
631631
}
632632
buffersSeen.put(udle, this);
633633

java/memory/src/main/java/org/apache/arrow/memory/BufferAllocator.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public interface BufferAllocator extends AutoCloseable {
3030
*
3131
* @param size
3232
* The size in bytes.
33-
* @return a new DrillBuf, or null if the request can't be satisfied
33+
* @return a new ArrowBuf, or null if the request can't be satisfied
3434
* @throws OutOfMemoryException
3535
* if buffer cannot be allocated
3636
*/
@@ -44,7 +44,7 @@ public interface BufferAllocator extends AutoCloseable {
4444
* The size in bytes.
4545
* @param manager
4646
* A buffer manager to manage reallocation.
47-
* @return a new DrillBuf, or null if the request can't be satisfied
47+
* @return a new ArrowBuf, or null if the request can't be satisfied
4848
* @throws OutOfMemoryException
4949
* if buffer cannot be allocated
5050
*/

0 commit comments

Comments
 (0)