Skip to content

Commit

Permalink
Revert "Add support for byte arrays in primary key of history"
Browse files Browse the repository at this point in the history
This reverts commit 0aca021.
  • Loading branch information
Sunjeet committed Mar 13, 2024
1 parent 0aca021 commit ab522de
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
*
*/
public class HollowDiff {
private final EnumSet<FieldType> SINGLE_FIELD_SUPPORTED_TYPES = EnumSet.of(FieldType.INT, FieldType.LONG, FieldType.DOUBLE, FieldType.STRING, FieldType.FLOAT, FieldType.BOOLEAN, FieldType.BYTES);
private final EnumSet<FieldType> SINGLE_FIELD_SUPPORTED_TYPES = EnumSet.of(FieldType.INT, FieldType.LONG, FieldType.DOUBLE, FieldType.STRING, FieldType.FLOAT, FieldType.BOOLEAN);

private final Logger log = Logger.getLogger(HollowDiff.class.getName());
private final HollowReadStateEngine fromStateEngine;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ public Object getObject(int ordinal, FieldType type) {
return getLong(pointer);
case STRING:
return getString(pointer);
case BYTES:
return getBytes(pointer);
default:
throw new IllegalArgumentException("Unknown type " + type);
}
Expand Down Expand Up @@ -84,17 +82,13 @@ public long getLong(long pointer) {
}

public String getString(long pointer) {
return new String(getBytes(pointer));
}

public byte[] getBytes(long pointer) {
ByteData byteData = ordinalMap.getByteData().getUnderlyingArray();
int length = VarInt.readVInt(byteData, pointer);
byte[] bytes = new byte[length];
for(int i=0;i<length;i++) {
bytes[i] = byteData.get(pointer+1+i);
}
return bytes;
return new String(bytes);
}

public int writeAndGetOrdinal(Object objectToIntern) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ public static Object[] parseKey(HollowReadStateEngine readStateEngine, PrimaryKe
key[i] = Float.parseFloat(fields[i]);
break;
case BYTES:
key[i] = fields[i];
break;
throw new IllegalArgumentException("Primary key contains a field of type BYTES");
}
}
return key;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package com.netflix.hollow.tools.util;

import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import com.netflix.hollow.core.schema.HollowObjectSchema.FieldType;

Expand Down Expand Up @@ -163,32 +162,6 @@ public void testString() {
assertEquals(retrievedString2, "I can do this all day");
}

@Test
public void testBytes() {
byte[] bytesObj1 = "I am Groot".getBytes();
byte[] bytesObj2 = "I am Groot".getBytes();
byte[] bytesObj3 = "I can do this all day".getBytes();
byte[] bytesObj4 = "I can do this all day".getBytes();

int bytes1Ordinal = internPool.writeAndGetOrdinal(bytesObj1);
int bytes2Ordinal = internPool.writeAndGetOrdinal(bytesObj2);
internPool.prepareForRead();

byte[] retrievedString1 = (byte[]) internPool.getObject(bytes1Ordinal, FieldType.BYTES);

assertEquals(bytes1Ordinal, bytes2Ordinal);
assertArrayEquals(retrievedString1, "I am Groot".getBytes());

int bytes3Ordinal = internPool.writeAndGetOrdinal(bytesObj3);
int bytes4Ordinal = internPool.writeAndGetOrdinal(bytesObj4);
internPool.prepareForRead();

byte[] retrievedBytes2 = (byte[]) internPool.getObject(bytes3Ordinal, FieldType.BYTES);

assertEquals(bytes3Ordinal, bytes4Ordinal);
assertArrayEquals(retrievedBytes2, "I can do this all day".getBytes());
}

@Test
public void testBool() {
Boolean boolObj1 = true;
Expand Down

0 comments on commit ab522de

Please sign in to comment.