com.mellanox.erasurecode.rawcoder.MellanoxRSRawEncoder.java Source code

Java tutorial

Introduction

Here is the source code for com.mellanox.erasurecode.rawcoder.MellanoxRSRawEncoder.java

Source

/*
 ** Copyright (C) 2016 Mellanox Technologies
 **
 ** Licensed under the Apache License, Version 2.0 (the "License");
 ** you may not use this file except in compliance with the License.
 ** You may obtain a copy of the License at:
 **
 ** http://www.apache.org/licenses/LICENSE-2.0
 **
 ** Unless required by applicable law or agreed to in writing, software
 ** distributed under the License is distributed on an "AS IS" BASIS,
 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 ** either express or implied. See the License for the specific language
 ** governing permissions and  limitations under the License.
 **
 */

package com.mellanox.erasurecode.rawcoder;

import java.nio.ByteBuffer;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.io.erasurecode.rawcoder.AbstractNativeRawEncoder;

public class MellanoxRSRawEncoder extends AbstractNativeRawEncoder {

    static final Log LOG = LogFactory.getLog(MellanoxRSRawEncoder.class.getName());

    static {
        MellanoxECLibraryLoader.checkNativeCodeLoaded();
    }

    public MellanoxRSRawEncoder(int numDataUnits, int numParityUnits) {
        super(numDataUnits, numParityUnits);
        initImpl(numDataUnits, numParityUnits);
    }

    @Override
    protected void performEncodeImpl(ByteBuffer[] inputs, int[] inputOffsets, int dataLen, ByteBuffer[] outputs,
            int[] outputOffsets) {
        encodeImpl(inputs, inputOffsets, dataLen, outputs, outputOffsets);
    }

    @Override
    public void release() {
        destroyImpl();
    }

    private native void initImpl(int numDataUnits, int numParityUnits);

    private native void encodeImpl(ByteBuffer[] inputs, int[] inputOffsets, int dataLen, ByteBuffer[] outputs,
            int[] outputOffsets);

    private native void destroyImpl();
}