GithubHelp home page GithubHelp logo

Comments (4)

dfntrs avatar dfntrs commented on June 16, 2024

Might trying the following help your issue?
src/main/java/com/savy3/hadoop/hive/serde3/cobo/CobolNumberField.java:

public Object deserialize(byte[] rowBytes) throws CobolSerdeException {
	byte[] temp = transcodeField(super.getBytes(rowBytes));
	String s1 = new String(temp);

	if (this.compType > 0) {
		if (this.compType == 3) {
			s1 = unpackData(super.getBytes(rowBytes), this.decimalLocation);
		}else if(this.compType == 4){
			s1 = getBinary(super.getBytes(rowBytes), this.decimalLocation);
		}
	//} else if (this.decimalLocation > 0) {
	  } else {
			//Now calling unpackSign on all numeric fields for which compType resolves to 0.
			//
			//The function will check to see if the least significant byte has been overpunched with a sign and
			//return a negative number if a negative sign is found.
			s1 = unpackSign(super.getBytes(rowBytes), this.decimalLocation);
	}



//Adding unpackSign to handle signed fields (sign overpunched into the least significant byte)
public String unpackSign(byte[] packedData, int decimalPointLocation) {
	String unpackedData = "";
	final int negativeSign = 13;
	for (int currentByteIndex = 0; currentByteIndex < packedData.length; currentByteIndex++) {

		int firstDigit = ((packedData[currentByteIndex] >> 4) & 0x0f);
		int secondDigit = (packedData[currentByteIndex] & 0x0F);
		//System.out.println("unpack_"+firstDigit+"_"+secondDigit);
		unpackedData += String.valueOf(secondDigit);
		if (currentByteIndex == (packedData.length - 1)) {
			if (firstDigit == negativeSign) {
				unpackedData = "-" + unpackedData;
			}
		}
	}
	if (decimalPointLocation > 0) {
		unpackedData = unpackedData.substring(0,
				(unpackedData.length() - decimalPointLocation))
				+ "."
				+ unpackedData.substring(unpackedData.length()
						- decimalPointLocation);
	}
	return unpackedData;
}

from cobol-to-hive.

ameet123 avatar ameet123 commented on June 16, 2024

ok, so what happens to the

else if (this.decimalLocation > 0) 

block? Are you removing it completely?
Also does the try/catch after the if then else stay as it is?

sorry*

ah I see that you have added it in the unpackSign method

ok let me try to build and give it a shot.

thanks much.

from cobol-to-hive.

rbheemana avatar rbheemana commented on June 16, 2024

@dfntrs Thanks for the contribution. I have added the your code to the branch https://github.com/rbheemana/Cobol-to-Hive/tree/Issue%2351-Field-with-format-S9(11)V99-displays-null-value-in-hive

@dfntrs @ameet123 Could you please test if all scenarios are working fine with the new branch jar

from cobol-to-hive.

rbheemana avatar rbheemana commented on June 16, 2024

closing the issue

from cobol-to-hive.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.