/** * Adds all elements within a given collection to this set. * * @param collect the input collection. * @return true if the add succeeds. * @throws DataAccessLayerException in case of data access failure. */ public boolean addAll(final Collection<? extends E> collect) throws DataAccessLayerException { if (collect == null || collect.isEmpty()) { return false; } boolean changed = false; for (final E obj : collect) { changed = changed | add(obj); } return changed; }
/** * Returns true if all given elements are found within this set. * * @param collect the element collection. * @return true if all given elements are found within this set, false otherwise. * @throws DataAccessLayerException in case of data access failure. */ public boolean containsAll(final Collection<? extends E> collect) throws DataAccessLayerException { for (final E obj : collect) { if (!contains(obj)) { return false; } } return true; }
@Override public void initialise(final DataAccessLayerFactory factory) throws InitialisationException { _classesSet.initialise(factory); _dPropsSet.initialise(factory); _oPropsSet.initialise(factory); }
public void index(final Store store, final ITopLevelDictionary dictionary) throws DataAccessLayerException { PersistentSet<byte[]> clazzes_cassandra = new PersistentSet<byte[]>(byte[].class, COL_CLAZZES); PersistentSet<byte[]> d_props_cassandra = new PersistentSet<byte[]>(byte[].class, COL_D_PROPS); PersistentSet<byte[]> o_props_cassandra = new PersistentSet<byte[]>(byte[].class, COL_O_PROPS); clazzes_cassandra.add(dictionary.getID(iterator.next().getObject(), false)); LOG.info(MessageCatalog._00065_HOW_MANY_CLASSES_FOUND, clazzes_cassandra.size()); counter = 0; d_props_cassandra.add(dictionary.getID(predicate, true)); } else { o_props_cassandra.add(dictionary.getID(predicate, true));
@Test public void addTest() throws DataAccessLayerException { CLASS_UNDER_TEST.clear(); assertTrue(CLASS_UNDER_TEST.isEmpty()); for (String key : TESTDATA1) { assertTrue(CLASS_UNDER_TEST.add(key)); } assertTrue(CLASS_UNDER_TEST.size() == TESTDATA1.size()); assertTrue(CLASS_UNDER_TEST.containsAll(TESTDATA1)); }
@Test public void removeTest() throws DataAccessLayerException { for (String key : TESTDATA2) { assertTrue(!CLASS_UNDER_TEST.remove(key)); } assertTrue(CLASS_UNDER_TEST.size() == TESTDATA1.size()); for (String key : TESTDATA1) { assertTrue(CLASS_UNDER_TEST.remove(key)); } assertTrue(CLASS_UNDER_TEST.isEmpty()); }
if (!_classesSet.contains(triple[2])) { _classesSet.add(triple[2]); if (!_classesSet.contains(triple[0])) { _classesSet.add(triple[0]); if (!_classesSet.contains(triple[2])) { _classesSet.add(triple[2]); if (!_oPropsSet.contains(triple[1])) { _oPropsSet.add(triple[1]); if (!_dPropsSet.contains(triple[1])) { _dPropsSet.add(triple[1]);
@BeforeClass public static void beforeAllTests() throws Exception { _tripleStore = newTripleStore(); _tripleStore.open(); CLASS_UNDER_TEST = new PersistentSet<String>(String.class, "SET_" + randomString()); CLASS_UNDER_TEST.initialise(_tripleStore.getDataAccessLayerFactory()); }
@Test public void containsTest() throws DataAccessLayerException { for (String key : TESTDATA1) { assertTrue(CLASS_UNDER_TEST.contains(key)); } assertTrue(CLASS_UNDER_TEST.containsAll(TESTDATA1)); for (String key : TESTDATA2) { assertTrue(!CLASS_UNDER_TEST.contains(key)); } assertTrue(!CLASS_UNDER_TEST.containsAll(TESTDATA2)); }
@Override public int size() { try { return _ids.size(); } catch (final DataAccessLayerException exception) { throw new RuntimeException(exception); } } }
/** * Builds a new schema for a given store. * * @param dictionary the dictionary used by the store. */ protected Schema(final ITopLevelDictionary dictionary) { _dictionary = dictionary; _classesSet = new PersistentSet<byte[]>(byte[].class, COL_CLAZZES); _dPropsSet = new PersistentSet<byte[]>(byte[].class, COL_D_PROPS); _oPropsSet = new PersistentSet<byte[]>(byte[].class, COL_O_PROPS); _classes = new DictionarySetDecorator(_classesSet, _dictionary, false); _dataProperties = new DictionarySetDecorator(_dPropsSet, _dictionary, true); _objectProperties = new DictionarySetDecorator(_oPropsSet, _dictionary, true); }
@Override public Iterator<Value> iterator() { final Iterator<byte[]> iterator = _ids.iterator(); return new AbstractIterator<Value>() { @Override protected Value computeNext() { if (!iterator.hasNext()) { return endOfData(); } else { try { final Value n = getValue(iterator.next()); return (n != null) ? n : endOfData(); } catch (final DataAccessLayerException exception) { LOGGER.error(MessageCatalog._00093_DATA_ACCESS_LAYER_FAILURE, exception); return endOfData(); } } } }; }
/** * Removes from this set all elements that are not within a given set of elements. * * @param collect the set of elements to be retained. * @return true if at least one element has been retained. * @throws DataAccessLayerException in case of data access failure. */ public boolean retainAll(final Collection<? extends E> collect) throws DataAccessLayerException { if (collect == null || collect.isEmpty()) { return false; } boolean changed = false; final Set<E> keys = new HashSet<E>(_map.keySet()); for (final E key : keys) { if (!collect.contains(key)) { changed = changed | remove(key); } } return changed; }
public void index(final Store store, final ITopLevelDictionary dictionary) throws DataAccessLayerException { PersistentSet<byte[]> clazzes_cassandra = new PersistentSet<byte[]>(byte[].class, COL_CLAZZES); PersistentSet<byte[]> d_props_cassandra = new PersistentSet<byte[]>(byte[].class, COL_D_PROPS); PersistentSet<byte[]> o_props_cassandra = new PersistentSet<byte[]>(byte[].class, COL_O_PROPS); clazzes_cassandra.add(dictionary.getID(iterator.next().getObject(), false)); LOG.info(MessageCatalog._00065_HOW_MANY_CLASSES_FOUND, clazzes_cassandra.size()); counter = 0; d_props_cassandra.add(dictionary.getID(predicate, true)); } else { o_props_cassandra.add(dictionary.getID(predicate, true));
if (!_classesSet.contains(triple[2])) { _classesSet.add(triple[2]); if (!_classesSet.contains(triple[0])) { _classesSet.add(triple[0]); if (!_classesSet.contains(triple[2])) { _classesSet.add(triple[2]); if (!_oPropsSet.contains(triple[1])) { _oPropsSet.add(triple[1]); if (!_dPropsSet.contains(triple[1])) { _dPropsSet.add(triple[1]);