hadoop-common-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Grey <jason.grey.w...@gmail.com>
Subject Text and/or ImmutableBytesWritable issue?
Date Wed, 21 Nov 2007 16:27:23 GMT
Can anyone explain why "testTextToBytes" doesn't assert and
"testStringToBytes" does?


import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.hadoop.io.Text;

import junit.framework.TestCase;

public class TestImmutableBytesWritable extends TestCase {
	
	public void testTextToBytes(){
	
		Text input = new Text("this is a test.");
		
		ImmutableBytesWritable bytes =
			new ImmutableBytesWritable( input.getBytes() );
		
		Text output = new Text( bytes.get() );
		
		assertEquals(input, output);
		
	}

	public void testStringToBytes(){
		
		String input = "this is a test.";
		
		ImmutableBytesWritable bytes =
			new ImmutableBytesWritable( input.getBytes() );
		
		String output = new String( bytes.get() );
		
		assertEquals(input, output);
		
	}
}


If I inspect the objects during debugging at the point of the assert I
see the following:

* input
	bytes = [116, 104, 105, 115, 32, 105
		, 115, 32, 97, 32, 116, 101
		, 115, 116, 46, 0]
	length = 15

* bytes = 	[116, 104, 105, 115, 32, 105
		, 115, 32, 97, 32, 116, 101
		, 115, 116, 46, 0]

* output
	bytes = [116, 104, 105, 115, 32, 105
		, 115, 32, 97, 32, 116, 101
		, 115, 116, 46, 0]
	length = 16

The length property appears to be off between the two Text objects, but
all the data is correct... any help would be greatly appreciated.

Thanks

-jg-


Mime
View raw message