Package com.linkedin.data.schema

Examples of com.linkedin.data.schema.ArrayDataSchema


      ArrayTemplate array2a = DataTemplateUtil.wrap(dataList2, templateClass); // without schema arg
      assertEquals(array1, array2a);
      assertSame(array2.data(), array2a.data());

      // schema()
      ArrayDataSchema schema1 = array1.schema();
      assertTrue(schema1 != null);
      assertEquals(schema1.getType(), DataSchema.Type.ARRAY);
      assertEquals(schema1, schema);

      // add(E element), get(int index)
      ArrayTemplate array3 = templateClass.newInstance();
      for (int i = 0; i < adds.size(); ++i)
View Full Code Here


  }

  @Test
  public void testBooleanArray()
  {
    ArrayDataSchema schema = (ArrayDataSchema) DataTemplateUtil.parseSchema("{ \"type\" : \"array\", \"items\" : \"boolean\" }");

    List<Boolean> input = Arrays.asList(true, false); // must be unique
    List<Boolean> adds = Arrays.asList(false, true, true, false);
    List<Object> badInput = asList(1, 2L, 3f, 4.0, "hello", ByteString.empty(), new StringMap(), new StringArray(), null);
    List<Object> badOutput = asList(1, 2L, 3f, 4.0, "hello", ByteString.empty(), new DataMap(), new DataList());
View Full Code Here

  }

  @Test
  public void testIntegerArray()
  {
    ArrayDataSchema schema = (ArrayDataSchema) DataTemplateUtil.parseSchema("{ \"type\" : \"array\", \"items\" : \"int\" }");

    List<Integer> input = Arrays.asList(1, 3, 5, 7, 11); // must be unique
    List<Integer> adds = Arrays.asList(13, 17, 19);
    List<Object> badInput = asList(true, "hello", ByteString.empty(), new StringMap(), new StringArray(), null);
    List<Object> badOutput = asList(true, "hello", ByteString.empty(), new DataMap(), new DataList());
View Full Code Here

  }

  @Test
  public void testLongArray()
  {
    ArrayDataSchema schema = (ArrayDataSchema) DataTemplateUtil.parseSchema("{ \"type\" : \"array\", \"items\" : \"long\" }");

    List<Long> input = Arrays.asList(1L, 3L, 5L, 7L, 11L); // must be unique
    List<Long> adds = Arrays.asList(13L, 17L, 19L);
    List<Object> badInput = asList(true, "hello", ByteString.empty(), new StringMap(), new StringArray(), null);
    List<Object> badOutput = asList(true, "hello", ByteString.empty(), new DataMap(), new DataList());
View Full Code Here

  }

  @Test
  public void testFloatArray()
  {
    ArrayDataSchema schema = (ArrayDataSchema) DataTemplateUtil.parseSchema("{ \"type\" : \"array\", \"items\" : \"float\" }");

    List<Float> input = Arrays.asList(1.0f, 3.0f, 5.0f, 7.0f, 11.0f); // must be unique
    List<Float> adds = Arrays.asList(13.0f, 17.0f, 19.0f);
    List<Object> badInput = asList(true, "hello", ByteString.empty(), new StringMap(), new StringArray(), null);
    List<Object> badOutput = asList(true, "hello", ByteString.empty(), new DataMap(), new DataList());
View Full Code Here

  }

  @Test
  public void testDoubleArray()
  {
    ArrayDataSchema schema = (ArrayDataSchema) DataTemplateUtil.parseSchema("{ \"type\" : \"array\", \"items\" : \"double\" }");

    List<Double> input = Arrays.asList(1.0, 3.0, 5.0, 7.0, 11.0); // must be unique
    List<Double> adds = Arrays.asList(13.0, 17.0, 19.0);
    List<Object> badInput = asList(true, "hello", ByteString.empty(), new StringMap(), new StringArray(), null);
    List<Object> badOutput = asList(true, "hello", ByteString.empty(), new DataMap(), new DataList());
View Full Code Here

  }

  @Test
  public void testStringArray()
  {
    ArrayDataSchema schema = (ArrayDataSchema) DataTemplateUtil.parseSchema("{ \"type\" : \"array\", \"items\" : \"string\" }");

    List<String> input = Arrays.asList("apple", "banana", "orange", "pineapple", "graphs"); // must be unique
    List<String> adds = Arrays.asList("foo", "bar", "baz");
    List<Object> badInput = asList(true, 1, 2L, 3.0f, 4.0, ByteString.empty(), new StringMap(), new StringArray(), null);
    List<Object> badOutput = asList(true, 1, 2L, 3.0f, 4.0, ByteString.empty(), new DataMap(), new DataList());
View Full Code Here

  }

  @Test
  public void testBytesArray()
  {
    ArrayDataSchema schema = (ArrayDataSchema) DataTemplateUtil.parseSchema("{ \"type\" : \"array\", \"items\" : \"bytes\" }");

    List<ByteString> input = Arrays.asList(ByteString.copyAvroString("1", false), ByteString.copyAvroString("3", false), ByteString.copyAvroString("5", false), ByteString.copyAvroString("7", false), ByteString.copyAvroString("11", false));
    List<ByteString> adds = Arrays.asList(ByteString.copyAvroString("13", false), ByteString.copyAvroString("17", false), ByteString.copyAvroString("19", false));
    List<Object> badInput = asList(true, 99, 999L, 88.0f, 888.0, "\u0100", new StringMap(), new StringArray(), null);
    List<Object> badOutput = asList(true, 99, 999L, 88.0f, 888.0, "\u0100", new DataMap(), new DataList());
View Full Code Here

      "double", Double.class,
      "boolean", Boolean.class,
      "string", String.class);
    for (Map.Entry<String, Class<?>> e : primitiveStringToClassMap.entrySet())
    {
      ArrayDataSchema schema = (ArrayDataSchema) DataTemplateUtil.parseSchema("{ \"type\" : \"array\", \"items\" : \"" + e.getKey() + "\" }");
      @SuppressWarnings("unchecked")
      PrimitiveLegacyArray<?> array = new PrimitiveLegacyArray<Object>(new DataList(), schema, (Class)e.getValue());
    }
    EnumLegacyArray enumArray = new EnumLegacyArray(new DataList());
  }
View Full Code Here

    {
      arrayClass._extends(_wrappingArrayClass.narrow(itemClass));
    }

    // see schemaForArrayItemsOrMapValues
    ArrayDataSchema bareSchema = new ArrayDataSchema(schemaForArrayItemsOrMapValues(customInfo, itemSchema));
    JVar schemaField = generateSchemaField(arrayClass, bareSchema);

    generateConstructorWithNoArg(arrayClass, _dataListClass);
    generateConstructorWithInitialCapacity(arrayClass, _dataListClass);
    generateConstructorWithCollection(arrayClass, itemClass);
View Full Code Here

TOP

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

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.