Search in sources :

Example 1 with IndexDefinitionUpdater

use of org.apache.jackrabbit.oak.plugins.index.importer.IndexDefinitionUpdater in project jackrabbit-oak by apache.

the class IndexCommand method computeIndexPaths.

private List<String> computeIndexPaths(IndexOptions indexOpts) throws IOException {
    // Combine the indexPaths from json and cli args
    Set<String> indexPaths = new LinkedHashSet<>(indexOpts.getIndexPaths());
    File definitions = indexOpts.getIndexDefinitionsFile();
    if (definitions != null) {
        IndexDefinitionUpdater updater = new IndexDefinitionUpdater(definitions);
        Set<String> indexPathsFromJson = updater.getIndexPaths();
        Set<String> diff = Sets.difference(indexPathsFromJson, indexPaths);
        if (!diff.isEmpty()) {
            log.info("Augmenting the indexPaths with {} which are present in {}", diff, definitions);
        }
        indexPaths.addAll(indexPathsFromJson);
    }
    return new ArrayList<>(indexPaths);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) IndexDefinitionUpdater(org.apache.jackrabbit.oak.plugins.index.importer.IndexDefinitionUpdater) ArrayList(java.util.ArrayList) File(java.io.File)

Example 2 with IndexDefinitionUpdater

use of org.apache.jackrabbit.oak.plugins.index.importer.IndexDefinitionUpdater in project jackrabbit-oak by apache.

the class ElasticIndexCommand method computeIndexPaths.

private List<String> computeIndexPaths(ElasticIndexOptions indexOpts) throws IOException {
    // Combine the indexPaths from json and cli args
    Set<String> indexPaths = new LinkedHashSet<>(indexOpts.getIndexPaths());
    File definitions = indexOpts.getIndexDefinitionsFile();
    if (definitions != null) {
        IndexDefinitionUpdater updater = new IndexDefinitionUpdater(definitions);
        Set<String> indexPathsFromJson = updater.getIndexPaths();
        Set<String> diff = Sets.difference(indexPathsFromJson, indexPaths);
        if (!diff.isEmpty()) {
            log.info("Augmenting the indexPaths with {} which are present in {}", diff, definitions);
        }
        indexPaths.addAll(indexPathsFromJson);
    }
    return new ArrayList<>(indexPaths);
}
Also used : IndexDefinitionUpdater(org.apache.jackrabbit.oak.plugins.index.importer.IndexDefinitionUpdater) File(java.io.File)

Example 3 with IndexDefinitionUpdater

use of org.apache.jackrabbit.oak.plugins.index.importer.IndexDefinitionUpdater in project jackrabbit-oak by apache.

the class IndexDefinitionPrinterTest method binaryProps.

@Test
public void binaryProps() throws Exception {
    NodeBuilder builder = store.getRoot().builder();
    builder.child("a").setProperty("foo", new ArrayBasedBlob("hello".getBytes()));
    store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
    when(pathService.getIndexPaths()).thenReturn(Lists.newArrayList("/a"));
    String json = getJSON();
    IndexDefinitionUpdater updater = new IndexDefinitionUpdater(json);
    assertTrue(updater.getIndexPaths().contains("/a"));
}
Also used : IndexDefinitionUpdater(org.apache.jackrabbit.oak.plugins.index.importer.IndexDefinitionUpdater) ArrayBasedBlob(org.apache.jackrabbit.oak.plugins.memory.ArrayBasedBlob) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Aggregations

IndexDefinitionUpdater (org.apache.jackrabbit.oak.plugins.index.importer.IndexDefinitionUpdater)3 File (java.io.File)2 ArrayList (java.util.ArrayList)1 LinkedHashSet (java.util.LinkedHashSet)1 ArrayBasedBlob (org.apache.jackrabbit.oak.plugins.memory.ArrayBasedBlob)1 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)1 Test (org.junit.Test)1