Github user charsyam commented on a diff in the pull request:

    https://github.com/apache/tajo/pull/876#discussion_r46093935
  
    --- Diff: 
tajo-core/src/main/java/org/apache/tajo/ws/rs/resources/outputs/CSVStreamingOutput.java
 ---
    @@ -0,0 +1,134 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.tajo.ws.rs.resources.outputs;
    +
    +import com.google.protobuf.ByteString;
    +import org.apache.commons.lang.StringEscapeUtils;
    +import org.apache.tajo.catalog.Column;
    +import org.apache.tajo.catalog.Schema;
    +import org.apache.tajo.common.TajoDataTypes;
    +import org.apache.tajo.datum.Datum;
    +import org.apache.tajo.engine.function.annotation.ParamTypes;
    +import org.apache.tajo.master.exec.NonForwardQueryResultScanner;
    +import org.apache.tajo.storage.Tuple;
    +import org.apache.tajo.ws.rs.annotation.RestReturnType;
    +
    +import javax.ws.rs.WebApplicationException;
    +import javax.ws.rs.core.MediaType;
    +import java.io.BufferedOutputStream;
    +import java.io.DataOutputStream;
    +import java.io.IOException;
    +import java.io.OutputStream;
    +import java.util.List;
    +
    +@RestReturnType(
    +        description = "default binary streaming output",
    +        headerType = "application/csv"
    +)
    +public class CSVStreamingOutput extends AbstractStreamingOutput {
    +    private List<Tuple> outpuTupletList;
    +    private String output;
    +    private boolean alreadyCalculated = false;
    +    private int length = 0;
    +
    +    public CSVStreamingOutput(NonForwardQueryResultScanner 
cachedQueryResultScanner, Integer count, Integer startOffset) throws 
IOException {
    +        super(cachedQueryResultScanner, count, startOffset);
    +    }
    +
    +    @Override
    +    public boolean hasLength() {
    +        return true;
    +    }
    +
    +    @Override
    +    public int length() {
    +        try {
    +            fetch();
    +            return output.length();
    +        } catch (Exception e) {
    +            return 0;
    +        }
    +    }
    +
    +    @Override
    +    public int count() {
    +        try {
    +            fetch();
    +            return outpuTupletList.size();
    +        } catch (Exception e) {
    +            return 0;
    +        }
    +    }
    +
    +    private void fetch() throws IOException {
    +        if (output != null) {
    +            return;
    +        }
    +
    +        outpuTupletList = scanner.getNextTupleRows(count);
    +
    +        StringBuilder sb = new StringBuilder();
    +        if (startOffset == 0) {
    +            Schema schema = this.scanner.getLogicalSchema();
    +            List<Column> columns = schema.getAllColumns();
    +            boolean first = true;
    +            for (Column column : columns) {
    +                if (first == false) {
    --- End diff --
    
    @jihoonson you mean just replace first == false -> !first
    is it coding convention of tajo?
    Actually, I prefer using this explict expression
    
    but it is coding convention of tajo. I will replace :) 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to