@Test public void testBadPrefixes() { String[] badPrefixes = {"q:she6:test1", "q:she6:test1", "p:Mhe6:test1", "p;she6:test1", "p:she6;test1", "p;she6;test1", "p:+he6:test1", "p:s?e6:test1", "p:sh{6:test1", "p:sh6:"}; RowHasher rh = new RowHasher("p"); for (String badPrefix : badPrefixes) { try { rh.removeHash(Bytes.of(badPrefix)); Assert.fail(); } catch (IllegalArgumentException e) { } } }
public Bytes removeHash(Bytes row) { Preconditions.checkArgument(row.length() >= prefixBytes.length() + 5, "Row is shorter than expected " + row); Preconditions.checkArgument(row.subSequence(0, prefixBytes.length()).equals(prefixBytes), "Row does not have expected prefix " + row); Preconditions.checkArgument(hasHash(row), "Row does not have expected hash " + row); return row.subSequence(prefixBytes.length() + 5, row.length()); }
RowHasher { public Bytes removeHash(Bytes row) { Preconditions.checkArgument(row.length() >= prefixBytes.length() + 5, "Row is shorter than expected " + row); Preconditions.checkArgument(row.subSequence(0, prefixBytes.length()).equals(prefixBytes), "Row does not have expected prefix " + row); Preconditions.checkArgument(hasHash(row), "Row does not have expected hash " + row); return row.subSequence(prefixBytes.length() + 5, row.length()); } }
RowHasher { public Bytes removeHash(Bytes row) { Preconditions.checkArgument(row.length() >= prefixBytes.length() + 5, "Row is shorter than expected " + row); Preconditions.checkArgument(row.subSequence(0, prefixBytes.length()).equals(prefixBytes), "Row does not have expected prefix " + row); Preconditions.checkArgument(hasHash(row), "Row does not have expected hash " + row); return row.subSequence(prefixBytes.length() + 5, row.length()); } RowHasher(String prefix); }
RowHasher { public Bytes removeHash(Bytes row) { Preconditions.checkArgument(row.length() >= prefixBytes.length() + 5, "Row is shorter than expected " + row); Preconditions.checkArgument(row.subSequence(0, prefixBytes.length()).equals(prefixBytes), "Row does not have expected prefix " + row); Preconditions.checkArgument(hasHash(row), "Row does not have expected hash " + row); return row.subSequence(prefixBytes.length() + 5, row.length()); } RowHasher(String prefix); static void configure(FluoConfiguration fluoConfig, String prefix, int numTablets); String getPrefix(); Bytes addHash(String row); Bytes addHash(Bytes row); Bytes removeHash(Bytes row); }
RowHasher { public Bytes removeHash(Bytes row) { Preconditions.checkArgument(row.length() >= prefixBytes.length() + 5, "Row is shorter than expected " + row); Preconditions.checkArgument(row.subSequence(0, prefixBytes.length()).equals(prefixBytes), "Row does not have expected prefix " + row); Preconditions.checkArgument(hasHash(row), "Row does not have expected hash " + row); return row.subSequence(prefixBytes.length() + 5, row.length()); } RowHasher(String prefix); static void configure(FluoConfiguration fluoConfig, String prefix, int numTablets); String getPrefix(); Bytes addHash(String row); Bytes addHash(Bytes row); Bytes removeHash(Bytes row);  }