예제 #1
0
  @Override
  public <M extends Message> EntityIdToFieldFullKeyImpl<M> getEntityIdToFieldFullKeyFromBytes(
      Subspace subspace, BadgerEntityDescriptor<M> expectedBadgerEntityDescriptor, byte[] bytes) {
    TupleIterator tupleIterator = TupleIterator.unpack(subspace, bytes);
    BadgerEntityDescriptor<M> badgerEntityDescriptor =
        checkTupleAndGetBadgerEntityDescriptor(
            tupleIterator,
            expectedBadgerEntityDescriptor,
            EntityIdToFieldAllFieldsKeyImpl.getKeyTypeId());

    String entityId = tupleIterator.nextString();
    ImmutableList<Integer> orderedFieldNumbers = getIntegerValues(tupleIterator, true);
    ImmutableList<Integer> orderedRepeatedFieldIndexes =
        tupleIterator.hasNext()
            ? getIntegerValues(tupleIterator, true)
            : ImmutableList.<Integer>of();

    return new EntityIdToFieldFullKeyImpl<>(
        badgerEntityDescriptor,
        entityId,
        badgerEntityDescriptor.getBadgerTag(orderedFieldNumbers, orderedRepeatedFieldIndexes));
  }
예제 #2
0
  @Override
  public <M extends Message> FieldToEntityIdFullKeyImpl<M> getFieldToEntityIdFullKeyFromBytes(
      Subspace subspace, BadgerEntityDescriptor<M> expectedBadgerEntityDescriptor, byte[] bytes) {
    TupleIterator tupleIterator = TupleIterator.unpack(subspace, bytes);
    BadgerEntityDescriptor<M> badgerEntityDescriptor =
        checkTupleAndGetBadgerEntityDescriptor(
            tupleIterator,
            expectedBadgerEntityDescriptor,
            FieldToEntityIdBoundsKeyImpl.getKeyTypeId());

    ImmutableList<Integer> orderedFieldNumbers = getIntegerValues(tupleIterator, false);
    Object value = tupleIterator.nextObject();
    String entityId = tupleIterator.nextString();
    ImmutableList<Integer> orderedRepeatedFieldIndexes =
        tupleIterator.hasNext()
            ? getIntegerValues(tupleIterator, true)
            : ImmutableList.<Integer>of();

    BadgerTag badgerTag =
        badgerEntityDescriptor.getBadgerTag(orderedFieldNumbers, orderedRepeatedFieldIndexes);
    value = Tuples.fromTupleObject(badgerTag.getBadgerTagDescriptor(), value);
    return new FieldToEntityIdFullKeyImpl<>(badgerEntityDescriptor, badgerTag, value, entityId);
  }
예제 #3
0
 private <M extends Message> BadgerEntityDescriptor<M> checkAndGetBadgerEntityDescriptor(
     TupleIterator tupleIterator, BadgerEntityDescriptor<M> badgerEntityDescriptor) {
   Preconditions.checkArgument(
       badgerEntityDescriptor.getFullName().equals(tupleIterator.nextString()));
   return badgerEntityDescriptor;
 }