/** * synchronously indexes the row with all the indexes. ignores failures. * @param row */ protected void indexRow(Row<T, K> row) { for (Index<T,K,?> index : indexes) { try { index.index(row); } catch (RuntimeException e) { e.printStackTrace(); // TODO: log } } }
public Iterable<Row<T, K>> search(Q query) throws AvroBaseException { return Iterables.transform(index.search(query), new Function<K, Row<T,K>>() { @Override public Row<T, K> apply(K from) { if (from == null) return null; return delegate().get(from); } }); }
@Override public void delete(K row) throws AvroBaseException { delegate().delete(row); index.unindex(row); }
@Override public void delete(K row) throws AvroBaseException { delegate().delete(row); for (Index<T,K,?> index : indexes) { index.unindex(row); } }
public void reindex() { final Iterable<Row<T, K>> rows = scan(null, null); for (Row<T, K> row : rows) { for (Index<T, K, ?> idx : indexes) { idx.index(row); } } } }
public void reindex() { final Iterable<Row<T, K>> rows = scan(null, null); for (Row<T, K> row : rows) { index.index(row); } } }
@Override public Row<T, K> mutate(K row, final Mutator<T> tMutator) throws AvroBaseException { final boolean[] success = {false}; final Row<T, K> newRow = delegate().mutate(row, new Mutator<T>() { @Override public T mutate(T value) { T mutate = tMutator.mutate(value); if (mutate != null) { success[0] = true; } return mutate; } }); if (success[0]) { index.index(newRow); } return newRow; }
@Override public Row<T, K> mutate(K row, final Mutator<T> tMutator, Creator<T> tCreator) throws AvroBaseException { final boolean[] success = {false}; final Row<T, K> newRow = delegate().mutate(row, new Mutator<T>() { @Override public T mutate(T value) { T mutate = tMutator.mutate(value); if (mutate != null) { success[0] = true; } return mutate; } }, tCreator); if (success[0]) { index.index(newRow); } return newRow; }
@Override public K create(T value) throws AvroBaseException { final K row = delegate().create(value); index.index(new Row<T,K>(value, row)); return row; }
@Override public boolean put(K row, T value, long version) throws AvroBaseException { final boolean rv = delegate().put(row, value, version); if (rv) { index.index(new Row<T,K>(value, row)); } return rv; }
@Override public void put(K row, T value) throws AvroBaseException { delegate().put(row, value); index.index(new Row<T,K>(value, row)); }