@Override public void accept(List<String> keys, ReadOnlyStringVisitor visitor) { errorHandler.wrapVoidCall( delegate.accept_bulk( stringListTo2DByteArray(keys), new ReadOnlyStringVisitorAdapter(visitor, this), AccessType.READ_ONLY.value())); }
@Override public void accept(String key, WritableStringVisitor visitor) { errorHandler.wrapVoidCall( delegate.accept( stringToByteArray(key), new WritableStringVisitorAdapter(visitor, this), AccessType.READ_WRITE.value())); }
@Override public void accept(String key, ReadOnlyStringVisitor visitor) { errorHandler.wrapVoidCall( delegate.accept( stringToByteArray(key), new ReadOnlyStringVisitorAdapter(visitor, this), AccessType.READ_ONLY.value())); }
@Override public synchronized void close() throws IOException { if (!open) { throw new IOException("Connection already closed: " + this); } errorHandler.wrapVoidIoCall(delegate.close(), "Could not close db: " + descriptor); open = false; }
@Override public synchronized void open() throws IOException { if (open) { throw new IllegalStateException("Connection already open: " + this); } errorHandler.wrapVoidIoCall( delegate.open(descriptor, buildModeMask()), "Could not open database: " + descriptor); open = true; }
@Override public void mergeWith(MergeType mergeType, KyotoDb... dbs) { DB[] internal = new DB[dbs.length]; for (int index = 0; index < dbs.length; index++) { internal[index] = ((KyotoDbImpl) dbs[index]).getDelegate(); } errorHandler.wrapVoidCall( delegate.merge(internal, mergeType.value()), "Could not merge DBs: " + Arrays.toString(dbs)); }
@Override public void synchronize(Synchronization synchronization, KyotoFileProcessor fileProcessor) { FileProcessor adapted = null; if (fileProcessor != null) { adapted = new FileProcessorAdapter(fileProcessor); } errorHandler.wrapVoidCall( delegate.synchronize(synchronization.value(), adapted), "Could not " + synchronization + " synchronize DB " + descriptor + " with " + fileProcessor); }
@Override public void set(byte[] key, byte[] value) { errorHandler.wrapVoidCall(delegate.set(key, value)); }
@Override public long set(Map<String, String> keyValues, Atomicity atomicity) { return errorHandler.wrapLongCall(delegate.set_bulk(keyValues, atomicity.value()), -1); }
@Override public boolean replace(byte[] key, byte[] newValue) { return errorHandler.wrapBooleanCall(delegate.replace(key, newValue)); }
@Override public boolean replace(String key, String newValue) { return errorHandler.wrapBooleanCall(delegate.replace(key, newValue)); }
@Override public double increment(String key, double delta) { return errorHandler.wrapDoubleCall(delegate.increment_double(key, delta), Double.NaN); }
@Override public boolean remove(String key) { return errorHandler.wrapBooleanCall(delegate.remove(key)); }
@Override public Map<String, String> status() { return errorHandler.wrapObjectCall(delegate.status()); }
@Override public void iterate(ReadOnlyStringVisitor visitor) { errorHandler.wrapVoidCall( delegate.iterate( new ReadOnlyStringVisitorAdapter(visitor, this), AccessType.READ_ONLY.value())); }
@Override public List<String> matchKeysByRegex(String regex, long limit) { return errorHandler.wrapObjectCall(delegate.match_regex(regex, limit)); }
@Override public List<String> matchKeysByRegex(String regex) { return errorHandler.wrapObjectCall(delegate.match_regex(regex, NO_LIMIT)); }
@Override public List<String> matchKeysByPrefix(String prefix) { return errorHandler.wrapObjectCall(delegate.match_prefix(prefix, NO_LIMIT)); }
@Override public void loadSnapshotFrom(File source) throws IOException { errorHandler.wrapVoidIoCall( delegate.load_snapshot(source.getAbsolutePath()), "Could not load snapshot from: " + source.getAbsolutePath()); }
@Override public void iterate(WritableStringVisitor visitor) { errorHandler.wrapVoidCall( delegate.iterate( new WritableStringVisitorAdapter(visitor, this), AccessType.READ_WRITE.value())); }
@Override public void set(String key, String value) { errorHandler.wrapVoidCall(delegate.set(key, value)); }
@Override public void setEncoding(String encoding) { errorHandler.wrapVoidCall( delegate.tune_encoding(encoding), "Could not set encoding: " + encoding); this.encoding = encoding; }
@Override public long sizeInBytes() { return errorHandler.wrapLongCall(delegate.size(), -1); }
@Override public long increment(String key, long delta) { return errorHandler.wrapLongCall(delegate.increment(key, delta), Long.MIN_VALUE); }
@Override public Map<String, String> get(List<String> keys, Atomicity atomicity) { return errorHandler.wrapObjectCall(delegate.get_bulk(keys, atomicity.value())); }
@Override public byte[][] get(byte[][] keys, Atomicity atomicity) { return errorHandler.wrapObjectCall(delegate.get_bulk(keys, atomicity.value())); }
@Override public void accept(byte[][] keys, ReadOnlyVisitor visitor) { errorHandler.wrapVoidCall( delegate.accept_bulk( keys, new ReadOnlyVisitorAdapter(visitor), AccessType.READ_ONLY.value())); }
@Override public String get(String key) { return errorHandler.wrapObjectCall(delegate.get(key)); }
@Override public long remove(List<String> keys, Atomicity atomicity) { return errorHandler.wrapLongCall(delegate.remove_bulk(keys, atomicity.value()), -1); }
@Override public byte[] get(byte[] key) { return errorHandler.wrapObjectCall(delegate.get(key)); }