You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@samza.apache.org by ca...@apache.org on 2020/03/18 23:14:05 UTC
[samza-hello-samza] branch master updated: [minor] remove unused
files that seem to be left over from an improper merge/cleanup (#74)
This is an automated email from the ASF dual-hosted git repository.
cameronlee pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/samza-hello-samza.git
The following commit(s) were added to refs/heads/master by this push:
new ed99d19 [minor] remove unused files that seem to be left over from an improper merge/cleanup (#74)
ed99d19 is described below
commit ed99d197d2ceb8705569234facf2001c52a961ab
Author: Cameron Lee <ca...@linkedin.com>
AuthorDate: Wed Mar 18 16:13:56 2020 -0700
[minor] remove unused files that seem to be left over from an improper merge/cleanup (#74)
---
.../java/samza/examples/avro/AvroSerDeFactory.java | 92 ----------------------
src/main/java/samza/examples/cookbook/AdClick.java | 58 --------------
.../java/samza/examples/cookbook/PageView.java | 61 --------------
3 files changed, 211 deletions(-)
diff --git a/src/main/java/samza/examples/avro/AvroSerDeFactory.java b/src/main/java/samza/examples/avro/AvroSerDeFactory.java
deleted file mode 100644
index 3e829e4..0000000
--- a/src/main/java/samza/examples/avro/AvroSerDeFactory.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package samza.examples.avro;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import org.apache.avro.Schema;
-import org.apache.avro.generic.GenericDatumReader;
-import org.apache.avro.generic.GenericDatumWriter;
-import org.apache.avro.generic.GenericRecord;
-import org.apache.avro.generic.IndexedRecord;
-import org.apache.avro.io.BinaryDecoder;
-import org.apache.avro.io.DatumWriter;
-import org.apache.avro.io.DecoderFactory;
-import org.apache.avro.io.Encoder;
-import org.apache.avro.io.EncoderFactory;
-import org.apache.samza.SamzaException;
-import org.apache.samza.config.Config;
-import org.apache.samza.serializers.Serde;
-import org.apache.samza.serializers.SerdeFactory;
-
-
-public class AvroSerDeFactory implements SerdeFactory {
-
- public static String CFG_AVRO_SCHEMA = "serializers.avro.schema";
-
- @Override
- public Serde getSerde(String name, Config config) {
- return new AvroSerDe(config);
- }
-
- private class AvroSerDe implements Serde {
- private final Schema schema;
-
- public AvroSerDe(Config config) {
- schema = Schema.parse(config.get(CFG_AVRO_SCHEMA));
- }
-
- @Override
- public Object fromBytes(byte[] bytes) {
- GenericRecord record;
- try {
- record = genericRecordFromBytes(bytes, schema);
- } catch (IOException e) {
- throw new SamzaException("Unable to deserialize the record", e);
- }
- return record;
- }
-
- @Override
- public byte[] toBytes(Object o) {
- GenericRecord record = (GenericRecord) o;
- try {
- return encodeAvroGenericRecord(schema, record);
- } catch (IOException e) {
- throw new SamzaException("Unable to serialize the record", e);
- }
- }
- }
-
- public byte[] encodeAvroGenericRecord(Schema schema, GenericRecord record) throws IOException {
- DatumWriter<IndexedRecord> msgDatumWriter = new GenericDatumWriter<>(schema);
- ByteArrayOutputStream os = new ByteArrayOutputStream();
- Encoder encoder = EncoderFactory.get().binaryEncoder(os, null);
- msgDatumWriter.write(record, encoder);
- encoder.flush();
- return os.toByteArray();
- }
-
- private static <T> T genericRecordFromBytes(byte[] bytes, Schema schema) throws IOException {
- BinaryDecoder binDecoder = DecoderFactory.defaultFactory().createBinaryDecoder(bytes, null);
- GenericDatumReader<T> reader = new GenericDatumReader<>(schema);
- return reader.read(null, binDecoder);
- }
-}
diff --git a/src/main/java/samza/examples/cookbook/AdClick.java b/src/main/java/samza/examples/cookbook/AdClick.java
deleted file mode 100644
index 2d15cec..0000000
--- a/src/main/java/samza/examples/cookbook/AdClick.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package samza.examples.cookbook;
-
-/**
- * Represents an ad click event.
- */
-public class AdClick {
- /*
- * An unique identifier for the ad
- */
- private final String adId;
- /**
- * The user that clicked the ad
- */
- private final String userId;
- /**
- * The id of the page that the ad was served from
- */
- private final String pageId;
-
- public AdClick(String message) {
- String[] adClickFields = message.split(",");
- this.adId = adClickFields[0];
- this.userId = adClickFields[1];
- this.pageId = adClickFields[2];
- }
-
- public String getAdId() {
- return adId;
- }
-
- public String getUserId() {
- return userId;
- }
-
- public String getPageId() {
- return pageId;
- }
-
-}
\ No newline at end of file
diff --git a/src/main/java/samza/examples/cookbook/PageView.java b/src/main/java/samza/examples/cookbook/PageView.java
deleted file mode 100644
index 7803db7..0000000
--- a/src/main/java/samza/examples/cookbook/PageView.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package samza.examples.cookbook;
-
-/**
- * Represents a Page view event
- */
-class PageView {
- /**
- * The user that viewed the page
- */
- private final String userId;
- /**
- * The region that the page was viewed from
- */
- private final String country;
- /**
- * A trackingId for the page
- */
- private final String pageId;
-
- /**
- * Constructs a {@link PageView} from the provided string.
- *
- * @param message in the following CSV format - userId,country,url
- */
- PageView(String message) {
- String[] pageViewFields = message.split(",");
- userId = pageViewFields[0];
- country = pageViewFields[1];
- pageId = pageViewFields[2];
- }
-
- String getUserId() {
- return userId;
- }
-
- String getCountry() {
- return country;
- }
-
- String getPageId() {
- return pageId;
- }
-}