cool-core/src/main/java/com/nus/cool/loader/DataLoader.java
public void load() throws IOException {
        // create a new cube file
        DataOutputStream out = newCublet();
        int userKeyIndex = tableSchema.getUserKeyField();
        String lastUser = null;
        int tuples = 0;
        ChunkWS chunk = ChunkWS.newChunk(tableSchema, metaFields, offset);

        // store the dataset file into cool native format
        while (reader.hasNext()) {
            String[] tuple = parser.parse(reader.next());
            String curUser = tuple[userKeyIndex];
            if (lastUser == null) {
                lastUser = curUser;
            }
            if ((!curUser.equals(lastUser)) && (tuples >= chunkSize)) {
                chunk = switchChunk(out, chunk);
                // When a cublet is full, create another one
                if (offset >= cubletSize) {
                    closeCublet(out);
                    out = newCublet();
                }
                tuples = 0;
            }
            lastUser = curUser;
            chunk.put(tuple);
            tuples++;
        }
        offset += chunk.writeTo(out);
        chunkOffsets.add(offset-Ints.BYTES);
        closeCublet(out);
    }
/**
     * load data into cool native format
     * @throws IOException
     */
load data into cool native format
@throws IOException
load data into cool native format @throws IOException
public void load() throws IOException {
        DataOutputStream out = newCublet();
        int userKeyIndex = tableSchema.getUserKeyField();
        String lastUser = null;
        int tuples = 0;
        ChunkWS chunk = ChunkWS.newChunk(tableSchema, metaFields, offset);
        while (reader.hasNext()) {
            String[] tuple = parser.parse(reader.next());
            String curUser = tuple[userKeyIndex];
            if (lastUser == null) {
                lastUser = curUser;
            }
            if ((!curUser.equals(lastUser)) && (tuples >= chunkSize)) {
                chunk = switchChunk(out, chunk);
                if (offset >= cubletSize) {
                    closeCublet(out);
                    out = newCublet();
                }
                tuples = 0;
            }
            lastUser = curUser;
            chunk.put(tuple);
            tuples++;
        }
        offset += chunk.writeTo(out);
        chunkOffsets.add(offset-Ints.BYTES);
        closeCublet(out);
    }
public void load ( ) throws IOException { DataOutputStream out = newCublet ( ) ; int userKeyIndex = tableSchema . getUserKeyField ( ) ; String lastUser = null ; int tuples = 0 ; ChunkWS chunk = ChunkWS . newChunk ( tableSchema , metaFields , offset ) ; while ( reader . hasNext ( ) ) { String [ ] tuple = parser . parse ( reader . next ( ) ) ; String curUser = tuple [ userKeyIndex ] ; if ( lastUser == null ) { lastUser = curUser ; } if ( ( ! curUser . equals ( lastUser ) ) && ( tuples >= chunkSize ) ) { chunk = switchChunk ( out , chunk ) ; if ( offset >= cubletSize ) { closeCublet ( out ) ; out = newCublet ( ) ; } tuples = 0 ; } lastUser = curUser ; chunk . put ( tuple ) ; tuples ++ ; } offset += chunk . writeTo ( out ) ; chunkOffsets . add ( offset - Ints . BYTES ) ; closeCublet ( out ) ; }
load data into cool native format
 @throws IOException
load data into cool native format @throws IOException
// create a new cube file // store the dataset file into cool native format // When a cublet is full, create another one