commonlib/src/main/java/com/streamsets/pipeline/lib/util/AvroSchemaHelper.java
public Optional<Integer> detectSchemaId(byte[] data) {
    if (data.length < 5) {
      return Optional.empty();
    }

    ByteBuffer wrapped = ByteBuffer.wrap(data);
    // 5 == MAGIC_BYTE + ID_SIZE
    if (wrapped.get() != MAGIC_BYTE) {
      return Optional.empty();
    }

    return Optional.of(wrapped.getInt());
  }
public Optional<Integer> detectSchemaId(byte[] data) {
    if (data.length < 5) {
      return Optional.empty();
    }

    ByteBuffer wrapped = ByteBuffer.wrap(data);
    // 5 == MAGIC_BYTE + ID_SIZE
    if (wrapped.get() != MAGIC_BYTE) {
      return Optional.empty();
    }

    return Optional.of(wrapped.getInt());
  }
public Optional < Integer > detectSchemaId ( byte [ ] data ) { if ( data . length < 5 ) { return Optional . empty ( ) ; } ByteBuffer wrapped = ByteBuffer . wrap ( data ) ; // 5 == MAGIC_BYTE + ID_SIZE if ( wrapped . get ( ) != MAGIC_BYTE ) { return Optional . empty ( ) ; } return Optional . of ( wrapped . getInt ( ) ) ; }
Checks for a magic byte in the data and if present extracts the schemaId
@param data byte array representing a kafka message
@return parsed schema ID
Checks for a magic byte in the data and if present extracts the schemaId