All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.zuinnote.flink.bitcoin.AbstractBitcoinFlinkInputFormat Maven / Gradle / Ivy

Go to download

HadoopCryptoLedger library to analyse cryptoledgers, such as the Bitcoin blockchain, by using Big Data technologies, such as Hadoop/Hive/Flink/Spark

There is a newer version: 1.3.2
Show newest version
/**
* Copyright 2017 ZuInnoTe (Jörn Franke) 
*
* 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.
**/

/**
 * Flink Data Source base for Bitcoin Input formats
 */

package org.zuinnote.flink.bitcoin;

import java.io.IOException;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.flink.api.common.io.FileInputFormat;
import org.apache.flink.core.fs.FileInputSplit;
import org.zuinnote.hadoop.bitcoin.format.common.BitcoinBlockReader;
import org.zuinnote.hadoop.bitcoin.format.common.BitcoinUtil;
import org.zuinnote.hadoop.bitcoin.format.exception.HadoopCryptoLedgerConfigurationException;
import org.zuinnote.hadoop.bitcoin.format.mapred.AbstractBitcoinRecordReader;

public abstract class AbstractBitcoinFlinkInputFormat extends FileInputFormat {

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

	private transient BitcoinBlockReader bbr;
	private int maxSizeBitcoinBlock;
	private byte [][] specificMagicArray;
	private boolean useDirectBuffer;
	/**
	 * 
	 */
	private static final long serialVersionUID = -4661705676237973665L;
	
	public AbstractBitcoinFlinkInputFormat() throws HadoopCryptoLedgerConfigurationException {
		this(AbstractBitcoinRecordReader.DEFAULT_MAXSIZE_BITCOINBLOCK,AbstractBitcoinRecordReader.DEFAULT_MAGIC,AbstractBitcoinRecordReader.DEFAULT_USEDIRECTBUFFER);
	}
	
	public AbstractBitcoinFlinkInputFormat(int maxSizeBitcoinBlock, String specificMagicStr, boolean useDirectBuffer) throws HadoopCryptoLedgerConfigurationException {
		this.maxSizeBitcoinBlock=maxSizeBitcoinBlock;
		this.useDirectBuffer=useDirectBuffer;
		if ((specificMagicStr!=null) && (specificMagicStr.length()>0)) {
			String[] specificMagicStringArray=specificMagicStr.split(",");
			this.specificMagicArray=new byte[specificMagicStringArray.length][4]; // each magic is always 4 byte
			for (int i=0;i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy