Search in sources :

Example 91 with Entity

use of net.minecraft.server.v1_8_R1.Entity in project DataflowTemplates by GoogleCloudPlatform.

the class BigQueryConvertersTest method testAvroToEntityNoIdColumn.

/**
 * Tests that {@link BigQueryConverters.AvroToEntity} creates an Entity without a key when the
 * unique name column is missing.
 */
@Test
public void testAvroToEntityNoIdColumn() throws Exception {
    // Create test data
    List<TableFieldSchema> fields = new ArrayList<>();
    fields.add(new TableFieldSchema().setName(shortStringField).setType("STRING"));
    TableSchema bqSchema = new TableSchema().setFields(fields);
    Record record = generateSingleFieldAvroRecord(shortStringField, "string", shortStringFieldDesc, shortStringFieldValue);
    SchemaAndRecord inputBqData = new SchemaAndRecord(record, bqSchema);
    // Run the test
    Entity outputEntity = converter.apply(inputBqData);
    assertTrue(!outputEntity.hasKey());
}
Also used : Entity(com.google.datastore.v1.Entity) AvroToEntity(com.google.cloud.teleport.templates.common.BigQueryConverters.AvroToEntity) TableSchema(com.google.api.services.bigquery.model.TableSchema) ArrayList(java.util.ArrayList) Record(org.apache.avro.generic.GenericData.Record) SchemaAndRecord(org.apache.beam.sdk.io.gcp.bigquery.SchemaAndRecord) TableFieldSchema(com.google.api.services.bigquery.model.TableFieldSchema) SchemaAndRecord(org.apache.beam.sdk.io.gcp.bigquery.SchemaAndRecord) Test(org.junit.Test)

Example 92 with Entity

use of net.minecraft.server.v1_8_R1.Entity in project DataflowTemplates by GoogleCloudPlatform.

the class BigQueryConvertersTest method testAvroToEntityDefaultNamespace.

/**
 * Tests that {@link BigQueryConverters.AvroToEntity} creates an Entity with a default namespace
 * when the namespace is not specified.
 */
@Test
public void testAvroToEntityDefaultNamespace() throws Exception {
    // Create test data
    List<TableFieldSchema> fields = new ArrayList<>();
    fields.add(new TableFieldSchema().setName(idField).setType("STRING"));
    fields.add(new TableFieldSchema().setName(shortStringField).setType("STRING"));
    TableSchema bqSchema = new TableSchema().setFields(fields);
    Schema avroSchema = new Schema.Parser().parse(String.format(avroSchemaTemplate, new StringBuilder().append(String.format(avroFieldTemplate, idField, "int", idFieldDesc)).append(",").append(generateShortStringField()).toString()));
    GenericRecordBuilder builder = new GenericRecordBuilder(avroSchema);
    builder.set(idField, 1);
    builder.set(shortStringField, shortStringFieldValue);
    Record record = builder.build();
    SchemaAndRecord inputBqData = new SchemaAndRecord(record, bqSchema);
    // Run the test
    AvroToEntity noNamespaceConverter = AvroToEntity.newBuilder().setEntityKind(entityKind).setUniqueNameColumn(uniqueNameColumn).build();
    Entity outputEntity = noNamespaceConverter.apply(inputBqData);
    // Assess results
    assertTrue(outputEntity.hasKey());
    assertEquals("", outputEntity.getKey().getPartitionId().getNamespaceId());
}
Also used : Entity(com.google.datastore.v1.Entity) AvroToEntity(com.google.cloud.teleport.templates.common.BigQueryConverters.AvroToEntity) TableSchema(com.google.api.services.bigquery.model.TableSchema) TableSchema(com.google.api.services.bigquery.model.TableSchema) Schema(org.apache.avro.Schema) TableFieldSchema(com.google.api.services.bigquery.model.TableFieldSchema) ArrayList(java.util.ArrayList) GenericRecordBuilder(org.apache.avro.generic.GenericRecordBuilder) Record(org.apache.avro.generic.GenericData.Record) SchemaAndRecord(org.apache.beam.sdk.io.gcp.bigquery.SchemaAndRecord) TableFieldSchema(com.google.api.services.bigquery.model.TableFieldSchema) SchemaAndRecord(org.apache.beam.sdk.io.gcp.bigquery.SchemaAndRecord) AvroToEntity(com.google.cloud.teleport.templates.common.BigQueryConverters.AvroToEntity) Test(org.junit.Test)

Example 93 with Entity

use of net.minecraft.server.v1_8_R1.Entity in project DataflowTemplates by GoogleCloudPlatform.

the class BigQueryConvertersTest method testAvroToEntityNullIdColumn.

/**
 * Tests that {@link BigQueryConverters.AvroToEntity} creates an Entity without a key when the
 * unique name column is null.
 */
@Test
public void testAvroToEntityNullIdColumn() throws Exception {
    // Create test data
    List<TableFieldSchema> fields = new ArrayList<>();
    fields.add(new TableFieldSchema().setName(idField).setType("STRING"));
    fields.add(new TableFieldSchema().setName(shortStringField).setType("STRING"));
    TableSchema bqSchema = new TableSchema().setFields(fields);
    Schema avroSchema = new Schema.Parser().parse(String.format(avroSchemaTemplate, new StringBuilder().append(String.format(avroFieldTemplate, idField, "null", idFieldDesc)).append(",").append(generateShortStringField()).toString()));
    GenericRecordBuilder builder = new GenericRecordBuilder(avroSchema);
    builder.set(idField, null);
    builder.set(shortStringField, shortStringFieldValue);
    Record record = builder.build();
    SchemaAndRecord inputBqData = new SchemaAndRecord(record, bqSchema);
    // Run the test
    Entity outputEntity = converter.apply(inputBqData);
    assertTrue(!outputEntity.hasKey());
}
Also used : Entity(com.google.datastore.v1.Entity) AvroToEntity(com.google.cloud.teleport.templates.common.BigQueryConverters.AvroToEntity) TableSchema(com.google.api.services.bigquery.model.TableSchema) TableSchema(com.google.api.services.bigquery.model.TableSchema) Schema(org.apache.avro.Schema) TableFieldSchema(com.google.api.services.bigquery.model.TableFieldSchema) ArrayList(java.util.ArrayList) GenericRecordBuilder(org.apache.avro.generic.GenericRecordBuilder) Record(org.apache.avro.generic.GenericData.Record) SchemaAndRecord(org.apache.beam.sdk.io.gcp.bigquery.SchemaAndRecord) TableFieldSchema(com.google.api.services.bigquery.model.TableFieldSchema) SchemaAndRecord(org.apache.beam.sdk.io.gcp.bigquery.SchemaAndRecord) Test(org.junit.Test)

Example 94 with Entity

use of net.minecraft.server.v1_8_R1.Entity in project DataflowTemplates by GoogleCloudPlatform.

the class BigQueryToDatastore method main.

/**
 * Runs a pipeline which reads data from BigQuery and writes it to Datastore.
 *
 * @param args arguments to the pipeline
 */
public static void main(String[] args) {
    BigQueryToDatastoreOptions options = PipelineOptionsFactory.fromArgs(args).withValidation().as(BigQueryToDatastoreOptions.class);
    Pipeline pipeline = Pipeline.create(options);
    // Read from BigQuery and convert data to Datastore Entity format with 2 possible outcomes,
    // success or failure, based on the possibility to create valid Entity keys from BQ data
    TupleTag<Entity> successTag = new TupleTag<Entity>() {
    };
    TupleTag<String> failureTag = new TupleTag<String>("failures") {
    };
    PCollectionTuple entities = pipeline.apply(BigQueryToEntity.newBuilder().setQuery(options.getReadQuery()).setUniqueNameColumn(options.getReadIdColumn()).setEntityKind(options.getDatastoreWriteEntityKind()).setNamespace(options.getDatastoreWriteNamespace()).setSuccessTag(successTag).setFailureTag(failureTag).build());
    // Write on GCS data that could not be converted to valid Datastore entities
    entities.apply(LogErrors.newBuilder().setErrorWritePath(options.getInvalidOutputPath()).setErrorTag(failureTag).build());
    // Write valid entities to Datastore
    TupleTag<String> errorTag = new TupleTag<String>("errors") {
    };
    entities.get(successTag).apply(WriteEntities.newBuilder().setProjectId(options.getDatastoreWriteProjectId()).setHintNumWorkers(options.getDatastoreHintNumWorkers()).setErrorTag(errorTag).build()).apply(LogErrors.newBuilder().setErrorWritePath(options.getErrorWritePath()).setErrorTag(errorTag).build());
    pipeline.run();
}
Also used : BigQueryToEntity(com.google.cloud.teleport.templates.common.BigQueryConverters.BigQueryToEntity) Entity(com.google.datastore.v1.Entity) TupleTag(org.apache.beam.sdk.values.TupleTag) PCollectionTuple(org.apache.beam.sdk.values.PCollectionTuple) Pipeline(org.apache.beam.sdk.Pipeline)

Example 95 with Entity

use of net.minecraft.server.v1_8_R1.Entity in project SilkSpawners by timbru31.

the class NMSHandler method spawnEntity.

@Override
public void spawnEntity(final org.bukkit.World w, final String entityID, final double x, final double y, final double z, final Player player) {
    final NBTTagCompound tag = new NBTTagCompound();
    tag.setString("id", entityID);
    final World world = ((CraftWorld) w).getHandle();
    final Entity entity = EntityTypes.a(tag, world);
    if (entity == null) {
        Bukkit.getLogger().warning("[SilkSpawners] Failed to spawn, falling through. You should report this (entity == null)!");
        return;
    }
    final float yaw = world.random.nextFloat() * (-180 - 180) + 180;
    entity.setPositionRotation(x, y, z, yaw, 0);
    world.addEntity(entity, SpawnReason.SPAWNER_EGG);
    final PacketPlayOutEntityHeadRotation rotation = new PacketPlayOutEntityHeadRotation(entity, (byte) yaw);
    ((CraftPlayer) player).getHandle().playerConnection.sendPacket(rotation);
}
Also used : Entity(net.minecraft.server.v1_12_R1.Entity) NBTTagCompound(net.minecraft.server.v1_12_R1.NBTTagCompound) PacketPlayOutEntityHeadRotation(net.minecraft.server.v1_12_R1.PacketPlayOutEntityHeadRotation) CraftPlayer(org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer) World(net.minecraft.server.v1_12_R1.World) CraftWorld(org.bukkit.craftbukkit.v1_12_R1.CraftWorld) CraftWorld(org.bukkit.craftbukkit.v1_12_R1.CraftWorld)

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 Entity (com.google.datastore.v1.Entity)33 ArrayList (java.util.ArrayList)32 net.minecraft.world.entity (net.minecraft.world.entity)32 org.bukkit.entity (org.bukkit.entity)32 EnrichedEntity (org.hypertrace.entity.data.service.v1.EnrichedEntity)32 Location (org.bukkit.Location)29 Event (org.hypertrace.core.datamodel.Event)27 AttributeValue (org.hypertrace.core.datamodel.AttributeValue)22 BackendInfo (org.hypertrace.traceenricher.enrichment.enrichers.resolver.backend.BackendInfo)21 Entity (net.minecraft.server.v1_16_R3.Entity)19 NPCHolder (net.citizensnpcs.npc.ai.NPCHolder)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 VideoAnnotationResults (com.google.cloud.videointelligence.v1.VideoAnnotationResults)17