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

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

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

Box.count介绍

[英]Returns the count of all stored objects in this box.
[中]返回此框中所有存储对象的计数。

代码示例

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

/**
 * Returns the count of all stored objects in this box.
 */
public long count() {
  return count(0);
}

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

@Override
  public void run() {
    box.count();
  }
});

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

@Override
  public void run() {
    counts[0] = box.count();
    store.runInReadTx(new Runnable() {
      @Override
      public void run() {
        counts[1] = box.count();
      }
    });
  }
});

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

@Override
  public long[] call() throws Exception {
    long count1 = store.callInReadTx(new Callable<Long>() {
      @Override
      public Long call() throws Exception {
        return box.count();
      }
    });
    return new long[]{box.count(), count1};
  }
});

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

@Override
  public void run() {
    // Dummy TX, still will be committed, should not add anything to objectCounts
    getTestEntityBox().count();
  }
});

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

@Override
  public void run() {
    try {
      getTestEntityBox().count();
    } catch (Exception e) {
      exHolder[0] = e;
    }
  }
});

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

@Override
  public void run() {
    getTestEntityBox().count();
    thread.start();
    try {
      thread.join(5000);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
  }
});

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

@Override
  public void run() {
    // Dummy TX, still will be committed
    getTestEntityBox().count();
  }
});

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

@Override
  @SuppressWarnings("NullableProblems")
  public Long transform(Class source) throws Exception {
    assertNotSame(testThread, Thread.currentThread());
    return store.boxFor(source).count();
  }
});

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

@Override
  public void run() {
    box.put(new TestEntity());
    counts[0] = box.count();
    box.put(new TestEntity());
    counts[1] = box.count();
  }
});

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

@Test
public void testTwoReaders() {
  store.close();
  store.deleteAllFiles();
  store = createBoxStoreBuilderWithTwoEntities(false).build();
  box = store.boxFor(TestEntity.class);
  box.count();
  Box<TestEntityMinimal> box2 = store.boxFor(TestEntityMinimal.class);
  box2.count();
  box.count();
}

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

@Test
public void testClear_removeFromTargetBox() {
  Customer customer = putCustomerWithOrders(5);
  ToMany<Order> toMany = (ToMany<Order>) customer.orders;
  toMany.setRemoveFromTargetBox(true);
  toMany.clear();
  customerBox.put(customer);
  assertEquals(0, orderBox.count());
}

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

@Test
public void testClear_removeFromTargetBox() {
  Customer customer = putCustomerWithOrders(5);
  ToMany<Order> toMany = customer.ordersStandalone;
  toMany.setRemoveFromTargetBox(true);
  toMany.clear();
  customerBox.put(customer);
  assertEquals(0, orderBox.count());
}

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

@Test
public void testPanicModeRemoveAllObjects() {
  assertEquals(0, box.panicModeRemoveAll());
  putTestEntities(7);
  assertEquals(7, box.panicModeRemoveAll());
  assertEquals(0, box.count());
}

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

@Test
public void testAddRemove() {
  Customer customer = putCustomer();
  ToMany<Order> toMany = (ToMany<Order>) customer.orders;
  Order order = new Order();
  toMany.add(order);
  toMany.remove(order);
  toMany.applyChangesToDb();
  assertEquals(0, orderBox.count());
}

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

@Test
public void testAddRemove_notPersisted() {
  Customer customer = putCustomer();
  ToMany<Order> toMany = customer.ordersStandalone;
  Order order = new Order();
  toMany.add(order);
  toMany.remove(order);
  customerBox.put(customer);
  assertEquals(0, orderBox.count());
}

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

@Test
public void testRemove() {
  putTestEntitiesScalars();
  Query<TestEntity> query = box.query().greater(simpleInt, 2003).build();
  assertEquals(6, query.remove());
  assertEquals(4, box.count());
}

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

@Test
public void testClear() {
  int count = 5;
  Customer customer = putCustomerWithOrders(count);
  ToMany<Order> toMany = customer.ordersStandalone;
  toMany.clear();
  customerBox.put(customer);
  Customer customer2 = customerBox.get(customer.getId());
  assertEquals(0, customer2.getOrdersStandalone().size());
  assertEquals(count, orderBox.count());
}

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

private void assertOrder2And4Removed(int count, Customer customer, ToMany<Order> toMany) {
  assertEquals(count, orderBox.count());
  toMany.reset();
  assertEquals(3, toMany.size());
  assertEquals("order1", toMany.get(0).getText());
  assertEquals("order3", toMany.get(1).getText());
  assertEquals("order5", toMany.get(2).getText());
}

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

private void assertOrder2And4Removed(int count, Customer customer, ToMany<Order> toMany) {
  assertEquals(count - 2, countOrdersWithCustomerId(customer.getId()));
  assertEquals(count, orderBox.count());
  assertEquals(2, countOrdersWithCustomerId(0));
  toMany.reset();
  assertEquals(3, toMany.size());
  assertEquals("order1", toMany.get(0).getText());
  assertEquals("order3", toMany.get(1).getText());
  assertEquals("order5", toMany.get(2).getText());
}

相关文章