Search in sources :

Example 26 with Entity

use of com.google.cloud.videointelligence.v1p3beta1.Entity in project osmosis by openstreetmap.

the class ChangeDeriverTest method rightEmpty.

/**
 * Deriving change with an empty right input should yield
 * a change with creates only.
 *
 * @throws Exception if something goes wrong.
 */
@Test
public void rightEmpty() throws Exception {
    // Cannot be tested with file comparison as the derived
    // change contains deletes which have a current timestamp
    // that cannot be reliably predicted.
    // Therefore, check all relevant attributes manually.
    ChangeDeriver deriver = new ChangeDeriver(1);
    RunnableSource left = new XmlReader(dataUtils.createDataFile("v0_6/derive_change/simple.osm"), true, CompressionMethod.None);
    RunnableSource right = new EmptyReader();
    SinkChangeInspector result = RunTaskUtilities.run(deriver, left, right);
    List<ChangeContainer> changes = result.getProcessedChanges();
    Assert.assertEquals(3, changes.size());
    for (ChangeContainer changeContainer : changes) {
        Assert.assertEquals(ChangeAction.Delete, changeContainer.getAction());
    }
    Entity e;
    e = changes.get(0).getEntityContainer().getEntity();
    Assert.assertEquals(EntityType.Node, e.getType());
    Assert.assertEquals(10, e.getId());
    Assert.assertEquals(34, e.getVersion());
    e = changes.get(1).getEntityContainer().getEntity();
    Assert.assertEquals(EntityType.Way, e.getType());
    Assert.assertEquals(100, e.getId());
    Assert.assertEquals(56, e.getVersion());
    e = changes.get(2).getEntityContainer().getEntity();
    Assert.assertEquals(EntityType.Relation, e.getType());
    Assert.assertEquals(1000, e.getId());
    Assert.assertEquals(78, e.getVersion());
}
Also used : SinkChangeInspector(org.openstreetmap.osmosis.testutil.v0_6.SinkChangeInspector) Entity(org.openstreetmap.osmosis.core.domain.v0_6.Entity) ChangeContainer(org.openstreetmap.osmosis.core.container.v0_6.ChangeContainer) XmlReader(org.openstreetmap.osmosis.xml.v0_6.XmlReader) RunnableSource(org.openstreetmap.osmosis.core.task.v0_6.RunnableSource) EmptyReader(org.openstreetmap.osmosis.core.misc.v0_6.EmptyReader) AbstractDataTest(org.openstreetmap.osmosis.testutil.AbstractDataTest) Test(org.junit.Test)

Example 27 with Entity

use of com.google.cloud.videointelligence.v1p3beta1.Entity in project osmosis by openstreetmap.

the class EntityHistoryListReader method next.

/**
 * {@inheritDoc}
 */
@Override
public List<ChangeContainer> next() {
    List<ChangeContainer> changeList;
    Entity peekEntity;
    long currentId;
    EntityType currentEntityType;
    // Get the next change from the underlying stream.
    peekEntity = sourceIterator.peekNext().getEntityContainer().getEntity();
    currentId = peekEntity.getId();
    currentEntityType = peekEntity.getType();
    // Loop until all history values for the current element are exhausted.
    changeList = new ArrayList<ChangeContainer>();
    while (sourceIterator.hasNext()) {
        ChangeContainer tmpChangeContainer = sourceIterator.peekNext();
        // Break out of the loop when we reach the next entity in the stream.
        if (currentId != tmpChangeContainer.getEntityContainer().getEntity().getId() || !currentEntityType.equals(tmpChangeContainer.getEntityContainer().getEntity().getType())) {
            break;
        }
        // We want the value that we have already peeked from the iterator, so remove it from the iterator.
        sourceIterator.next();
        // Add the change to the result list.
        changeList.add(tmpChangeContainer);
    }
    return changeList;
}
Also used : EntityType(org.openstreetmap.osmosis.core.domain.v0_6.EntityType) Entity(org.openstreetmap.osmosis.core.domain.v0_6.Entity) ChangeContainer(org.openstreetmap.osmosis.core.container.v0_6.ChangeContainer)

Example 28 with Entity

use of com.google.cloud.videointelligence.v1p3beta1.Entity in project osmosis by openstreetmap.

the class PostgreSqlChangeWriter method process.

/**
 * {@inheritDoc}
 */
public void process(ChangeContainer change) {
    ChangeAction action;
    initialize();
    // Verify that the schema version is supported.
    schemaVersionValidator.validateVersion(PostgreSqlVersionConstants.SCHEMA_VERSION);
    action = change.getAction();
    if (!actionWriterMap.containsKey(action)) {
        throw new OsmosisRuntimeException("The action " + action + " is unrecognized.");
    }
    final Entity entity = change.getEntityContainer().getEntity();
    this.appliedChangeSets.add(entity.getChangesetId());
    this.earliestTimestamp = Math.min(this.earliestTimestamp, entity.getTimestamp().getTime());
    this.latestTimestamp = Math.max(this.latestTimestamp, entity.getTimestamp().getTime());
    final String name = entity.getType().name() + "-" + action.name();
    final int count = modifications.getOrDefault(name, 0) + 1;
    modifications.put(name, count);
    // Process the entity using the action writer appropriate for the change
    // action.
    change.getEntityContainer().process(actionWriterMap.get(action));
}
Also used : Entity(org.openstreetmap.osmosis.core.domain.v0_6.Entity) ChangeAction(org.openstreetmap.osmosis.core.task.common.ChangeAction) OsmosisRuntimeException(org.openstreetmap.osmosis.core.OsmosisRuntimeException)

Example 29 with Entity

use of com.google.cloud.videointelligence.v1p3beta1.Entity in project entity-service by hypertrace.

the class EntityDataCachingClientTest method createOrUpdateEventuallyThrottlesAndMergesTheUpdateRequests.

@Test
void createOrUpdateEventuallyThrottlesAndMergesTheUpdateRequests() {
    // Just reflect entities in this test
    this.possibleResponseEntities = Collections.emptyList();
    Entity firstEntity = this.defaultResponseEntity.toBuilder().setEntityName("first name").putAttributes("key1", createAttribute("value1-1")).putAttributes("key2", createAttribute("value2-1")).build();
    Entity secondEntity = this.defaultResponseEntity.toBuilder().setEntityName("second name").putAttributes("key2", createAttribute("value2-2")).build();
    Entity thirdEntity = this.defaultResponseEntity.toBuilder().setEntityName("third name").putAttributes("key3", createAttribute("value3-3")).build();
    this.dataClient.createOrUpdateEntityEventually(REQUEST_CONTEXT, firstEntity, UpsertCondition.getDefaultInstance(), Duration.ofMillis(1000));
    testScheduler.advanceTimeBy(300, TimeUnit.MILLISECONDS);
    this.dataClient.createOrUpdateEntityEventually(REQUEST_CONTEXT, secondEntity, UpsertCondition.getDefaultInstance(), Duration.ofMillis(200));
    testScheduler.advanceTimeBy(150, TimeUnit.MILLISECONDS);
    this.dataClient.createOrUpdateEntityEventually(REQUEST_CONTEXT, thirdEntity, UpsertCondition.getDefaultInstance(), Duration.ofMillis(5000));
    testScheduler.advanceTimeBy(49, TimeUnit.MILLISECONDS);
    // All 3 should complete at 500ms (we're currently at 499ms)
    verifyNoInteractions(this.mockDataService);
    testScheduler.advanceTimeBy(1, TimeUnit.MILLISECONDS);
    verify(this.mockDataService, times(1)).mergeAndUpsertEntity(eq(MergeAndUpsertEntityRequest.newBuilder().setEntity(Entity.newBuilder().setEntityId(thirdEntity.getEntityId()).setEntityType(thirdEntity.getEntityType()).setEntityName(thirdEntity.getEntityName()).putAttributes("key1", createAttribute("value1-1")).putAttributes("key2", createAttribute("value2-2")).putAttributes("key3", createAttribute("value3-3")).build()).setUpsertCondition(UpsertCondition.getDefaultInstance()).build()), any());
}
Also used : Entity(org.hypertrace.entity.data.service.v1.Entity) Test(org.junit.jupiter.api.Test)

Example 30 with Entity

use of com.google.cloud.videointelligence.v1p3beta1.Entity in project entity-service by hypertrace.

the class EntityKeyTest method matchesSameEntityIdSameRequestContext.

@Test
void matchesSameEntityIdSameRequestContext() {
    RequestContext matchingContext = RequestContext.forTenantId(TENANT_ID_1);
    // Change some attributes to make sure it's not a deep compare
    Entity matchingEntity = this.entityV2.toBuilder().clearAttributes().build();
    assertEquals(new EntityKey(REQUEST_CONTEXT_1, this.entityV2), new EntityKey(matchingContext, matchingEntity));
}
Also used : Entity(org.hypertrace.entity.data.service.v1.Entity) RequestContext(org.hypertrace.core.grpcutils.context.RequestContext) Test(org.junit.jupiter.api.Test)

Aggregations

Entity (org.hypertrace.entity.data.service.v1.Entity)110 LivingEntity (org.bukkit.entity.LivingEntity)95 Test (org.junit.jupiter.api.Test)95 SkinnableEntity (net.citizensnpcs.npc.skin.SkinnableEntity)88 net.minecraft.world.entity (net.minecraft.world.entity)40 org.bukkit.entity (org.bukkit.entity)40 Entity (com.google.datastore.v1.Entity)33 ArrayList (java.util.ArrayList)33 Location (org.bukkit.Location)33 EnrichedEntity (org.hypertrace.entity.data.service.v1.EnrichedEntity)32 Event (org.hypertrace.core.datamodel.Event)27 AttributeValue (org.hypertrace.core.datamodel.AttributeValue)22 BackendInfo (org.hypertrace.traceenricher.enrichment.enrichers.resolver.backend.BackendInfo)21 Mob (net.minecraft.world.entity.Mob)20 NPCHolder (net.citizensnpcs.npc.ai.NPCHolder)18 Entity (net.minecraft.server.v1_8_R3.Entity)18 AnnotateVideoProgress (com.google.cloud.videointelligence.v1.AnnotateVideoProgress)17 AnnotateVideoRequest (com.google.cloud.videointelligence.v1.AnnotateVideoRequest)17 AnnotateVideoResponse (com.google.cloud.videointelligence.v1.AnnotateVideoResponse)17 Entity (com.google.cloud.videointelligence.v1.Entity)17