Package org.lilyproject.repository.api

Examples of org.lilyproject.repository.api.RecordId


    }

    @Test
    public void testIngest() throws InterruptedException, RepositoryException, IOException {
        Record record = mock(Record.class);
        RecordId recordId = mock(RecordId.class);
        when(record.getId()).thenReturn(recordId);
        Put expectedPut = mock(Put.class);

        configurePutCreation(record, expectedPut);
View Full Code Here


    @Test
    public void testIngest_NoIdOnRecord() throws InterruptedException, RepositoryException, IOException {
        Record record = mock(Record.class);
        Put expectedPut = mock(Put.class);

        RecordId recordId = mock(RecordId.class);
        IdGenerator idGenerator = mock(IdGenerator.class);
        when(idGenerator.newRecordId()).thenReturn(recordId);
        when(hbaseRepository.getIdGenerator()).thenReturn(idGenerator);

        configurePutCreation(record, expectedPut);
View Full Code Here

    public void emptyDependencies() throws Exception {
        String idPrefix = newIdPrefix();

        final SchemaId dummyVtag = ids.getSchemaId(UUID.randomUUID());
        final SchemaId dummyField = ids.getSchemaId(UUID.randomUUID());
        final RecordId id1 = ids.newRecordId(idPrefix + "id1");

        final HashMap<DependencyEntry, Set<SchemaId>> empty =
                new HashMap<DependencyEntry, Set<SchemaId>>();
        derefMap.updateDependants(absId(id1), dummyVtag, empty);
View Full Code Here

        String idPrefix = newIdPrefix();

        final SchemaId dummyVtag = ids.getSchemaId(UUID.randomUUID());
        final SchemaId dependencyField = ids.getSchemaId(UUID.randomUUID());
        final SchemaId anotherField = ids.getSchemaId(UUID.randomUUID());
        final RecordId dependant = ids.newRecordId(idPrefix + idPrefix + "dependant");
        final RecordId dependency = ids.newRecordId(idPrefix + idPrefix + "dependency");
        final RecordId dependencyAfterUpdate = ids.newRecordId(idPrefix + idPrefix + "dependencyAfterUpdate");

        // the dependant depends on the dependencyField of the dependency
        final HashMap<DependencyEntry, Set<SchemaId>> dependencies =
                new HashMap<DependencyEntry, Set<SchemaId>>();
        dependencies.put(new DependencyEntry(absId(dependency)), Sets.newHashSet(dependencyField));
View Full Code Here

    @Test
    public void oneDependencyWithMoreDimensionedVariants() throws Exception {
        String idPrefix = newIdPrefix();

        final SchemaId dummyVtag = ids.getSchemaId(UUID.randomUUID());
        final RecordId dependant = ids.newRecordId(idPrefix + "master", ImmutableMap.of("bar", "x"));
        final RecordId dependency = ids.newRecordId(idPrefix + "master", ImmutableMap.of("bar", "x", "foo", "y"));

        // the dependant depends on the dependencyField of the dependency via a "+foo" dereferencing rule
        final HashMap<DependencyEntry, Set<SchemaId>> dependencies =
                new HashMap<DependencyEntry, Set<SchemaId>>();
        dependencies.put(new DependencyEntry(absId(dependency),
                ImmutableSet.of("foo")), Sets.<SchemaId>newHashSet());
        derefMap.updateDependants(absId(dependant), dummyVtag, dependencies);

        // consistency check
        final Set<DependencyEntry> found = derefMap.findDependencies(absId(dependant), dummyVtag);
        assertEquals(1, found.size());
        final DependencyEntry foundDependencyEntry = found.iterator().next();
        assertEquals(absId(ids.newRecordId(idPrefix + "master", ImmutableMap.of("bar", "x"))), foundDependencyEntry.getDependency());
        assertEquals(Sets.newHashSet("foo"), foundDependencyEntry.getMoreDimensionedVariants());

        // check that the dependant is found as only dependant of the dependency (without specifying a field)
        DependantRecordIdsIterator dependants = derefMap.findDependantsOf(absId(dependency));
        assertTrue(dependants.hasNext());
        assertEquals(absId(dependant), dependants.next());
        assertFalse(dependants.hasNext());

        // check that other records (which would in reality not yet exist at index time) that match the "+foo" rule
        // are returned as dependants of our dependant (such that in reality reindexation of the dependant happens)

        final RecordId shouldTriggerOurDependant =
                ids.newRecordId(idPrefix + "master", ImmutableMap.of("bar", "x", "foo", "another-value"));
        dependants = derefMap.findDependantsOf(absId(shouldTriggerOurDependant));
        assertTrue(dependants.hasNext());
        assertEquals(absId(dependant), dependants.next());
        assertFalse(dependants.hasNext());

        // doesn't have the foo property
        final RecordId shouldNotTriggerOurDependant1 = ids.newRecordId(idPrefix + "master", ImmutableMap.of("bar", "x"));
        assertFalse(derefMap.findDependantsOf(absId(shouldNotTriggerOurDependant1)).hasNext());

        // doesn't have the bar property
        final RecordId shouldNotTriggerOurDependant2 = ids.newRecordId(idPrefix + "master", ImmutableMap.of("foo", "x"));
        assertFalse(derefMap.findDependantsOf(absId(shouldNotTriggerOurDependant2)).hasNext());

        // wrong value for the bar property
        final RecordId shouldNotTriggerOurDependant3 =
                ids.newRecordId(idPrefix + "master", ImmutableMap.of("bar", "y", "foo", "another-value"));
        assertFalse(derefMap.findDependantsOf(absId(shouldNotTriggerOurDependant3)).hasNext());

        // additional unmatched property
        final RecordId shouldNotTriggerOurDependant4 =
                ids.newRecordId(idPrefix + "master", ImmutableMap.of("bar", "x", "foo", "another-value", "baz", "z"));
        assertFalse(derefMap.findDependantsOf(absId(shouldNotTriggerOurDependant4)).hasNext());

        // another master
        final RecordId shouldNotTriggerOurDependant5 =
                ids.newRecordId(idPrefix + "another-master", ImmutableMap.of("bar", "x", "foo", "another-value"));
        assertFalse(derefMap.findDependantsOf(absId(shouldNotTriggerOurDependant5)).hasNext());

        // wrong properties
        final RecordId shouldNotTriggerOurDependant6 = ids.newRecordId(idPrefix + "master", ImmutableMap.of("a", "b", "c", "d"));
        assertFalse(derefMap.findDependantsOf(absId(shouldNotTriggerOurDependant6)).hasNext());

        // no properties
        final RecordId shouldNotTriggerOurDependant7 = ids.newRecordId(idPrefix + "master", ImmutableMap.<String, String>of());
        assertFalse(derefMap.findDependantsOf(absId(shouldNotTriggerOurDependant7)).hasNext());
    }
View Full Code Here

        final SchemaId dummyVtag = ids.getSchemaId(UUID.randomUUID());
        final SchemaId linkField1 = ids.getSchemaId(UUID.randomUUID());
        final SchemaId linkField2 = ids.getSchemaId(UUID.randomUUID());
        final SchemaId field = ids.getSchemaId(UUID.randomUUID());
        final RecordId dependant = ids.newRecordId(idPrefix + "dependant");
        final RecordId dependency1 = ids.newRecordId(idPrefix + "dependency1");
        final RecordId dependency2 = ids.newRecordId(idPrefix + "dependency2");

        // scenario: dependant has linkField1 -> dependency1 which has linkField2 -> dependency2 which has field "field"
        final Map<DependencyEntry, Set<SchemaId>> dependencies =
                new HashMap<DependencyEntry, Set<SchemaId>>();
        // 1) dependant depends on dependency1 from which it uses linkField2
View Full Code Here

        final SchemaId dummyVtag = ids.getSchemaId(UUID.randomUUID());
        final SchemaId linkField1 = ids.getSchemaId(UUID.randomUUID());
        final SchemaId linkField2 = ids.getSchemaId(UUID.randomUUID());
        final SchemaId linkField3 = ids.getSchemaId(UUID.randomUUID());
        final RecordId dependant = ids.newRecordId(idPrefix + "dependant");
        final RecordId dependency1 = ids.newRecordId(idPrefix + "dependency1");
        final RecordId dependency2 = ids.newRecordId(idPrefix + "dependency2");
        final RecordId dependency3 = ids.newRecordId(idPrefix + "dependency3");

        // scenario: dependant has linkField1 -> dependency1 which has linkField2 -> dependency2 which has linkField3 -> dependency3
        final Map<DependencyEntry, Set<SchemaId>> dependencies =
                new HashMap<DependencyEntry, Set<SchemaId>>();
        // 1) dependant depends on dependency1 from which it uses linkField2
View Full Code Here

        String idPrefix = newIdPrefix();

        final SchemaId dummyVtag = ids.getSchemaId(UUID.randomUUID());
        final SchemaId linkField1 = ids.getSchemaId(UUID.randomUUID());
        final SchemaId field = ids.getSchemaId(UUID.randomUUID());
        final RecordId dependant = ids.newRecordId(idPrefix + "dependant");
        final RecordId dependantWithProp1 = ids.newRecordId(idPrefix + "dependant", ImmutableMap.of("prop1", "x"));
        final RecordId dependency1 = ids.newRecordId(idPrefix + "dependency1");
        final RecordId dependency1WithProp2 = ids.newRecordId(idPrefix + "dependency1", ImmutableMap.of("prop2", "y"));

        // scenario: dependant depends on all dependant +prop1 records. One such a record (dependantWithProp1) exists
        // with a linkField1 pointing to dependency1. Via the +prop2 rule, we end up with all dependency1 + prop2
        // records, of which there is one instance (dependency1WithProp2). Of this instance, we use the field "field".
        final Map<DependencyEntry, Set<SchemaId>> dependencies =
                new HashMap<DependencyEntry, Set<SchemaId>>();
        // 1) dependant depends on all similar with prop1, of which it uses linkField1
        dependencies
                .put(new DependencyEntry(absId(dependant), ImmutableSet.of("prop1")), Sets.newHashSet(linkField1));
        // 2) dependant depends on dependency1WithProp2 (and all similar with prop2) from which it uses field "field"
        dependencies.put(new DependencyEntry(absId(dependency1WithProp2), ImmutableSet.of("prop2")),
                Sets.newHashSet(field));
        derefMap.updateDependants(absId(dependant), dummyVtag, dependencies);

        // consistency check
        final Set<DependencyEntry> found = derefMap.findDependencies(absId(dependant), dummyVtag);
        assertEquals(2, found.size());

        // check that the dependant is found as only dependant of the dependencies via the corresponding fields (in a few scenarios)

        // scenario1: as if a dependency1 with prop2=value is being created
        final RecordId someRecordLikeDependency1WithProp2 =
                ids.newRecordId(idPrefix + "dependency1", ImmutableMap.of("prop2", "value"));
        DependantRecordIdsIterator scenario1 =
                derefMap.findDependantsOf(absId(someRecordLikeDependency1WithProp2), field, dummyVtag);
        assertTrue(scenario1.hasNext());
        assertEquals(absId(dependant), scenario1.next());
        assertFalse(scenario1.hasNext());

        // scenario2: as if a new record like dependant is created with prop1=value
        final RecordId someRecordLikeDependantWithProp1 =
                ids.newRecordId(idPrefix + "dependant", ImmutableMap.of("prop1", "value"));
        DependantRecordIdsIterator scenario2 =
                derefMap.findDependantsOf(absId(someRecordLikeDependantWithProp1), linkField1, dummyVtag);
        assertTrue(scenario2.hasNext());
        assertEquals(absId(dependant), scenario2.next());
View Full Code Here

    public void multipleDependencies() throws Exception {
        String idPrefix = newIdPrefix();

        final SchemaId dummyVtag = ids.getSchemaId(UUID.randomUUID());
        final SchemaId dependencyField = ids.getSchemaId(UUID.randomUUID());
        final RecordId dependant = ids.newRecordId(idPrefix + "dependant");
        final RecordId dependency1 = ids.newRecordId(idPrefix + "dependency1");
        final RecordId dependency2 = ids.newRecordId(idPrefix + "dependency2");

        // the dependant depends on the dependencyField of the dependency1 and dependency2
        final HashMap<DependencyEntry, Set<SchemaId>> dependencies =
                new HashMap<DependencyEntry, Set<SchemaId>>();
        dependencies.put(new DependencyEntry(absId(dependency1)), Sets.newHashSet(dependencyField));
View Full Code Here

        String idPrefix = newIdPrefix();

        final SchemaId dummyVtag = ids.getSchemaId(UUID.randomUUID());
        final SchemaId dependencyField = ids.getSchemaId(UUID.randomUUID());

        final RecordId master = ids.newRecordId(idPrefix + "myrecord");
        final RecordId v1variant = ids.newRecordId(idPrefix + "myrecord", Collections.singletonMap("v1", "x"));
        final RecordId v1v2variant = ids.newRecordId(idPrefix + "myrecord", map("v1", "x", "v2", "y"));

        final HashMap<DependencyEntry, Set<SchemaId>> dependencies =
                new HashMap<DependencyEntry, Set<SchemaId>>();
        dependencies.put(new DependencyEntry(absId(master)), Sets.newHashSet(dependencyField));
        derefMap.updateDependants(absId(v1variant), dummyVtag, dependencies);
View Full Code Here

TOP

Related Classes of org.lilyproject.repository.api.RecordId

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.