Package com.linkedin.data.schema

Examples of com.linkedin.data.schema.FixedDataSchema


  }

  @Test
  public void testFixedSchema()
  {
    final FixedDataSchema schema = (FixedDataSchema) DataTemplateUtil.getSchema(FixedMD5.class);
    final ByteString value = (ByteString) SchemaSampleDataGenerator.buildData(schema, _spec);
    Assert.assertSame(value.length(), schema.getSize());
  }
View Full Code Here


          }
          else
          {
            throw new IllegalArgumentException(message(path, "fixed value %1$s is not a String or ByteString", value));
          }
          FixedDataSchema fixedDataSchema = (FixedDataSchema) dataSchema;
          if (fixedDataSchema.getSize() != byteString.length())
          {
            throw new IllegalArgumentException(message(path,
                                                       "ByteString size %1$d != FixedDataSchema size %2$d",
                                                       byteString.length(),
                                                       fixedDataSchema.getSize()));
          }
          result = byteString;
          break;
        case MAP:
          DataMap map = (DataMap) value;
View Full Code Here

          result = enumValue;
          break;
        case FIXED:
          GenericFixed fixed = (GenericFixed) value;
          byte[] fixedBytes = fixed.bytes();
          FixedDataSchema fixedDataSchema = (FixedDataSchema) dereferencedDataSchema;
          if (fixedDataSchema.getSize() != fixedBytes.length)
          {
            appendMessage("GenericFixed size %1$d != FixedDataSchema size %2$d",
                          fixedBytes.length,
                          fixedDataSchema.getSize());
            result = BAD_RESULT;
            break;
          }
          byteString = ByteString.copy(fixedBytes);
          result = byteString;
View Full Code Here

          }
          result = _avroAdapter.createEnumSymbol(avroSchema, enumValue);
          break;
        case FIXED:
          byte[] bytes = translateBytes(value);
          FixedDataSchema fixedDataSchema = (FixedDataSchema) dereferencedDataSchema;
          if (fixedDataSchema.getSize() != bytes.length)
          {
            appendMessage("ByteString size %1$d != FixedDataSchema size %2$d",
                          bytes.length,
                          fixedDataSchema.getSize());
            result = null;
            break;
          }
          GenericData.Fixed fixed = new GenericData.Fixed(avroSchema);
          fixed.bytes(bytes);
View Full Code Here

      // check for Object constructor
      Constructor<T> objectConstructor = fixedClass.getConstructor(Object.class);

      // has embedded FixedDataSchema
      FixedDataSchema schema = (FixedDataSchema) DataTemplateUtil.getSchema(fixedClass);

      // get size of fixed
      int size = schema.getSize();

      // create input value
      StringBuilder sb = new StringBuilder();
      for (int i = 0; i < size; i++)
      {
View Full Code Here

TOP

Related Classes of com.linkedin.data.schema.FixedDataSchema

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.