java类com.google.common.collect.Sets的实例源码

TestDatasetSink.java 文件源码 项目:flume-release-1.7.0 阅读 41 收藏 0 点赞 0 评论 0
@Test
public void testDatasetUriOverridesOldConfig() throws EventDeliveryException {
  // CONFIG_KITE_DATASET_URI is still set, otherwise this will cause an error
  config.put(DatasetSinkConstants.CONFIG_KITE_REPO_URI, "bad uri");
  config.put(DatasetSinkConstants.CONFIG_KITE_DATASET_NAME, "");

  DatasetSink sink = sink(in, config);

  // run the sink
  sink.start();
  sink.process();
  sink.stop();

  Assert.assertEquals(
      Sets.newHashSet(expected),
      read(Datasets.load(FILE_DATASET_URI)));
  Assert.assertEquals("Should have committed", 0, remaining(in));
}
RouterCreateCommand.java 文件源码 项目:athena 阅读 22 收藏 0 点赞 0 评论 0
@Override
protected void execute() {
    RouterService service = get(RouterService.class);
    try {
        List<String> routes = new ArrayList<String>();
        Router router = new DefaultRouter(
                                          RouterId.valueOf(id),
                                          routerName,
                                          adminStateUp,
                                          status == null ? Status.ACTIVE
                                                        : Status.valueOf(status),
                                          distributed,
                                          null,
                                          VirtualPortId.portId(gatewayPortId),
                                          TenantId.tenantId(tenantId),
                                          routes);
        Set<Router> routerSet = Sets.newHashSet(router);
        service.createRouters(routerSet);
    } catch (Exception e) {
        print(null, e.getMessage());
    }
}
TestDatasetSink.java 文件源码 项目:flume-release-1.7.0 阅读 40 收藏 0 点赞 0 评论 0
@Test
public void testSerializedWithIncompatibleSchemasWithSavePolicy()
    throws EventDeliveryException {
  if (Datasets.exists(ERROR_DATASET_URI)) {
    Datasets.delete(ERROR_DATASET_URI);
  }
  config.put(DatasetSinkConstants.CONFIG_FAILURE_POLICY,
      DatasetSinkConstants.SAVE_FAILURE_POLICY);
  config.put(DatasetSinkConstants.CONFIG_KITE_ERROR_DATASET_URI,
      ERROR_DATASET_URI);
  final DatasetSink sink = sink(in, config);

  GenericRecordBuilder builder = new GenericRecordBuilder(
      INCOMPATIBLE_SCHEMA);
  GenericData.Record rec = builder.set("username", "koala").build();

  // We pass in a valid schema in the header, but an incompatible schema
  // was used to serialize the record
  Event badEvent = event(rec, INCOMPATIBLE_SCHEMA, SCHEMA_FILE, true);
  putToChannel(in, badEvent);

  // run the sink
  sink.start();
  sink.process();
  sink.stop();

  Assert.assertEquals("Good records should have been written",
      Sets.newHashSet(expected),
      read(Datasets.load(FILE_DATASET_URI)));
  Assert.assertEquals("Should not have rolled back", 0, remaining(in));
  Assert.assertEquals("Should have saved the bad event",
      Sets.newHashSet(AvroFlumeEvent.newBuilder()
        .setBody(ByteBuffer.wrap(badEvent.getBody()))
        .setHeaders(toUtf8Map(badEvent.getHeaders()))
        .build()),
      read(Datasets.load(ERROR_DATASET_URI, AvroFlumeEvent.class)));
}
Injectors.java 文件源码 项目:Elasticsearch 阅读 30 收藏 0 点赞 0 评论 0
/**
 * Returns a collection of all bindings of the given base type
 *
 * @param baseClass the base type of objects required
 * @return a set of objects returned from this injector
 */
public static Set<Binding<?>> getBindingsOf(Injector injector, Class<?> baseClass) {
    Set<Binding<?>> answer = Sets.newHashSet();
    Set<Entry<Key<?>, Binding<?>>> entries = injector.getBindings().entrySet();
    for (Entry<Key<?>, Binding<?>> entry : entries) {
        Key<?> key = entry.getKey();
        Class<?> keyType = getKeyType(key);
        if (keyType != null && baseClass.isAssignableFrom(keyType)) {
            answer.add(entry.getValue());
        }
    }
    return answer;
}
SetMultimapAsMapTester.java 文件源码 项目:googles-monorepo-demo 阅读 21 收藏 0 点赞 0 评论 0
@CollectionSize.Require(SEVERAL)
public void testEquals() {
  resetContainer(
      Helpers.mapEntry(k0(), v0()),
      Helpers.mapEntry(k1(), v0()),
      Helpers.mapEntry(k0(), v3()));
  Map<K, Collection<V>> expected = Maps.newHashMap();
  expected.put(k0(), Sets.newHashSet(v0(), v3()));
  expected.put(k1(), Sets.newHashSet(v0()));
  new EqualsTester().addEqualityGroup(expected, multimap().asMap()).testEquals();
}
TermIdsTest.java 文件源码 项目:ontolib 阅读 21 收藏 0 点赞 0 评论 0
@Test
public void test() {
  Set<TermId> inputIds = Sets.newHashSet(id1);
  Set<TermId> outputIds =
      ImmutableSortedSet.copyOf(TermIds.augmentWithAncestors(ontology, inputIds, true));
  assertEquals(
      "[ImmutableTermId [prefix=ImmutableTermPrefix [value=HP], id=0000001], ImmutableTermId [prefix=ImmutableTermPrefix [value=HP], id=0000002], ImmutableTermId [prefix=ImmutableTermPrefix [value=HP], id=0000003], ImmutableTermId [prefix=ImmutableTermPrefix [value=HP], id=0000004], ImmutableTermId [prefix=ImmutableTermPrefix [value=HP], id=0000005]]",
      outputIds.toString());
}
TestSchemaHomology.java 文件源码 项目:morf 阅读 21 收藏 0 点赞 0 评论 0
/**
 * Test that when two schemas differ in the number of tables, it doesn't matter if they are included on the
 * list of excluded tables.
 */
@Test
public void testDifferingSchemasWithExcludedTablesMatch() {
  Schema schema1 = schema(appleTable, pearTable, simpleTable);
  Schema schema2 = schema(appleTable, pearTable);

  Set<String> exclusionRegex = Sets.newHashSet("MYTABLE");
  assertTrue("Schemas", schemaHomology.schemasMatch(schema1, schema2, exclusionRegex));
}
ModifiableAttributeInstance.java 文件源码 项目:DecompiledMinecraft 阅读 33 收藏 0 点赞 0 评论 0
public Collection<AttributeModifier> func_111122_c()
{
    Set<AttributeModifier> set = Sets.<AttributeModifier>newHashSet();

    for (int i = 0; i < 3; ++i)
    {
        set.addAll(this.getModifiersByOperation(i));
    }

    return set;
}
GlobalDictionaryBuilder.java 文件源码 项目:dremio-oss 阅读 30 收藏 0 点赞 0 评论 0
private static VectorContainer buildDoubleGlobalDictionary(List<Dictionary> dictionaries, VectorContainer existingDict, ColumnDescriptor columnDescriptor, BufferAllocator bufferAllocator) {
  final Field field = new Field(SchemaPath.getCompoundPath(columnDescriptor.getPath()).getAsUnescapedPath(), true, new ArrowType.FloatingPoint(FloatingPointPrecision.DOUBLE), null);
  final VectorContainer input = new VectorContainer(bufferAllocator);
  final NullableFloat8Vector doubleVector = input.addOrGet(field);
  doubleVector.allocateNew();
  SortedSet<Double> values = Sets.newTreeSet();
  for (Dictionary dictionary : dictionaries) {
    for (int i = 0; i <= dictionary.getMaxId(); ++i) {
      values.add(dictionary.decodeToDouble(i));
    }
  }
  if (existingDict != null) {
    final NullableFloat8Vector existingDictValues = existingDict.getValueAccessorById(NullableFloat8Vector.class, 0).getValueVector();
    for (int i = 0; i < existingDict.getRecordCount(); ++i) {
      values.add(existingDictValues.getAccessor().get(i));
    }
  }
  final Iterator<Double> iter = values.iterator();
  int recordCount = 0;
  while (iter.hasNext()) {
    doubleVector.getMutator().setSafe(recordCount++, iter.next());
  }
  doubleVector.getMutator().setValueCount(recordCount);
  input.setRecordCount(recordCount);
  input.buildSchema(BatchSchema.SelectionVectorMode.NONE);
  return input;
}
ModelBakery.java 文件源码 项目:BaseClient 阅读 38 收藏 0 点赞 0 评论 0
private Set<ResourceLocation> getVariantsTextureLocations()
{
    Set<ResourceLocation> set = Sets.<ResourceLocation>newHashSet();
    List<ModelResourceLocation> list = Lists.newArrayList(this.variants.keySet());
    Collections.sort(list, new Comparator<ModelResourceLocation>()
    {
        public int compare(ModelResourceLocation p_compare_1_, ModelResourceLocation p_compare_2_)
        {
            return p_compare_1_.toString().compareTo(p_compare_2_.toString());
        }
    });

    for (ModelResourceLocation modelresourcelocation : list)
    {
        ModelBlockDefinition.Variants modelblockdefinition$variants = (ModelBlockDefinition.Variants)this.variants.get(modelresourcelocation);

        for (ModelBlockDefinition.Variant modelblockdefinition$variant : modelblockdefinition$variants.getVariants())
        {
            ModelBlock modelblock = (ModelBlock)this.models.get(modelblockdefinition$variant.getModelLocation());

            if (modelblock == null)
            {
                LOGGER.warn("Missing model for: " + modelresourcelocation);
            }
            else
            {
                set.addAll(this.getTextureLocations(modelblock));
            }
        }
    }

    set.addAll(LOCATIONS_BUILTIN_TEXTURES);
    return set;
}


问题


面经


文章

微信
公众号

扫码关注公众号