Search in sources :

Example 31 with MutableInt

use of org.apache.commons.lang.mutable.MutableInt in project tdi-studio-se by Talend.

the class EBCDICType3 method getNextByte.

private static byte getNextByte(String number, MutableInt recentlyReturned) {
    MutableInt zero = new MutableInt(0);
    recentlyReturned.decrement();
    if (recentlyReturned.compareTo(zero) >= 0) {
        while (!"0123456789".contains(String.valueOf(number.charAt(recentlyReturned.intValue())))) {
            recentlyReturned.decrement();
            if (recentlyReturned.compareTo(zero) < 0) {
                return 0;
            }
        }
        return (byte) (Character.getNumericValue(number.charAt(recentlyReturned.intValue())));
    } else {
        return 0;
    }
}
Also used : MutableInt(org.apache.commons.lang.mutable.MutableInt)

Example 32 with MutableInt

use of org.apache.commons.lang.mutable.MutableInt in project tdi-studio-se by Talend.

the class EBCDICType3 method writeType3Value.

public static byte[] writeType3Value(int length, int decimal, BigDecimal value, boolean isSigned) throws Exception {
    if (decimal != value.scale()) {
        BigDecimal tmp = value.setScale(decimal, BigDecimal.ROUND_FLOOR);
        value = tmp;
    }
    String str = value.toPlainString();
    int len = str.length();
    byte[] buf = new byte[length];
    MutableInt k = new MutableInt(len);
    // left and right nibble ( we go from right to left )
    byte even;
    byte odd;
    for (int i = length - 1; i >= 0; i--) {
        // Last byte needs sign nibble
        if (i == (length - 1)) {
            even = getNextByte(str, k);
            if (isSigned) {
                if (value.signum() >= 0) {
                    odd = 0x0C;
                } else {
                    odd = 0x0D;
                }
            } else {
                odd = (byte) 0x0F;
            }
        } else {
            // Packing rest of the digits...
            // Get even digit if exist or zero
            odd = getNextByte(str, k);
            even = getNextByte(str, k);
        }
        buf[i] = (byte) ((even << 4) | odd);
    }
    // TODO: Check if str ">" buf and eventually throw an Exc.
    return buf;
}
Also used : MutableInt(org.apache.commons.lang.mutable.MutableInt) BigDecimal(java.math.BigDecimal)

Example 33 with MutableInt

use of org.apache.commons.lang.mutable.MutableInt in project incubator-systemml by apache.

the class ReaderTextCSV method readCSVMatrixFromHDFS.

@SuppressWarnings("unchecked")
private MatrixBlock readCSVMatrixFromHDFS(Path path, JobConf job, FileSystem fs, MatrixBlock dest, long rlen, long clen, int brlen, int bclen, boolean hasHeader, String delim, boolean fill, double fillValue) throws IOException {
    //prepare file paths in alphanumeric order
    ArrayList<Path> files = new ArrayList<Path>();
    if (fs.isDirectory(path)) {
        for (FileStatus stat : fs.listStatus(path, CSVReblockMR.hiddenFileFilter)) files.add(stat.getPath());
        Collections.sort(files);
    } else
        files.add(path);
    //determine matrix size via additional pass if required
    if (dest == null) {
        dest = computeCSVSize(files, job, fs, hasHeader, delim, fill, fillValue);
        clen = dest.getNumColumns();
    }
    //actual read of individual files
    long lnnz = 0;
    MutableInt row = new MutableInt(0);
    for (int fileNo = 0; fileNo < files.size(); fileNo++) {
        lnnz += readCSVMatrixFromInputStream(fs.open(files.get(fileNo)), path.toString(), dest, row, rlen, clen, brlen, bclen, hasHeader, delim, fill, fillValue, fileNo == 0);
    }
    //post processing
    dest.setNonZeros(lnnz);
    return dest;
}
Also used : Path(org.apache.hadoop.fs.Path) FileStatus(org.apache.hadoop.fs.FileStatus) MutableInt(org.apache.commons.lang.mutable.MutableInt) ArrayList(java.util.ArrayList)

Example 34 with MutableInt

use of org.apache.commons.lang.mutable.MutableInt in project incubator-systemml by apache.

the class ReaderTextCSV method readMatrixFromInputStream.

@Override
public MatrixBlock readMatrixFromInputStream(InputStream is, long rlen, long clen, int brlen, int bclen, long estnnz) throws IOException, DMLRuntimeException {
    //allocate output matrix block
    MatrixBlock ret = createOutputMatrixBlock(rlen, clen, (int) rlen, (int) clen, estnnz, true, false);
    //core read 
    long lnnz = readCSVMatrixFromInputStream(is, "external inputstream", ret, new MutableInt(0), rlen, clen, brlen, bclen, _props.hasHeader(), _props.getDelim(), _props.isFill(), _props.getFillValue(), true);
    //finally check if change of sparse/dense block representation required
    ret.setNonZeros(lnnz);
    ret.examSparsity();
    return ret;
}
Also used : MatrixBlock(org.apache.sysml.runtime.matrix.data.MatrixBlock) MutableInt(org.apache.commons.lang.mutable.MutableInt)

Example 35 with MutableInt

use of org.apache.commons.lang.mutable.MutableInt in project gatk by broadinstitute.

the class AnnotateVcfWithBamDepth method apply.

@Override
public void apply(final VariantContext vc, final ReadsContext readsContext, final ReferenceContext refContext, final FeatureContext fc) {
    final MutableInt depth = new MutableInt(0);
    for (final GATKRead read : readsContext) {
        if (!read.failsVendorQualityCheck() && !read.isDuplicate() && !read.isUnmapped() && read.getEnd() > read.getStart() && new SimpleInterval(read).contains(vc)) {
            depth.increment();
        }
    }
    vcfWriter.add(new VariantContextBuilder(vc).attribute(POOLED_BAM_DEPTH_ANNOTATION_NAME, depth.intValue()).make());
}
Also used : GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) VariantContextBuilder(htsjdk.variant.variantcontext.VariantContextBuilder) MutableInt(org.apache.commons.lang.mutable.MutableInt) SimpleInterval(org.broadinstitute.hellbender.utils.SimpleInterval)

Aggregations

MutableInt (org.apache.commons.lang.mutable.MutableInt)35 List (java.util.List)8 PrismObject (com.evolveum.midpoint.prism.PrismObject)5 ArrayList (java.util.ArrayList)5 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)4 ResultHandler (com.evolveum.midpoint.schema.ResultHandler)4 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)4 Map (java.util.Map)4 Test (org.junit.Test)4 Versioned (voldemort.versioning.Versioned)4 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)3 MutableObject (org.apache.commons.lang.mutable.MutableObject)3 DateTime (org.joda.time.DateTime)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 HashMap (java.util.HashMap)2 LinkedList (java.util.LinkedList)2 Random (java.util.Random)2 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)2 ExecutionException (java.util.concurrent.ExecutionException)2 CompositeName (javax.naming.CompositeName)2