package org.elasql.bench.server.metadata;

import org.elasql.bench.benchmarks.ycsb.ElasqlYcsbConstants;
import org.elasql.sql.RecordKey;
import org.elasql.storage.metadata.PartitionPlan;

public class YcsbMultiTenantsPartitionPlan extends PartitionPlan {
	
	public static int getTenantId(RecordKey key) {
		String tableName = key.getTableName();
		if (!tableName.startsWith("ycsb"))
			throw new IllegalArgumentException("does not recongnize " + key);
		return Integer.parseInt(tableName.substring(4));
	}
	
	@Override
	public boolean isFullyReplicated(RecordKey key) {
		return false;
	}

	@Override
	public int getPartition(RecordKey key) {
		int tenantId = getTenantId(key);
		return tenantId / ElasqlYcsbConstants.TENANTS_PER_PART;
	}

}

@@ -733,10 +733,179 @@
 RT;%0A%09%7D%0A%0A
+%09@Override%0A%09public PartitionPlan getBasePlan() %7B%0A%09%09return this;%0A%09%7D%0A%0A%09@Override%0A%09public void setBasePlan(PartitionPlan plan) %7B%0A%09%09new UnsupportedOperationException();%0A%09%7D%0A%0A
 %7D%0A

Update for correctness