<commit_before>package org.genericsystem.distributed.cacheonclient;

import io.vertx.core.buffer.Buffer;

import java.util.Arrays;

import org.genericsystem.api.core.exceptions.ConcurrencyControlException;
import org.genericsystem.api.core.exceptions.OptimisticLockConstraintViolationException;
import org.genericsystem.common.Vertex;
import org.genericsystem.distributed.AbstractGSClient;
import org.genericsystem.distributed.GSBuffer;

public abstract class AbstractGSHeavyClient extends AbstractGSClient implements ClientCacheProtocole {

	@Override
	public Vertex getVertex(long id) {
		return synchronizeTask(task -> send(Buffer.buffer().appendInt(GET_VERTEX).appendLong(id), buff -> task.handle(new GSBuffer(buff).getGSVertex())));
	}

	@Override
	public Vertex[] getDependencies(long ts, long id) {
		return synchronizeTask(task -> send(Buffer.buffer().appendInt(GET_DEPENDENCIES).appendLong(ts).appendLong(id), buff -> {
			task.handle(new GSBuffer(buff).getGSVertexArray());
		}));

	}

	@Override
	public void apply(long ts, long[] removes, Vertex[] adds) throws ConcurrencyControlException, OptimisticLockConstraintViolationException {
		if (!Arrays.stream(adds).allMatch(v -> (v.getBirthTs() == Long.MAX_VALUE)))
			throw new IllegalStateException("");
		GSBuffer gsBuffer = new GSBuffer();
		gsBuffer.appendInt(APPLY);
		gsBuffer.appendLong(ts);
		gsBuffer.appendGSLongArray(removes);
		gsBuffer.appendGSVertexArray(adds);
		Object res = synchronizeTask(task -> send(gsBuffer, buff -> task.handle(new GSBuffer(buff).getLongThrowException())));
		// so as to be sent up
		if (res instanceof OptimisticLockConstraintViolationException) {
			throw (OptimisticLockConstraintViolationException) res;
		}
		if (res instanceof ConcurrencyControlException) {
			throw (ConcurrencyControlException) res;
		}<commit_msg>definitive impl of throw in AbstractGSHeavyClient::apply() <commit_after>package org.genericsystem.distributed.cacheonclient;

import io.vertx.core.buffer.Buffer;

import java.util.Arrays;

import org.genericsystem.api.core.exceptions.ConcurrencyControlException;
import org.genericsystem.api.core.exceptions.OptimisticLockConstraintViolationException;
import org.genericsystem.common.Vertex;
import org.genericsystem.distributed.AbstractGSClient;
import org.genericsystem.distributed.GSBuffer;

public abstract class AbstractGSHeavyClient extends AbstractGSClient implements ClientCacheProtocole {

	@Override
	public Vertex getVertex(long id) {
		return synchronizeTask(task -> send(Buffer.buffer().appendInt(GET_VERTEX).appendLong(id), buff -> task.handle(new GSBuffer(buff).getGSVertex())));
	}

	@Override
	public Vertex[] getDependencies(long ts, long id) {
		return synchronizeTask(task -> send(Buffer.buffer().appendInt(GET_DEPENDENCIES).appendLong(ts).appendLong(id), buff -> {
			task.handle(new GSBuffer(buff).getGSVertexArray());
		}));

	}

	@Override
	public void apply(long ts, long[] removes, Vertex[] adds) throws ConcurrencyControlException, OptimisticLockConstraintViolationException {
		if (!Arrays.stream(adds).allMatch(v -> (v.getBirthTs() == Long.MAX_VALUE)))
			throw new IllegalStateException("");
		GSBuffer gsBuffer = new GSBuffer();
		gsBuffer.appendInt(APPLY);
		gsBuffer.appendLong(ts);
		gsBuffer.appendGSLongArray(removes);
		gsBuffer.appendGSVertexArray(adds);
		Object res = synchronizeTask(task -> send(gsBuffer, buff -> task.handle(new GSBuffer(buff).getLongThrowException())));
		// so as to be sent up
		if (res instanceof OptimisticLockConstraintViolationException)
			throw (OptimisticLockConstraintViolationException) res;
		if (res instanceof ConcurrencyControlException)
			throw (ConcurrencyControlException) res;
		if (res instanceof Throwable)
			throw new IllegalStateException((Throwable) res);
{'fraction_non_alphanumeric': 0.1096945551128818, 'fraction_numerical': 0.0, 'mean_word_length': 6.654471544715447, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1094519', 'n_tokens_mistral': 1172, 'n_tokens_neox': 1109, 'n_words': 218}