Package com.linkedin.data

Examples of com.linkedin.data.DataMap


        return false;
      }
      else if (opChild.getClass() == DataMap.class)
      {
        usedFields.put(name, CHILD_PROCESS_PSEUDOCOMMAND);
        DataMap opChildDataMap = (DataMap) opChild;
        Object dataChild = dataNode.get(name);
        if (dataChild == null)
        {

          // this is an optimization: if respective object does not exist in data
          // and if patch's branch contains only deletes operations, then it is
          // not necessary to create nodes on the data object and process that branch
          if (!hasDeletesOnly(opChildDataMap))
          {

            // if patch does data manipulations other than deletes, then we need to
            // create respective branch in data object and continue processing patch
            // on that branch
            dataChild = new DataMap();
            dataNode.put(name, dataChild);
            instrCtx.scheduleInstruction(new Instruction(opChild, (DataMap)dataChild, instrCtx.getPath()));
          }
        }
        else
View Full Code Here


      assert deleteCommand.getClass() == DataList.class;
      // data is of type DataMap
      assert data.getClass() == DataMap.class;

      DataList delDataList = (DataList) deleteCommand;
      DataMap dataDataMap = (DataMap) data;

      for (Object key : delDataList)
      {
        if (usedFields.containsKey(key))
        {
          instrCtx.addErrorMessage("field %1$s can not be used in both %2$s operation and " +
              DELETE_COMMAND + " operation at the same time", key, usedFields.get(key));
          return false;
        }
        else
        {
          usedFields.put(key.toString(), DELETE_COMMAND);
          dataDataMap.remove(key);
        }
      }
    }
    return true;
  }
View Full Code Here

      // deleteCommand value is of DataMap type
      assert setCommand.getClass() == DataMap.class : setCommand.getClass();
      // data is of DataMap type
      assert data.getClass() == DataMap.class : data.getClass();

      DataMap setDataMap = (DataMap) setCommand;
      DataMap dataDataMap = (DataMap) data;

      for (Entry<String, Object> entry : setDataMap.entrySet())
      {
        String key = entry.getKey();
        if (usedFields.containsKey(key))
        {
          instrCtx.addErrorMessage("field %1$s can not be used in both %2$s operation and " +
              SET_COMMAND + " operation at the same time", key, usedFields.get(key));
          return false;
        }
        else
        {
          usedFields.put(key.toString(), SET_COMMAND);
          dataDataMap.put(key, entry.getValue());
        }
      }
    }
    return true;
  }
View Full Code Here

  /**
   * Initialize a new {@link MaskTree}.
   */
  public MaskTree()
  {
    _representation = new DataMap();
  }
View Full Code Here

  public void addOperation(PathSpec path, MaskOperation op)
  {
    List<String> segments = path.getPathComponents();


    final DataMap fieldMask = new DataMap();
    DataMap map = fieldMask;  //map variable contains DataMap, into which current segment will be put
    for (int ii = 0; ii<segments.size()-1; ++ii)
    {
      String segment = Escaper.escapePathSegment(segments.get(ii));
      DataMap childMap = new DataMap();
      map.put(segment, childMap);
      map = childMap;
    }
    String lastSegment = Escaper.escapePathSegment(segments.get(segments.size()-1));
    map.put(lastSegment, op.getRepresentation());
View Full Code Here

  }

  @Override
  protected Object onFilterDataMap(DataMap data, Map<String, Object> fieldToOperation)
  {
    final DataMap resultMap = new DataMap((int)(fieldToOperation.size() / 0.75f + 1));

    for (Map.Entry<String, Object> entry : fieldToOperation.entrySet())
    {
      final Object operation = entry.getValue();
      final Object value;
View Full Code Here

    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());

    testArray(BooleanArray.class, schema, input, adds);
    testArrayBadInput(BooleanArray.class, schema, input, badInput, badOutput);
  }
View Full Code Here

    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());

    testArray(IntegerArray.class, schema, input, adds);
    testArrayBadInput(IntegerArray.class, schema, input, badInput, badOutput);

    @SuppressWarnings("unchecked")
View Full Code Here

    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());

    testArray(LongArray.class, schema, input, adds);
    testArrayBadInput(LongArray.class, schema, input, badInput, badOutput);

    @SuppressWarnings("unchecked")
View Full Code Here

    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());

    testArray(FloatArray.class, schema, input, adds);
    testArrayBadInput(FloatArray.class, schema, input, badInput, badOutput);

    @SuppressWarnings("unchecked")
View Full Code Here

TOP

Related Classes of com.linkedin.data.DataMap

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.