Skip to content

Instantly share code, notes, and snippets.

func communicateJava(input interface{}) (interface{}, error) {
inBytes, err := json.Marshal(input)
inputStr := string(inBytes)
goRequest <- inputStr
respStr := <-javaResponse
var resp interface{}
err = json.Unmarshal([]byte(respStr), &resp)
}
//export Java_Test_start
SELECT destinationaddress,
SUM(bytes) AS totalBytes
FROM flows TABLESAMPLE SYSTEM (10)
GROUP BY destinationaddress
ORDER BY totalBytes DESC LIMIT 10
SELECT sum(packets) AS total,
split_part(sourceaddress,’.’, 1) = ‘10’ AS isInternal,
action
FROM flows
GROUP BY 2, action
ORDER BY total DESC LIMIT 10
SELECT corr(bytes,packets), action FROM flows GROUP BY action
SELECT destinationport,
COUNT(*) AS total
FROM flows
WHERE action = ‘REJECT’
GROUP BY destinationport
ORDER BY total DESC LIMIT 10
SELECT sourceaddress,
destinationaddress,
SUM(bytes) AS totalBytes
FROM flows
GROUP BY sourceaddress, destinationaddress
ORDER BY totalBytes DESC LIMIT 10
SELECT
destinationaddress,
SUM(bytes) AS totalBytes
FROM flows
GROUP BY destinationaddress
ORDER BY totalBytes DESC LIMIT 10
CREATE EXTERNAL TABLE `flows`(
`version` int,
`account` string,
`interfaceid` string,
`sourceaddress` string,
`destinationaddress` string,
`sourceport` int,
`destinationport` int,
`protocol` int,
`packets` int,
SchemaBuilder.RecordBuilder<Schema> builder = SchemaBuilder
.record("flow_logs").namespace("com.opsgenie");
schema = builder.fields()
.name("version").type().intType().intDefault(0)
.name("account").type().stringType().stringDefault("")
.name("interfaceId").type().stringType().stringDefault("")
.name("sourceAddress").type().stringType().stringDefault("")
// continues for remaining 10 fields..
Configuration conf = new Configuration();
Path p = new Path("data.parquet"); // This is not java.nio.file.Path
ParquetWriter<FlowLogs> writer = AvroParquetWriter.<FlowLog>builder(p)
.withSchema(ReflectData.AllowNull.get().getSchema(FlowLog.class))
.withDataModel(ReflectData.get())
.withConf(conf)
.withCompressionCodec(CompressionCodecName.SNAPPY)
.withWriteMode(Mode.OVERWRITE)
.build();