Skip to content

Commit 2fdc153

Browse files
committed
Update SerDe Name and License and minor PR fixes
1 parent 94532c9 commit 2fdc153

31 files changed

+69
-74
lines changed

Diff for: core/trino-spi/src/main/java/io/trino/spi/block/BlockUtil.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ static int countAndMarkSelectedPositionsFromOffsets(boolean[] positions, int[] o
229229
}
230230

231231
/**
232-
* Returns <tt>true</tt> if the two specified arrays contain the same object in every position.
232+
* Returns <var>true</var> if the two specified arrays contain the same object in every position.
233233
* Unlike the {@link Arrays#equals(Object[], Object[])} method, this method compares using reference equals.
234234
*/
235235
static boolean arraySame(Object[] array1, Object[] array2)

Diff for: lib/trino-hive-formats/src/main/java/io/trino/hive/formats/line/grok/BooleanConverter.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
/*
2-
* Copyright 2014 Anthony Corbacho, and contributors.
3-
*
42
* Licensed under the Apache License, Version 2.0 (the "License");
53
* you may not use this file except in compliance with the License.
64
* You may obtain a copy of the License at
@@ -15,6 +13,8 @@
1513
*/
1614
package io.trino.hive.formats.line.grok;
1715

16+
// Note: this code is forked from oi.thekraken.grok.api
17+
// Copyright 2014 Anthony Corbacho, and contributors.
1818
class BooleanConverter
1919
extends IConverter<Boolean>
2020
{

Diff for: lib/trino-hive-formats/src/main/java/io/trino/hive/formats/line/grok/ByteConverter.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
/*
2-
* Copyright 2014 Anthony Corbacho, and contributors.
3-
*
42
* Licensed under the Apache License, Version 2.0 (the "License");
53
* you may not use this file except in compliance with the License.
64
* You may obtain a copy of the License at
@@ -15,6 +13,8 @@
1513
*/
1614
package io.trino.hive.formats.line.grok;
1715

16+
// Note: this code is forked from oi.thekraken.grok.api
17+
// Copyright 2014 Anthony Corbacho, and contributors.
1818
class ByteConverter
1919
extends IConverter<Byte>
2020
{

Diff for: lib/trino-hive-formats/src/main/java/io/trino/hive/formats/line/grok/Converter.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
/*
2-
* Copyright 2014 Anthony Corbacho, and contributors.
3-
*
42
* Licensed under the Apache License, Version 2.0 (the "License");
53
* you may not use this file except in compliance with the License.
64
* You may obtain a copy of the License at
@@ -30,6 +28,8 @@
3028
* @author anthonyc
3129
*
3230
*/
31+
// Note: this code is forked from oi.thekraken.grok.api
32+
// Copyright 2014 Anthony Corbacho, and contributors.
3333
public class Converter
3434
{
3535
private Converter() {}

Diff for: lib/trino-hive-formats/src/main/java/io/trino/hive/formats/line/grok/DateConverter.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
/*
2-
* Copyright 2014 Anthony Corbacho, and contributors.
3-
*
42
* Licensed under the Apache License, Version 2.0 (the "License");
53
* you may not use this file except in compliance with the License.
64
* You may obtain a copy of the License at
@@ -19,6 +17,8 @@
1917
import java.text.SimpleDateFormat;
2018
import java.util.Date;
2119

20+
// Note: this code is forked from oi.thekraken.grok.api
21+
// Copyright 2014 Anthony Corbacho, and contributors.
2222
class DateConverter
2323
extends IConverter<Date>
2424
{

Diff for: lib/trino-hive-formats/src/main/java/io/trino/hive/formats/line/grok/Discovery.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
/*
2-
* Copyright 2014 Anthony Corbacho, and contributors.
3-
*
42
* Licensed under the Apache License, Version 2.0 (the "License");
53
* you may not use this file except in compliance with the License.
64
* You may obtain a copy of the License at
@@ -36,6 +34,8 @@
3634
* @author anthonycorbacho
3735
* @since 0.0.2
3836
*/
37+
// Note: this code is forked from oi.thekraken.grok.api
38+
// Copyright 2014 Anthony Corbacho, and contributors.
3939
public class Discovery
4040
{
4141
private Grok grok;
@@ -61,6 +61,7 @@ private Map<String, Grok> sort(Map<String, Grok> groks)
6161
List<Grok> groky = new ArrayList<Grok>(groks.values());
6262
Map<String, Grok> mGrok = new LinkedHashMap<String, Grok>();
6363
Collections.sort(groky, new Comparator<Grok>() {
64+
@Override
6465
public int compare(Grok g1, Grok g2)
6566
{
6667
return (this.complexity(g1.getNamedRegex()) < this.complexity(g2.getNamedRegex())) ? 1

Diff for: lib/trino-hive-formats/src/main/java/io/trino/hive/formats/line/grok/DoubleConverter.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
/*
2-
* Copyright 2014 Anthony Corbacho, and contributors.
3-
*
42
* Licensed under the Apache License, Version 2.0 (the "License");
53
* you may not use this file except in compliance with the License.
64
* You may obtain a copy of the License at
@@ -15,6 +13,8 @@
1513
*/
1614
package io.trino.hive.formats.line.grok;
1715

16+
// Note: this code is forked from oi.thekraken.grok.api
17+
// Copyright 2014 Anthony Corbacho, and contributors.
1818
class DoubleConverter
1919
extends IConverter<Double>
2020
{

Diff for: lib/trino-hive-formats/src/main/java/io/trino/hive/formats/line/grok/FloatConverter.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
/*
2-
* Copyright 2014 Anthony Corbacho, and contributors.
3-
*
42
* Licensed under the Apache License, Version 2.0 (the "License");
53
* you may not use this file except in compliance with the License.
64
* You may obtain a copy of the License at
@@ -15,6 +13,8 @@
1513
*/
1614
package io.trino.hive.formats.line.grok;
1715

16+
// Note: this code is forked from oi.thekraken.grok.api
17+
// Copyright 2014 Anthony Corbacho, and contributors.
1818
class FloatConverter
1919
extends IConverter<Float>
2020
{

Diff for: lib/trino-hive-formats/src/main/java/io/trino/hive/formats/line/grok/Garbage.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
/*
2-
* Copyright 2014 Anthony Corbacho, and contributors.
3-
*
42
* Licensed under the Apache License, Version 2.0 (the "License");
53
* you may not use this file except in compliance with the License.
64
* You may obtain a copy of the License at
@@ -28,6 +26,8 @@
2826
* @author anthonycorbacho
2927
* @since 0.0.2
3028
*/
29+
// Note: this code is forked from oi.thekraken.grok.api
30+
// Copyright 2014 Anthony Corbacho, and contributors.
3131
public class Garbage
3232
{
3333
private List<String> toRemove;

Diff for: lib/trino-hive-formats/src/main/java/io/trino/hive/formats/line/grok/Grok.java

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
/*
2-
* Copyright 2014 Anthony Corbacho, and contributors.
3-
*
42
* Licensed under the Apache License, Version 2.0 (the "License");
53
* you may not use this file except in compliance with the License.
64
* You may obtain a copy of the License at
@@ -24,6 +22,7 @@
2422
import java.io.InputStreamReader;
2523
import java.io.Reader;
2624
import java.io.Serializable;
25+
import java.nio.charset.Charset;
2726
import java.nio.file.Files;
2827
import java.util.ArrayList;
2928
import java.util.HashMap;
@@ -51,6 +50,8 @@
5150
* @since 0.0.1
5251
* @author anthonycorbacho
5352
*/
53+
// Note: this code is forked from oi.thekraken.grok.api
54+
// Copyright 2014 Anthony Corbacho, and contributors.
5455
public class Grok
5556
implements Serializable
5657
{
@@ -244,7 +245,7 @@ public static Grok create(String grokPatternPath, String grokDatatypePath, Strin
244245
static Reader getFileFromResouces(String filePath)
245246
throws GrokException
246247
{
247-
Reader reader = new InputStreamReader(Grok.class.getClassLoader().getResourceAsStream(filePath));
248+
Reader reader = new InputStreamReader(Grok.class.getClassLoader().getResourceAsStream(filePath), Charset.defaultCharset());
248249
if (reader == null) {
249250
throw new GrokException("File <" + filePath + "> not found.");
250251
}
@@ -481,7 +482,7 @@ public void addDateFormatFromReader(Reader r)
481482

482483
// match log with regex and capture results
483484
/**
484-
* Match the given <tt>log</tt> with the named regex.
485+
* Match the given <var>log</var> with the named regex.
485486
* And return the json representation of the matched element
486487
*
487488
* @param log : log to match
@@ -496,7 +497,7 @@ public String capture(String log)
496497
}
497498

498499
/**
499-
* Match the given list of <tt>log</tt> with the named regex
500+
* Match the given list of <var>log</var> with the named regex
500501
* and return the list of json representation of the matched elements.
501502
*
502503
* @param logs : list of log
@@ -521,7 +522,7 @@ public List<String> captures(List<String> logs)
521522
}
522523

523524
/**
524-
* Match the given <tt>text</tt> with the named regex
525+
* Match the given <var>text</var> with the named regex
525526
* {@code Grok} will extract data from the string and get an extence of {@link Match}.
526527
*
527528
* @param text : Single line of log
@@ -593,7 +594,7 @@ public void compile(String pattern, boolean namedOnly)
593594
// Match %{Foo=regex} -> add new regex definition
594595
if (m.find()) {
595596
continueIteration = true;
596-
Map<String, String> group = GrokUtils.namedGroups(m, m.group()); // AMZN - probably don't need this tag since it's going into OSS Trino
597+
Map<String, String> group = GrokUtils.namedGroups(m, m.group());
597598
if (group.get("definition") != null) {
598599
try {
599600
addPattern(group.get("pattern"), group.get("definition"));
@@ -692,9 +693,9 @@ public String getSaved_pattern()
692693
return savedPattern;
693694
}
694695

695-
public void setSaved_pattern(String savedpattern)
696+
public void setSaved_pattern(String savedPattern)
696697
{
697-
this.savedPattern = savedpattern;
698+
this.savedPattern = savedPattern;
698699
}
699700

700701
public boolean getStrictMode()

Diff for: lib/trino-hive-formats/src/main/java/io/trino/hive/formats/line/grok/GrokDeserializer.java

-6
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import java.util.ArrayList;
3636
import java.util.List;
3737
import java.util.Map;
38-
import java.util.Optional;
3938

4039
import static com.google.common.collect.ImmutableList.toImmutableList;
4140
import static io.trino.hive.formats.HiveFormatUtils.parseHiveDate;
@@ -62,8 +61,6 @@ public class GrokDeserializer
6261
implements LineDeserializer
6362
{
6463
private final List<Column> columns;
65-
private final String inputFormat;
66-
private final Optional<String> inputGrokCustomPatterns;
6764
private Grok grokPattern;
6865
private final List<Type> types;
6966

@@ -74,9 +71,6 @@ public GrokDeserializer(List<Column> columns, String inputFormat, String inputGr
7471
.map(Column::type)
7572
.collect(toImmutableList());
7673

77-
this.inputFormat = inputFormat;
78-
this.inputGrokCustomPatterns = Optional.ofNullable(inputGrokCustomPatterns);
79-
8074
//assert that columns size and types size are the same
8175
if (columns.size() != types.size()) {
8276
throw new RuntimeException("Number of columns does not match the number of types for each column");

Diff for: lib/trino-hive-formats/src/main/java/io/trino/hive/formats/line/grok/GrokDeserializerFactory.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class GrokDeserializerFactory
3131
@Override
3232
public Set<String> getHiveSerDeClassNames()
3333
{
34-
return ImmutableSet.of("com.amazonaws.glue.serde.GrokSerDe"); //what should this value be (there isn't a hive grok serde)
34+
return ImmutableSet.of("com.amazonaws.serde.GrokSerDe");
3535
}
3636

3737
@Override

Diff for: lib/trino-hive-formats/src/main/java/io/trino/hive/formats/line/grok/GrokUtils.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
/*
2-
* Copyright 2014 Anthony Corbacho, and contributors.
3-
*
42
* Licensed under the Apache License, Version 2.0 (the "License");
53
* you may not use this file except in compliance with the License.
64
* You may obtain a copy of the License at
@@ -28,6 +26,8 @@
2826
* @author anthonycorbacho
2927
* @since 0.0.6
3028
*/
29+
// Note: this code is forked from oi.thekraken.grok.api
30+
// Copyright 2014 Anthony Corbacho, and contributors.
3131
public class GrokUtils
3232
{
3333
private GrokUtils() {}

Diff for: lib/trino-hive-formats/src/main/java/io/trino/hive/formats/line/grok/IConverter.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
/*
2-
* Copyright 2014 Anthony Corbacho, and contributors.
3-
*
42
* Licensed under the Apache License, Version 2.0 (the "License");
53
* you may not use this file except in compliance with the License.
64
* You may obtain a copy of the License at
@@ -15,6 +13,8 @@
1513
*/
1614
package io.trino.hive.formats.line.grok;
1715

16+
// Note: this code is forked from oi.thekraken.grok.api
17+
// Copyright 2014 Anthony Corbacho, and contributors.
1818
abstract class IConverter<T>
1919
{
2020
public T convert(String value, String informat)

Diff for: lib/trino-hive-formats/src/main/java/io/trino/hive/formats/line/grok/IntegerConverter.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
/*
2-
* Copyright 2014 Anthony Corbacho, and contributors.
3-
*
42
* Licensed under the Apache License, Version 2.0 (the "License");
53
* you may not use this file except in compliance with the License.
64
* You may obtain a copy of the License at
@@ -15,6 +13,8 @@
1513
*/
1614
package io.trino.hive.formats.line.grok;
1715

16+
// Note: this code is forked from oi.thekraken.grok.api
17+
// Copyright 2014 Anthony Corbacho, and contributors.
1818
class IntegerConverter
1919
extends IConverter<Integer>
2020
{

Diff for: lib/trino-hive-formats/src/main/java/io/trino/hive/formats/line/grok/KeyValue.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
/*
2-
* Copyright 2014 Anthony Corbacho, and contributors.
3-
*
42
* Licensed under the Apache License, Version 2.0 (the "License");
53
* you may not use this file except in compliance with the License.
64
* You may obtain a copy of the License at
@@ -15,6 +13,8 @@
1513
*/
1614
package io.trino.hive.formats.line.grok;
1715

16+
// Note: this code is forked from oi.thekraken.grok.api
17+
// Copyright 2014 Anthony Corbacho, and contributors.
1818
public class KeyValue
1919
{
2020
private String key;

Diff for: lib/trino-hive-formats/src/main/java/io/trino/hive/formats/line/grok/LongConverter.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
/*
2-
* Copyright 2014 Anthony Corbacho, and contributors.
3-
*
42
* Licensed under the Apache License, Version 2.0 (the "License");
53
* you may not use this file except in compliance with the License.
64
* You may obtain a copy of the License at
@@ -15,6 +13,8 @@
1513
*/
1614
package io.trino.hive.formats.line.grok;
1715

16+
// Note: this code is forked from oi.thekraken.grok.api
17+
// Copyright 2014 Anthony Corbacho, and contributors.
1818
class LongConverter
1919
extends IConverter<Long>
2020
{

Diff for: lib/trino-hive-formats/src/main/java/io/trino/hive/formats/line/grok/Match.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
/*
2-
* Copyright 2014 Anthony Corbacho, and contributors.
3-
*
42
* Licensed under the Apache License, Version 2.0 (the "License");
53
* you may not use this file except in compliance with the License.
64
* You may obtain a copy of the License at
@@ -31,6 +29,8 @@
3129
* @author anthonycorbacho
3230
* @since 0.0.1
3331
*/
32+
// Note: this code is forked from oi.thekraken.grok.api
33+
// Copyright 2014 Anthony Corbacho, and contributors.
3434
public class Match
3535
{
3636
private static final Gson PRETTY_GSON =
@@ -149,7 +149,7 @@ public String getSubject()
149149
}
150150

151151
/**
152-
* Match to the <tt>subject</tt> the <tt>regex</tt> and save the matched element into a map.
152+
* Match to the <var>subject</var> the <var>regex</var> and save the matched element into a map.
153153
*
154154
*/
155155
public void captures()

Diff for: lib/trino-hive-formats/src/main/java/io/trino/hive/formats/line/grok/Pile.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
/*
2-
* Copyright 2014 Anthony Corbacho, and contributors.
3-
*
42
* Licensed under the Apache License, Version 2.0 (the "License");
53
* you may not use this file except in compliance with the License.
64
* You may obtain a copy of the License at
@@ -28,6 +26,8 @@
2826
* @author anthonycorbacho
2927
* @since 0.0.1
3028
*/
29+
// Note: this code is forked from oi.thekraken.grok.api
30+
// Copyright 2014 Anthony Corbacho, and contributors.
3131
@Deprecated
3232
public class Pile
3333
{
@@ -117,7 +117,7 @@ public void compile(String pattern)
117117
Map<String, String> map = new TreeMap<String, String>();
118118

119119
for (Map.Entry<String, String> entry : patterns.entrySet()) {
120-
if (!map.containsValue((entry.getValue()))) {
120+
if (!map.containsValue(entry.getValue())) {
121121
grok.addPattern(entry.getKey(), entry.getValue());
122122
}
123123
}

0 commit comments

Comments
 (0)