Search in sources :

Example 1 with IgfsStringDelimiterRecordResolver

use of org.apache.ignite.igfs.mapreduce.records.IgfsStringDelimiterRecordResolver in project ignite by apache.

the class IgfsTaskSelfTest method testTask.

/**
     * Test task.
     *
     * @throws Exception If failed.
     */
@SuppressWarnings("ConstantConditions")
public void testTask() throws Exception {
    String arg = DICTIONARY[new Random(System.currentTimeMillis()).nextInt(DICTIONARY.length)];
    generateFile(TOTAL_WORDS);
    Long genLen = igfs.info(FILE).length();
    IgniteBiTuple<Long, Integer> taskRes = igfs.execute(new Task(), new IgfsStringDelimiterRecordResolver(" "), Collections.singleton(FILE), arg);
    assert F.eq(genLen, taskRes.getKey());
    assert F.eq(TOTAL_WORDS, taskRes.getValue());
}
Also used : IgfsTask(org.apache.ignite.igfs.mapreduce.IgfsTask) Random(java.util.Random) IgfsStringDelimiterRecordResolver(org.apache.ignite.igfs.mapreduce.records.IgfsStringDelimiterRecordResolver)

Example 2 with IgfsStringDelimiterRecordResolver

use of org.apache.ignite.igfs.mapreduce.records.IgfsStringDelimiterRecordResolver in project ignite by apache.

the class IgfsStringDelimiterRecordResolverSelfTest method assertSplitNull.

/**
     * Check the split resolution resulted in {@code null}.
     *
     * @param suggestedStart Suggested start.
     * @param suggestedLen Suggested length.
     * @param data File data.
     * @param delims Delimiters.
     * @throws Exception If failed.
     */
public void assertSplitNull(long suggestedStart, long suggestedLen, byte[] data, String... delims) throws Exception {
    write(data);
    IgfsStringDelimiterRecordResolver rslvr = resolver(delims);
    IgfsFileRange split;
    try (IgfsInputStream is = read()) {
        split = rslvr.resolveRecords(igfs, is, split(suggestedStart, suggestedLen));
    }
    assert split == null : "Split is not null.";
}
Also used : IgfsInputStream(org.apache.ignite.igfs.IgfsInputStream) IgfsFileRange(org.apache.ignite.igfs.mapreduce.IgfsFileRange) IgfsStringDelimiterRecordResolver(org.apache.ignite.igfs.mapreduce.records.IgfsStringDelimiterRecordResolver)

Aggregations

IgfsStringDelimiterRecordResolver (org.apache.ignite.igfs.mapreduce.records.IgfsStringDelimiterRecordResolver)2 Random (java.util.Random)1 IgfsInputStream (org.apache.ignite.igfs.IgfsInputStream)1 IgfsFileRange (org.apache.ignite.igfs.mapreduce.IgfsFileRange)1 IgfsTask (org.apache.ignite.igfs.mapreduce.IgfsTask)1