/** * Delete them all. * @return How many were deleted */ public int flush() { final Iterator<Item> items = this.table.frame().iterator(); int total = 0; while (items.hasNext()) { items.next(); items.remove(); ++total; } return total; }
Region region = new Region.Simple(credentials); Table table = region.table("my-table"); Collection<Item> items = table.frame().where("name", "Jeff"); for (Item item : items) { System.out.println(item.get("salary").getS()); }
@Override @RetryOnFailure(verbose = false, delay = Tv.FIVE, unit = TimeUnit.SECONDS) public Frame frame() { return new ReFrame(this.origin.frame()); }
Credentials credentials = new Credentials.Simple("AWS key", "AWS secret"); Region region = new Region.Simple(credentials); Table table = region.table("foo"); Collection<Item> items = table.frame().where("id", Conditions.equalTo(123)); for (Item item : items) { System.out.println(item.get("name").getS()); }
Credentials credentials = new Credentials.Simple("AWS key", "AWS secret"); Region region = new Region.Simple(credentials); Table table = region.table("foo"); Collection<Item> items = table.frame().where("id", Conditions.equalTo(123)); for (Item item : items) { System.out.println(item.get("name").getS()); }
@Override @RetryOnFailure(verbose = false, delay = Tv.FIVE, unit = TimeUnit.SECONDS) public Frame frame() { return new ReFrame(this.origin.frame()); }
@Override @Cacheable.FlushBefore public boolean remove(@NotNull final Domain domain) { final Iterator<Item> items = this.region.table(this.table).frame() .where(DefaultDynamo.NAME, domain.name()) .through(new ScanValve().withLimit(Tv.MILLION)) .iterator(); boolean removed = false; while (items.hasNext()) { items.next(); items.remove(); removed = true; } return removed; }
@Override public void unlock(final String name) { Iterables.removeIf( this.table.frame() .through(new QueryValve()) .where(DyLocks.HASH, this.owner.toString()) .where(DyLocks.RANGE, name), Predicates.alwaysTrue() ); }
@Override @Cacheable(forever = true) public boolean exists() { return this.region.table(DefaultUser.TOKENS) .frame().through(new QueryValve()) .where(DefaultUser.HASH, Conditions.equalTo(this.name)) .iterator().hasNext(); }
@Override @Cacheable(lifetime = 1, unit = TimeUnit.HOURS) public Iterable<String> names() { return Iterables.transform( this.table.frame() .through(new QueryValve()) .where(DyCounters.HASH, Conditions.equalTo(this.owner)), new Function<Item, String>() { @Override public String apply(final Item item) { try { return item.get(DyCounters.RANGE).getS(); } catch (final IOException ex) { throw new IllegalStateException(ex); } } } ); } }
@Override public String label(final String name) throws IOException { final Iterator<Item> items = this.table.frame() .through(new QueryValve()) .where(DyLocks.HASH, this.owner.toString()) .where(DyLocks.RANGE, name) .iterator(); String msg = ""; if (items.hasNext()) { msg = items.next().get(DyLocks.ATTR_LABEL).getS(); } return msg; } }
@Override public Map<String, String> names() { final ImmutableMap.Builder<String, String> map = new ImmutableMap.Builder<String, String>(); Iterables.all( this.table.frame().through( new QueryValve().withAttributesToGet( DyLocks.ATTR_LABEL ) ).where(DyLocks.HASH, Conditions.equalTo(this.owner)), new Predicate<Item>() { @Override public boolean apply(final Item item) { try { map.put( item.get(DyLocks.RANGE).getS(), item.get(DyLocks.ATTR_LABEL).getS() ); } catch (final IOException ex) { throw new IllegalStateException(ex); } return true; } } ); return map.build(); }
@Override @Cacheable.FlushAfter public void delete(final String name) { Iterators.removeIf( this.table.frame() .through(new QueryValve().withLimit(1)) .where(DyCounters.HASH, Conditions.equalTo(this.owner)) .where(DyCounters.RANGE, Conditions.equalTo(name)) .iterator(), Predicates.alwaysTrue() ); }
@Override @Cacheable(lifetime = 1, unit = TimeUnit.HOURS) public String token() throws IOException { final Iterator<Item> items = this.region.table(DefaultUser.TOKENS) .frame().through(new QueryValve()) .where(DefaultUser.HASH, Conditions.equalTo(this.name)) .iterator(); final String token; if (items.hasNext()) { token = items.next().get(DefaultUser.ATTR_TOKEN).getS(); } else { this.refresh(); token = this.token(); } return token; }
@Override @NotNull @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops") @Cacheable(lifetime = Tv.FIVE, unit = TimeUnit.MINUTES) public ConcurrentMap<URN, Domains> load() throws IOException { final ConcurrentMap<URN, Domains> domains = new ConcurrentHashMap<URN, Domains>(0); final Iterable<Item> items = this.region .table(this.table) .frame() .through( new ScanValve().withAttributeToGet( DefaultDynamo.USER, DefaultDynamo.NAME, DefaultDynamo.KEY, DefaultDynamo.SECRET, DefaultDynamo.BUCKET, DefaultDynamo.REGION, DefaultDynamo.SYSLOG ).withLimit(Tv.MILLION) ); for (final Item item : items) { final URN user = URN.create(item.get(DefaultDynamo.USER).getS()); domains.putIfAbsent(user, new Domains()); domains.get(user).add(DefaultDynamo.domain(item)); } return domains; }
@Override @Cacheable(lifetime = 1, unit = TimeUnit.HOURS) public Counter get(final String name) { return new DyCounter( this.table.frame() .through(new QueryValve().withLimit(1)) .where(DyCounters.HASH, Conditions.equalTo(this.owner)) .where(DyCounters.RANGE, Conditions.equalTo(name)) .iterator() .next() ); }
/** * Recent artifacts.. * @return List of them */ public Iterable<Iterable<Directive>> recent() { return new Mapped<>( item -> { final String[] parts = item.get("artifact").getS().split(":"); return new Directives() .add("repo") .add("group").set(parts[0]).up() .add("artifact").set(parts[1]).up() .up(); }, this.table.frame() .where("good", "true") .through( new QueryValve() .withScanIndexForward(false) .withIndexName("recent") .withConsistentRead(false) // @checkstyle MagicNumber (1 line) .withLimit(25) .withAttributesToGet("artifact") ) ); }
.up(); }, this.table.frame() .where( "elements",
.up(); }, this.table.frame() .where("version", new Version().value()) .through(
.add("sigma").set(new DyNum(item, "sigma").doubleValue()).up() .up(), this.table.frame() .where("version", new Version().value()) .through(