use of org.hypertrace.entity.data.service.v1.Entity in project Denizen-For-Bukkit by DenizenScript.
the class WorldHelper_v1_8_R3 method setWorldAccess.
@Override
public void setWorldAccess(World world, final WorldAccess worldAccess) {
if (worldAccessMap.containsKey(world)) {
removeWorldAccess(world);
}
IWorldAccess nmsWorldAccess = new IWorldAccess() {
@Override
public void a(BlockPosition blockPosition) {
}
@Override
public void b(BlockPosition blockPosition) {
}
@Override
public void a(int i, int i1, int i2, int i3, int i4, int i5) {
}
@Override
public void a(String s, double v, double v1, double v2, float v3, float v4) {
}
@Override
public void a(EntityHuman entityHuman, String s, double v, double v1, double v2, float v3, float v4) {
}
@Override
public void a(int i, boolean b, double v, double v1, double v2, double v3, double v4, double v5, int... ints) {
}
@Override
public void a(Entity entity) {
}
@Override
public void b(Entity entity) {
worldAccess.despawn(entity.getBukkitEntity());
}
@Override
public void a(String s, BlockPosition blockPosition) {
}
@Override
public void a(int i, BlockPosition blockPosition, int i1) {
}
@Override
public void a(EntityHuman entityHuman, int i, BlockPosition blockPosition, int i1) {
}
@Override
public void b(int i, BlockPosition blockPosition, int i1) {
}
};
worldAccessMap.put(world, nmsWorldAccess);
((CraftWorld) world).getHandle().addIWorldAccess(nmsWorldAccess);
}
use of org.hypertrace.entity.data.service.v1.Entity in project GeoGig by boundlessgeo.
the class OSMExport method getFeatures.
private Iterator<EntityContainer> getFeatures(String ref) {
Optional<ObjectId> id = geogig.command(RevParse.class).setRefSpec(ref).call();
if (!id.isPresent()) {
return Iterators.emptyIterator();
}
LsTreeOp op = geogig.command(LsTreeOp.class).setStrategy(Strategy.DEPTHFIRST_ONLY_FEATURES).setReference(ref);
if (bbox != null) {
final Envelope env;
try {
env = new Envelope(Double.parseDouble(bbox.get(0)), Double.parseDouble(bbox.get(2)), Double.parseDouble(bbox.get(1)), Double.parseDouble(bbox.get(3)));
} catch (NumberFormatException e) {
throw new IllegalArgumentException("Wrong bbox definition");
}
Predicate<Bounded> filter = new Predicate<Bounded>() {
@Override
public boolean apply(final Bounded bounded) {
boolean intersects = bounded.intersects(env);
return intersects;
}
};
op.setBoundsFilter(filter);
}
Iterator<NodeRef> iterator = op.call();
final EntityConverter converter = new EntityConverter();
Function<NodeRef, EntityContainer> function = new Function<NodeRef, EntityContainer>() {
@Override
@Nullable
public EntityContainer apply(@Nullable NodeRef ref) {
RevFeature revFeature = geogig.command(RevObjectParse.class).setObjectId(ref.objectId()).call(RevFeature.class).get();
SimpleFeatureType featureType;
if (ref.path().startsWith(OSMUtils.NODE_TYPE_NAME)) {
featureType = OSMUtils.nodeType();
} else {
featureType = OSMUtils.wayType();
}
SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(featureType);
RevFeatureType revFeatureType = RevFeatureTypeImpl.build(featureType);
List<PropertyDescriptor> descriptors = revFeatureType.sortedDescriptors();
ImmutableList<Optional<Object>> values = revFeature.getValues();
for (int i = 0; i < descriptors.size(); i++) {
PropertyDescriptor descriptor = descriptors.get(i);
Optional<Object> value = values.get(i);
featureBuilder.set(descriptor.getName(), value.orNull());
}
SimpleFeature feature = featureBuilder.buildFeature(ref.name());
Entity entity = converter.toEntity(feature, null);
EntityContainer container;
if (entity instanceof Node) {
container = new NodeContainer((Node) entity);
} else {
container = new WayContainer((Way) entity);
}
return container;
}
};
return Iterators.transform(iterator, function);
}
use of org.hypertrace.entity.data.service.v1.Entity in project beam by apache.
the class EntityToRowRowToEntityTest method testRowToEntityConverterWithoutKey.
@Test
public void testRowToEntityConverterWithoutKey() {
Schema schemaWithoutKey = Schema.builder().addFields(SCHEMA.getFields().stream().filter(f -> !f.getName().equals("__key__")).collect(Collectors.toList())).build();
Row rowWithoutKey = Row.withSchema(schemaWithoutKey).addValues(schemaWithoutKey.getFieldNames().stream().map(ROW::getValue).collect(Collectors.toList())).build();
PCollection<Entity> result = pipeline.apply(Create.of(rowWithoutKey)).setRowSchema(schemaWithoutKey).apply(RowToEntity.createTest(UUID_VALUE, "__key__", KIND));
PAssert.that(result).containsInAnyOrder(ENTITY);
pipeline.run().waitUntilFinish();
}
use of org.hypertrace.entity.data.service.v1.Entity in project beam by apache.
the class EntityToRowRowToEntityTest method testEntityToRowConverterWithoutKey.
@Test
public void testEntityToRowConverterWithoutKey() {
Schema schemaWithoutKey = Schema.builder().addFields(SCHEMA.getFields().stream().filter(f -> !f.getName().equals("__key__")).collect(Collectors.toList())).build();
Row rowWithoutKey = Row.withSchema(schemaWithoutKey).addValues(schemaWithoutKey.getFieldNames().stream().map(ROW::getValue).collect(Collectors.toList())).build();
PCollection<Row> result = pipeline.apply(Create.of(ENTITY)).apply(EntityToRow.create(schemaWithoutKey, DEFAULT_KEY_FIELD));
PAssert.that(result).containsInAnyOrder(rowWithoutKey);
pipeline.run().waitUntilFinish();
}
use of org.hypertrace.entity.data.service.v1.Entity in project beam by apache.
the class DatastoreV1Test method testReadFnRetriesErrors.
/**
* Tests that {@link ReadFn} retries after an error.
*/
@Test
public void testReadFnRetriesErrors() throws Exception {
// An empty query to read entities.
Query query = Query.newBuilder().setLimit(Int32Value.newBuilder().setValue(1)).build();
// Use mockResponseForQuery to generate results.
when(mockDatastore.runQuery(any(RunQueryRequest.class))).thenThrow(new DatastoreException("RunQuery", Code.DEADLINE_EXCEEDED, "", null)).thenAnswer(invocationOnMock -> {
Query q = ((RunQueryRequest) invocationOnMock.getArguments()[0]).getQuery();
return mockResponseForQuery(q);
});
ReadFn readFn = new ReadFn(V_1_OPTIONS, mockDatastoreFactory);
DoFnTester<Query, Entity> doFnTester = DoFnTester.of(readFn);
doFnTester.setCloningBehavior(CloningBehavior.DO_NOT_CLONE);
doFnTester.processBundle(query);
verifyMetricWasSet("BatchDatastoreRead", "ok", NAMESPACE, 1);
verifyMetricWasSet("BatchDatastoreRead", "unknown", NAMESPACE, 1);
}
Aggregations