当前位置: 首页>>代码示例>>Java>>正文


Java PdxInstance类代码示例

本文整理汇总了Java中org.apache.geode.pdx.PdxInstance的典型用法代码示例。如果您正苦于以下问题:Java PdxInstance类的具体用法?Java PdxInstance怎么用?Java PdxInstance使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PdxInstance类属于org.apache.geode.pdx包,在下文中一共展示了PdxInstance类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: pdxToJson

import org.apache.geode.pdx.PdxInstance; //导入依赖的package包/类
private static String pdxToJson(PdxInstance obj) {
  if (obj != null) {
    try {
      GfJsonObject json = new GfJsonObject();
      for (String field : obj.getFieldNames()) {
        Object fieldValue = obj.getField(field);
        if (fieldValue != null) {
          if (JsonUtil.isPrimitiveOrWrapper(fieldValue.getClass())) {
            json.put(field, fieldValue);
          } else {
            json.put(field, fieldValue.getClass());
          }
        }
      }
      return json.toString();
    } catch (GfJsonException e) {
      return null;
    }
  }
  return null;
}
 
开发者ID:ampool,项目名称:monarch,代码行数:22,代码来源:DataCommandFunction.java

示例2: readPdxEnum

import org.apache.geode.pdx.PdxInstance; //导入依赖的package包/类
/**
 * @throws IOException since 6.6.2
 */
private static Object readPdxEnum(DataInput in) throws IOException {
  int dsId = in.readByte();
  int tmp = readArrayLength(in);
  int enumId = (dsId << 24) | (tmp & 0xFFFFFF);
  if (logger.isTraceEnabled(LogMarker.SERIALIZER)) {
    logger.trace(LogMarker.SERIALIZER, "read PdxEnum id={}", enumId);
  }
  GemFireCacheImpl gfc = GemFireCacheImpl
      .getForPdx("PDX registry is unavailable because the Cache has been closed.");
  TypeRegistry tr = gfc.getPdxRegistry();

  Object result = tr.getEnumById(enumId);
  if (result instanceof PdxInstance) {
    getDMStats(gfc).incPdxInstanceCreations();
  }
  return result;
}
 
开发者ID:ampool,项目名称:monarch,代码行数:21,代码来源:InternalDataSerializer.java

示例3: checkEquals

import org.apache.geode.pdx.PdxInstance; //导入依赖的package包/类
static boolean checkEquals(@Unretained Object v1, @Unretained Object v2,
    boolean isCompressedOffHeap) {
  // need to give PdxInstance#equals priority
  if (v1 instanceof PdxInstance) {
    return checkPdxEquals((PdxInstance) v1, v2);
  } else if (v2 instanceof PdxInstance) {
    return checkPdxEquals((PdxInstance) v2, v1);
  } else if (v1 instanceof StoredObject) {
    return checkOffHeapEquals((StoredObject) v1, v2);
  } else if (v2 instanceof StoredObject) {
    return checkOffHeapEquals((StoredObject) v2, v1);
  } else if (v1 instanceof CachedDeserializable) {
    return checkCDEquals((CachedDeserializable) v1, v2, isCompressedOffHeap);
  } else if (v2 instanceof CachedDeserializable) {
    return checkCDEquals((CachedDeserializable) v2, v1, isCompressedOffHeap);
  } else {
    return basicEquals(v1, v2);
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:20,代码来源:AbstractRegionEntry.java

示例4: verifyAndGetPdxDomainObject

import org.apache.geode.pdx.PdxInstance; //导入依赖的package包/类
private Object verifyAndGetPdxDomainObject(Object value) {
  if (value instanceof StructImpl) {
    // Doing hasPdx check first, since its cheaper.
    if (((StructImpl) value).isHasPdx() && !((GemFireCacheImpl) this.region.getCache())
        .getPdxReadSerializedByAnyGemFireServices()) {
      // Set the pdx values for the struct object.
      StructImpl v = (StructImpl) value;
      Object[] fieldValues = v.getPdxFieldValues();
      return new StructImpl((StructTypeImpl) v.getStructType(), fieldValues);
    }
  } else if (value instanceof PdxInstance && !((GemFireCacheImpl) this.region.getCache())
      .getPdxReadSerializedByAnyGemFireServices()) {
    return ((PdxInstance) value).getObject();
  }
  return value;
}
 
开发者ID:ampool,项目名称:monarch,代码行数:17,代码来源:AbstractIndex.java

示例5: deserializePdxForLocalDistinctQuery

import org.apache.geode.pdx.PdxInstance; //导入依赖的package包/类
private Object deserializePdxForLocalDistinctQuery(ExecutionContext context, Object val)
    throws QueryInvocationTargetException {
  if (!((DefaultQuery) context.getQuery()).isRemoteQuery()) {
    if (context.isDistinct() && val instanceof PdxInstance
        && !this.region.getCache().getPdxReadSerialized()) {
      try {
        val = ((PdxInstance) val).getObject();
      } catch (Exception ex) {
        throw new QueryInvocationTargetException(
            "Unable to retrieve domain object from PdxInstance while building the ResultSet. "
                + ex.getMessage());
      }
    } else if (val instanceof PdxString) {
      val = ((PdxString) val).toString();
    }
  }
  return val;
}
 
开发者ID:ampool,项目名称:monarch,代码行数:19,代码来源:AbstractIndex.java

示例6: StructImpl

import org.apache.geode.pdx.PdxInstance; //导入依赖的package包/类
/** Creates a new instance of StructImpl */
public StructImpl(StructTypeImpl type, Object[] values) {
  if (type == null) {
    throw new IllegalArgumentException(
        LocalizedStrings.StructImpl_TYPE_MUST_NOT_BE_NULL.toLocalizedString());
  }
  this.type = type;
  this.values = values;
  if (this.values != null) {
    for (Object o : values) {
      if (o instanceof PdxInstance || o instanceof PdxString) {
        this.hasPdx = true;
        break;
      }
    }
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:18,代码来源:StructImpl.java

示例7: getPdxFieldValues

import org.apache.geode.pdx.PdxInstance; //导入依赖的package包/类
/**
 * Helper method, Returns field values, in case of PdxInstance gets the domain objects.
 */
public Object[] getPdxFieldValues() {
  if (this.values == null) {
    return new Object[0];
  }

  Object[] fValues = new Object[this.values.length];
  for (int i = 0; i < this.values.length; i++) {
    if (this.values[i] instanceof PdxInstance) {
      fValues[i] = ((PdxInstance) this.values[i]).getObject();
    } else if (this.values[i] instanceof PdxString) {
      fValues[i] = ((PdxString) this.values[i]).toString();
    } else {
      fValues[i] = this.values[i];
    }
  }
  return fValues;
}
 
开发者ID:ampool,项目名称:monarch,代码行数:21,代码来源:StructImpl.java

示例8: testPDXObject

import org.apache.geode.pdx.PdxInstance; //导入依赖的package包/类
@Test
public void testPDXObject() {
  final Properties props = new Properties();
  props.setProperty(MCAST_PORT, "0");
  DistributedSystem.connect(props);
  Cache cache = new CacheFactory().create();
  PdxInstanceFactory pf = PdxInstanceFactoryImpl.newCreator("Portfolio", false);
  Portfolio p = new Portfolio(2);
  pf.writeInt("ID", 111);
  pf.writeString("status", "active");
  pf.writeString("secId", "IBM");
  pf.writeObject("portfolio", p);
  PdxInstance pi = pf.create();

  TypedJson tJsonObj = new TypedJson(RESULT, pi);
  System.out.println(tJsonObj);
  cache.close();

}
 
开发者ID:ampool,项目名称:monarch,代码行数:20,代码来源:TypedJsonJUnitTest.java

示例9: testNestedPDXObject

import org.apache.geode.pdx.PdxInstance; //导入依赖的package包/类
@Test
public void testNestedPDXObject() {
  final Properties props = new Properties();
  props.setProperty(MCAST_PORT, "0");
  DistributedSystem.connect(props);
  Cache cache = new CacheFactory().create();

  PdxInstanceFactory pf = PdxInstanceFactoryImpl.newCreator("Portfolio", false);

  pf.writeInt("ID", 111);
  pf.writeString("status", "active");
  pf.writeString("secId", "IBM");
  PdxInstance pi = pf.create();

  PDXContainer cont = new PDXContainer(1);
  cont.setPi(pi);

  TypedJson tJsonObj = new TypedJson(RESULT, cont);
  System.out.println(tJsonObj);
  cache.close();

}
 
开发者ID:ampool,项目名称:monarch,代码行数:23,代码来源:TypedJsonJUnitTest.java

示例10: testPdxWithStringIndexKeyValues

import org.apache.geode.pdx.PdxInstance; //导入依赖的package包/类
@Test
public void testPdxWithStringIndexKeyValues() throws Exception {
  createPartitionedRegion("test_region");
  int numEntries = 10;
  Index index = qs.createHashIndex("idHash", "p.id", "/test_region p");
  for (int i = 0; i < numEntries; i++) {
    PdxInstance record = CacheUtils.getCache().createPdxInstanceFactory("test_region")
        .writeString("id", "" + i).writeString("domain", "A").create();
    region.put("" + i, record);
  }

  SelectResults results = (SelectResults) qs
      .newQuery("SELECT DISTINCT tr.domain FROM /test_region tr WHERE tr.id='1'").execute();
  assertEquals(1, results.size());
  assertTrue(observer.indexUsed);
}
 
开发者ID:ampool,项目名称:monarch,代码行数:17,代码来源:HashIndexQueryIntegrationTest.java

示例11: putHeterogeneousObjects

import org.apache.geode.pdx.PdxInstance; //导入依赖的package包/类
public void putHeterogeneousObjects() throws Exception {
  PdxInstanceFactory pf = PdxInstanceFactoryImpl.newCreator("Portfolio", false);
  pf.writeInt("ID", 111);
  pf.writeString("secId", "IBM");
  pf.writeString("status", "active");
  PdxInstance pi = pf.create();
  r.put("IBM", pi);

  r.put("YHOO", new TestObject(222, "YHOO", "inactive"));
  r.put("GOOGL", new TestObject(333, "GOOGL", "active"));

  pf = PdxInstanceFactoryImpl.newCreator("Portfolio", false);
  pf.writeInt("ID", 111);
  pf.writeString("secId", "VMW");
  pf.writeString("status", "inactive");
  pi = pf.create();
  r.put("VMW", pi);
}
 
开发者ID:ampool,项目名称:monarch,代码行数:19,代码来源:PdxStringQueryJUnitTest.java

示例12: createPdxInstance

import org.apache.geode.pdx.PdxInstance; //导入依赖的package包/类
public PdxInstance createPdxInstance(PdxInstanceFactory pdxFactory) {
  pdxFactory.writeInt("ID", this.ID);
  pdxFactory.writeString("pkid", this.pkid);
  pdxFactory.writeObject("position1", this.position1);
  pdxFactory.writeObject("position2", this.position2);
  pdxFactory.writeObject("positions", this.positions);
  pdxFactory.writeObject("collectionHolderMap", this.collectionHolderMap);
  pdxFactory.writeString("type", this.type);
  pdxFactory.writeString("status", this.status);
  pdxFactory.writeStringArray("names", this.names);
  pdxFactory.writeString("description", this.description);
  pdxFactory.writeLong("createTime", this.createTime);
  pdxFactory.writeObjectArray("position3", this.position3);

  return pdxFactory.create();

}
 
开发者ID:ampool,项目名称:monarch,代码行数:18,代码来源:PortfolioPdxVersion.java

示例13: toJSON

import org.apache.geode.pdx.PdxInstance; //导入依赖的package包/类
/**
 * Converts a PdxInstance into a JSON document
 * 
 * @return the JSON string.
 * @throws JSONFormatterException if unable to create the JSON document
 */
public static String toJSON(PdxInstance pdxInstance) {
  try {
    PdxToJSON pj = new PdxToJSON(pdxInstance);
    return pj.getJSON();
  } catch (Exception e) {
    throw new JSONFormatterException("Could not create JSON document from PdxInstance", e);
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:15,代码来源:JSONFormatter.java

示例14: toJSONByteArray

import org.apache.geode.pdx.PdxInstance; //导入依赖的package包/类
/**
 * Converts a PdxInstance into a JSON document in byte-array form
 * 
 * @return the JSON byte array.
 * @throws JSONFormatterException if unable to create the JSON document
 */
public static byte[] toJSONByteArray(PdxInstance pdxInstance) {
  try {
    PdxToJSON pj = new PdxToJSON(pdxInstance);
    return pj.getJSONByteArray();
  } catch (Exception e) {
    throw new JSONFormatterException("Could not create JSON document from PdxInstance", e);
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:15,代码来源:JSONFormatter.java

示例15: getJSONString

import org.apache.geode.pdx.PdxInstance; //导入依赖的package包/类
private String getJSONString(JsonGenerator jg, PdxInstance pdxInstance)
    throws JsonGenerationException, IOException {
  jg.writeStartObject();

  List<String> pdxFields = pdxInstance.getFieldNames();

  for (String pf : pdxFields) {
    Object value = pdxInstance.getField(pf);
    jg.writeFieldName(pf);
    writeValue(jg, value, pf);
  }
  jg.writeEndObject();
  return null;
}
 
开发者ID:ampool,项目名称:monarch,代码行数:15,代码来源:PdxToJSON.java


注:本文中的org.apache.geode.pdx.PdxInstance类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。