Skip to content

Commit d8ec3be

Browse files
author
Lee Rhodes
committed
Removed trailing blanks.
1 parent 01d0046 commit d8ec3be

59 files changed

Lines changed: 1661 additions & 1661 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

memory/src/main/java/com/yahoo/memory/AllocMemory.java

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@
88
import static com.yahoo.memory.UnsafeUtil.unsafe;
99

1010
/**
11-
* The AllocMemory class is a subclass of NativeMemory and is used to allocate direct, off-heap
12-
* native memory, which is then accessed by the NativeMemory methods.
13-
* It is the responsibility of the calling class to free this memory using freeMemory() when done.
14-
*
15-
* <p>The task of direct allocation was moved to this sub-class for performance reasons.
11+
* The AllocMemory class is a subclass of NativeMemory and is used to allocate direct, off-heap
12+
* native memory, which is then accessed by the NativeMemory methods.
13+
* It is the responsibility of the calling class to free this memory using freeMemory() when done.
14+
*
15+
* <p>The task of direct allocation was moved to this sub-class for performance reasons.
1616
*
1717
* @author Lee Rhodes
1818
*/
1919
//@SuppressWarnings("restriction")
2020
public class AllocMemory extends MemoryMappedFile {
21-
21+
2222
/**
23-
* Constructor for allocate native memory.
24-
*
25-
* <p>Allocates and provides access to capacityBytes directly in native (off-heap) memory
23+
* Constructor for allocate native memory.
24+
*
25+
* <p>Allocates and provides access to capacityBytes directly in native (off-heap) memory
2626
* leveraging the Memory interface. The MemoryRequest callback is set to null.
2727
* @param capacityBytes the size in bytes of the native memory
2828
*/
@@ -32,12 +32,12 @@ public AllocMemory(long capacityBytes) {
3232
super.capacityBytes_ = capacityBytes;
3333
super.memReq_ = null;
3434
}
35-
35+
3636
/**
3737
* Constructor for allocate native memory with MemoryRequest.
38-
*
38+
*
3939
* <p>Allocates and provides access to capacityBytes directly in native (off-heap) memory leveraging
40-
* the Memory interface.
40+
* the Memory interface.
4141
* @param capacityBytes the size in bytes of the native memory
4242
* @param memReq The MemoryRequest callback
4343
*/
@@ -47,49 +47,49 @@ public AllocMemory(long capacityBytes, MemoryRequest memReq) {
4747
super.capacityBytes_ = capacityBytes;
4848
super.memReq_ = memReq;
4949
}
50-
50+
5151
/**
5252
* Constructor for reallocate native memory.
53-
*
54-
* <p>Reallocates the given off-heap NativeMemory to a new a new native (off-heap) memory
55-
* location and copies the contents of the original given NativeMemory to the new location.
56-
* Any memory beyond the capacity of the original given NativeMemory will be uninitialized.
57-
* Dispose of this new memory by calling {@link NativeMemory#freeMemory()}.
58-
* @param origMem The original NativeMemory that needs to be reallocated and must not be null.
59-
* The OS is free to just expand the capacity of the current allocation at the same native
60-
* address, or reassign a completely different native address in which case the origMem will be
61-
* freed by the OS.
53+
*
54+
* <p>Reallocates the given off-heap NativeMemory to a new a new native (off-heap) memory
55+
* location and copies the contents of the original given NativeMemory to the new location.
56+
* Any memory beyond the capacity of the original given NativeMemory will be uninitialized.
57+
* Dispose of this new memory by calling {@link NativeMemory#freeMemory()}.
58+
* @param origMem The original NativeMemory that needs to be reallocated and must not be null.
59+
* The OS is free to just expand the capacity of the current allocation at the same native
60+
* address, or reassign a completely different native address in which case the origMem will be
61+
* freed by the OS.
6262
* The origMem capacity will be set to zero and must not be used again.
63-
*
63+
*
6464
* @param newCapacityBytes the desired new capacity of the newly allocated memory in bytes
6565
* @param memReq The MemoryRequest callback, which may be null.
6666
*/
6767
public AllocMemory(NativeMemory origMem, long newCapacityBytes, MemoryRequest memReq) {
6868
super(0L, null, null);
69-
super.nativeRawStartAddress_ = unsafe.reallocateMemory(origMem.nativeRawStartAddress_,
69+
super.nativeRawStartAddress_ = unsafe.reallocateMemory(origMem.nativeRawStartAddress_,
7070
newCapacityBytes);
7171
super.capacityBytes_ = newCapacityBytes;
7272
this.memReq_ = memReq;
7373
origMem.nativeRawStartAddress_ = 0; //does not require freeMem
7474
origMem.capacityBytes_ = 0; //Cannot be used again
7575
}
76-
76+
7777
/**
7878
* Constructor for allocate native memory, copy and clear.
79-
*
80-
* <p>Allocate a new native (off-heap) memory with capacityBytes; copy the contents of origMem
79+
*
80+
* <p>Allocate a new native (off-heap) memory with capacityBytes; copy the contents of origMem
8181
* from zero to copyToBytes; clear the new memory from copyToBytes to capacityBytes.
82-
* @param origMem The original NativeMemory, a portion of which will be copied to the
83-
* newly allocated Memory.
82+
* @param origMem The original NativeMemory, a portion of which will be copied to the
83+
* newly allocated Memory.
8484
* The reference must not be null.
8585
* This origMem is not modified in any way, may be reused and must be freed appropriately.
86-
* @param copyToBytes the upper limit of the region to be copied from origMem to the newly
87-
* allocated memory.
88-
* @param capacityBytes the desired new capacity of the newly allocated memory in bytes and the
89-
* upper limit of the region to be cleared.
86+
* @param copyToBytes the upper limit of the region to be copied from origMem to the newly
87+
* allocated memory.
88+
* @param capacityBytes the desired new capacity of the newly allocated memory in bytes and the
89+
* upper limit of the region to be cleared.
9090
* @param memReq The MemoryRequest callback, which may be null.
9191
*/
92-
public AllocMemory(NativeMemory origMem, long copyToBytes, long capacityBytes,
92+
public AllocMemory(NativeMemory origMem, long copyToBytes, long capacityBytes,
9393
MemoryRequest memReq) {
9494
super(0L, null, null);
9595
super.nativeRawStartAddress_ = unsafe.allocateMemory(capacityBytes);
@@ -98,10 +98,10 @@ public AllocMemory(NativeMemory origMem, long copyToBytes, long capacityBytes,
9898
NativeMemory.copy(origMem, 0, this, 0, copyToBytes);
9999
this.clear(copyToBytes, capacityBytes - copyToBytes);
100100
}
101-
101+
102102
@Override
103103
public void freeMemory() {
104104
super.freeMemory();
105105
}
106-
106+
107107
}

memory/src/main/java/com/yahoo/memory/Memory.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ public interface Memory {
9696
*/
9797
long getAndSetLong(long offsetBytes, long newValue);
9898

99-
10099
/**
101100
* Gets the boolean value at the given offset
102101
* @param offsetBytes offset bytes relative to this Memory start
@@ -131,7 +130,6 @@ public interface Memory {
131130
*/
132131
void getByteArray(long offsetBytes, byte[] dstArray, int dstOffset, int length);
133132

134-
135133
/**
136134
* Gets the char at the given offset
137135
* @param offsetBytes offset bytes relative to this Memory start

memory/src/main/java/com/yahoo/memory/MemoryRegion.java

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -27,41 +27,41 @@
2727
import java.nio.ByteBuffer;
2828

2929
/**
30-
* The MemoryRegion class implements the Memory interface and provides a means of
31-
* hierarchically partitioning a large block of native memory into
32-
* smaller regions of memory, each with their own capacity and offsets.
33-
*
34-
* <p>If asserts are enabled in the JVM, the methods in this class perform bounds checking against
30+
* The MemoryRegion class implements the Memory interface and provides a means of
31+
* hierarchically partitioning a large block of native memory into
32+
* smaller regions of memory, each with their own capacity and offsets.
33+
*
34+
* <p>If asserts are enabled in the JVM, the methods in this class perform bounds checking against
3535
* the region's defined boundaries and then redirect the call to the parent Memory class. If the
36-
* parent class is also a MemoryRegion it does a similar check and then calls its parent.
36+
* parent class is also a MemoryRegion it does a similar check and then calls its parent.
3737
* The root of this hierarchy will be a NativeMemory class that ultimately performs the desired
38-
* task. If asserts are not enabled the JIT compiler will eliminate all the asserts and the
39-
* hierarchical calls should collapse to a call to the NativeMemory method.</p>
40-
*
41-
* <p>Because asserts must be specifically enabled in the JVM, it is incumbent on the user of this
42-
* class to make sure that their code is thoroughly tested.
38+
* task. If asserts are not enabled the JIT compiler will eliminate all the asserts and the
39+
* hierarchical calls should collapse to a call to the NativeMemory method.</p>
40+
*
41+
* <p>Because asserts must be specifically enabled in the JVM, it is incumbent on the user of this
42+
* class to make sure that their code is thoroughly tested.
4343
* Violating memory bounds can cause memory segment faults, which takes
4444
* down the JVM and can be very difficult to debug.</p>
45-
*
45+
*
4646
* @see NativeMemory
4747
* @author Lee Rhodes
4848
*/
4949
public class MemoryRegion implements Memory {
5050
/**
5151
* The parent Memory object from which an offset and capacity is defined by this class.
52-
* This field is used to keep a reference to the parent Memory to
52+
* This field is used to keep a reference to the parent Memory to
5353
* ensure that its memory isn't freed before we are done with it.
5454
*/
5555
private final Memory mem_;
5656
private volatile long memOffsetBytes_;
5757
private volatile long capacityBytes_;
5858
private volatile MemoryRequest memReq_ = null;
59-
59+
6060
/**
61-
* Defines a region of the given parent Memory by defining an offset and capacity that are
61+
* Defines a region of the given parent Memory by defining an offset and capacity that are
6262
* within the boundaries of the parent.
6363
* @param memory the parent Memory
64-
* @param memOffsetBytes the starting offset in bytes of this region with respect to the
64+
* @param memOffsetBytes the starting offset in bytes of this region with respect to the
6565
* start of the parent memory.
6666
* @param capacityBytes the capacity in bytes of this region.
6767
*/
@@ -71,12 +71,12 @@ public MemoryRegion(Memory memory, long memOffsetBytes, long capacityBytes) {
7171
memOffsetBytes_ = memOffsetBytes;
7272
capacityBytes_ = capacityBytes;
7373
}
74-
74+
7575
/**
76-
* Defines a region of the given parent Memory by defining an offset and capacity that are
76+
* Defines a region of the given parent Memory by defining an offset and capacity that are
7777
* within the boundaries of the parent.
7878
* @param memory the parent Memory
79-
* @param memOffsetBytes the starting offset in bytes of this region with respect to the
79+
* @param memOffsetBytes the starting offset in bytes of this region with respect to the
8080
* start of the parent memory.
8181
* @param capacityBytes the capacity in bytes of this region.
8282
* @param memReq a MemoryRequest object
@@ -88,7 +88,7 @@ public MemoryRegion(Memory memory, long memOffsetBytes, long capacityBytes, Memo
8888
capacityBytes_ = capacityBytes;
8989
memReq_ = memReq;
9090
}
91-
91+
9292
/**
9393
* Reassign the offset and capacity of this MemoryRegion
9494
* @param memOffsetBytes the given offset from the parent's start
@@ -99,7 +99,7 @@ public void reassign(long memOffsetBytes, long capacityBytes) {
9999
memOffsetBytes_ = memOffsetBytes;
100100
capacityBytes_ = capacityBytes;
101101
}
102-
102+
103103
@Override
104104
public void clear() {
105105
fill(0, capacityBytes_, (byte) 0);
@@ -124,7 +124,7 @@ public void copy(long srcOffsetBytes, long dstOffsetBytes, long lengthBytes) {
124124
long max = Math.max(srcOffsetBytes, dstOffsetBytes);
125125
assertBounds(min, lengthBytes, max); //regions must not overlap
126126
long srcAdd = getAddress(srcOffsetBytes);
127-
long dstAdd = getAddress(dstOffsetBytes);
127+
long dstAdd = getAddress(dstOffsetBytes);
128128
mem_.copy(srcAdd, dstAdd, lengthBytes);
129129
}
130130

@@ -138,7 +138,7 @@ public void fill(long offsetBytes, long lengthBytes, byte value) {
138138
assertBounds(offsetBytes, lengthBytes, capacityBytes_);
139139
mem_.fill(getAddress(offsetBytes), lengthBytes, value);
140140
}
141-
141+
142142
@Override
143143
public int getAndAddInt(long offsetBytes, int delta) {
144144
assertBounds(offsetBytes, ARRAY_INT_INDEX_SCALE, capacityBytes_);
@@ -278,7 +278,7 @@ public void getShortArray(long offsetBytes, short[] dstArray, int dstOffset, int
278278
@Override
279279
public boolean isAllBitsClear(long offsetBytes, byte bitMask) {
280280
assertBounds(offsetBytes, ARRAY_BYTE_INDEX_SCALE, capacityBytes_);
281-
int value = ~mem_.getByte(getAddress(offsetBytes)) & bitMask & 0XFF;
281+
int value = ~mem_.getByte(getAddress(offsetBytes)) & bitMask & 0XFF;
282282
return value == bitMask;
283283
}
284284

@@ -292,7 +292,7 @@ public boolean isAllBitsSet(long offsetBytes, byte bitMask) {
292292
@Override
293293
public boolean isAnyBitsClear(long offsetBytes, byte bitMask) {
294294
assertBounds(offsetBytes, ARRAY_BYTE_INDEX_SCALE, capacityBytes_);
295-
int value = ~mem_.getByte(getAddress(offsetBytes)) & bitMask & 0XFF;
295+
int value = ~mem_.getByte(getAddress(offsetBytes)) & bitMask & 0XFF;
296296
return value != 0;
297297
}
298298

@@ -429,18 +429,18 @@ public void setBits(long offsetBytes, byte bitMask) {
429429
public Object array() {
430430
return mem_.array();
431431
}
432-
432+
433433
@Override
434434
public Memory asReadOnlyMemory() {
435435
Memory readOnlyMem = mem_.asReadOnlyMemory();
436436
return new MemoryRegionR(readOnlyMem, memOffsetBytes_, capacityBytes_, memReq_);
437437
}
438-
438+
439439
@Override
440440
public ByteBuffer byteBuffer() {
441441
return mem_.byteBuffer();
442442
}
443-
443+
444444
/**
445445
* Returns the start address of this Memory relative to its parent plus the given offsetBytes.
446446
* @param offsetBytes the given offset in bytes from the start address of this Memory
@@ -461,47 +461,47 @@ public long getCapacity() {
461461
public long getCumulativeOffset(final long offsetBytes) {
462462
return mem_.getCumulativeOffset(0L) + getAddress(offsetBytes);
463463
}
464-
464+
465465
@Override
466466
public MemoryRequest getMemoryRequest() {
467467
return memReq_;
468468
}
469-
469+
470470
@Override
471471
public NativeMemory getNativeMemory() {
472472
return mem_.getNativeMemory();
473473
}
474-
474+
475475
@Override
476476
public Object getParent() {
477477
return mem_;
478478
}
479-
479+
480480
@Override
481481
public boolean hasArray() {
482482
return mem_.hasArray();
483483
}
484-
484+
485485
@Override
486486
public boolean hasByteBuffer() {
487487
return mem_.hasByteBuffer();
488488
}
489-
489+
490490
@Override
491491
public boolean isAllocated() {
492492
return (capacityBytes_ > 0L);
493493
}
494-
494+
495495
@Override
496496
public boolean isDirect() {
497497
return mem_.isDirect();
498498
}
499-
499+
500500
@Override
501501
public boolean isReadOnly() {
502502
return false;
503503
}
504-
504+
505505
@Override
506506
public void setMemoryRequest(MemoryRequest memReq) {
507507
memReq_ = memReq;

0 commit comments

Comments
 (0)