@Override public byte[] compose(final byte[] id1, final byte[] id2, final byte[] id3) { return _decoratee.compose(id1, id2, id3); }
@Override public boolean contains(final Object o) { try { return (o instanceof Value && _ids.contains(_dict.getID((Value) o, _p))); } catch (DataAccessLayerException exception) { throw new RuntimeException(exception); } }
/** * Returns the value associated with the given identifier. * * @param id the identifier. * @return the value associated with the given identifier, null in case no value is found. * @throws DataAccessLayerException in case of data access failure. */ private Value getValue(final byte[] id) throws DataAccessLayerException { return _dict.getValue(id, _p); }
Value createValue(final byte[] id, final boolean isPredicate) { if (dictionary.isBNode(id)) { return new NativeCumulusBNode(id, dictionary); } else if (dictionary.isLiteral(id)) { return new NativeCumulusLiteral(id, dictionary); } else if (dictionary.isResource(id)) { return new NativeCumulusURI(id, dictionary, isPredicate); } else { throw new IllegalArgumentException("Could not create sesame value from node ID " + Arrays.toString(id)); } } }
@Override public boolean isLiteral(final byte[] id) { return id != null && id[0] != KNOWN_URI_MARKER && _decoratee.isLiteral(id); }
/** * Remove() method itself has no effect on the {@link TransientValueDictionary} unless the given value is a long literal. * * @throws Exception never otherwise the test fails. */ @Test public void removeValueInvolvesLongLiteralDictionary() throws Exception { final byte[] persistentId = { TransientValueDictionary.THRESHOLD_EXCEEDED, 2, 3, 4, 5, 6, 7, 78, 8, 9 }; final ITopLevelDictionary decoratee = mock(ITopLevelDictionary.class); when(decoratee.getID(_longLiteral, false)).thenReturn(persistentId); _cut = new TransientValueDictionary(randomString(), decoratee, TransientValueDictionary.DEFAULT_THRESHOLD); _cut.removeValue(_longLiteral, false); verify(decoratee).removeValue(_longLiteral, false); }
@Override public byte[][] decompose(final byte[] compositeId) { return _decoratee.decompose(compositeId); }
@Override public void removeValue(final Value value, final boolean p) throws DataAccessLayerException { if (value != null && !(value instanceof URI)) { _bNodesAndLiterals.removeValue(value, p); } }
@Override protected void closeInternal() { _decoratee.close(); } }
@Override protected void initialiseInternal(final DataAccessLayerFactory factory) throws InitialisationException { _longLiteralsDictionary.initialise(factory); }
@Override public boolean isBNode(final byte[] id) { return id != null && id[0] != KNOWN_URI_MARKER && _decoratee.isBNode(id); }
@Override public boolean isResource(final byte[] id) { return id != null && ((id[0] == KNOWN_URI_MARKER && id[1] == RESOURCE_BYTE_FLAG && id.length == ID_LENGTH) || (_decoratee.isResource(id))); }
@Override public boolean isLiteral(final byte[] id) { return _decoratee.isLiteral(id); }
Value createValue(final byte[] id, final boolean isPredicate) { if (dictionary.isBNode(id)) { return new NativeCumulusBNode(id, dictionary); } else if (dictionary.isLiteral(id)) { return new NativeCumulusLiteral(id, dictionary); } else if (dictionary.isResource(id)) { return new NativeCumulusURI(id, dictionary, isPredicate); } else { throw new IllegalArgumentException("Could not create sesame value from node ID " + Arrays.toString(id)); } } }
/** * The remove() method must remove the value from cache and call remove() on decoratee. * * @throws Exception never otherwise the test fails. */ @Test public void removeValue() 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)); _cut.removeValue(_aValue, false); assertTrue(_cut._node2id_cache.isEmpty()); assertTrue(_cut._id2node_cache.isEmpty()); verify(_decoratee).removeValue(_aValue, false); }
@Override public byte[][] decompose(final byte[] compositeId) { return _decoratee.decompose(compositeId); }
@Override public void removeValue(final Value value, final boolean p) throws DataAccessLayerException { if (value != null && !(value instanceof URI)) { _bNodesAndLiterals.removeValue(value, p); } }
@Override protected void closeInternal() { _decoratee.close(); } }
@Override protected void initialiseInternal(final DataAccessLayerFactory factory) throws InitialisationException { _longLiteralsDictionary.initialise(factory); }
@Override public boolean isBNode(final byte[] id) { return _decoratee.isBNode(id); }