Search in sources :

Example 1 with UnmanagedFileSplit

use of org.apache.hyracks.api.io.UnmanagedFileSplit in project asterixdb by apache.

the class WordCountMain method parseFileSplits.

private static FileSplit[] parseFileSplits(String fileSplits) {
    String[] splits = fileSplits.split(",");
    FileSplit[] fSplits = new FileSplit[splits.length];
    for (int i = 0; i < splits.length; ++i) {
        String s = splits[i].trim();
        int idx = s.indexOf(':');
        if (idx < 0) {
            throw new IllegalArgumentException("File split " + s + " not well formed");
        }
        File file = new File(s.substring(idx + 1));
        fSplits[i] = new UnmanagedFileSplit(s.substring(0, idx), file.getAbsolutePath());
        fileSize += file.length();
    }
    return fSplits;
}
Also used : FileSplit(org.apache.hyracks.api.io.FileSplit) UnmanagedFileSplit(org.apache.hyracks.api.io.UnmanagedFileSplit) UnmanagedFileSplit(org.apache.hyracks.api.io.UnmanagedFileSplit) File(java.io.File)

Example 2 with UnmanagedFileSplit

use of org.apache.hyracks.api.io.UnmanagedFileSplit in project asterixdb by apache.

the class FileSplitUtils method parseFileSplits.

public static FileSplit[] parseFileSplits(String fileSplits) {
    String[] splits = fileSplits.split(",");
    FileSplit[] fSplits = new FileSplit[splits.length];
    for (int i = 0; i < splits.length; ++i) {
        String s = splits[i].trim();
        int idx = s.indexOf(':');
        if (idx < 0) {
            throw new IllegalArgumentException("File split " + s + " not well formed");
        }
        fSplits[i] = new UnmanagedFileSplit(s.substring(0, idx), new File(s.substring(idx + 1)).getAbsolutePath());
    }
    return fSplits;
}
Also used : FileSplit(org.apache.hyracks.api.io.FileSplit) UnmanagedFileSplit(org.apache.hyracks.api.io.UnmanagedFileSplit) UnmanagedFileSplit(org.apache.hyracks.api.io.UnmanagedFileSplit) File(java.io.File)

Example 3 with UnmanagedFileSplit

use of org.apache.hyracks.api.io.UnmanagedFileSplit in project asterixdb by apache.

the class QueryTranslator method handleWriteStatement.

protected Pair<IAWriterFactory, FileSplit> handleWriteStatement(Statement stmt) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
    WriteStatement ws = (WriteStatement) stmt;
    File f = new File(ws.getFileName());
    FileSplit outputFile = new UnmanagedFileSplit(ws.getNcName().getValue(), f.getPath());
    IAWriterFactory writerFactory = null;
    if (ws.getWriterClassName() != null) {
        writerFactory = (IAWriterFactory) Class.forName(ws.getWriterClassName()).newInstance();
    }
    return new Pair<>(writerFactory, outputFile);
}
Also used : WriteStatement(org.apache.asterix.lang.common.statement.WriteStatement) FileSplit(org.apache.hyracks.api.io.FileSplit) UnmanagedFileSplit(org.apache.hyracks.api.io.UnmanagedFileSplit) UnmanagedFileSplit(org.apache.hyracks.api.io.UnmanagedFileSplit) ExternalFile(org.apache.asterix.external.indexing.ExternalFile) File(java.io.File) IAWriterFactory(org.apache.hyracks.algebricks.data.IAWriterFactory) Pair(org.apache.hyracks.algebricks.common.utils.Pair)

Example 4 with UnmanagedFileSplit

use of org.apache.hyracks.api.io.UnmanagedFileSplit in project asterixdb by apache.

the class Common method parseFileSplits.

static FileSplit[] parseFileSplits(String fileSplits) {
    String[] splits = fileSplits.split(",");
    FileSplit[] fSplits = new FileSplit[splits.length];
    for (int i = 0; i < splits.length; ++i) {
        String s = splits[i].trim();
        int idx = s.indexOf(':');
        if (idx < 0) {
            throw new IllegalArgumentException("File split " + s + " not well formed");
        }
        fSplits[i] = new UnmanagedFileSplit(s.substring(0, idx), new File(s.substring(idx + 1)).getAbsolutePath());
    }
    return fSplits;
}
Also used : FileSplit(org.apache.hyracks.api.io.FileSplit) UnmanagedFileSplit(org.apache.hyracks.api.io.UnmanagedFileSplit) UnmanagedFileSplit(org.apache.hyracks.api.io.UnmanagedFileSplit) File(java.io.File)

Example 5 with UnmanagedFileSplit

use of org.apache.hyracks.api.io.UnmanagedFileSplit in project asterixdb by apache.

the class LocalFSInputStreamFactory method configureFileSplits.

private void configureFileSplits(ICcApplicationContext appCtx, String[] splits) throws AsterixException {
    INodeResolver resolver = getNodeResolver();
    Map<InetAddress, Set<String>> ncMap = RuntimeUtils.getForcedNodeControllerMap(appCtx);
    Set<String> ncs = ncMap.values().stream().flatMap(Collection::stream).collect(Collectors.toSet());
    inputFileSplits = new UnmanagedFileSplit[splits.length];
    String node;
    String path;
    int count = 0;
    String trimmedValue;
    for (String splitPath : splits) {
        trimmedValue = splitPath.trim();
        if (!trimmedValue.contains("://")) {
            throw new AsterixException("Invalid path: " + splitPath + "\nUsage- path=\"Host://Absolute File Path\"");
        }
        node = resolver.resolveNode(appCtx, trimmedValue.split(":")[0], ncMap, ncs);
        path = trimmedValue.split("://")[1];
        inputFileSplits[count++] = new UnmanagedFileSplit(node, path);
    }
}
Also used : TreeSet(java.util.TreeSet) Set(java.util.Set) AsterixException(org.apache.asterix.common.exceptions.AsterixException) INodeResolver(org.apache.asterix.external.api.INodeResolver) UnmanagedFileSplit(org.apache.hyracks.api.io.UnmanagedFileSplit) InetAddress(java.net.InetAddress) AlgebricksAbsolutePartitionConstraint(org.apache.hyracks.algebricks.common.constraints.AlgebricksAbsolutePartitionConstraint)

Aggregations

UnmanagedFileSplit (org.apache.hyracks.api.io.UnmanagedFileSplit)5 File (java.io.File)4 FileSplit (org.apache.hyracks.api.io.FileSplit)4 InetAddress (java.net.InetAddress)1 Set (java.util.Set)1 TreeSet (java.util.TreeSet)1 AsterixException (org.apache.asterix.common.exceptions.AsterixException)1 INodeResolver (org.apache.asterix.external.api.INodeResolver)1 ExternalFile (org.apache.asterix.external.indexing.ExternalFile)1 WriteStatement (org.apache.asterix.lang.common.statement.WriteStatement)1 AlgebricksAbsolutePartitionConstraint (org.apache.hyracks.algebricks.common.constraints.AlgebricksAbsolutePartitionConstraint)1 Pair (org.apache.hyracks.algebricks.common.utils.Pair)1 IAWriterFactory (org.apache.hyracks.algebricks.data.IAWriterFactory)1