net.openhft.chronicle.bytes.NoBytesStore Maven / Gradle / Ivy
/*
* Copyright 2016 higherfrequencytrading.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.openhft.chronicle.bytes;
import net.openhft.chronicle.core.OS;
import org.jetbrains.annotations.NotNull;
import java.nio.BufferOverflowException;
import java.nio.ByteBuffer;
public enum NoBytesStore implements BytesStore {
NO_BYTES_STORE;
public static final long NO_PAGE;
public static final Bytes NO_BYTES;
static {
try {
NO_PAGE = OS.memory().allocate(OS.pageSize());
NO_BYTES = new VanillaBytes(noBytesStore());
} catch (IllegalArgumentException | IllegalStateException e) {
throw new AssertionError(e);
}
}
@NotNull
public static > BytesStore noBytesStore() {
return NO_BYTES_STORE;
}
@Override
public void reserve() throws IllegalStateException {
}
@Override
public void release() throws IllegalStateException {
}
@Override
public long refCount() {
return 0L;
}
@NotNull
@Override
public RandomDataOutput writeByte(long offset, byte i8) {
throw new UnsupportedOperationException();
}
@NotNull
@Override
public RandomDataOutput writeShort(long offset, short i) {
throw new UnsupportedOperationException();
}
@NotNull
@Override
public RandomDataOutput writeInt(long offset, int i) {
throw new UnsupportedOperationException();
}
@NotNull
@Override
public RandomDataOutput writeOrderedInt(long offset, int i) {
throw new UnsupportedOperationException();
}
@NotNull
@Override
public RandomDataOutput writeLong(long offset, long i) {
throw new UnsupportedOperationException();
}
@NotNull
@Override
public RandomDataOutput writeOrderedLong(long offset, long i) {
throw new UnsupportedOperationException();
}
@NotNull
@Override
public RandomDataOutput writeFloat(long offset, float d) {
throw new UnsupportedOperationException();
}
@NotNull
@Override
public RandomDataOutput writeDouble(long offset, double d) {
throw new UnsupportedOperationException();
}
@Override
public RandomDataOutput writeVolatileByte(long offset, byte i8) {
throw new UnsupportedOperationException();
}
@Override
public RandomDataOutput writeVolatileShort(long offset, short i16) {
throw new UnsupportedOperationException();
}
@Override
public RandomDataOutput writeVolatileInt(long offset, int i32) {
throw new UnsupportedOperationException();
}
@Override
public RandomDataOutput writeVolatileLong(long offset, long i64) {
throw new UnsupportedOperationException();
}
@NotNull
@Override
public RandomDataOutput write(long offsetInRDO, byte[] bytes, int offset, int length) {
throw new UnsupportedOperationException();
}
@Override
public void write(long offsetInRDO, ByteBuffer bytes, int offset, int length) {
throw new UnsupportedOperationException();
}
@NotNull
@Override
public RandomDataOutput write(long offsetInRDO, RandomDataInput bytes, long offset, long length) {
throw new UnsupportedOperationException();
}
@Override
public byte readByte(long offset) {
throw new UnsupportedOperationException();
}
@Override
public short readShort(long offset) {
throw new UnsupportedOperationException();
}
@Override
public int readInt(long offset) {
throw new UnsupportedOperationException();
}
@Override
public long readLong(long offset) {
throw new UnsupportedOperationException();
}
@Override
public float readFloat(long offset) {
throw new UnsupportedOperationException();
}
@Override
public double readDouble(long offset) {
throw new UnsupportedOperationException();
}
@NotNull
@Override
public BytesStore copy() {
return this;
}
@Override
public long capacity() {
return 0;
}
@Override
public Void underlyingObject() {
return null;
}
@Override
public boolean inside(long offset) {
return false;
}
@Override
public long copyTo(BytesStore store) {
// nothing to copy.
return 0L;
}
@Override
public void nativeWrite(long address, long position, long size) {
throw new UnsupportedOperationException();
}
@Override
public void nativeRead(long position, long address, long size) {
throw new UnsupportedOperationException();
}
@Override
public boolean compareAndSwapInt(long offset, int expected, int value) {
throw new UnsupportedOperationException();
}
@Override
public boolean compareAndSwapLong(long offset, long expected, long value) {
throw new UnsupportedOperationException();
}
@Override
public boolean equalBytes(BytesStore bytesStore, long length) {
return length == 0;
}
@Override
public void move(long from, long to, long length) {
throw new UnsupportedOperationException();
}
@Override
public long address(long offset) throws BufferOverflowException {
if (offset != 0)
throw new BufferOverflowException();
return NO_PAGE;
}
@NotNull
@Override
public Bytes bytesForWrite() {
throw new UnsupportedOperationException("todo");
}
@Override
public boolean sharedMemory() {
return false;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy