@Override protected String getValueInternal(final byte[] id, final boolean p) throws DataAccessLayerException { final ByteBuffer key = ByteBuffer.wrap(id); String value = _id2node_cache.get(key); if (value == null) { value = _decoratee.getValue(id, p); _cacheStrategy.cacheId(key, value); } else { _valueHitsCount.incrementAndGet(); } return value; }
@Override protected String getValueInternal(final byte[] id, final boolean p) throws DataAccessLayerException { final ByteBuffer key = ByteBuffer.wrap(id); String value = _id2node_cache.get(key); if (value == null) { value = _decoratee.getValue(id, p); _cacheStrategy.cacheId(key, value); } else { _valueHitsCount.incrementAndGet(); } return value; }
@Override protected Value getValueInternal(final byte[] id, final boolean p) throws DataAccessLayerException { if (id[0] == MARKER) { return SESAME_VALUE_FACTORY.createURI( _namespaces.getValue(subarray(id, 1, 8), p), _localNames.getValue(subarray(id, 9, id.length - 9), p)); } else { return _bNodesAndLiterals.getValue(id, p); } }
@Override protected Value getValueInternal(final byte[] id, final boolean p) throws DataAccessLayerException { if (id[0] == MARKER) { return SESAME_VALUE_FACTORY.createURI( _namespaces.getValue(subarray(id, 1, 8), p), _localNames.getValue(subarray(id, 9, id.length - 9), p)); } else { return _bNodesAndLiterals.getValue(id, p); } }
/** * Tests ID creation and caching. * * @throws Exception never otherwise the test fails. */ @Test public void getValue() throws Exception { when(_decoratee.getValue(_id, false)).thenReturn(_aValue); assertTrue(_cut._id2node_cache.isEmpty()); assertEquals(_aValue, _cut.getValue(_id, false)); assertEquals(_aValue, _cut._id2node_cache.get(ByteBuffer.wrap(_id))); verify(_decoratee).getValue(_id, false); }