Package org.lilyproject.indexer.model.indexerconf

Examples of org.lilyproject.indexer.model.indexerconf.LilyIndexerConf


                        "recordType='*:typeB' vtags='vtag1'",
                        "recordType='{*}typeC' vtags='vtag2'"),
                Collections.<String>emptyList()
        );

        LilyIndexerConf idxConf = LilyIndexerConfBuilder.build(new ByteArrayInputStream(conf.getBytes()), repository);

        Record recordNs1TypeB = newRecordOfType(new QName("ns1", "typeB"));
        Record recordNs2TypeB = newRecordOfType(new QName("ns2", "typeB"));
        Record recordNs1TypeC = newRecordOfType(new QName("ns1", "typeC"));
        Record recordNs2TypeC = newRecordOfType(new QName("ns2", "typeC"));
        Record recordNs1TypeA = newRecordOfType(new QName("ns1", "typeA"));

        assertNull(idxConf.getRecordFilter().getIndexCase(Table.RECORD.name, recordNs1TypeA));

        assertNotNull(idxConf.getRecordFilter().getIndexCase(Table.RECORD.name, recordNs1TypeB));
        assertNotNull(idxConf.getRecordFilter().getIndexCase(Table.RECORD.name, recordNs2TypeB));

        assertNotNull(idxConf.getRecordFilter().getIndexCase(Table.RECORD.name, recordNs1TypeC));
        assertNotNull(idxConf.getRecordFilter().getIndexCase(Table.RECORD.name, recordNs2TypeC));
    }
View Full Code Here


                    Lists.newArrayList(
                            "instanceOf='ns1:" + rt + "' vtags='vtag1'"),
                    Collections.<String>emptyList()
            );

            LilyIndexerConf idxConf = LilyIndexerConfBuilder.build(new ByteArrayInputStream(conf.getBytes()), repository);

            if (rt.equals("rt6")) {
                assertNull(idxConf.getRecordFilter().getIndexCase(Table.RECORD.name, record));
            } else {
                assertNotNull("don't expect null for case instanceOf=" + rt,
                        idxConf.getRecordFilter().getIndexCase(Table.RECORD.name, record));
                assertEquals(ImmutableSet.of(vtag1.getId()),
                        idxConf.getRecordFilter().getIndexCase(Table.RECORD.name, record).getVersionTags());
            }
        }
    }
View Full Code Here

                Lists.newArrayList(
                        "recordType='ns1:typeA' vtags='vtag1'"),
                Collections.<String>emptyList()
        );

        LilyIndexerConf idxConf = LilyIndexerConfBuilder.build(new ByteArrayInputStream(conf.getBytes()), repository);

        Record record = repository.getDefaultTable().recordBuilder().id("record").build();

        assertNull(idxConf.getRecordFilter().getIndexCase(Table.RECORD.name, record));
    }
View Full Code Here

                Lists.newArrayList(
                        "vtags='vtag1'"),
                Collections.<String>emptyList()
        );

        LilyIndexerConf idxConf = LilyIndexerConfBuilder.build(new ByteArrayInputStream(conf.getBytes()), repository);

        Record record = repository.getDefaultTable().recordBuilder().id("record").build();

        assertNotNull(idxConf.getRecordFilter().getIndexCase(Table.RECORD.name, record));
    }
View Full Code Here

                        "field='ns:string=zeus' vtags='vtag1'",
                        "field='ns:bool=true' vtags='vtag2'"),
                Collections.<String>emptyList()
        );

        LilyIndexerConf idxConf = LilyIndexerConfBuilder.build(new ByteArrayInputStream(conf.getBytes()), repository);

        //
        // Test string field
        //
        Record zeus = repository.getDefaultTable().recordBuilder()
                .id("record")
                .recordType(new QName("ns1", "typeA"))
                .field(new QName("ns", "string"), "zeus")
                .field(new QName("ns", "bool"), Boolean.TRUE)
                .field(new QName("ns", "int"), 5)
                .build();

        Record hera = repository.getDefaultTable().recordBuilder()
                .id("record")
                .recordType(new QName("ns1", "typeA"))
                .field(new QName("ns", "string"), "hera")
                .field(new QName("ns", "int"), 10)
                .build();

        assertNull(idxConf.getRecordFilter().getIndexCase(Table.RECORD.name, hera));
        assertEquals(ImmutableSet.of(vtag1.getId()), idxConf.getRecordFilter()
                        .getIndexCase(Table.RECORD.name, zeus).getVersionTags());

        //
        // Test boolean field
        //
        Record trueRecord = repository.getDefaultTable().recordBuilder()
                .id("record")
                .recordType(new QName("ns1", "typeA"))
                .field(new QName("ns", "bool"), Boolean.TRUE)
                .build();

        Record falseRecord = repository.getDefaultTable().recordBuilder()
                .id("record")
                .recordType(new QName("ns1", "typeA"))
                .field(new QName("ns", "bool"), Boolean.FALSE)
                .build();

        assertNull(idxConf.getRecordFilter().getIndexCase(Table.RECORD.name, falseRecord));
        assertEquals(ImmutableSet.of(vtag2.getId()),
                idxConf.getRecordFilter().getIndexCase(Table.RECORD.name, trueRecord).getVersionTags());
    }
View Full Code Here

                "xmlns:ns1='ns1' xmlns:ns='ns'",
                Lists.newArrayList("field='ns:bool!=true' vtags='vtag1'"),
                Collections.<String>emptyList()
        );

        LilyIndexerConf idxConf = LilyIndexerConfBuilder.build(new ByteArrayInputStream(conf.getBytes()), repository);

        Record trueRecord = repository.getDefaultTable().recordBuilder()
                .id("record")
                .recordType(new QName("ns1", "typeA"))
                .field(new QName("ns", "bool"), Boolean.TRUE)
                .build();

        Record falseRecord = repository.getDefaultTable().recordBuilder()
                .id("record")
                .recordType(new QName("ns1", "typeA"))
                .field(new QName("ns", "bool"), Boolean.FALSE)
                .build();

        Record nullRecord = repository.getDefaultTable().recordBuilder()
                .id("record")
                .recordType(new QName("ns1", "typeA"))
                .build();

        assertNull(idxConf.getRecordFilter().getIndexCase(Table.RECORD.name, trueRecord));

        // false and null field value are both treated as being not equal to true
        assertNotNull(idxConf.getRecordFilter().getIndexCase(Table.RECORD.name, falseRecord));
        assertNotNull(idxConf.getRecordFilter().getIndexCase(Table.RECORD.name, nullRecord));
    }
View Full Code Here

                        "variant='prop1,prop2=artemis' vtags='vtag1'",
                        "variant='prop1,prop2,*' vtags='vtag2'"),
                Collections.<String>emptyList()
        );

        LilyIndexerConf idxConf = LilyIndexerConfBuilder.build(new ByteArrayInputStream(conf.getBytes()), repository);

        //
        // Record with exactly two properties should be matched by first rule
        //
        Record recordProp1Prop2 = repository.getDefaultTable().recordBuilder()
                .id("record", ImmutableMap.of("prop1", "val1", "prop2", "artemis"))
                .recordType(new QName("ns1", "typeA"))
                .field(new QName("ns", "string"), "something")
                .build();

        assertEquals(Sets.newHashSet(vtag1.getId()),
                idxConf.getRecordFilter().getIndexCase(Table.RECORD.name, recordProp1Prop2).getVersionTags());

        //
        // Record with more properties than prop1 & prop2 should be matched by second rule
        //
        Record recordProp1Prop2Prop3 = repository.getDefaultTable().recordBuilder()
                .id("record", ImmutableMap.of("prop1", "val1", "prop2", "artemis", "prop3", "val3"))
                .recordType(new QName("ns1", "typeA"))
                .field(new QName("ns", "string"), "something")
                .build();

        assertEquals(Sets.newHashSet(vtag2.getId()),
                idxConf.getRecordFilter().getIndexCase(Table.RECORD.name, recordProp1Prop2Prop3).getVersionTags());

        //
        // Record with one prop should not be matched by any rules
        //
        Record recordProp1 = repository.getDefaultTable().recordBuilder()
                .id("record", ImmutableMap.of("prop1", "val1"))
                .recordType(new QName("ns1", "typeA"))
                .field(new QName("ns", "string"), "something")
                .build();

        assertNull(idxConf.getRecordFilter().getIndexCase(Table.RECORD.name, recordProp1));
    }
View Full Code Here

                "xmlns:ns1='ns1' xmlns:ns='ns'",
                Lists.newArrayList("variant='' vtags='vtag1'"),
                Collections.<String>emptyList()
        );

        LilyIndexerConf idxConf = LilyIndexerConfBuilder.build(new ByteArrayInputStream(conf.getBytes()), repository);

        // An empty variant expression should only match record without variant properties
        Record recordProp1 = repository.getDefaultTable().recordBuilder()
                .id("record", ImmutableMap.of("prop1", "val1"))
                .recordType(new QName("ns1", "typeA"))
                .field(new QName("ns", "string"), "something")
                .build();

        assertNull(idxConf.getRecordFilter().getIndexCase(Table.RECORD.name, recordProp1));

        Record record = repository.getDefaultTable().recordBuilder()
                .id("record")
                .recordType(new QName("ns1", "typeA"))
                .field(new QName("ns", "string"), "something")
                .build();

        assertNotNull(idxConf.getRecordFilter().getIndexCase(Table.RECORD.name, record));
    }
View Full Code Here

                "xmlns:ns1='ns1' xmlns:ns='ns'",
                Lists.newArrayList("vtags='vtag1'"),
                Collections.<String>emptyList()
        );

        LilyIndexerConf idxConf = LilyIndexerConfBuilder.build(new ByteArrayInputStream(conf.getBytes()), repository);

        // There are no conditions on variant properties, so a record id with variant properties should pass
        Record recordProp1 = repository.getDefaultTable().recordBuilder()
                .id("record", ImmutableMap.of("prop1", "val1"))
                .recordType(new QName("ns1", "typeA"))
                .field(new QName("ns", "string"), "something")
                .build();

        assertNotNull(idxConf.getRecordFilter().getIndexCase(Table.RECORD.name, recordProp1));
    }
View Full Code Here

                "xmlns:ns1='ns1'",
                Lists.newArrayList("recordType='*:typeA' vtags='vtag1'"),
                Lists.newArrayList("recordType='ns2:*'")
        );

        LilyIndexerConf idxConf = LilyIndexerConfBuilder.build(new ByteArrayInputStream(conf.getBytes()), repository);

        Record recordNs1TypeA = newRecordOfType(new QName("ns1", "typeA"));
        Record recordNs2TypeA = newRecordOfType(new QName("ns2", "typeA"));

        assertNotNull(idxConf.getRecordFilter().getIndexCase(Table.RECORD.name, recordNs1TypeA));
        assertNull(idxConf.getRecordFilter().getIndexCase(Table.RECORD.name, recordNs2TypeA));
    }
View Full Code Here

TOP

Related Classes of org.lilyproject.indexer.model.indexerconf.LilyIndexerConf

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.