@Override protected void closeInternal() { _id2node_cache.clear(); _node2id_cache.clear(); _decoratee.close(); }
@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 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 void initialiseInternal(final DataAccessLayerFactory factory) throws InitialisationException { _decoratee.initialise(factory); }
@Override public void removeValue(final String value, final boolean p) throws DataAccessLayerException { _decoratee.removeValue(value, p); }
@Override protected void initialiseInternal(final DataAccessLayerFactory factory) throws InitialisationException { _decoratee.initialise(factory); }
@Override public void removeValue(final String value, final boolean p) throws DataAccessLayerException { _decoratee.removeValue(value, p); }
@Override protected void initialiseInternal(final DataAccessLayerFactory factory) throws InitialisationException { _namespaces.initialise(factory); _localNames.initialise(factory); _bNodesAndLiterals.initialise(factory); }
@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 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; }
/** * Removing a Literal won't involve namespaces and local names dictionaries. * * @throws Exception never otherwise the test fails. */ @Test public void removeLiteral() throws Exception { final boolean isPredicate = RANDOMIZER.nextBoolean(); _cut.removeValue(_aLiteral, isPredicate); verify(_namespacesDictionary, times(0)).removeValue(anyString(), eq(isPredicate)); verify(_localNamesDictionary, times(0)).removeValue(anyString(), eq(isPredicate)); verify(_bnodesAndLiteralsDictionary).removeValue(_aLiteral, isPredicate); } }
@Override protected void closeInternal() { _id2node_cache.clear(); _node2id_cache.clear(); _decoratee.close(); }
@Override protected void initialiseInternal(final DataAccessLayerFactory factory) throws InitialisationException { _namespaces.initialise(factory); _localNames.initialise(factory); _bNodesAndLiterals.initialise(factory); }
@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 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); } }
/** * Removing a BNode won't involve namespaces and local names dictionaries. * * @throws Exception never otherwise the test fails. */ @Test public void removeBNode() throws Exception { final boolean isPredicate = RANDOMIZER.nextBoolean(); _cut.removeValue(_aBNode, isPredicate); verify(_namespacesDictionary, times(0)).removeValue(anyString(), eq(isPredicate)); verify(_localNamesDictionary, times(0)).removeValue(anyString(), eq(isPredicate)); verify(_bnodesAndLiteralsDictionary).removeValue(_aBNode, isPredicate); }
/** * On initialisation, decoratee instance must be initialised too. * * @throws InitialisationException never, otherwise the test fails. */ @Test public void decorateeInitialisation() throws InitialisationException { _cut.initialise(T_DATA_ACCESS_LAYER_FACTORY); verify(_namespacesDictionary).initialise(T_DATA_ACCESS_LAYER_FACTORY); verify(_localNamesDictionary).initialise(T_DATA_ACCESS_LAYER_FACTORY); verify(_bnodesAndLiteralsDictionary).initialise(T_DATA_ACCESS_LAYER_FACTORY); }
@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); } }