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


Java ObjectIntCursor类代码示例

本文整理汇总了Java中com.carrotsearch.hppc.cursors.ObjectIntCursor的典型用法代码示例。如果您正苦于以下问题:Java ObjectIntCursor类的具体用法?Java ObjectIntCursor怎么用?Java ObjectIntCursor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: toXContent

import com.carrotsearch.hppc.cursors.ObjectIntCursor; //导入依赖的package包/类
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    builder.timeValueField(Fields.MAX_UPTIME_IN_MILLIS, Fields.MAX_UPTIME, maxUptime);
    builder.startArray(Fields.VERSIONS);
    for (ObjectIntCursor<JvmVersion> v : versions) {
        builder.startObject();
        builder.field(Fields.VERSION, v.key.version);
        builder.field(Fields.VM_NAME, v.key.vmName);
        builder.field(Fields.VM_VERSION, v.key.vmVersion);
        builder.field(Fields.VM_VENDOR, v.key.vmVendor);
        builder.field(Fields.COUNT, v.value);
        builder.endObject();
    }
    builder.endArray();
    builder.startObject(Fields.MEM);
    builder.byteSizeField(Fields.HEAP_USED_IN_BYTES, Fields.HEAP_USED, heapUsed);
    builder.byteSizeField(Fields.HEAP_MAX_IN_BYTES, Fields.HEAP_MAX, heapMax);
    builder.endObject();

    builder.field(Fields.THREADS, threads);
    return builder;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:23,代码来源:ClusterStatsNodes.java

示例2: toXContent

import com.carrotsearch.hppc.cursors.ObjectIntCursor; //导入依赖的package包/类
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    builder.field(Fields.AVAILABLE_PROCESSORS, availableProcessors);
    builder.field(Fields.ALLOCATED_PROCESSORS, allocatedProcessors);
    builder.startObject(Fields.MEM);
    builder.byteSizeField(Fields.TOTAL_IN_BYTES, Fields.TOTAL, availableMemory);
    builder.endObject();

    builder.startArray(Fields.NAMES);
    for (ObjectIntCursor<String> name : names) {
        builder.startObject();
        builder.field(Fields.NAME, name.key);
        builder.field(Fields.COUNT, name.value);
        builder.endObject();
    }
    builder.endArray();

    return builder;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:20,代码来源:ClusterStatsNodes.java

示例3: getCommentCharacter

import com.carrotsearch.hppc.cursors.ObjectIntCursor; //导入依赖的package包/类
public String getCommentCharacter() {
    int[] topCount = { 0 };
    String[] commentCharacter = { null };
    firstCharacterFrequencies.forEach((Consumer<? super ObjectIntCursor<String>>) c -> {
        if (c.value > topCount[0]) {
            commentCharacter[0] = c.key;
            topCount[0] = c.value;
        }
    });

    if (commentCharacter[0] == null) {
        return DEFAULT_COMMENT_CHARACTER;
    }

    return commentCharacter[0];
}
 
开发者ID:baryshnikova-lab,项目名称:safe-java,代码行数:17,代码来源:IdMappingResult.java

示例4: exportSymbols

import com.carrotsearch.hppc.cursors.ObjectIntCursor; //导入依赖的package包/类
/**
 * Exports a symbols' map to the openfst text format
 *
 * @param syms     the symbols' map
 * @param filename the the openfst's symbols filename
 */
private static void exportSymbols(SymbolTable syms, String filename) {
  if (syms == null) {
    return;
  }

  try {
    FileWriter file = new FileWriter(filename);
    PrintWriter out = new PrintWriter(file);

    for (ObjectIntCursor<String> sym : syms) {
      out.println(sym.key + "\t" + sym.value);
    }

    out.close();
  } catch (IOException e) {
    throw Throwables.propagate(e);
  }
}
 
开发者ID:steveash,项目名称:jopenfst,代码行数:25,代码来源:Convert.java

示例5: makeEpsMapper

import com.carrotsearch.hppc.cursors.ObjectIntCursor; //导入依赖的package包/类
private static ImmutableFst makeEpsMapper(ImmutableSymbolTable osyms, ImmutableSet<String> skipLabels) {
  MutableFst epsMapper = new MutableFst(RING);
  epsMapper.setInputSymbolsAsCopy(osyms);
  epsMapper.setOutputSymbolsAsCopy(osyms);
  MutableState start = epsMapper.newStartState();
  int oeps = osyms.get(Fst.EPS);
  for (ObjectIntCursor<String> cursor : osyms) {
    int olabel = cursor.value;
    if (skipLabels.contains(cursor.key)) {
      olabel = oeps;
    }
    epsMapper.addArc(start, cursor.value, olabel, start, RING.one());
  }
  start.setFinalWeight(RING.one());
  ArcSort.sortByInput(epsMapper);
  return new ImmutableFst(epsMapper);
}
 
开发者ID:steveash,项目名称:jg2p,代码行数:18,代码来源:SeqTransducer.java

示例6: testTopMatch

import com.carrotsearch.hppc.cursors.ObjectIntCursor; //导入依赖的package包/类
public void testTopMatch() throws Exception {
    for (int precision = 1; precision <= PRECISION; precision++) {
        SearchResponse response = client().prepareSearch("idx")
                .addAggregation(geohashGrid("geohashgrid")
                        .field("location")
                        .size(1)
                        .shardSize(100)
                        .precision(precision)
                )
                .execute().actionGet();

        assertSearchResponse(response);

        GeoHashGrid geoGrid = response.getAggregations().get("geohashgrid");
        //Check we only have one bucket with the best match for that resolution
        assertThat(geoGrid.getBuckets().size(), equalTo(1));
        for (GeoHashGrid.Bucket cell : geoGrid.getBuckets()) {
            String geohash = cell.getKeyAsString();
            long bucketCount = cell.getDocCount();
            int expectedBucketCount = 0;
            for (ObjectIntCursor<String> cursor : expectedDocCountsForGeoHash) {
                if (cursor.key.length() == precision) {
                    expectedBucketCount = Math.max(expectedBucketCount, cursor.value);
                }
            }
            assertNotSame(bucketCount, 0);
            assertEquals("Geohash " + geohash + " has wrong doc count ",
                    expectedBucketCount, bucketCount);
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:32,代码来源:GeoHashGridIT.java

示例7: dump

import com.carrotsearch.hppc.cursors.ObjectIntCursor; //导入依赖的package包/类
public void dump(final StringBuilder sb) {
  sb.append("ValueHolderIden: type=" + type + '\n');
  for (ObjectIntCursor<String> oic : fieldMap) {
    sb.append("  " + oic.key + ": i=" + oic.value + ", type=" + types[oic.value] +
        ", offset=" + offsets[oic.value] + '\n');
  }
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:8,代码来源:ValueHolderIden.java

示例8: writeTo

import com.carrotsearch.hppc.cursors.ObjectIntCursor; //导入依赖的package包/类
@Override
public void writeTo(StreamOutput out) throws IOException {
    out.writeVInt(availableProcessors);
    if (out.getVersion().onOrAfter(Version.V_2_1_0)) {
        out.writeVInt(allocatedProcessors);
    }

    out.writeLong(availableMemory);
    out.writeVInt(names.size());
    for (ObjectIntCursor<String> name : names) {
        out.writeString(name.key);
        out.writeVInt(name.value);
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:15,代码来源:ClusterStatsNodes.java

示例9: iterator

import com.carrotsearch.hppc.cursors.ObjectIntCursor; //导入依赖的package包/类
@Override
public Iterator<ObjectIntCursor<String>> iterator() {
  if (filter == null) {
    return backing.iterator();
  }
  return Iterators.concat(backing.iterator(), filter.iterator());
}
 
开发者ID:steveash,项目名称:jopenfst,代码行数:8,代码来源:UnionSymbolTable.java

示例10: makeFilter

import com.carrotsearch.hppc.cursors.ObjectIntCursor; //导入依赖的package包/类
/**
 * Get a filter to use for avoiding multiple epsilon paths in the resulting Fst
 *
 * See: M. Mohri, "Weighted automata algorithms", Handbook of Weighted Automata. Springer, pp. 213-250, 2009.
 *
 * @param table    the filter's input/output symbols
 * @param semiring the semiring to use in the operation
 */
private static MutableFst makeFilter(WriteableSymbolTable table, Semiring semiring, String eps1, String eps2) {

  MutableFst filter = new MutableFst(semiring, table, table);

  // State 0
  MutableState s0 = filter.newStartState();
  s0.setFinalWeight(semiring.one());
  MutableState s1 = filter.newState();
  s1.setFinalWeight(semiring.one());
  MutableState s2 = filter.newState();
  s2.setFinalWeight(semiring.one());

  filter.addArc(s0, eps2, eps1, s0, semiring.one());
  filter.addArc(s0, eps1, eps1, s1, semiring.one());
  filter.addArc(s0, eps2, eps2, s2, semiring.one());
  // self loops
  filter.addArc(s1, eps1, eps1, s1, semiring.one());
  filter.addArc(s2, eps2, eps2, s2, semiring.one());
  for (ObjectIntCursor<String> cursor : table) {
    int i = cursor.value;
    String key = cursor.key;
    if (key.equals(Fst.EPS) || key.equals(eps1) || key.equals(eps2)) {
      continue;
    }
    filter.addArc(s0, i, i, s0, semiring.one());
    filter.addArc(s1, i, i, s0, semiring.one());
    filter.addArc(s2, i, i, s0, semiring.one());
  }

  // now we need to augment the input fsts to emit the eps1/eps2 in their I/O labels to compose this

  return filter;
}
 
开发者ID:steveash,项目名称:jopenfst,代码行数:42,代码来源:Compose.java

示例11: maxIdIn

import com.carrotsearch.hppc.cursors.ObjectIntCursor; //导入依赖的package包/类
public static int maxIdIn(SymbolTable table) {
  int max = 0;
  for (ObjectIntCursor<String> cursor : table) {
    max = Math.max(max, cursor.value);
  }
  return max;
}
 
开发者ID:steveash,项目名称:jopenfst,代码行数:8,代码来源:AbstractSymbolTable.java

示例12: AbstractSymbolTable

import com.carrotsearch.hppc.cursors.ObjectIntCursor; //导入依赖的package包/类
protected AbstractSymbolTable(SymbolTable copyFrom) {

    this.symbolToId = new ObjectIntOpenHashMap<>(copyFrom.size());
    this.idToSymbol = new IntObjectOpenHashMap<>(copyFrom.size());
    for (ObjectIntCursor<String> cursor : copyFrom) {
      symbolToId.put(cursor.key, cursor.value);
      idToSymbol.put(cursor.value, cursor.key);
    }
  }
 
开发者ID:steveash,项目名称:jopenfst,代码行数:10,代码来源:AbstractSymbolTable.java

示例13: symbolTableEquals

import com.carrotsearch.hppc.cursors.ObjectIntCursor; //导入依赖的package包/类
public static boolean symbolTableEquals(Object thisSyms,
                                        Object thatSyms,
                                        EqualsReporter reporter) {
  if (thisSyms == thatSyms) {
    return true;
  }
  if (thisSyms == null || thatSyms == null) {
    return false;
  }
  if (!SymbolTable.class.isAssignableFrom(thisSyms.getClass()) || !SymbolTable.class.isAssignableFrom(thatSyms.getClass())) {
    reporter.report("symbolTable.isAssignable", thisSyms, thatSyms);
    return false;
  }

  SymbolTable thisS = (SymbolTable) thisSyms;
  SymbolTable thatS = (SymbolTable) thatSyms;

  if (thisS.size() != thatS.size()) {
    reporter.report("symbolTable.size", thisS.size(), thatS.size());
    return false;
  }
  for (ObjectIntCursor<String> cursor : thisS) {
    if (thatS.contains(cursor.key)) {
      int thatV = thatS.get(cursor.key);
      if (thatV == cursor.value) {
        continue;
      }
      reporter.report("symbolTable.key", cursor.value, thatV);
    } else {
      reporter.report("symbolTable.missingKey", cursor.key, cursor.value);
    }
    return false;
  }
  return true;
}
 
开发者ID:steveash,项目名称:jopenfst,代码行数:36,代码来源:FstUtils.java

示例14: writeStringMap

import com.carrotsearch.hppc.cursors.ObjectIntCursor; //导入依赖的package包/类
/**
 * Serializes a symbol map to an ObjectOutput
 *
 * @param map the symbol map to serialize
 * @param out the ObjectOutput. It should be already be initialized by the caller.
 */
private static void writeStringMap(SymbolTable map, ObjectOutput out)
    throws IOException {
  out.writeInt(map.size());
  for (ObjectIntCursor<String> cursor : map) {
    out.writeUTF(cursor.key);
    out.writeInt(cursor.value);
  }
}
 
开发者ID:steveash,项目名称:jopenfst,代码行数:15,代码来源:FstInputOutput.java

示例15: iterator

import com.carrotsearch.hppc.cursors.ObjectIntCursor; //导入依赖的package包/类
@Override
public Iterator<ObjectIntCursor<String>> iterator() {
  return symbolToId.iterator();
}
 
开发者ID:steveash,项目名称:jopenfst,代码行数:5,代码来源:AbstractSymbolTable.java


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