/** * Include the record which matches the specified key. * * @param idx the index in which to query for the key * @param key the key */ public void includeKey(HollowPrimaryKeyIndex idx, Object... key) { inverseCopyDirector.excludeKey(idx, key); }
primaryKeyCopyDirector.excludeKey(indexes[j], recordKey);
@Test public void testExplicitlyExcludedButOtherwiseReferencedKeys() throws IOException { HollowPrimaryKeyIndex cIdx3 = new HollowPrimaryKeyIndex(input3, "TypeC", "key"); HollowCombinerExcludePrimaryKeysCopyDirector director = new HollowCombinerExcludePrimaryKeysCopyDirector(); director.excludeKey(cIdx3, 8); HollowCombiner combiner = new HollowCombiner(director, input1, input2, input3); combiner.setPrimaryKeys(new PrimaryKey("TypeB", "key", "c.key"), new PrimaryKey("TypeC", "key")); combiner.combine(); HollowReadStateEngine output = StateEngineRoundTripper.roundTripSnapshot(combiner.getCombinedStateEngine()); assertObject(output, 9, 3, 8, 3, 8, 3); }
@Test public void testExplicitlyExcludedAndRemappedKeys() throws IOException { HollowPrimaryKeyIndex cIdx1 = new HollowPrimaryKeyIndex(input1, "TypeC", "key"); HollowCombinerExcludePrimaryKeysCopyDirector director = new HollowCombinerExcludePrimaryKeysCopyDirector(); director.excludeKey(cIdx1, 3); HollowCombiner combiner = new HollowCombiner(director, input1, input2, input3); combiner.setPrimaryKeys(new PrimaryKey("TypeB", "key", "c.key"), new PrimaryKey("TypeC", "key")); combiner.combine(); HollowReadStateEngine output = StateEngineRoundTripper.roundTripSnapshot(combiner.getCombinedStateEngine()); assertObject(output, 1, 1, 1, 1, 1, 1); assertObject(output, 2, 1, 2, 1, 2, 1); assertObject(output, 3, 1, 3, 1, 3, 2); assertObject(output, 4, 2, 2, 2, 3, 2); assertObject(output, 5, 2, 4, 2, 4, 2); assertObject(output, 6, 2, 6, 2, 6, 2); assertObject(output, 7, 3, 2, 2, 3, 2); assertObject(output, 8, 3, 7, 3, 6, 2); assertObject(output, 9, 3, 8, 3, 8, 3); assertObject(output, 10,3, 4, 3, 10,3); }
@Test public void testExcludeReferencedObjectsFromPrimaryKeyCopyDirector() throws IOException { HollowPrimaryKeyIndex aIdx3 = new HollowPrimaryKeyIndex(input3, "TypeA", "key"); HollowCombinerExcludePrimaryKeysCopyDirector director = new HollowCombinerExcludePrimaryKeysCopyDirector(); director.excludeKey(aIdx3, 9); HollowCombiner combiner = new HollowCombiner(director, input1, input2, input3); combiner.setPrimaryKeys(new PrimaryKey("TypeB", "key", "c.key"), new PrimaryKey("TypeC", "key")); combiner.combine(); HollowReadStateEngine output = StateEngineRoundTripper.roundTripSnapshot(combiner.getCombinedStateEngine()); Assert.assertEquals(-1, new HollowPrimaryKeyIndex(output, "TypeA", "key").getMatchingOrdinal(9)); Assert.assertNotEquals(-1, new HollowPrimaryKeyIndex(output, "TypeB", "key").getMatchingOrdinal(8)); Assert.assertNotEquals(-1, new HollowPrimaryKeyIndex(output, "TypeC", "key").getMatchingOrdinal(8)); director.excludeReferencedObjects(); combiner = new HollowCombiner(director, input1, input2, input3); combiner.setPrimaryKeys(new PrimaryKey("TypeB", "key", "c.key"), new PrimaryKey("TypeC", "key")); combiner.combine(); output = StateEngineRoundTripper.roundTripSnapshot(combiner.getCombinedStateEngine()); Assert.assertEquals(-1, new HollowPrimaryKeyIndex(output, "TypeA", "key").getMatchingOrdinal(9)); Assert.assertEquals(-1, new HollowPrimaryKeyIndex(output, "TypeB", "key").getMatchingOrdinal(8)); Assert.assertEquals(-1, new HollowPrimaryKeyIndex(output, "TypeC", "key").getMatchingOrdinal(8)); }