当前位置: 首页>>代码示例>>Java>>正文


Java WritablesToStringFunction类代码示例

本文整理汇总了Java中org.datavec.spark.transform.misc.WritablesToStringFunction的典型用法代码示例。如果您正苦于以下问题:Java WritablesToStringFunction类的具体用法?Java WritablesToStringFunction怎么用?Java WritablesToStringFunction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


WritablesToStringFunction类属于org.datavec.spark.transform.misc包,在下文中一共展示了WritablesToStringFunction类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: exportCSVLocal

import org.datavec.spark.transform.misc.WritablesToStringFunction; //导入依赖的package包/类
public static void exportCSVLocal(String outputDir, String baseFileName, int numFiles, String delimiter,
                String quote, JavaRDD<List<Writable>> data, int rngSeed) throws Exception {

    JavaRDD<String> lines = data.map(new WritablesToStringFunction(delimiter, quote));
    double[] split = new double[numFiles];
    for (int i = 0; i < split.length; i++)
        split[i] = 1.0 / numFiles;
    JavaRDD<String>[] splitData = lines.randomSplit(split);

    int count = 0;
    Random r = new Random(rngSeed);
    for (JavaRDD<String> subset : splitData) {
        String path = FilenameUtils.concat(outputDir, baseFileName + (count++) + ".csv");
        List<String> linesList = subset.collect();
        if (!(linesList instanceof ArrayList))
            linesList = new ArrayList<>(linesList);
        Collections.shuffle(linesList, r);
        FileUtils.writeLines(new File(path), linesList);
    }
}
 
开发者ID:deeplearning4j,项目名称:DataVec,代码行数:21,代码来源:SparkExport.java

示例2: exportCSVSpark

import org.datavec.spark.transform.misc.WritablesToStringFunction; //导入依赖的package包/类
public static void exportCSVSpark(String directory, String delimiter, String quote, int outputSplits,
                JavaRDD<List<Writable>> data) {

    //NOTE: Order is probably not random here...
    JavaRDD<String> lines = data.map(new WritablesToStringFunction(delimiter, quote));
    lines.coalesce(outputSplits);

    lines.saveAsTextFile(directory);
}
 
开发者ID:deeplearning4j,项目名称:DataVec,代码行数:10,代码来源:SparkExport.java

示例3: testWritablesToString

import org.datavec.spark.transform.misc.WritablesToStringFunction; //导入依赖的package包/类
@Test
public void testWritablesToString() throws Exception {

    List<Writable> l = Arrays.<Writable>asList(new DoubleWritable(1.5), new Text("someValue"));
    String expected = l.get(0).toString() + "," + l.get(1).toString();

    assertEquals(expected, new WritablesToStringFunction(",").call(l));
}
 
开发者ID:deeplearning4j,项目名称:DataVec,代码行数:9,代码来源:TestWritablesToStringFunctions.java


注:本文中的org.datavec.spark.transform.misc.WritablesToStringFunction类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。