当前位置: 首页>>代码示例>>Java>>正文


Java Maps.newTreeMap方法代码示例

本文整理汇总了Java中com.google.common.collect.Maps.newTreeMap方法的典型用法代码示例。如果您正苦于以下问题:Java Maps.newTreeMap方法的具体用法?Java Maps.newTreeMap怎么用?Java Maps.newTreeMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.collect.Maps的用法示例。


在下文中一共展示了Maps.newTreeMap方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: renderVariants

import com.google.common.collect.Maps; //导入方法依赖的package包/类
protected void renderVariants(T binary, TextReportBuilder builder) {
    ModelSchema<?> schema = schemaStore.getSchema(((BinarySpecInternal)binary).getPublicType());
    if (!(schema instanceof StructSchema)) {
        return;
    }
    Map<String, Object> variants = Maps.newTreeMap();
    VariantAspect variantAspect = ((StructSchema<?>) schema).getAspect(VariantAspect.class);
    if (variantAspect != null) {
        for (ModelProperty<?> property : variantAspect.getDimensions()) {
            variants.put(property.getName(), property.getPropertyValue(binary));
        }
    }

    for (Map.Entry<String, Object> variant : variants.entrySet()) {
        String variantName = GUtil.toWords(variant.getKey());
        builder.item(variantName, RendererUtils.displayValueOf(variant.getValue()));
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:19,代码来源:AbstractBinaryRenderer.java

示例2: incrementCounter

import com.google.common.collect.Maps; //导入方法依赖的package包/类
/**
 * Helper function for {@link #coalesceIncrements} to increment a counter
 * value in the passed data structure.
 *
 * @param counters  Nested data structure containing the counters.
 * @param row       Row key to increment.
 * @param family    Column family to increment.
 * @param qualifier Column qualifier to increment.
 * @param count     Amount to increment by.
 */
private void incrementCounter(
    Map<byte[], Map<byte[], NavigableMap<byte[], Long>>> counters,
    byte[] row, byte[] family, byte[] qualifier, Long count) {

  Map<byte[], NavigableMap<byte[], Long>> families = counters.get(row);
  if (families == null) {
    families = Maps.newTreeMap(Bytes.BYTES_COMPARATOR);
    counters.put(row, families);
  }

  NavigableMap<byte[], Long> qualifiers = families.get(family);
  if (qualifiers == null) {
    qualifiers = Maps.newTreeMap(Bytes.BYTES_COMPARATOR);
    families.put(family, qualifiers);
  }

  Long existingValue = qualifiers.get(qualifier);
  if (existingValue == null) {
    qualifiers.put(qualifier, count);
  } else {
    qualifiers.put(qualifier, existingValue + count);
  }
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:34,代码来源:HBaseSink.java

示例3: addAttribuut

import com.google.common.collect.Maps; //导入方法依赖的package包/类
/**
 * Voegt een attribuut toe.
 * 
 * @param element het attribuut element
 * @param value de waarde van het attribuut
 */
public void addAttribuut(final Element element, final Object value) {
    if (SoortElement.ATTRIBUUT != element.getSoort()) {
        throw new IllegalArgumentException("Ongeldig Attribuut Element: " + element);
    }
    if (value == null || "".equals(value)) {
        return;
    }
    if (attributen == null) {
        attributen = Maps.newTreeMap();
    }
    final Object valueConverted;
    if (value instanceof Timestamp) {
        valueConverted = ((Timestamp) value).getTime();
    } else {
        valueConverted = value;
    }
    attributen.put(element.getId(), valueConverted);
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:25,代码来源:BlobRecord.java

示例4: open

import com.google.common.collect.Maps; //导入方法依赖的package包/类
/**
 * Called to initialize this implementation.
 * @param spoutConfig used to pass in any configuration values.
 */
public void open(Map spoutConfig) {
    // Load config options.
    if (spoutConfig.containsKey(SpoutConfig.RETRY_MANAGER_RETRY_LIMIT)) {
        retryLimit = ((Number) spoutConfig.get(SpoutConfig.RETRY_MANAGER_RETRY_LIMIT)).intValue();
    }
    if (spoutConfig.containsKey(SpoutConfig.RETRY_MANAGER_INITIAL_DELAY_MS)) {
        initialRetryDelayMs = ((Number) spoutConfig.get(SpoutConfig.RETRY_MANAGER_INITIAL_DELAY_MS)).longValue();
    }
    if (spoutConfig.containsKey(SpoutConfig.RETRY_MANAGER_DELAY_MULTIPLIER)) {
        retryDelayMultiplier = ((Number) spoutConfig.get(SpoutConfig.RETRY_MANAGER_DELAY_MULTIPLIER)).doubleValue();
    }
    if (spoutConfig.containsKey(SpoutConfig.RETRY_MANAGER_MAX_DELAY_MS)) {
        retryDelayMaxMs = ((Number) spoutConfig.get(SpoutConfig.RETRY_MANAGER_MAX_DELAY_MS)).longValue();
    }

    // Init data structures.
    retriesInFlight = Sets.newHashSet();
    numberOfTimesFailed = Maps.newHashMap();
    failedMessageIds = Maps.newTreeMap();
}
 
开发者ID:salesforce,项目名称:storm-dynamic-spout,代码行数:25,代码来源:DefaultRetryManager.java

示例5: loadMappings

import com.google.common.collect.Maps; //导入方法依赖的package包/类
public static SortedMap<String, ContextMapping> loadMappings(Object configuration, Version indexVersionCreated)
        throws ElasticsearchParseException {
    if (configuration instanceof Map) {
        Map<String, Object> configurations = (Map<String, Object>)configuration;
        SortedMap<String, ContextMapping> mappings = Maps.newTreeMap();
        for (Entry<String,Object> config : configurations.entrySet()) {
            String name = config.getKey();
            mappings.put(name, loadMapping(name, (Map<String, Object>) config.getValue(), indexVersionCreated));
        }
        return mappings;
    } else if (configuration == null) {
        return ContextMapping.EMPTY_MAPPING;
    } else {
        throw new ElasticsearchParseException("no valid context configuration");
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:17,代码来源:ContextBuilder.java

示例6: extract

import com.google.common.collect.Maps; //导入方法依赖的package包/类
<T, D> StructBindings<T> extract(ModelType<T> publicType, Iterable<? extends ModelType<?>> internalViewTypes, ModelType<D> delegateType) {
    if (delegateType != null && Modifier.isAbstract(delegateType.getConcreteClass().getModifiers())) {
        throw new InvalidManagedTypeException(String.format("Type '%s' is not a valid managed type: delegate type must be null or a non-abstract type instead of '%s'.",
            publicType.getDisplayName(), delegateType.getDisplayName()));
    }

    Set<ModelType<?>> implementedViews = collectImplementedViews(publicType, internalViewTypes, delegateType);
    StructSchema<T> publicSchema = getStructSchema(publicType);
    Iterable<StructSchema<?>> declaredViewSchemas = getStructSchemas(Iterables.concat(Collections.singleton(publicType), internalViewTypes));
    Iterable<StructSchema<?>> implementedSchemas = getStructSchemas(implementedViews);
    StructSchema<D> delegateSchema = delegateType == null ? null : getStructSchema(delegateType);

    StructBindingExtractionContext<T> extractionContext = new StructBindingExtractionContext<T>(publicSchema, implementedSchemas, delegateSchema);

    if (!(publicSchema instanceof RuleSourceSchema)) {
        validateTypeHierarchy(extractionContext, publicType);
        for (ModelType<?> internalViewType : internalViewTypes) {
            validateTypeHierarchy(extractionContext, internalViewType);
        }
    }

    Map<String, Multimap<PropertyAccessorType, StructMethodBinding>> propertyBindings = Maps.newTreeMap();
    Set<StructMethodBinding> methodBindings = collectMethodBindings(extractionContext, propertyBindings);
    ImmutableSortedMap<String, ManagedProperty<?>> managedProperties = collectManagedProperties(extractionContext, propertyBindings);

    if (extractionContext.problems.hasProblems()) {
        throw new InvalidManagedTypeException(extractionContext.problems.format());
    }

    return new DefaultStructBindings<T>(
        publicSchema, declaredViewSchemas, implementedSchemas, delegateSchema,
        managedProperties, methodBindings
    );
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:35,代码来源:DefaultStructBindingsStore.java

示例7: buildAll

import com.google.common.collect.Maps; //导入方法依赖的package包/类
@Override
@SuppressWarnings("StringEquality")
public DefaultBuildInvocations buildAll(String modelName, Project project) {
    if (!canBuild(modelName)) {
        throw new GradleException("Unknown model name " + modelName);
    }

    DefaultProjectIdentifier projectIdentifier = getProjectIdentifier(project);
    // construct task selectors
    List<LaunchableGradleTaskSelector> selectors = Lists.newArrayList();
    Map<String, LaunchableGradleTaskSelector> selectorsByName = Maps.newTreeMap(Ordering.natural());
    Set<String> visibleTasks = Sets.newLinkedHashSet();
    findTasks(project, selectorsByName, visibleTasks);
    for (String selectorName : selectorsByName.keySet()) {
        LaunchableGradleTaskSelector selector = selectorsByName.get(selectorName);
        selectors.add(selector.
                setName(selectorName).
                setTaskName(selectorName).
                setProjectIdentifier(projectIdentifier).
                setDisplayName(selectorName + " in " + project + " and subprojects.").
                setPublic(visibleTasks.contains(selectorName)));
    }

    // construct project tasks
    List<LaunchableGradleTask> projectTasks = tasks(project);

    // construct build invocations from task selectors and project tasks
    return new DefaultBuildInvocations()
        .setSelectors(selectors)
        .setTasks(projectTasks)
        .setProjectIdentifier(projectIdentifier);
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:33,代码来源:BuildInvocationsBuilder.java

示例8: testAssignmentManagerTruncatedList

import com.google.common.collect.Maps; //导入方法依赖的package包/类
@Test
public void testAssignmentManagerTruncatedList() throws IOException {
  AssignmentManager am = Mockito.mock(AssignmentManager.class);
  RegionStates rs = Mockito.mock(RegionStates.class);

  // Add 100 regions as in-transition
  NavigableMap<String, RegionState> regionsInTransition =
    Maps.newTreeMap();
  for (byte i = 0; i < 100; i++) {
    HRegionInfo hri = new HRegionInfo(FAKE_TABLE.getTableName(),
        new byte[]{i}, new byte[]{(byte) (i+1)});
    regionsInTransition.put(hri.getEncodedName(),
      new RegionState(hri, RegionState.State.CLOSING, 12345L, FAKE_HOST));
  }
  // Add hbase:meta in transition as well
  regionsInTransition.put(
      HRegionInfo.FIRST_META_REGIONINFO.getEncodedName(),
      new RegionState(HRegionInfo.FIRST_META_REGIONINFO,
                      RegionState.State.CLOSING, 12345L, FAKE_HOST));
  Mockito.doReturn(rs).when(am).getRegionStates();
  Mockito.doReturn(regionsInTransition).when(rs).getRegionsInTransition();

  // Render to a string
  StringWriter sw = new StringWriter();
  new AssignmentManagerStatusTmpl()
    .setLimit(50)
    .render(sw, am);
  String result = sw.toString();

  // Should always include META
  assertTrue(result.contains(HRegionInfo.FIRST_META_REGIONINFO.getEncodedName()));

  // Make sure we only see 50 of them
  Matcher matcher = Pattern.compile("CLOSING").matcher(result);
  int count = 0;
  while (matcher.find()) {
    count++;
  }
  assertEquals(50, count);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:41,代码来源:TestMasterStatusServlet.java

示例9: createMap

import com.google.common.collect.Maps; //导入方法依赖的package包/类
/** Returns an empty mutable map whose keys will respect this {@link ElementOrder}. */
<K extends T, V> Map<K, V> createMap(int expectedSize) {
  switch (type) {
    case UNORDERED:
      return Maps.newHashMapWithExpectedSize(expectedSize);
    case INSERTION:
      return Maps.newLinkedHashMapWithExpectedSize(expectedSize);
    case SORTED:
      return Maps.newTreeMap(comparator());
    default:
      throw new AssertionError();
  }
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:14,代码来源:ElementOrder.java

示例10: testValidateEmptyEditLog

import com.google.common.collect.Maps; //导入方法依赖的package包/类
@Test
public void testValidateEmptyEditLog() throws IOException {
  File testDir = new File(TEST_DIR, "testValidateEmptyEditLog");
  SortedMap<Long, Long> offsetToTxId = Maps.newTreeMap();
  File logFile = prepareUnfinalizedTestEditLog(testDir, 0, offsetToTxId);
  // Truncate the file so that there is nothing except the header and
  // layout flags section.
  truncateFile(logFile, 8);
  EditLogValidation validation =
      EditLogFileInputStream.validateEditLog(logFile);
  assertTrue(!validation.hasCorruptHeader());
  assertEquals(HdfsConstants.INVALID_TXID, validation.getEndTxId());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:14,代码来源:TestFSEditLogLoader.java

示例11: testHBaseGroupScanAssignmentNoAfinity

import com.google.common.collect.Maps; //导入方法依赖的package包/类
@Test
public void testHBaseGroupScanAssignmentNoAfinity() throws Exception {
  NavigableMap<HRegionInfo,ServerName> regionsToScan = Maps.newTreeMap();
  regionsToScan.put(new HRegionInfo(TABLE_NAME, splits[0], splits[1]), SERVER_X);
  regionsToScan.put(new HRegionInfo(TABLE_NAME, splits[1], splits[2]), SERVER_X);
  regionsToScan.put(new HRegionInfo(TABLE_NAME, splits[2], splits[3]), SERVER_X);
  regionsToScan.put(new HRegionInfo(TABLE_NAME, splits[3], splits[4]), SERVER_X);
  regionsToScan.put(new HRegionInfo(TABLE_NAME, splits[4], splits[5]), SERVER_X);
  regionsToScan.put(new HRegionInfo(TABLE_NAME, splits[5], splits[6]), SERVER_X);
  regionsToScan.put(new HRegionInfo(TABLE_NAME, splits[6], splits[7]), SERVER_X);
  regionsToScan.put(new HRegionInfo(TABLE_NAME, splits[7], splits[0]), SERVER_X);

  final List<DrillbitEndpoint> endpoints = Lists.newArrayList();
  endpoints.add(DrillbitEndpoint.newBuilder().setAddress(HOST_A).setControlPort(1234).build());
  endpoints.add(DrillbitEndpoint.newBuilder().setAddress(HOST_B).setControlPort(1234).build());
  endpoints.add(DrillbitEndpoint.newBuilder().setAddress(HOST_C).setControlPort(1234).build());
  endpoints.add(DrillbitEndpoint.newBuilder().setAddress(HOST_D).setControlPort(1234).build());
  endpoints.add(DrillbitEndpoint.newBuilder().setAddress(HOST_E).setControlPort(1234).build());
  endpoints.add(DrillbitEndpoint.newBuilder().setAddress(HOST_F).setControlPort(1234).build());
  endpoints.add(DrillbitEndpoint.newBuilder().setAddress(HOST_G).setControlPort(1234).build());
  endpoints.add(DrillbitEndpoint.newBuilder().setAddress(HOST_H).setControlPort(1234).build());

  HBaseGroupScan scan = new HBaseGroupScan();
  scan.setRegionsToScan(regionsToScan);
  scan.setHBaseScanSpec(new HBaseScanSpec(TABLE_NAME_STR, splits[0], splits[0], null));
  scan.applyAssignments(endpoints);

  int i = 0;
  assertEquals(1, scan.getSpecificScan(i++).getRegionScanSpecList().size()); // 'A'
  assertEquals(1, scan.getSpecificScan(i++).getRegionScanSpecList().size()); // 'B'
  assertEquals(1, scan.getSpecificScan(i++).getRegionScanSpecList().size()); // 'C'
  assertEquals(1, scan.getSpecificScan(i++).getRegionScanSpecList().size()); // 'D'
  assertEquals(1, scan.getSpecificScan(i++).getRegionScanSpecList().size()); // 'E'
  assertEquals(1, scan.getSpecificScan(i++).getRegionScanSpecList().size()); // 'F'
  assertEquals(1, scan.getSpecificScan(i++).getRegionScanSpecList().size()); // 'G'
  assertEquals(1, scan.getSpecificScan(i++).getRegionScanSpecList().size()); // 'H'
  testParallelizationWidth(scan, i);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:39,代码来源:TestHBaseRegionScanAssignments.java

示例12: MethodMapping

import com.google.common.collect.Maps; //导入方法依赖的package包/类
public MethodMapping(MethodMapping other, ClassNameReplacer obfClassNameReplacer) {
	m_obfName = other.m_obfName;
	m_deobfName = other.m_deobfName;
	m_obfSignature = new Signature(other.m_obfSignature, obfClassNameReplacer);
	m_arguments = Maps.newTreeMap();
	for (Entry<Integer,ArgumentMapping> entry : other.m_arguments.entrySet()) {
		m_arguments.put(entry.getKey(), new ArgumentMapping(entry.getValue()));
	}
}
 
开发者ID:cccssw,项目名称:enigma-vk,代码行数:10,代码来源:MethodMapping.java

示例13: toVars

import com.google.common.collect.Maps; //导入方法依赖的package包/类
private Map<String, Object> toVars() {
    Map<String, Object> vars = Maps.newTreeMap();
    for (Field field : fields) {
        Object value = fieldValue(field, this);
        if (value == null) {
            throw new IllegalArgumentException("Field cannot be null (was it set?): " + field);
        }
        Object old = vars.put(field.getName(), value);
        if (old != null) {
            throw new IllegalArgumentException("Two fields called " + field.getName() + "?!");
        }
    }
    return ImmutableMap.copyOf(vars);
}
 
开发者ID:sopak,项目名称:auto-value-step-builder,代码行数:15,代码来源:TemplateVars.java

示例14: setAttributen

import com.google.common.collect.Maps; //导入方法依赖的package包/类
/**
 * @param attributen map met attributen.
 */
public void setAttributen(final Map<Integer, Object> attributen) {
    this.attributen = Maps.newTreeMap();
    this.attributen.putAll(attributen);
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:8,代码来源:BlobRecord.java

示例15: addNode

import com.google.common.collect.Maps; //导入方法依赖的package包/类
private void addNode(ModelNodeInternal child, ModelRegistration registration) {
    ModelPath childPath = child.getPath();
    if (!getPath().isDirectChild(childPath)) {
        throw new IllegalArgumentException(String.format("Element registration has a path (%s) which is not a child of this node (%s).", childPath, getPath()));
    }

    ModelNodeInternal currentChild = links == null ? null : links.get(childPath.getName());
    if (currentChild != null) {
        if (!currentChild.isAtLeast(Created)) {
            throw new DuplicateModelException(
                String.format(
                    "Cannot create '%s' using creation rule '%s' as the rule '%s' is already registered to create this model element.",
                    childPath,
                    describe(registration.getDescriptor()),
                    describe(currentChild.getDescriptor())
                )
            );
        }
        throw new DuplicateModelException(
            String.format(
                "Cannot create '%s' using creation rule '%s' as the rule '%s' has already been used to create this model element.",
                childPath,
                describe(registration.getDescriptor()),
                describe(currentChild.getDescriptor())
            )
        );
    }
    if (!isMutable()) {
        throw new IllegalStateException(
            String.format(
                "Cannot create '%s' using creation rule '%s' as model element '%s' is no longer mutable.",
                childPath,
                describe(registration.getDescriptor()),
                getPath()
            )
        );
    }
    if (links == null) {
        links = Maps.newTreeMap();
    }
    links.put(child.getPath().getName(), child);
    modelRegistry.registerNode(child, registration.getActions());
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:44,代码来源:ModelElementNode.java


注:本文中的com.google.common.collect.Maps.newTreeMap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。