@Override protected void doStop() { notifyStopped(); }
@Override protected <T extends Entity> IndexedCollection<EntityHandle<T>> createIndexedCollection(Persistence<EntityHandle<T>, ? extends Comparable> persistence) { return new ConcurrentMemoryIndexedCollection<>(persistence); }
@Override public Journal.Transaction beginTransaction() { return new Transaction(this); }
@Test @SneakyThrows public void cascading() { MemoryJournal journal = new MemoryJournal(); CascadingIndexEngine indexEngine = new CascadingIndexEngine(new FailingIndexEngine(), new MemoryIndexEngine()); indexEngine.setJournal(journal); assertNotNull(indexEngine.getIndexOnAttribute(INDEX, IndexEngine.IndexFeature.LT)); }
@Override protected void doStart() { if (repository == null) { notifyFailed(new IllegalStateException("repository == null")); } notifyStarted(); }
@Override public <O extends Entity> IndexedCollection<EntityHandle<O>> createIndexedCollection(Class<O> klass) { return new MemoryIndexEngine().createIndexedCollection(new OnHeapPersistence()); }
public MemoryJournalTest() { super(new MemoryJournal()); } }
public MemoryIndexEngineTest() { super(new MemoryIndexEngine()); } }
public SpecialEquality(Query<O> query) { super(compatibleAttribute(((Equal) query).getAttribute()), ((Equal) query).getValue()); }
@Override public void setRepository(Repository repository) throws IllegalStateException { if (isRunning()) { throw new IllegalStateException(); } this.repository = repository; }
@Override public ResultSet<O> retrieve(Query<O> query) { return super.retrieve(compatibleQuery(query)); }
private Query<O> compatibleQuery(Query<O> query) { if (query instanceof Equal) { if (((Equal) query).getAttributeType() == byte[].class) { Equal<O, Object> newQuery = new SpecialEquality<>(query); return newQuery; } } return query; }
public static <O extends Entity, A> Attribute<EntityHandle<O>, ?> compatibleAttribute(Attribute<EntityHandle<O>, A> attribute) { if (attribute.getAttributeType() == byte[].class) { return new ByteArrayWrappingAttribute<>((Attribute<EntityHandle<O>, byte[]>) attribute); } else { return attribute; } }
@Override protected void doStart() { if (repository == null) { notifyFailed(new IllegalStateException("repository == null")); } notifyStarted(); }
protected Journal createJournal() { return new MemoryJournal(); } }
@Override protected void doStop() { notifyStopped(); }
@Override public Journal.Transaction beginTransaction() { return new Transaction(this); }
@Override public <A, O extends Entity> HashIndex onAttribute(Attribute<O, A> attribute) { return HashIndex.onAttribute(MemoryIndexEngine.compatibleAttribute(attribute)); } }
@Override public void setJournal(Journal journal) throws IllegalStateException { if (isRunning()) { throw new IllegalStateException(); } this.journal = journal; }
@Override public ResultSet<O> retrieve(Query<O> query, QueryOptions queryOptions) { return super.retrieve(compatibleQuery(query), queryOptions); }