Example usage for org.apache.commons.lang3 ArrayUtils addAll

List of usage examples for org.apache.commons.lang3 ArrayUtils addAll

Introduction

In this page you can find the example usage for org.apache.commons.lang3 ArrayUtils addAll.

Prototype

public static double[] addAll(final double[] array1, final double... array2) 

Source Link

Document

Adds all the elements of the given arrays into a new array.

The new array contains all of the element of array1 followed by all of the elements array2 .

Usage

From source file:eu.amidst.flinklink.examples.misc.DynamicParallelVMPExtended.java

/**
*
* ./bin/flink run -m yarn-cluster -yn 8 -ys 4 -yjm 1024 -ytm 9000
*              -c eu.amidst.flinklink.examples.misc.DynamicParallelVMPExtended ../flinklink.jar 0 10 1000000 100 100 100 3 0
*
*
* @param args command line arguments//from w ww . j  ava2 s  . c  om
* @throws Exception
*/
public static void main(String[] args) throws Exception {

    int nCVars = Integer.parseInt(args[0]);
    int nMVars = Integer.parseInt(args[1]);
    int nSamples = Integer.parseInt(args[2]);
    int windowSize = Integer.parseInt(args[3]);
    int globalIter = Integer.parseInt(args[4]);
    int localIter = Integer.parseInt(args[5]);
    int nsets = Integer.parseInt(args[6]);
    int seed = Integer.parseInt(args[7]);
    boolean generateData = Boolean.parseBoolean(args[8]);

    /*
     * Generate dynamic datasets
     */
    if (generateData) {
        String[] argsDatasets = ArrayUtils.addAll(ArrayUtils.subarray(args, 0, 4),
                ArrayUtils.subarray(args, 6, 8));
        DynamicDataSets dynamicDataSets = new DynamicDataSets();
        dynamicDataSets.generateDynamicDataset(argsDatasets);
    }

    /*
     * Logging
     */
    //PropertyConfigurator.configure(args[6]);
    BasicConfigurator.configure();

    logger.info("Starting DynamicVMPExtended experiments");

    //String fileName = "hdfs:///tmp"+nCVars+"_"+nMVars+"_"+nSamples+"_"+nsets+"_"+seed;
    String fileName = "./datasets/tmp" + nCVars + "_" + nMVars + "_" + nSamples + "_" + nsets + "_" + seed;

    final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

    DataFlink<DynamicDataInstance> data0 = DataFlinkLoader.loadDynamicDataFromFolder(env,
            fileName + "_iter_" + 0 + ".arff", false);

    DynamicDAG hiddenNB = getHiddenDynamicNaiveBayesStructure(data0.getAttributes(), false);

    System.out.println(hiddenNB.toString());

    //Structure learning is excluded from the test, i.e., we use directly the initial Asia network structure
    // and just learn then test the parameter learning

    long start = System.nanoTime();

    //Parameter Learning
    DynamicParallelVB parallelVB = new DynamicParallelVB();
    parallelVB.setGlobalThreshold(0.1);
    parallelVB.setMaximumGlobalIterations(globalIter);
    parallelVB.setLocalThreshold(0.1);
    parallelVB.setMaximumLocalIterations(localIter);
    parallelVB.setSeed(5);
    parallelVB.setOutput(true);

    //Set the window size
    parallelVB.setBatchSize(windowSize);
    parallelVB.setDAG(hiddenNB);
    parallelVB.initLearning();

    System.out.println("--------------- DATA " + 0 + " --------------------------");
    parallelVB.updateModelWithNewTimeSlice(0, data0);

    for (int i = 1; i < nsets; i++) {
        logger.info("--------------- DATA " + i + " --------------------------");
        DataFlink<DynamicDataInstance> dataNew = DataFlinkLoader.loadDynamicDataFromFolder(env,
                fileName + "_iter_" + i + ".arff", false);
        parallelVB.updateModelWithNewTimeSlice(i, dataNew);
    }

    logger.info(parallelVB.getLearntDynamicBayesianNetwork().toString());

    long duration = (System.nanoTime() - start) / 1;
    double seconds = duration / 1000000000.0;
    logger.info("Running time: {} seconds.", seconds);

}

From source file:com.l2jfree.gameserver.CoreInfo.java

public static String[] getFullVersionInfo() {
    return ArrayUtils.addAll(new String[] { "l2jfree-core    :    " + CORE_VERSION.getFullVersionInfo() },
            CommonsInfo.getFullVersionInfo());
}

From source file:com.l2jfree.loginserver.LoginInfo.java

public static String[] getFullVersionInfo() {
    return ArrayUtils.addAll(new String[] { "l2jfree-login   :    " + LOGIN_VERSION.getFullVersionInfo() },
            CommonsInfo.getFullVersionInfo());
}

From source file:net.eledge.android.europeana.search.model.record.abstracts.Resource.java

@SuppressWarnings("unchecked")
public static <T> T[] mergeArray(T[] array1, T[] array2) {
    return ArrayUtils.addAll(array1, array2);
}

From source file:com.mirth.connect.server.util.Pre22PasswordChecker.java

/**
 * The pre-2.2 password has been migrated to the following
 * format:/*w  w w . ja v a 2s. co m*/
 * 
 * SALT_ + 8-bit salt + base64(sha(salt + password))
 * 
 * To compare:
 * 
 * 1. Strip the known pre-2.2 prefix
 * 2. Get the first 8-bits and Base64 decode it, this the salt
 * 3. Get the remaining bits and Base64 decode it, this is the hash
 * 4. Pass it into the pre-2.2 password checker algorithm
 * 
 * @param plainPassword The plain text password to check against the hash
 * @param encodedPassword The hashed password
 * @return true if the password matches the hash using the pre-2.2 algorithm, false otherwise
 */
public static boolean checkPassword(String plainPassword, String encodedPassword) throws Exception {
    String saltHash = StringUtils.substringAfter(encodedPassword, SALT_PREFIX);
    String encodedSalt = StringUtils.substring(saltHash, 0, SALT_LENGTH);
    byte[] decodedSalt = Base64.decodeBase64(encodedSalt);
    byte[] decodedHash = Base64.decodeBase64(StringUtils.substring(saltHash, encodedSalt.length()));

    if (Arrays.equals(decodedHash, DigestUtils.sha(ArrayUtils.addAll(decodedSalt, plainPassword.getBytes())))) {
        return true;
    }

    return false;
}

From source file:io.fabric8.maven.core.util.ClassUtil.java

private static ClassLoader[] mergeClassLoaders(List<ClassLoader> additionalClassLoaders) {
    ClassLoader[] classLoaders;//from  w  ww.ja  va  2s. c om

    if (additionalClassLoaders != null && !additionalClassLoaders.isEmpty()) {
        classLoaders = ArrayUtils.addAll(getClassLoaders(),
                additionalClassLoaders.toArray(new ClassLoader[additionalClassLoaders.size()]));
    } else {
        classLoaders = getClassLoaders();
    }
    return classLoaders;
}

From source file:de.sanandrew.mods.turretmod.util.ParticleProxy.java

public void spawnParticle(double posX, double posY, double posZ, int dimension, short particleId,
        Tuple additionalData) {/*from ww w  .  ja va 2  s .  co m*/
    Object[] obj = new Object[] { posX, posY, posZ, particleId, additionalData != null };
    if (additionalData != null) {
        obj = ArrayUtils.addAll(obj, additionalData.toArray());
    }

    PacketManager.sendToAllAround(PacketManager.SPAWN_PARTICLE, dimension, posX, posY, posZ, 128.0D,
            Tuple.from(obj));
}

From source file:com.mac.holdempoker.app.impl.SimpleHand.java

public SimpleHand(Player p, Board b) throws IllegalAccessException, Exception {
    evaluator = new HandEvaluator();
    Card[] cards = ArrayUtils.addAll(p.getHoleCards(), b.getBoard());
    evaluator.haveCards(cards);/*from   www  .  ja  v  a  2  s .  com*/
}

From source file:FileMangement.PathFinder.java

@SuppressWarnings("empty-statement")
public Path[] FileCreator(String filename, boolean m3uCheck) throws IOException {

    File paths = new File(filename);
    String[] pattern;//from   w  w w. j  a v  a  2s  .c  o m

    if (m3uCheck != true) {
        pattern = patternCreator.patternCreator(true, false, false, false, 1);
    } else {
        pattern = new String[1];
        pattern[0] = "*.m3u";
    }

    String str = paths.toString();
    String slash = "\\";

    String s = new StringBuilder(str).append(slash).toString();
    Path startingDir = Paths.get(s);

    int i = 0;
    while (i < pattern.length) {
        Finder finder = new Finder(pattern[i]);
        Files.walkFileTree(startingDir, finder);

        listOfPaths = ArrayUtils.addAll(listOfPaths, NullCleaner(finder.returnArray()));
        finalTotal = finder.done(finalTotal);
        i++;
    }

    //    StringBuffer sb = new StringBuffer(listOfPaths[1].getFileName().toString());
    //  sb.delete(sb.length()-4,sb.length()) ;

    //  System.out.println(sb);

    //  System.out.println(Arrays.toString(listOfPaths));

    //   System.out.println("Total Matched Number of Files : " + finalTotal);

    return listOfPaths;
}

From source file:com.chiorichan.util.WebFunc.java

public static String createGUID(String seed) {
    if (seed == null)
        seed = "";

    byte[] bytes;
    try {//from   w w w .j av  a  2s .co  m
        bytes = seed.getBytes("ISO-8859-1");
    } catch (UnsupportedEncodingException e) {
        bytes = new byte[0];
    }

    byte[] bytesScrambled = new byte[0];

    for (byte b : bytes) {
        byte[] tbyte = new byte[2];
        new Random().nextBytes(bytes);

        tbyte[0] = (byte) (b + tbyte[0]);
        tbyte[1] = (byte) (b + tbyte[1]);

        bytesScrambled = ArrayUtils.addAll(bytesScrambled, tbyte);
    }

    return "{" + UUID.nameUUIDFromBytes(bytesScrambled).toString() + "}";
}