You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by bb...@apache.org on 2017/06/01 14:30:13 UTC
nifi git commit: NIFI-3995: Updated Hwx Encoded Schema Ref Writer to
write 13 bytes for header instead of 14; added unit test to verify
Repository: nifi
Updated Branches:
refs/heads/master a0b2311ff -> 7035694e3
NIFI-3995: Updated Hwx Encoded Schema Ref Writer to write 13 bytes for header instead of 14; added unit test to verify
This closes #1876.
Signed-off-by: Bryan Bende <bb...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/7035694e
Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/7035694e
Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/7035694e
Branch: refs/heads/master
Commit: 7035694e37b79bd58d9168cb5010b14a15db0396
Parents: a0b2311
Author: Mark Payne <ma...@hotmail.com>
Authored: Thu Jun 1 09:45:44 2017 -0400
Committer: Bryan Bende <bb...@apache.org>
Committed: Thu Jun 1 10:29:58 2017 -0400
----------------------------------------------------------------------
...HortonworksEncodedSchemaReferenceWriter.java | 2 +-
...HortonworksEncodedSchemaReferenceWriter.java | 55 ++++++++++++++++++++
2 files changed, 56 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/nifi/blob/7035694e/nifi-nar-bundles/nifi-extension-utils/nifi-record-utils/nifi-standard-record-utils/src/main/java/org/apache/nifi/schema/access/HortonworksEncodedSchemaReferenceWriter.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-extension-utils/nifi-record-utils/nifi-standard-record-utils/src/main/java/org/apache/nifi/schema/access/HortonworksEncodedSchemaReferenceWriter.java b/nifi-nar-bundles/nifi-extension-utils/nifi-record-utils/nifi-standard-record-utils/src/main/java/org/apache/nifi/schema/access/HortonworksEncodedSchemaReferenceWriter.java
index 87d7f0b..bf6a9ea 100644
--- a/nifi-nar-bundles/nifi-extension-utils/nifi-record-utils/nifi-standard-record-utils/src/main/java/org/apache/nifi/schema/access/HortonworksEncodedSchemaReferenceWriter.java
+++ b/nifi-nar-bundles/nifi-extension-utils/nifi-record-utils/nifi-standard-record-utils/src/main/java/org/apache/nifi/schema/access/HortonworksEncodedSchemaReferenceWriter.java
@@ -43,7 +43,7 @@ public class HortonworksEncodedSchemaReferenceWriter implements SchemaAccessWrit
// This decoding follows the pattern that is provided for serializing data by the Hortonworks Schema Registry serializer
// as it is provided at:
// https://github.com/hortonworks/registry/blob/master/schema-registry/serdes/src/main/java/com/hortonworks/registries/schemaregistry/serdes/avro/AvroSnapshotSerializer.java
- final ByteBuffer bb = ByteBuffer.allocate(14);
+ final ByteBuffer bb = ByteBuffer.allocate(13);
bb.put((byte) LATEST_PROTOCOL_VERSION);
bb.putLong(id);
bb.putInt(version);
http://git-wip-us.apache.org/repos/asf/nifi/blob/7035694e/nifi-nar-bundles/nifi-extension-utils/nifi-record-utils/nifi-standard-record-utils/src/test/java/org/apache/nifi/schema/access/TestHortonworksEncodedSchemaReferenceWriter.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-extension-utils/nifi-record-utils/nifi-standard-record-utils/src/test/java/org/apache/nifi/schema/access/TestHortonworksEncodedSchemaReferenceWriter.java b/nifi-nar-bundles/nifi-extension-utils/nifi-record-utils/nifi-standard-record-utils/src/test/java/org/apache/nifi/schema/access/TestHortonworksEncodedSchemaReferenceWriter.java
new file mode 100644
index 0000000..5d7f4d7
--- /dev/null
+++ b/nifi-nar-bundles/nifi-extension-utils/nifi-record-utils/nifi-standard-record-utils/src/test/java/org/apache/nifi/schema/access/TestHortonworksEncodedSchemaReferenceWriter.java
@@ -0,0 +1,55 @@
+/*
+ * 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 org.apache.nifi.schema.access;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.util.Collections;
+
+import org.apache.nifi.serialization.SimpleRecordSchema;
+import org.apache.nifi.serialization.record.RecordSchema;
+import org.apache.nifi.serialization.record.SchemaIdentifier;
+import org.junit.Test;
+
+public class TestHortonworksEncodedSchemaReferenceWriter {
+
+ @Test
+ public void testHeader() throws IOException {
+ final HortonworksEncodedSchemaReferenceWriter writer = new HortonworksEncodedSchemaReferenceWriter();
+
+ final RecordSchema schema = new SimpleRecordSchema(Collections.emptyList(), SchemaIdentifier.of("name", 48L, 2));
+
+ final byte[] header;
+ try (final ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
+ writer.writeHeader(schema, baos);
+ header = baos.toByteArray();
+ }
+
+ try (final DataInputStream dis = new DataInputStream(new ByteArrayInputStream(header))) {
+ assertEquals(1, dis.read()); // verify 'protocol version'
+ assertEquals(48, dis.readLong()); // verify schema id
+ assertEquals(2, dis.readInt()); // verify schema version
+ assertEquals(-1, dis.read()); // no more bytes
+ }
+ }
+
+}