io.objectbox.Box.getReader()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(4.4k)|赞(0)|评价(0)|浏览(183)

本文整理了Java中io.objectbox.Box.getReader()方法的一些代码示例,展示了Box.getReader()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Box.getReader()方法的具体详情如下:
包路径:io.objectbox.Box
类名称:Box
方法名:getReader

Box.getReader介绍

暂无

代码示例

代码示例来源:origin: objectbox/objectbox-java

public static <T> Cursor<T> getReader(Box<T> box) {
  return box.getReader();
}

代码示例来源:origin: objectbox/objectbox-java

/** Used by tests */
int getPropertyId(String propertyName) {
  Cursor<T> reader = getReader();
  try {
    return reader.getPropertyId(propertyName);
  } finally {
    releaseReader(reader);
  }
}

代码示例来源:origin: objectbox/objectbox-java

/**
 * Returns the count of all stored objects in this box or the given maxCount, whichever is lower.
 *
 * @param maxCount maximum value to count or 0 (zero) to have no maximum limit
 */
public long count(long maxCount) {
  Cursor<T> reader = getReader();
  try {
    return reader.count(maxCount);
  } finally {
    releaseReader(reader);
  }
}

代码示例来源:origin: objectbox/objectbox-java

/**
 * Get the stored objects for the given IDs.
 *
 * @return null if not found
 */
public List<T> get(long[] ids) {
  ArrayList<T> list = new ArrayList<>(ids.length);
  Cursor<T> reader = getReader();
  try {
    for (Long id : ids) {
      T entity = reader.get(id);
      if (entity != null) {
        list.add(entity);
      }
    }
  } finally {
    releaseReader(reader);
  }
  return list;
}

代码示例来源:origin: objectbox/objectbox-java

/**
 * Get the stored objects for the given IDs.
 *
 * @return null if not found
 */
public List<T> get(Iterable<Long> ids) {
  ArrayList<T> list = new ArrayList<>();
  Cursor<T> reader = getReader();
  try {
    for (Long id : ids) {
      T entity = reader.get(id);
      if (entity != null) {
        list.add(entity);
      }
    }
  } finally {
    releaseReader(reader);
  }
  return list;
}

代码示例来源:origin: objectbox/objectbox-java

public synchronized EntityInfo getEntityInfo() {
  if (entityInfo == null) {
    Cursor<T> reader = getReader();
    try {
      entityInfo = reader.getEntityInfo();
    } finally {
      releaseReader(reader);
    }
  }
  return entityInfo;
}

代码示例来源:origin: objectbox/objectbox-java

/**
 * Get the stored objects for the given IDs as a Map with IDs as keys, and entities as values.
 * IDs for which no entity is found will be put in the map with null values.
 *
 * @return null if not found
 */
public Map<Long, T> getMap(Iterable<Long> ids) {
  HashMap<Long, T> map = new HashMap<>();
  Cursor<T> reader = getReader();
  try {
    for (Long id : ids) {
      map.put(id, reader.get(id));
    }
  } finally {
    releaseReader(reader);
  }
  return map;
}

代码示例来源:origin: objectbox/objectbox-java

/**
 * Get the stored object for the given ID.
 *
 * @return null if not found
 */
public T get(long id) {
  Cursor<T> reader = getReader();
  try {
    return reader.get(id);
  } finally {
    releaseReader(reader);
  }
}

代码示例来源:origin: objectbox/objectbox-java

@Internal
public List<T> internalGetBacklinkEntities(int entityId, Property relationIdProperty, long key) {
  Cursor<T> reader = getReader();
  try {
    return reader.getBacklinkEntities(entityId, relationIdProperty, key);
  } finally {
    releaseReader(reader);
  }
}

代码示例来源:origin: objectbox/objectbox-java

/**
 * Returns all stored Objects in this Box.
 */
public List<T> getAll() {
  Cursor<T> cursor = getReader();
  try {
    T first = cursor.first();
    if (first == null) {
      return Collections.emptyList();
    } else {
      ArrayList<T> list = new ArrayList<>();
      list.add(first);
      while (true) {
        T next = cursor.next();
        if (next != null) {
          list.add(next);
        } else {
          break;
        }
      }
      return list;
    }
  } finally {
    releaseReader(cursor);
  }
}

代码示例来源:origin: objectbox/objectbox-java

@Internal
public List<T> internalGetRelationEntities(int sourceEntityId, int relationId, long key, boolean backlink) {
  Cursor<T> reader = getReader();
  try {
    return reader.getRelationEntities(sourceEntityId, relationId, key, backlink);
  } finally {
    releaseReader(reader);
  }
}

代码示例来源:origin: objectbox/objectbox-java

public String getReaderDebugInfo() {
  Cursor<T> reader = getReader();
  try {
    return reader + " with " + reader.getTx() + "; store's commit count: " + getStore().commitCount;
  } finally {
    releaseReader(reader);
  }
}

代码示例来源:origin: objectbox/objectbox-java

@Internal
public <RESULT> RESULT internalCallWithReaderHandle(CallWithHandle<RESULT> task) {
  Cursor<T> reader = getReader();
  try {
    return task.call(reader.internalHandle());
  } finally {
    releaseReader(reader);
  }
}

代码示例来源:origin: objectbox/objectbox-java

@Test
public void testCloseThreadResources() {
  Box<TestEntity> box = store.boxFor(TestEntity.class);
  Cursor<TestEntity> reader = box.getReader();
  box.releaseReader(reader);
  Cursor<TestEntity> reader2 = box.getReader();
  box.releaseReader(reader2);
  assertSame(reader, reader2);
  store.closeThreadResources();
  Cursor<TestEntity> reader3 = box.getReader();
  box.releaseReader(reader3);
  assertNotSame(reader, reader3);
}

相关文章