Ejemplo n.º 1
0
 public static void insertOrUpdate(
     Realm realm, Iterator<? extends RealmModel> objects, Map<RealmModel, Long> cache) {
   Table table = realm.getTable(some.test.Simple.class);
   long tableNativePtr = table.getNativeTablePointer();
   SimpleColumnInfo columnInfo =
       (SimpleColumnInfo) realm.schema.getColumnInfo(some.test.Simple.class);
   some.test.Simple object = null;
   while (objects.hasNext()) {
     object = (some.test.Simple) objects.next();
     if (!cache.containsKey(object)) {
       long rowIndex = Table.nativeAddEmptyRow(tableNativePtr, 1);
       cache.put(object, rowIndex);
       String realmGet$name = ((SimpleRealmProxyInterface) object).realmGet$name();
       if (realmGet$name != null) {
         Table.nativeSetString(tableNativePtr, columnInfo.nameIndex, rowIndex, realmGet$name);
       } else {
         Table.nativeSetNull(tableNativePtr, columnInfo.nameIndex, rowIndex);
       }
       Table.nativeSetLong(
           tableNativePtr,
           columnInfo.ageIndex,
           rowIndex,
           ((SimpleRealmProxyInterface) object).realmGet$age());
     }
   }
 }
Ejemplo n.º 2
0
 public static long insert(Realm realm, some.test.Simple object, Map<RealmModel, Long> cache) {
   Table table = realm.getTable(some.test.Simple.class);
   long tableNativePtr = table.getNativeTablePointer();
   SimpleColumnInfo columnInfo =
       (SimpleColumnInfo) realm.schema.getColumnInfo(some.test.Simple.class);
   long rowIndex = Table.nativeAddEmptyRow(tableNativePtr, 1);
   cache.put(object, rowIndex);
   String realmGet$name = ((SimpleRealmProxyInterface) object).realmGet$name();
   if (realmGet$name != null) {
     Table.nativeSetString(tableNativePtr, columnInfo.nameIndex, rowIndex, realmGet$name);
   }
   Table.nativeSetLong(
       tableNativePtr,
       columnInfo.ageIndex,
       rowIndex,
       ((SimpleRealmProxyInterface) object).realmGet$age());
   return rowIndex;
 }