package com.cube.storage;
import java.io.IOException;
import java.util.*;
/**
* Storage engine interface for Cube database.
* Pure Java implementation with no native dependencies.
*/
public interface StorageEngine {
void put(String key, byte[] value) throws IOException;
byte[] get(String key) throws IOException;
boolean delete(String key) throws IOException;
Iterator<String> scan(String prefix) throws IOException;
Iterator<Map.Entry<String, byte[]>> scanEntries(String prefix) throws IOException;
void flush() throws IOException;
void compact() throws IOException;
StorageStats getStats();
void close() throws IOException;
class StorageStats {
private final long totalKeys;
private final long totalSize;
private final long memtableSize;
private final long sstableCount;
public StorageStats(long totalKeys, long totalSize, long memtableSize, long sstableCount) {
this.totalKeys = totalKeys;
this.totalSize = totalSize;
this.memtableSize = memtableSize;
this.sstableCount = sstableCount;
}
public long getTotalKeys() { return totalKeys; }
public long getTotalSize() { return totalSize; }
public long getMemtableSize() { return memtableSize; }
public long getSstableCount() { return sstableCount; }
@Override
public String toString() {
return "StorageStats{" +
"keys=" + totalKeys +
", size=" + totalSize +
", memtable=" + memtableSize +
", sstables=" + sstableCount +
'}';
}
}
}