Package com.linkedin.data.schema

Examples of com.linkedin.data.schema.MapDataSchema


    {
      mapClass._extends(_wrappingMapClass.narrow(valueClass));
    }

    // see schemaForArrayItemsOrMapValues
    MapDataSchema bareSchema = new MapDataSchema(schemaForArrayItemsOrMapValues(customInfo, valueSchema));
    JVar schemaField = generateSchemaField(mapClass, bareSchema);

    generateConstructorWithNoArg(mapClass, _dataMapClass);
    generateConstructorWithInitialCapacity(mapClass, _dataMapClass);
    generateConstructorWithInitialCapacityAndLoadFactor(mapClass);
View Full Code Here


          ClassInfo classInfo = classNameForUnnamedTraverse(parentClass, memberName, arraySchema.getItems());
          classInfo.name += ARRAY_SUFFIX;
          return classInfo;
        }
      case MAP:
        MapDataSchema mapSchema = (MapDataSchema) dereferencedDataSchema;
        customInfo = firstCustomInfo(mapSchema.getValues());
        if (customInfo != null)
        {
          return new ClassInfo(customInfo.customSchema.getNamespace(), customInfo.customSchema.getName() + MAP_SUFFIX);
        }
        else
        {
          ClassInfo classInfo = classNameForUnnamedTraverse(parentClass, memberName, mapSchema.getValues());
          classInfo.name += MAP_SUFFIX;
          return classInfo;
        }

      case UNION:
View Full Code Here

      ArrayDataSchema arraySchema = (ArrayDataSchema)schema;
      recordType(arraySchema.getItems(), foundTypes, typeOrder);
    }
    else if (schema instanceof MapDataSchema)
    {
      MapDataSchema mapSchema = (MapDataSchema)schema;
      recordType(mapSchema.getValues(), foundTypes, typeOrder);
    }
    else if (schema instanceof UnionDataSchema)
    {
      UnionDataSchema unionSchema = (UnionDataSchema)schema;
      for(DataSchema type : unionSchema.getTypes())
View Full Code Here

  public void testMapSchema()
  {
    for (Map.Entry<DataSchema.Type, Class<? extends DirectMapTemplate<?>>> entry: _dataSchemaTypeToprimitiveMapMap.entrySet())
    {
      final PrimitiveDataSchema valueSchema = DataSchemaUtil.dataSchemaTypeToPrimitiveDataSchema(entry.getKey());
      final MapDataSchema mapSchema = new MapDataSchema(valueSchema);
      final DataMap value = (DataMap) SchemaSampleDataGenerator.buildData(mapSchema, _spec);
      final ParameterizedType mapType = (ParameterizedType) entry.getValue().getGenericSuperclass();
      assert(mapType.getRawType() == DirectMapTemplate.class);
      Assert.assertSame(value.values().iterator().next().getClass(), mapType.getActualTypeArguments()[0]);
    }
View Full Code Here

        lastHash = newHash;
      }

      // schema()
      MapDataSchema schema1 = map1.schema();
      assertTrue(schema1 != null);
      assertEquals(schema1.getType(), DataSchema.Type.MAP);
      assertEquals(schema1, schema);

      // get(Object key), put(K key, V value, containsKey(Object key), containsValue(Object value), toString
      MapTemplate map3 = templateClass.newInstance();
      for (Map.Entry<String, E> e : input.entrySet())
View Full Code Here

  }

  @Test
  public void testBooleanMap()
  {
    MapDataSchema schema = (MapDataSchema) DataTemplateUtil.parseSchema("{ \"type\" : \"map\", \"values\" : \"boolean\" }");

    Map<String, Boolean> input = asMap("true", true, "false", false);
    Map<String, Boolean> adds = asMap("thirteen", true, "seventeen", false, "nineteen", true);
    Map<String, Object> badInput = asMap("integer", 99, "long", 999L, "float", 88.0f, "double", 888.0, "string", "hello",
                                         "bytes", ByteString.empty(),
View Full Code Here

  }

  @Test
  public void testIntegerMap()
  {
    MapDataSchema schema = (MapDataSchema) DataTemplateUtil.parseSchema("{ \"type\" : \"map\", \"values\" : \"int\" }");

    Map<String, Integer> input = asMap("one", 1, "three", 3, "five", 5, "seven", 7, "eleven", 11);
    Map<String, Integer> adds = asMap("thirteen", 13, "seventeen", 17, "nineteen", 19);
    Map<String, Object> badInput = asMap("boolean", true, "string", "hello",
                                         "bytes", ByteString.empty(),
View Full Code Here

  }

  @Test
  public void testLongMap()
  {
    MapDataSchema schema = (MapDataSchema) DataTemplateUtil.parseSchema("{ \"type\" : \"map\", \"values\" : \"long\" }");

    Map<String, Long> input = asMap("one", 1L, "three", 3L, "five", 5L, "seven", 7L, "eleven", 11L);
    Map<String, Long> adds = asMap("thirteen", 13L, "seventeen", 17L, "nineteen", 19L);
    Map<String, Object> badInput = asMap("boolean", true, "string", "hello",
                                         "bytes", ByteString.empty(),
View Full Code Here

  }

  @Test
  public void testFloatMap()
  {
    MapDataSchema schema = (MapDataSchema) DataTemplateUtil.parseSchema("{ \"type\" : \"map\", \"values\" : \"float\" }");

    Map<String, Float> input = asMap("one", 1.0f, "three", 3.0f, "five", 5.0f, "seven", 7.0f, "eleven", 11.0f);
    Map<String, Float> adds = asMap("thirteen", 13.0f, "seventeen", 17.0f, "nineteen", 19.0f);
    Map<String, Object> badInput = asMap("boolean", true, "string", "hello",
                                         "bytes", ByteString.empty(),
View Full Code Here

  }

  @Test
  public void testDoubleMap()
  {
    MapDataSchema schema = (MapDataSchema) DataTemplateUtil.parseSchema("{ \"type\" : \"map\", \"values\" : \"double\" }");

    Map<String, Double> input = asMap("one", 1.0, "three", 3.0, "five", 5.0, "seven", 7.0, "eleven", 11.0);
    Map<String, Double> adds = asMap("thirteen", 13.0, "seventeen", 17.0, "nineteen", 19.0);
    Map<String, Object> badInput = asMap("boolean", true, "string", "hello",
                                         "bytes", ByteString.empty(),
View Full Code Here

TOP

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

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.