Skip to content
This repository has been archived by the owner on Mar 3, 2024. It is now read-only.

Commit

Permalink
[add-timestamp] add timestamp instead of sequence (UpsertRemoveTest f…
Browse files Browse the repository at this point in the history
…ailed)
  • Loading branch information
ImLena committed Feb 29, 2024
1 parent 3e61170 commit 848f15d
Show file tree
Hide file tree
Showing 15 changed files with 1,396 additions and 559 deletions.
48 changes: 48 additions & 0 deletions src/main/java/ru/vk/itmo/khodosovaelena/ByteArraySegment.java
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 src/main/java/ru/vk/itmo/khodosovaelena/DiskStorage.java

This file was deleted.

Loading

0 comments on commit 848f15d

Please # to comment.