TextAnnotationMapDBHandler implements TextAnnotationCache { @Override public TextAnnotation getTextAnnotation(TextAnnotation ta) { for (String dataset : getAllDatasets()) { final ConcurrentMap<Integer, byte[]> data = getMap(dataset); if(data.containsKey(ta.getTokenizedText().hashCode())) { byte[] taData = data.get(ta.getTokenizedText().hashCode()); return SerializationHelper.deserializeTextAnnotationFromBytes(taData); } } return null; } TextAnnotationMapDBHandler(String dbFile); void close(); boolean isCached(String dataset, String dbFile); @Override void addTextAnnotation(String dataset, TextAnnotation ta); @Override void updateTextAnnotation(TextAnnotation ta); @Override IResetableIterator<TextAnnotation> getDataset(String dataset); @Override boolean contains(TextAnnotation ta); @Override void removeTextAnnotation(TextAnnotation ta); @Override TextAnnotation getTextAnnotation(TextAnnotation ta);  }
@Test public void testGetTextAnnotation() { TextAnnotation ta = DummyTextAnnotationGenerator.generateAnnotatedTextAnnotation(new String[]{ViewNames.POS, ViewNames.NER_CONLL, ViewNames.SRL_VERB}, false, 2); assertTrue(ta.hasView(ViewNames.SRL_VERB)); mapDBHandler.addTextAnnotation("test", ta); TextAnnotation queryTa = DummyTextAnnotationGenerator.generateAnnotatedTextAnnotation(new String[]{ViewNames.POS}, false, 2); assertFalse(queryTa.hasView(ViewNames.SRL_VERB)); TextAnnotation dbTa = mapDBHandler.getTextAnnotation(queryTa); assertNotNull(dbTa); assertTrue(dbTa.hasView(ViewNames.SRL_VERB)); mapDBHandler.removeTextAnnotation(dbTa); }