/** * {@inheritDoc} * * <p> * <strong>Algorithm Description</strong>: Uses a 2-cycle permutation * shuffle to generate a random permutation of <code>c.size()</code> and * then returns the elements whose indexes correspond to the elements of the * generated permutation. This technique is described, and proven to * generate random samples <a * href="http://www.maths.abdn.ac.uk/~igc/tch/mx4002/notes/node83.html"> * here</a> * </p> */ public Object[] nextSample(Collection<?> c, int k) throws NotStrictlyPositiveException, NumberIsTooLargeException { return delegate.nextSample(c, k); }
/** * {@inheritDoc} * * <p> * <strong>Algorithm Description</strong>: Uses a 2-cycle permutation * shuffle to generate a random permutation of <code>c.size()</code> and * then returns the elements whose indexes correspond to the elements of the * generated permutation. This technique is described, and proven to * generate random samples <a * href="http://www.maths.abdn.ac.uk/~igc/tch/mx4002/notes/node83.html"> * here</a> * </p> */ public Object[] nextSample(Collection<?> c, int k) throws NotStrictlyPositiveException, NumberIsTooLargeException { return delegate.nextSample(c, k); }
/** * {@inheritDoc} * * <p> * <strong>Algorithm Description</strong>: Uses a 2-cycle permutation * shuffle to generate a random permutation of <code>c.size()</code> and * then returns the elements whose indexes correspond to the elements of the * generated permutation. This technique is described, and proven to * generate random samples <a * href="http://www.maths.abdn.ac.uk/~igc/tch/mx4002/notes/node83.html"> * here</a> * </p> */ public Object[] nextSample(Collection<?> c, int k) throws NotStrictlyPositiveException, NumberIsTooLargeException { return delegate.nextSample(c, k); }
private void changeTableSetting(RandomDataGenerator random, State state, Environment env, Properties props) throws Exception { // pick a random property int choice = random.nextInt(0, tableSettings.length - 1); Setting setting = tableSettings[choice]; // pick a random table SortedSet<String> tables = env.getConnector().tableOperations().list().tailSet("ctt") .headSet("ctu"); if (tables.isEmpty()) return; String table = random.nextSample(tables, 1)[0].toString(); // generate a random value long newValue = random.nextLong(setting.min, setting.max); state.set(LAST_TABLE_SETTING, table + "," + choice); log.debug("Setting " + setting.property.getKey() + " on table " + table + " to " + newValue); try { env.getConnector().tableOperations().setProperty(table, setting.property.getKey(), "" + newValue); } catch (AccumuloException ex) { if (ex.getCause() instanceof ThriftTableOperationException) { ThriftTableOperationException ttoe = (ThriftTableOperationException) ex.getCause(); if (ttoe.type == TableOperationExceptionType.NOTFOUND) return; } throw ex; } }
private void changeNamespaceSetting(RandomDataGenerator random, State state, Environment env, Properties props) throws Exception { // pick a random property int choice = random.nextInt(0, tableSettings.length - 1); Setting setting = tableSettings[choice]; // pick a random table SortedSet<String> namespaces = env.getConnector().namespaceOperations().list().tailSet("nspc") .headSet("nspd"); if (namespaces.isEmpty()) return; String namespace = random.nextSample(namespaces, 1)[0].toString(); // generate a random value long newValue = random.nextLong(setting.min, setting.max); state.set(LAST_NAMESPACE_SETTING, namespace + "," + choice); log.debug( "Setting " + setting.property.getKey() + " on namespace " + namespace + " to " + newValue); try { env.getConnector().namespaceOperations().setProperty(namespace, setting.property.getKey(), "" + newValue); } catch (AccumuloException ex) { if (ex.getCause() instanceof ThriftTableOperationException) { ThriftTableOperationException ttoe = (ThriftTableOperationException) ex.getCause(); if (ttoe.type == TableOperationExceptionType.NAMESPACE_NOTFOUND) return; } throw ex; } }