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


Java Sets.newHashSet方法代码示例

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


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

示例1: getPinYin_Index

import org.elasticsearch.common.collect.Sets; //导入方法依赖的package包/类
/**
 * 解析词条拼音
 * 
 * @param word
 * @return
 */
public static Set<String> getPinYin_Index(String word) {
    Set<String> results = Sets.newHashSet();
    List<String> words = AnalyzeHelper.analyze(word);
    if (!words.contains(word)) {
        words.add(word);
    }

    String pinYin;
    for (String w : words) {
        pinYin = getPinYin(w);
        if (StringUtils.isNotEmpty(pinYin)) {
            results.add(pinYin);
        }
    }
    return results;
}
 
开发者ID:hailin0,项目名称:es-service-parent,代码行数:23,代码来源:PinYinHelper.java

示例2: getPinYinPrefix_Index

import org.elasticsearch.common.collect.Sets; //导入方法依赖的package包/类
/**
 * 解析词条拼音首字母
 * 
 * @param word
 * @return
 */
public static Set<String> getPinYinPrefix_Index(String word) {
    Set<String> results = Sets.newHashSet();
    List<String> words = AnalyzeHelper.analyze(word);
    if (!words.contains(word)) {
        words.add(word);
    }

    String prefixPinYin;
    for (String w : words) {
        prefixPinYin = getPinYinPrefix(w);
        if (StringUtils.isNotEmpty(prefixPinYin)) {
            results.add(prefixPinYin);
        }
    }
    return results;
}
 
开发者ID:hailin0,项目名称:es-service-parent,代码行数:23,代码来源:PinYinHelper.java

示例3: facets

import org.elasticsearch.common.collect.Sets; //导入方法依赖的package包/类
@Override
public QueryBuilderHelper facets() {
    Set<String> aggIds = Sets.newHashSet();
    for (Class<?> clazz : classes) {
        if (filters == null) {
            addAggregations(new HashMap(), clazz.getName(), searchRequestBuilder, aggIds);
        } else {
            addAggregations(filters, clazz.getName(), searchRequestBuilder, aggIds);
        }
    }
    return this;
}
 
开发者ID:alien4cloud,项目名称:elasticsearch-mapping-parent,代码行数:13,代码来源:QueryHelper.java

示例4: setTriggerFunctions

import org.elasticsearch.common.collect.Sets; //导入方法依赖的package包/类
public void setTriggerFunctions(Collection<String> triggerFunctions) {
    this.triggerFunctions = (triggerFunctions instanceof Set)
            ? (Set)triggerFunctions : Sets.newHashSet(triggerFunctions);
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:5,代码来源:BaseElasticSearchIndexBuilder.java

示例5: test_dynamodb_river

import org.elasticsearch.common.collect.Sets; //导入方法依赖的package包/类
@Test
public void test_dynamodb_river() throws IOException, InterruptedException {

    String tableName = randomAsciiOfLengthBetween(10, 50).toLowerCase();
    AmazonDynamoDBClient dynamoDBClient = getDynamoClient(tableName);

    // add test items to dynamodb
    Set<String> idSet = Sets.newHashSet();
    idSet.addAll(addTestItems(dynamoDBClient, tableName, randomIntBetween(1, 50)));

    Map<String, String> dynamoDbSetting = Maps.newHashMap();
    dynamoDbSetting.put("access_key", "test");
    dynamoDbSetting.put("secret_key", "test");
    dynamoDbSetting.put("region", "http://localhost:8000");  // test use DynamoDB Local
    dynamoDbSetting.put("table_name", tableName);
    dynamoDbSetting.put("updated_timestamp_field", "updated");
    dynamoDbSetting.put("deleted_timestamp_field", "deleted");
    dynamoDbSetting.put("interval", "1s");
    dynamoDbSetting.put("bulk_size", "2");  // less bulk size so items can be indexed when doing test
    dynamoDbSetting.put("flush_interval", "1s");  // less bulk interval so items can be indexed when doing test

    XContentBuilder riverBuilder = jsonBuilder().startObject();
    riverBuilder.field("type", "dynamodb");
    riverBuilder.field("dynamodb", dynamoDbSetting);
    riverBuilder.endObject();


    client().prepareIndex("_river", "dynamodb", "_meta").setSource(riverBuilder).get();

    Thread.sleep(10000);

    client().admin().indices().prepareRefresh(tableName).get();
    long count1 = client().prepareCount(tableName).get().getCount();
    assertThat(count1, equalTo((long) idSet.size()));

    // load more test data to dynamodb
    idSet.addAll(addTestItems(dynamoDBClient, tableName, randomIntBetween(1, 50)));

    Thread.sleep(10000);

    client().admin().indices().prepareRefresh(tableName).get();
    long count2 = client().prepareCount(tableName).get().getCount();
    assertThat(count2, equalTo((long) idSet.size()));


    // test delete
    int toDelete = randomIntBetween(1, idSet.size() - 1);
    for (int i = 0; i < toDelete; i ++) {
        String id = idSet.iterator().next();
        deleteFromDynamoDB(dynamoDBClient, tableName, id);
        idSet.remove(id);
    }

    Thread.sleep(10000);

    client().admin().indices().prepareRefresh(tableName).get();
    long count3 = client().prepareCount(tableName).get().getCount();
    assertThat(count3, equalTo((long) idSet.size()));



}
 
开发者ID:kzwang,项目名称:elasticsearch-river-dynamodb,代码行数:63,代码来源:DynamoDbRiverTests.java

示例6: addTestItems

import org.elasticsearch.common.collect.Sets; //导入方法依赖的package包/类
private Set<String> addTestItems(AmazonDynamoDBClient dynamoDBClient, String tableName, int size) {
    Set<String> idSet = Sets.newHashSet();
    for (int p = 0; p < size; p ++) {
        Map<String, AttributeValue> item = Maps.newHashMap();
        int fields = randomIntBetween(10, 20);
        for (int i = 0; i < fields; i ++) {
            int t = randomIntBetween(1, 4);
            switch (t){
                case 1:
                    item.put(randomAsciiOfLengthBetween(1, 10), new AttributeValue().withS(randomAsciiOfLengthBetween(1, 20)));
                    break;
                case 2:
                    item.put(randomAsciiOfLengthBetween(1, 10), new AttributeValue().withN(String.valueOf(randomInt())));
                    break;
                case 3:
                    Set<String> s = Sets.newHashSet();
                    int ss = randomIntBetween(5, 20);
                    for (int a = 0; a < ss; a ++) {
                        s.add(randomAsciiOfLengthBetween(1, 20));
                    }
                    item.put(randomAsciiOfLengthBetween(1, 10), new AttributeValue().withSS(s));
                    break;
                case 4:
                    Set<String> n = Sets.newHashSet();
                    int ns = randomIntBetween(5, 20);
                    for (int a = 0; a < ns; a ++) {
                        n.add(String.valueOf(randomIntBetween(1, 1000)));
                    }
                    item.put(randomAsciiOfLengthBetween(1, 10), new AttributeValue().withNS(n));
                    break;
            }
        }
        String id = randomAsciiOfLengthBetween(1, 50);
        idSet.add(id);
        item.put("id", new AttributeValue().withS(id));
        item.put("updated", new AttributeValue().withN(String.valueOf(new Date().getTime())));
        PutItemRequest putItemRequest = new PutItemRequest()
                .withTableName(tableName)
                .withItem(item);
        dynamoDBClient.putItem(putItemRequest);
    }
    return idSet;
}
 
开发者ID:kzwang,项目名称:elasticsearch-river-dynamodb,代码行数:44,代码来源:DynamoDbRiverTests.java


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