@java.lang.Override public int getSerializedSize() { int size = memoizedSize; if (size != -1) return size; size = 0; { int dataSize = 0; for (int i = 0; i < fieldName_.size(); i++) { dataSize += computeStringSizeNoTag(fieldName_.getRaw(i)); } size += dataSize; size += 1 * getFieldNameList().size(); } for (int i = 0; i < row_.size(); i++) { size += com.google.protobuf.CodedOutputStream .computeMessageSize(2, row_.get(i)); } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); if (getFieldNameCount() > 0) { hash = (37 * hash) + FIELDNAME_FIELD_NUMBER; hash = (53 * hash) + getFieldNameList().hashCode(); } if (getRowCount() > 0) { hash = (37 * hash) + ROW_FIELD_NUMBER; hash = (53 * hash) + getRowList().hashCode(); } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
@java.lang.Override public org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.Table buildPartial() { org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.Table result = new org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.Table(this); int from_bitField0_ = bitField0_; if (((bitField0_ & 0x00000001) == 0x00000001)) { fieldName_ = fieldName_.getUnmodifiableView(); bitField0_ = (bitField0_ & ~0x00000001); } result.fieldName_ = fieldName_; if (rowBuilder_ == null) { if (((bitField0_ & 0x00000002) == 0x00000002)) { row_ = java.util.Collections.unmodifiableList(row_); bitField0_ = (bitField0_ & ~0x00000002); } result.row_ = row_; } else { result.row_ = rowBuilder_.build(); } onBuilt(); return result; }
public Builder mergeFrom(org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.Table other) { if (other == org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.Table.getDefaultInstance()) return this; if (!other.fieldName_.isEmpty()) { if (fieldName_.isEmpty()) {
case 3: result = result && getTableResult() .equals(other.getTableResult()); break; case 0:
private OQLQueryResponse encodeResults(final ProtobufSerializationService serializationService, final Object value) throws EncodingException { final Builder builder = OQLQueryResponse.newBuilder(); // The result is a single value if (!(value instanceof SelectResults)) { builder.setSingleResult(serializationService.encode(value)); return builder.build(); } SelectResults<?> selectResults = (SelectResults<?>) value; // The result is a list of objects if (!selectResults.getCollectionType().getElementType().isStructType()) { BasicTypes.EncodedValueList.Builder listResult = BasicTypes.EncodedValueList.newBuilder(); selectResults.stream().map(serializationService::encode).forEach(listResult::addElement); builder.setListResult(listResult); return builder.build(); } // The result is a list of structs SelectResults<Struct> structResults = (SelectResults<Struct>) selectResults; StructType elementType = (StructType) structResults.getCollectionType().getElementType(); BasicTypes.Table.Builder tableResult = BasicTypes.Table.newBuilder(); tableResult.addAllFieldName(Arrays.asList(elementType.getFieldNames())); for (Struct row : structResults) { tableResult.addRow(encodeStruct(serializationService, row)); } builder.setTableResult(tableResult); return builder.build(); }
/** * <code>.org.apache.geode.internal.protocol.protobuf.v1.Table tableResult = 3;</code> */ public Builder mergeTableResult(org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.Table value) { if (tableResultBuilder_ == null) { if (resultCase_ == 3 && result_ != org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.Table.getDefaultInstance()) { result_ = org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.Table.newBuilder((org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.Table) result_) .mergeFrom(value).buildPartial(); } else { result_ = value; } onChanged(); } else { if (resultCase_ == 3) { tableResultBuilder_.mergeFrom(value); } tableResultBuilder_.setMessage(value); } resultCase_ = 3; return this; } /**
@Test public void queryForMultipleStructs() throws ConnectionStateException, DecodingException, InvalidExecutionContextException, EncodingException, NameResolutionException, TypeMismatchException, QueryInvocationTargetException, FunctionDomainException { Query query = mock(DefaultQuery.class); when(queryService.newQuery(eq(SELECT_STAR_QUERY))).thenReturn(query); SelectResults results = new LinkedStructSet(); StructTypeImpl elementType = new StructTypeImpl(new String[] {"field1"}); results.setElementType(elementType); results.add(new StructImpl(elementType, new Object[] {STRING_RESULT_1})); results.add(new StructImpl(elementType, new Object[] {STRING_RESULT_2})); when(query.execute((Object[]) any())).thenReturn(results); final OQLQueryRequest request = OQLQueryRequest.newBuilder().setQuery(SELECT_STAR_QUERY).build(); final Result<OQLQueryResponse> result = operationHandler.process(serializationService, request, TestExecutionContext.getNoAuthCacheExecutionContext(cacheStub)); assertEquals( Arrays.asList( BasicTypes.EncodedValueList.newBuilder() .addElement(serializationService.encode(STRING_RESULT_1)).build(), BasicTypes.EncodedValueList.newBuilder() .addElement(serializationService.encode(STRING_RESULT_2)).build()), result.getMessage().getTableResult().getRowList()); }
/** * <code>.org.apache.geode.internal.protocol.protobuf.v1.Table tableResult = 3;</code> */ private com.google.protobuf.SingleFieldBuilderV3< org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.Table, org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.Table.Builder, org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.TableOrBuilder> getTableResultFieldBuilder() { if (tableResultBuilder_ == null) { if (!(resultCase_ == 3)) { result_ = org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.Table.getDefaultInstance(); } tableResultBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.Table, org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.Table.Builder, org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.TableOrBuilder>( (org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.Table) result_, getParentForChildren(), isClean()); result_ = null; } resultCase_ = 3; onChanged();; return tableResultBuilder_; } @java.lang.Override
/** * <code>.org.apache.geode.internal.protocol.protobuf.v1.Table tableResult = 3;</code> */ public org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.Table getTableResult() { if (tableResultBuilder_ == null) { if (resultCase_ == 3) { return (org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.Table) result_; } return org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.Table.getDefaultInstance(); } else { if (resultCase_ == 3) { return tableResultBuilder_.getMessage(); } return org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.Table.getDefaultInstance(); } } /**
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.Table)) { return super.equals(obj); } org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.Table other = (org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.Table) obj; boolean result = true; result = result && getFieldNameList() .equals(other.getFieldNameList()); result = result && getRowList() .equals(other.getRowList()); result = result && unknownFields.equals(other.unknownFields); return result; }
private void checkResults(final String query, EncodedValue[] bindParameters, String[] fieldnames, final Object[]... rows) throws InvalidExecutionContextException, ConnectionStateException, EncodingException, DecodingException { ProtobufSerializationService serializer = new ProtobufSerializationService(); final Result<OQLQueryResponse> results = invokeHandler(query, bindParameters, serializer); List<BasicTypes.EncodedValueList> expected = new ArrayList<>(); for (Object[] row : rows) { List<EncodedValue> encodedRow = Arrays.asList(row).stream().map(serializer::encode).collect(Collectors.toList()); expected.add(BasicTypes.EncodedValueList.newBuilder().addAllElement(encodedRow).build()); } assertEquals(expected, results.getMessage().getTableResult().getRowList()); assertEquals(Arrays.asList(fieldnames), results.getMessage().getTableResult().getFieldNameList()); }
private List<Map<String, Object>> parseTableResult(final OQLQueryResponse response) { final Table table = response.getTableResult(); final ProtocolStringList fieldNames = table.getFieldNameList(); List<Map<String, Object>> results = new ArrayList<>(); for (BasicTypes.EncodedValueList row : table.getRowList()) { final List<Object> decodedRow = row.getElementList().stream().map(valueEncoder::decodeValue) .collect(Collectors.toList()); Map<String, Object> rowMap = new LinkedHashMap<>(decodedRow.size()); for (int i = 0; i < decodedRow.size(); i++) { rowMap.put(fieldNames.get(i), decodedRow.get(i)); } results.add(rowMap); } return results; }
@java.lang.Override public org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.Table getDefaultInstanceForType() { return org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.Table.getDefaultInstance(); }
@java.lang.Override public Builder newBuilderForType() { return newBuilder(); } public static Builder newBuilder() {
/** * <code>.org.apache.geode.internal.protocol.protobuf.v1.Table tableResult = 3;</code> */ public org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.TableOrBuilder getTableResultOrBuilder() { if ((resultCase_ == 3) && (tableResultBuilder_ != null)) { return tableResultBuilder_.getMessageOrBuilder(); } else { if (resultCase_ == 3) { return (org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.Table) result_; } return org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.Table.getDefaultInstance(); } } /**
/** * <code>.org.apache.geode.internal.protocol.protobuf.v1.Table tableResult = 3;</code> */ public org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.Table getTableResult() { if (resultCase_ == 3) { return (org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.Table) result_; } return org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.Table.getDefaultInstance(); } /**
/** * <code>.org.apache.geode.internal.protocol.protobuf.v1.Table tableResult = 3;</code> */ public org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.TableOrBuilder getTableResultOrBuilder() { if (resultCase_ == 3) { return (org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.Table) result_; } return org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.Table.getDefaultInstance(); }