@Override public boolean contains(Object key) { //we can do better if needed... return load(key) != null; }
private void prepareUpsertStatement(MarshalledEntry entry, String key, int segment, PreparedStatement ps) throws InterruptedException, SQLException { prepareStatement(entry, key, segment, ps, true); }
@Override public Flowable<K> publishKeys(Predicate<? super K> filter) { return publish(null, rs -> Flowable.fromIterable(() -> new ResultSetKeyIterator(rs, filter))); }
@Override public Builder<?> read(SharedConnectionFactoryConfiguration template) { this.connectionUrl = template.connectionUrl(); this.driverClass = template.driverClass(); this.username = template.username(); this.password = template.password(); return this; }
public String getStringMapping(Object key) { Person person = (Person) key; return person.getName() + "_" + person.getSurname() + "_" + person.getAge(); } }
@Override public Flowable<MarshalledEntry<K, V>> publishEntries(Predicate<? super K> filter, boolean fetchValue, boolean fetchMetadata) { return publish(null, rs -> Flowable.fromIterable(() -> new ResultSetEntryIterator(rs, filter, fetchValue, fetchMetadata))); }
private void write(MarshalledEntry entry, Connection connection, String keyStr, int segment) throws SQLException, InterruptedException { if (tableManager.isUpsertSupported()) { executeUpsert(connection, entry, keyStr, segment); } else { executeLegacyUpdate(connection, entry, keyStr, segment); } }
@Factory public Object[] factory() { return new Object[] { new JdbcStringBasedStoreTest().segmented(false), new JdbcStringBasedStoreTest().segmented(true), }; }
@Factory public Object[] factory() { return new Object[] { new JdbcStringBasedStoreVamTest().segmented(false), new JdbcStringBasedStoreVamTest().segmented(true), }; }
void initializeConnectionFactory(ConnectionFactory connectionFactory) throws PersistenceException { this.connectionFactory = connectionFactory; tableManager = getTableManager(); tableManager.setCacheName(cacheName); tableManager.start(); }
@AfterMethod public void clearStore() throws Exception { cacheStore.clear(); assertRowCount(0); }
protected ConnectionFactory getConnection() { JdbcStringBasedStore store = (JdbcStringBasedStore) cacheStore; return store.getConnectionFactory(); }
@Override public SharedConnectionFactoryConfiguration create() { return new SharedConnectionFactoryConfiguration(connectionUrl, driverClass, username, password); }
protected void assertRowCount(int size) { assertEquals(size, rowCount()); } }
@AfterClass @Override public void destroyStore() throws PersistenceException { super.destroyStore(); cm.stop(); }
protected int rowCount() { ConnectionFactory connectionFactory = getConnection(); TableName tableName = tableManager.getTableName(); return UnitTestDatabaseManager.rowCount(connectionFactory, tableName); }
@Override public Publisher<K> publishKeys(IntSet segments, Predicate<? super K> filter) { return publish(segments, rs -> Flowable.fromIterable(() -> new ResultSetKeyIterator(rs, filter))); }
@Override public Publisher<MarshalledEntry<K, V>> publishEntries(IntSet segments, Predicate<? super K> filter, boolean fetchValue, boolean fetchMetadata) { return publish(segments, rs -> Flowable.fromIterable(() -> new ResultSetEntryIterator(rs, filter, fetchValue, fetchMetadata))); }
public void testClear() throws Exception { assertRowCount(0); cacheStore.write(new MarshalledEntryImpl(MIRCEA, "value", null, marshaller)); cacheStore.write(new MarshalledEntryImpl(MANIK, "value", null, marshaller)); assertRowCount(2); cacheStore.clear(); assertRowCount(0); }