Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
9 changes: 2 additions & 7 deletions api/src/main/java/io/druid/data/input/MapBasedRow.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Function;
import com.google.common.collect.Lists;
import io.druid.java.util.common.parsers.ParseException;
import org.joda.time.DateTime;
Expand All @@ -35,13 +34,11 @@
*/
public class MapBasedRow implements Row
{
private static final Function<Object, String> TO_STRING_INCLUDING_NULL = String::valueOf;
private static final Pattern LONG_PAT = Pattern.compile("[-|+]?\\d+");

private final DateTime timestamp;
private final Map<String, Object> event;

private static final Pattern LONG_PAT = Pattern.compile("[-|+]?\\d+");

@JsonCreator
public MapBasedRow(
@JsonProperty("timestamp") DateTime timestamp,
Expand Down Expand Up @@ -88,9 +85,7 @@ public List<String> getDimension(String dimension)
return Collections.emptyList();
} else if (dimValue instanceof List) {
// guava's toString function fails on null objects, so please do not use it
return Lists.transform(
(List) dimValue,
TO_STRING_INCLUDING_NULL);
return Lists.transform((List) dimValue, String::valueOf);
} else {
return Collections.singletonList(String.valueOf(dimValue));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ public static enum MultiValueHandling
SORTED_SET,
ARRAY {
@Override
public boolean needSorting() { return false;}
public boolean needSorting()
{
return false;
}
};

public boolean needSorting()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,10 @@ private void fetchIfNeeded(long remainingBytes)
{
if ((fetchFuture == null || fetchFuture.isDone())
&& remainingBytes <= prefetchTriggerBytes) {
fetchFuture = fetchExecutor.submit(
() -> {
fetch();
return null;
}
);
fetchFuture = fetchExecutor.submit(() -> {
fetch();
return null;
});
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ public String toString()

//simple merge strategy on timestampSpec that checks if all are equal or else
//returns null. this can be improved in future but is good enough for most use-cases.
public static TimestampSpec mergeTimestampSpec(List<TimestampSpec> toMerge) {
public static TimestampSpec mergeTimestampSpec(List<TimestampSpec> toMerge)
{
if (toMerge == null || toMerge.size() == 0) {
return null;
}
Expand Down
6 changes: 2 additions & 4 deletions api/src/main/java/io/druid/guice/JsonConfigProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,9 @@ public static <T> void bindInstance(

if (bindKey.getAnnotationType() != null) {
supplierKey = Key.get(supType, bindKey.getAnnotationType());
}
else if (bindKey.getAnnotation() != null) {
} else if (bindKey.getAnnotation() != null) {
supplierKey = Key.get(supType, bindKey.getAnnotation());
}
else {
} else {
supplierKey = Key.get(supType);
}

Expand Down
15 changes: 7 additions & 8 deletions api/src/main/java/io/druid/guice/JsonConfigurator.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public <T> T configurate(Properties props, String propertyPrefix, Class<T> clazz
List<String> messages = Lists.newArrayList();

for (ConstraintViolation<T> violation : violations) {
String path = "";
StringBuilder path = new StringBuilder();
try {
Class<?> beanClazz = violation.getRootBeanClass();
final Iterator<Path.Node> iter = violation.getPropertyPath().iterator();
Expand All @@ -123,18 +123,17 @@ public <T> T configurate(Properties props, String propertyPrefix, Class<T> clazz
final Field theField = beanClazz.getDeclaredField(fieldName);

if (theField.getAnnotation(JacksonInject.class) != null) {
path = StringUtils.format(" -- Injected field[%s] not bound!?", fieldName);
path = new StringBuilder(StringUtils.format(" -- Injected field[%s] not bound!?", fieldName));
break;
}

JsonProperty annotation = theField.getAnnotation(JsonProperty.class);
final boolean noAnnotationValue = annotation == null || Strings.isNullOrEmpty(annotation.value());
final String pathPart = noAnnotationValue ? fieldName : annotation.value();
if (path.isEmpty()) {
path += pathPart;
}
else {
path += "." + pathPart;
if (path.length() == 0) {
path.append(pathPart);
} else {
path.append(".").append(pathPart);
}
}
}
Expand All @@ -143,7 +142,7 @@ public <T> T configurate(Properties props, String propertyPrefix, Class<T> clazz
throw Throwables.propagate(e);
}

messages.add(StringUtils.format("%s - %s", path, violation.getMessage()));
messages.add(StringUtils.format("%s - %s", path.toString(), violation.getMessage()));
}

throw new ProvisionException(
Expand Down
3 changes: 2 additions & 1 deletion api/src/main/java/io/druid/guice/LifecycleModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ public Lifecycle getLifecycle(final Injector injector)
final Key<Set<KeyHolder>> keyHolderKey = Key.get(new TypeLiteral<Set<KeyHolder>>(){}, Names.named("lifecycle"));
final Set<KeyHolder> eagerClasses = injector.getInstance(keyHolderKey);

Lifecycle lifecycle = new Lifecycle(){
Lifecycle lifecycle = new Lifecycle()
{
@Override
public void start() throws Exception
{
Expand Down
3 changes: 1 addition & 2 deletions api/src/main/java/io/druid/guice/LifecycleScope.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ public synchronized T get()
synchronized (instances) {
if (lifecycle == null) {
instances.add(retVal);
}
else {
} else {
try {
lifecycle.addMaybeStartManagedInstance(retVal, stage);
}
Expand Down
12 changes: 4 additions & 8 deletions api/src/main/java/io/druid/guice/PolyBind.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,11 @@ public static <T> MapBinder<String, T> optionBinder(Binder binder, Key<T> interf
return MapBinder.newMapBinder(
binder, TypeLiteral.get(String.class), interfaceType, interfaceKey.getAnnotation()
);
}
else if (interfaceKey.getAnnotationType() != null) {
} else if (interfaceKey.getAnnotationType() != null) {
return MapBinder.newMapBinder(
binder, TypeLiteral.get(String.class), interfaceType, interfaceKey.getAnnotationType()
);
}
else {
} else {
return MapBinder.newMapBinder(binder, TypeLiteral.get(String.class), interfaceType);
}
}
Expand Down Expand Up @@ -177,11 +175,9 @@ public T get()
final Map<String, Provider<T>> implsMap;
if (key.getAnnotation() != null) {
implsMap = (Map<String, Provider<T>>) injector.getInstance(Key.get(mapType, key.getAnnotation()));
}
else if (key.getAnnotationType() != null) {
} else if (key.getAnnotationType() != null) {
implsMap = (Map<String, Provider<T>>) injector.getInstance(Key.get(mapType, key.getAnnotation()));
}
else {
} else {
implsMap = (Map<String, Provider<T>>) injector.getInstance(Key.get(mapType));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,14 @@ public interface DataSegmentPusher
DataSegment push(File file, DataSegment segment) throws IOException;
//use map instead of LoadSpec class to avoid dependency pollution.
Map<String, Object> makeLoadSpec(URI finalIndexZipFilePath);
default String getStorageDir(DataSegment dataSegment) {

default String getStorageDir(DataSegment dataSegment)
{
return getDefaultStorageDir(dataSegment);
}
default String makeIndexPathName(DataSegment dataSegment, String indexName) {

default String makeIndexPathName(DataSegment dataSegment, String indexName)
{
return StringUtils.format("./%s/%s", getStorageDir(dataSegment), indexName);
}

Expand All @@ -60,7 +64,8 @@ default List<String> getAllowedPropertyPrefixesForHadoop()
// If above format is ever changed, make sure to change it appropriately in other places
// e.g. HDFSDataSegmentKiller uses this information to clean the version, interval and dataSource directories
// on segment deletion if segment being deleted was the only segment
static String getDefaultStorageDir(DataSegment segment) {
static String getDefaultStorageDir(DataSegment segment)
{
return JOINER.join(
segment.getDataSource(),
StringUtils.format("%s_%s", segment.getInterval().getStart(), segment.getInterval().getEnd()),
Expand Down
11 changes: 8 additions & 3 deletions api/src/main/java/io/druid/segment/loading/LoadSpec.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,17 @@ public interface LoadSpec
public LoadSpecResult loadSegment(File destDir) throws SegmentLoadingException;

// Hold interesting data about the results of the segment load
public static class LoadSpecResult{
public static class LoadSpecResult
{
private final long size;
public LoadSpecResult(long size){

public LoadSpecResult(long size)
{
this.size = size;
}
public long getSize(){

public long getSize()
{
return this.size;
}
}
Expand Down
3 changes: 2 additions & 1 deletion api/src/main/java/io/druid/timeline/DataSegmentUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ public static SegmentIdentifierParts valueOf(String dataSource, String identifie
version,
trail
);
} catch (IllegalArgumentException e) {
}
catch (IllegalArgumentException e) {
return null;
}
}
Expand Down
14 changes: 10 additions & 4 deletions api/src/main/java/io/druid/timeline/partition/NoneShardSpec.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,18 @@ public class NoneShardSpec implements ShardSpec
private final static NoneShardSpec INSTANCE = new NoneShardSpec();

@JsonCreator
public static NoneShardSpec instance() { return INSTANCE; }
public static NoneShardSpec instance()
{
return INSTANCE;
}

/**
* @deprecated use {@link #instance()} instead
*/
@Deprecated
// Use NoneShardSpec.instance() instead
public NoneShardSpec(){

public NoneShardSpec()
{
// empty
}

@Override
Expand Down
8 changes: 3 additions & 5 deletions api/src/main/java/io/druid/utils/Runnables.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@
*/
public class Runnables
{
public static Runnable getNoopRunnable(){
return new Runnable(){
@Override
public void run(){}
};
public static Runnable getNoopRunnable()
{
return () -> {};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,18 @@

package io.druid.data.input.impl;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableList;
import io.druid.TestObjectMapper;
import org.junit.Assert;
import org.junit.Test;

import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;

import org.junit.Assert;
import org.junit.Test;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableList;

public class JSONParseSpecTest {
public class JSONParseSpecTest
{
private final ObjectMapper jsonMapper = new TestObjectMapper();

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,8 @@ public String getSecretKey()
return secretKey;
}

public String getFileSessionCredentials() { return fileSessionCredentials; }
public String getFileSessionCredentials()
{
return fileSessionCredentials;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@

public class AWSCredentialsUtils
{
public static AWSCredentialsProviderChain defaultAWSCredentialsProviderChain(final AWSCredentialsConfig config) {
public static AWSCredentialsProviderChain defaultAWSCredentialsProviderChain(final AWSCredentialsConfig config)
{
return new AWSCredentialsProviderChain(
new ConfigDrivenAwsCredentialsConfigProvider(config),
new LazyFileSessionCredentialsProvider(config),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,26 @@ public class ConfigDrivenAwsCredentialsConfigProvider implements AWSCredentialsP
{
private AWSCredentialsConfig config;

public ConfigDrivenAwsCredentialsConfigProvider(AWSCredentialsConfig config) {
public ConfigDrivenAwsCredentialsConfigProvider(AWSCredentialsConfig config)
{
this.config = config;
}

@Override
public AWSCredentials getCredentials()
{
if (!Strings.isNullOrEmpty(config.getAccessKey()) && !Strings.isNullOrEmpty(config.getSecretKey())) {
return new AWSCredentials() {
return new AWSCredentials()
{
@Override
public String getAWSAccessKeyId() {
public String getAWSAccessKeyId()
{
return config.getAccessKey();
}

@Override
public String getAWSSecretKey() {
public String getAWSSecretKey()
{
return config.getSecretKey();
}
};
Expand Down
Loading