@Override protected byte[] getIdInternal(final String value, final boolean p) throws DataAccessLayerException { byte[] id = _node2id_cache.get(value); if (id == null) { id = _decoratee.getID(value, p); _cacheStrategy.cacheValue(value, id); } else { _idHitsCount.incrementAndGet(); } return id; }
@Override protected byte[] getIdInternal(final String value, final boolean p) throws DataAccessLayerException { byte[] id = _node2id_cache.get(value); if (id == null) { id = _decoratee.getID(value, p); _cacheStrategy.cacheValue(value, id); } else { _idHitsCount.incrementAndGet(); } return id; }
@Override protected byte[] getIdInternal(final Value value, final boolean p) throws DataAccessLayerException { if (value instanceof URI) { final URI uri = (URI) value; byte[] namespaceId = _namespaces.getID(uri.getNamespace(), p); byte[] localNameId = _localNames.getID(uri.getLocalName(), p); return concat(MARKER, namespaceId, localNameId); } else { return _bNodesAndLiterals.getID(value, p); } }
@Override protected byte[] getIdInternal(final Value value, final boolean p) throws DataAccessLayerException { if (value instanceof URI) { final URI uri = (URI) value; byte[] namespaceId = _namespaces.getID(uri.getNamespace(), p); byte[] localNameId = _localNames.getID(uri.getLocalName(), p); return concat(MARKER, namespaceId, localNameId); } else { return _bNodesAndLiterals.getID(value, p); } }
/** * Tests ID creation and caching. * * @throws Exception never otherwise the test fails. */ @Test public void getID() throws Exception { when(_decoratee.getID(_aValue, false)).thenReturn(_id); assertTrue(_cut._node2id_cache.isEmpty()); assertArrayEquals(_id, _cut.getID(_aValue, false)); assertEquals(_id, _cut._node2id_cache.get(_aValue)); assertArrayEquals(_id, _cut.getID(_aValue, false)); verify(_decoratee).getID(_aValue, false); }