Skip to content

Commit

Permalink
Make sure MappedBytes is used everywhere instead of MappedFile
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-lawrey committed Jan 11, 2016
1 parent 7f98af6 commit 0f07212
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 64 deletions.
Expand Up @@ -177,10 +177,10 @@ public StoreAppender(@NotNull AbstractChronicleQueue queue) throws IOException {
this.store = queue.storeForCycle(this.cycle, this.epoc);
this.index = this.store.lastIndex();

final MappedBytes mappedFile = store.mappedBytes();
final MappedBytes mappedBytes = store.mappedBytes();
if (LOG.isDebugEnabled())
LOG.debug("appender file=" + mappedFile.file().getAbsolutePath());
this.writeContext = new MappedBytes(mappedFile);
LOG.debug("appender file=" + mappedBytes.mappedFile().file().getAbsolutePath());
this.writeContext = mappedBytes;
}

@Override
Expand Down
Expand Up @@ -203,7 +203,6 @@ protected WireStore newStore(final long cycle, final long epoc) {

final Wire wire = SingleChronicleQueue.this.builder.wireType().apply(bytes);


// final SingleChronicleQueueStore store = new SingleChronicleQueueStore();
final AtomicReference<SingleChronicleQueueStore> result = new AtomicReference<>();

Expand All @@ -214,10 +213,6 @@ protected WireStore newStore(final long cycle, final long epoc) {
}, null);

return result.get();

} catch (IOException e) {
Jvm.rethrow(e);
}
}

Consumer<WiredBytes<WireStore>> consumer = ws -> {
Expand Down
Expand Up @@ -57,9 +57,8 @@ public class SingleChronicleQueueStore implements WireStore {
Bounds bounds = new Bounds();
private MappedBytes mappedBytes;
private Closeable resourceCleaner;
private SingleChronicleQueueBuilder builder;
private long appendTimeout = 1_000;
private final ReferenceCounter refCount = ReferenceCounter.onReleased(this::performRelease);
private long appendTimeout = 1_000;
private SingleChronicleQueueBuilder builder;
private Indexing indexing;

Expand Down Expand Up @@ -909,64 +908,10 @@ private boolean linearScan(MappedBytes context, long toIndex, long fromKnownInde
}
}

public enum IndexOffset {
;

public static long toAddress0(long index) {

long siftedIndex = index >> (17L + 6L);
long mask = (1L << 17L) - 1L;
long maskedShiftedIndex = mask & siftedIndex;

// convert to an offset
return maskedShiftedIndex * 8L;
}

public static long toAddress1(long index) {

long siftedIndex = index >> (6L);
long mask = (1L << 17L) - 1L;
long maskedShiftedIndex = mask & siftedIndex;

// convert to an offset
return maskedShiftedIndex;// * 8L;
}

@NotNull
public static String toBinaryString(long i) {

StringBuilder sb = new StringBuilder();

for (int n = 63; n >= 0; n--)
sb.append(((i & (1L << n)) != 0 ? "1" : "0"));

return sb.toString();
}

@NotNull
public static String toScale() {

StringBuilder units = new StringBuilder();
StringBuilder tens = new StringBuilder();

for (int n = 64; n >= 1; n--)
units.append((0 == (n % 10)) ? "|" : n % 10);

for (int n = 64; n >= 1; n--)
tens.append((0 == (n % 10)) ? n / 10 : " ");

return units.toString() + "\n" + tens.toString();
}
}

// *************************************************************************
//
// *************************************************************************

enum RollFields implements WireKey {
cycle, length, format, timeZone, nextCycle, epoc, nextCycleMetaPosition, appendTimeout
}

class Roll implements Marshallable {
private long epoc;
private int length;
Expand Down

0 comments on commit 0f07212

Please sign in to comment.