This repository has been archived by the owner on Mar 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[add-timestamp] add timestamp instead of sequence (UpsertRemoveTest f…
…ailed)
- Loading branch information
Showing
15 changed files
with
1,396 additions
and
559 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
src/main/java/ru/vk/itmo/khodosovaelena/ByteArraySegment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package ru.vk.itmo.khodosovaelena; | ||
|
||
import java.io.IOException; | ||
import java.lang.foreign.MemorySegment; | ||
import java.nio.ByteBuffer; | ||
|
||
/** | ||
* Growable buffer with {@link ByteBuffer} and {@link MemorySegment} interface. | ||
* | ||
* @author incubos | ||
*/ | ||
final class ByteArraySegment { | ||
private byte[] array; | ||
private MemorySegment segment; | ||
|
||
ByteArraySegment(final int capacity) { | ||
this.array = new byte[capacity]; | ||
this.segment = MemorySegment.ofArray(array); | ||
} | ||
|
||
void withArray(final ArrayConsumer consumer) throws IOException { | ||
consumer.process(array); | ||
} | ||
|
||
MemorySegment segment() { | ||
return segment; | ||
} | ||
|
||
void ensureCapacity(final long size) { | ||
if (size > Integer.MAX_VALUE) { | ||
throw new IllegalArgumentException("Too big!"); | ||
} | ||
|
||
final int capacity = (int) size; | ||
if (array.length >= capacity) { | ||
return; | ||
} | ||
|
||
// Grow to the nearest bigger power of 2 | ||
final int newSize = Integer.highestOneBit(capacity) << 1; | ||
array = new byte[newSize]; | ||
segment = MemorySegment.ofArray(array); | ||
} | ||
|
||
interface ArrayConsumer { | ||
void process(byte[] array) throws IOException; | ||
} | ||
} |
303 changes: 0 additions & 303 deletions
303
src/main/java/ru/vk/itmo/khodosovaelena/DiskStorage.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.