Search in sources :

Example 6 with BaseTransactionConfig

use of org.janusgraph.diskstorage.BaseTransactionConfig in project janusgraph by JanusGraph.

the class ElasticSearchConfigTest method simpleWriteAndQuery.

private void simpleWriteAndQuery(IndexProvider idx) throws BackendException, InterruptedException {
    final Duration maxWrite = Duration.ofMillis(2000L);
    final String storeName = "jvmlocal_test_store";
    final KeyInformation.IndexRetriever indexRetriever = IndexProviderTest.getIndexRetriever(IndexProviderTest.getMapping(idx.getFeatures(), ANALYZER_STANDARD, ANALYZER_KEYWORD));
    final BaseTransactionConfig txConfig = StandardBaseTransactionConfig.of(TimestampProviders.MILLI);
    IndexTransaction itx = new IndexTransaction(idx, indexRetriever, txConfig, maxWrite);
    for (final Entry<String, KeyInformation> entry : IndexProviderTest.getMapping(idx.getFeatures(), "english", "keyword").entrySet()) {
        idx.register(storeName, entry.getKey(), entry.getValue(), itx);
    }
    assertEquals(0, itx.queryStream(new IndexQuery(storeName, PredicateCondition.of(IndexProviderTest.NAME, Text.PREFIX, "ali"))).count());
    itx.add(storeName, "doc", IndexProviderTest.NAME, "alice", false);
    itx.commit();
    // Slightly longer than default 1s index.refresh_interval
    Thread.sleep(1500L);
    itx = new IndexTransaction(idx, indexRetriever, txConfig, maxWrite);
    assertEquals(0, itx.queryStream(new IndexQuery(storeName, PredicateCondition.of(IndexProviderTest.NAME, Text.PREFIX, "zed"))).count());
    assertEquals(1, itx.queryStream(new IndexQuery(storeName, PredicateCondition.of(IndexProviderTest.NAME, Text.PREFIX, "ali"))).count());
    itx.rollback();
}
Also used : Duration(java.time.Duration) StandardBaseTransactionConfig(org.janusgraph.diskstorage.util.StandardBaseTransactionConfig) BaseTransactionConfig(org.janusgraph.diskstorage.BaseTransactionConfig)

Aggregations

BaseTransactionConfig (org.janusgraph.diskstorage.BaseTransactionConfig)6 StandardBaseTransactionConfig (org.janusgraph.diskstorage.util.StandardBaseTransactionConfig)6 Duration (java.time.Duration)4 Configuration (org.janusgraph.diskstorage.configuration.Configuration)4 Test (org.junit.Test)4 BaseConfiguration (org.apache.commons.configuration.BaseConfiguration)3 HttpPut (org.apache.http.client.methods.HttpPut)3 StringEntity (org.apache.http.entity.StringEntity)3 PermanentBackendException (org.janusgraph.diskstorage.PermanentBackendException)3 BasicConfiguration (org.janusgraph.diskstorage.configuration.BasicConfiguration)3 ModifiableConfiguration (org.janusgraph.diskstorage.configuration.ModifiableConfiguration)3 CommonsConfiguration (org.janusgraph.diskstorage.configuration.backend.CommonsConfiguration)3 ElasticSearchIndex (org.janusgraph.diskstorage.es.ElasticSearchIndex)3 GraphDatabaseConfiguration (org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration)3 BackendException (org.janusgraph.diskstorage.BackendException)2 MergedConfiguration (org.janusgraph.diskstorage.configuration.MergedConfiguration)1