Search in sources :

Example 1 with StringJoiner

use of java.util.StringJoiner in project che by eclipse.

the class MavenArtifact method getDisplayString.

public String getDisplayString() {
    StringJoiner joiner = new StringJoiner(":");
    joiner.setEmptyValue("<unknown>");
    joiner.add(groupId).add(artifactId).add(version);
    return joiner.toString();
}
Also used : StringJoiner(java.util.StringJoiner)

Example 2 with StringJoiner

use of java.util.StringJoiner in project java-design-patterns by iluwatar.

the class App method prettyPrint.

private static <E> void prettyPrint(String delimiter, String prefix, Iterable<E> iterable) {
    StringJoiner joiner = new StringJoiner(delimiter, prefix, ".");
    Iterator<E> iterator = iterable.iterator();
    while (iterator.hasNext()) {
        joiner.add(iterator.next().toString());
    }
    LOGGER.info(joiner.toString());
}
Also used : StringJoiner(java.util.StringJoiner)

Example 3 with StringJoiner

use of java.util.StringJoiner in project jersey by jersey.

the class CombinedFeedControllerTest method testCreate.

@Test
public void testCreate() {
    Form form = new Form();
    form.param("title", params[0]);
    form.param("description", params[1]);
    form.param("urls", new StringJoiner(",").add(params[2]).add(params[3]).toString());
    form.param("refreshPeriod", params[4]);
    Response response = target().request().post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE));
    assertEquals(Status.OK.getStatusCode(), response.getStatus());
    String html = response.readEntity(String.class);
    // HTML page contains all information about the created entity
    assertTrue(html.contains(params[0]) && html.contains(params[1]) && html.contains(params[2]) && html.contains(params[3]) && html.contains(params[4]));
}
Also used : Response(javax.ws.rs.core.Response) Form(javax.ws.rs.core.Form) StringJoiner(java.util.StringJoiner) JerseyTest(org.glassfish.jersey.test.JerseyTest) Test(org.junit.Test)

Example 4 with StringJoiner

use of java.util.StringJoiner in project presto by prestodb.

the class ShardPredicate method createShardPredicate.

private static String createShardPredicate(ImmutableList.Builder<JDBCType> types, ImmutableList.Builder<Object> values, Domain domain, JDBCType jdbcType) {
    List<Range> ranges = domain.getValues().getRanges().getOrderedRanges();
    // only apply predicates if all ranges are single values
    if (ranges.isEmpty() || !ranges.stream().allMatch(Range::isSingleValue)) {
        return "true";
    }
    ImmutableList.Builder<Object> valuesBuilder = ImmutableList.builder();
    ImmutableList.Builder<JDBCType> typesBuilder = ImmutableList.builder();
    StringJoiner rangePredicate = new StringJoiner(" OR ");
    for (Range range : ranges) {
        Slice uuidText = (Slice) range.getSingleValue();
        try {
            Slice uuidBytes = uuidStringToBytes(uuidText);
            typesBuilder.add(jdbcType);
            valuesBuilder.add(uuidBytes);
        } catch (IllegalArgumentException e) {
            return "true";
        }
        rangePredicate.add("shard_uuid = ?");
    }
    types.addAll(typesBuilder.build());
    values.addAll(valuesBuilder.build());
    return rangePredicate.toString();
}
Also used : JDBCType(java.sql.JDBCType) ImmutableList(com.google.common.collect.ImmutableList) Slice(io.airlift.slice.Slice) Range(com.facebook.presto.spi.predicate.Range) StringJoiner(java.util.StringJoiner)

Example 5 with StringJoiner

use of java.util.StringJoiner in project presto by prestodb.

the class TestRaptorIntegrationSmokeTest method testShardingByTemporalTimestampColumn.

@Test
public void testShardingByTemporalTimestampColumn() throws Exception {
    // Make sure we have at least 2 different orderdate.
    assertEquals(computeActual("SELECT count(DISTINCT orderdate) >= 2 FROM orders WHERE orderdate < date '1992-02-08'").getOnlyValue(), true);
    assertUpdate("CREATE TABLE test_shard_temporal_timestamp(col1 BIGINT, col2 TIMESTAMP) WITH (temporal_column = 'col2')");
    int rows = 20;
    StringJoiner joiner = new StringJoiner(", ", "INSERT INTO test_shard_temporal_timestamp VALUES ", "");
    for (int i = 0; i < rows; i++) {
        joiner.add(format("(%s, TIMESTAMP '2016-08-08 01:00' + interval '%s' hour)", i, i * 4));
    }
    assertUpdate(joiner.toString(), format("VALUES(%s)", rows));
    MaterializedResult results = computeActual("SELECT format_datetime(col2, 'yyyyMMdd'), \"$shard_uuid\" FROM test_shard_temporal_timestamp");
    assertEquals(results.getRowCount(), rows);
    // Each shard will only contain data of one date.
    SetMultimap<String, String> shardDateMap = HashMultimap.create();
    for (MaterializedRow row : results.getMaterializedRows()) {
        shardDateMap.put((String) row.getField(1), (String) row.getField(0));
    }
    for (Collection<String> dates : shardDateMap.asMap().values()) {
        assertEquals(dates.size(), 1);
    }
    // Ensure one shard can contain different timestamps from the same day
    assertLessThan(shardDateMap.size(), rows);
}
Also used : MaterializedResult(com.facebook.presto.testing.MaterializedResult) StringJoiner(java.util.StringJoiner) MaterializedRow(com.facebook.presto.testing.MaterializedRow) Test(org.testng.annotations.Test) AbstractTestIntegrationSmokeTest(com.facebook.presto.tests.AbstractTestIntegrationSmokeTest)

Aggregations

StringJoiner (java.util.StringJoiner)94 ArrayList (java.util.ArrayList)20 List (java.util.List)10 HashSet (java.util.HashSet)6 Map (java.util.Map)6 IOException (java.io.IOException)4 HashMap (java.util.HashMap)4 Collectors (java.util.stream.Collectors)4 ClassName (com.squareup.javapoet.ClassName)3 FieldSpec (com.squareup.javapoet.FieldSpec)3 ParameterizedTypeName (com.squareup.javapoet.ParameterizedTypeName)3 TypeName (com.squareup.javapoet.TypeName)3 TypeSpec (com.squareup.javapoet.TypeSpec)3 Expression (com.sri.ai.expresso.api.Expression)3 Attribute (io.requery.meta.Attribute)3 Scanner (java.util.Scanner)3 RaptorColumnHandle (com.facebook.presto.raptor.RaptorColumnHandle)2 Range (com.facebook.presto.spi.predicate.Range)2 MaterializedResult (com.facebook.presto.testing.MaterializedResult)2 MaterializedRow (com.facebook.presto.testing.MaterializedRow)2