org.apache.kylin.rest.model.Query Java Examples

The following examples show how to use org.apache.kylin.rest.model.Query. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: QueryService.java    From Kylin with Apache License 2.0 6 votes vote down vote up
public void saveQuery(final String creator, final Query query) throws IOException {
    List<Query> queries = getQueries(creator);
    queries.add(query);
    Query[] queryArray = new Query[queries.size()];

    byte[] bytes = querySerializer.serialize(queries.toArray(queryArray));
    HTableInterface htable = null;
    try {
        htable = HBaseConnection.get(hbaseUrl).getTable(userTableName);
        Put put = new Put(Bytes.toBytes(creator));
        put.add(Bytes.toBytes(USER_QUERY_FAMILY), Bytes.toBytes(USER_QUERY_COLUMN), bytes);

        htable.put(put);
        htable.flushCommits();
    } finally {
        IOUtils.closeQuietly(htable);
    }
}
 
Example #2
Source File: QueryService.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
public void removeQuery(final String creator, final String id) throws IOException {
    List<Query> queries = getQueries(creator);
    Iterator<Query> queryIter = queries.iterator();

    boolean changed = false;
    while (queryIter.hasNext()) {
        Query temp = queryIter.next();
        if (temp.getId().equals(id)) {
            queryIter.remove();
            changed = true;
            break;
        }
    }

    if (!changed) {
        return;
    }
    Query[] queryArray = new Query[queries.size()];
    QueryRecord record = new QueryRecord(queries.toArray(queryArray));
    queryStore.putResource(getQueryKeyById(creator), record, System.currentTimeMillis(),
            QueryRecordSerializer.getInstance());
    return;
}
 
Example #3
Source File: QueryService.java    From kylin with Apache License 2.0 6 votes vote down vote up
public void removeQuery(final String creator, final String id) throws IOException {
    List<Query> queries = getQueries(creator);
    Iterator<Query> queryIter = queries.iterator();

    boolean changed = false;
    while (queryIter.hasNext()) {
        Query temp = queryIter.next();
        if (temp.getId().equals(id)) {
            queryIter.remove();
            changed = true;
            break;
        }
    }

    if (!changed) {
        return;
    }
    Query[] queryArray = new Query[queries.size()];
    QueryRecord record = new QueryRecord(queries.toArray(queryArray));
    queryStore.putResource(getQueryKeyById(creator), record, System.currentTimeMillis(),
            QueryRecordSerializer.getInstance());
    return;
}
 
Example #4
Source File: QueryService.java    From kylin with Apache License 2.0 5 votes vote down vote up
public void saveQuery(final String creator, final Query query) throws IOException {
    List<Query> queries = getQueries(creator);
    queries.add(query);
    Query[] queryArray = new Query[queries.size()];
    QueryRecord record = new QueryRecord(queries.toArray(queryArray));
    queryStore.putResource(getQueryKeyById(creator), record, System.currentTimeMillis(),
            QueryRecordSerializer.getInstance());
    return;
}
 
Example #5
Source File: QueryService.java    From Kylin with Apache License 2.0 5 votes vote down vote up
public void removeQuery(final String creator, final String id) throws IOException {
    List<Query> queries = getQueries(creator);
    Iterator<Query> queryIter = queries.iterator();

    boolean changed = false;
    while (queryIter.hasNext()) {
        Query temp = queryIter.next();
        if (temp.getId().equals(id)) {
            queryIter.remove();
            changed = true;
            break;
        }
    }

    if (!changed) {
        return;
    }

    Query[] queryArray = new Query[queries.size()];
    byte[] bytes = querySerializer.serialize(queries.toArray(queryArray));
    HTableInterface htable = null;
    try {
        htable = HBaseConnection.get(hbaseUrl).getTable(userTableName);
        Put put = new Put(Bytes.toBytes(creator));
        put.add(Bytes.toBytes(USER_QUERY_FAMILY), Bytes.toBytes(USER_QUERY_COLUMN), bytes);

        htable.put(put);
        htable.flushCommits();
    } finally {
        IOUtils.closeQuietly(htable);
    }
}
 
Example #6
Source File: QueryController.java    From Kylin with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = "/saved_queries", method = RequestMethod.GET)
@ResponseBody
@Timed(name = "getQueries")
public List<Query> getQueries() throws IOException {
    String creator = SecurityContextHolder.getContext().getAuthentication().getName();
    return queryService.getQueries(creator);
}
 
Example #7
Source File: QueryController.java    From Kylin with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = "/saved_queries", method = RequestMethod.POST)
@ResponseBody
@Timed(name = "saveQuery")
public void saveQuery(@RequestBody SaveSqlRequest sqlRequest) throws IOException {
    String creator = SecurityContextHolder.getContext().getAuthentication().getName();
    Query newQuery = new Query(sqlRequest.getName(), sqlRequest.getProject(), sqlRequest.getSql(), sqlRequest.getDescription());

    queryService.saveQuery(creator, newQuery);
}
 
Example #8
Source File: QueryService.java    From kylin with Apache License 2.0 5 votes vote down vote up
public List<Query> getQueries(final String creator, final String project) throws IOException {
    if (null == creator) {
        return null;
    }
    List<Query> queries = new ArrayList<>();
    QueryRecord record = queryStore.getResource(getQueryKeyById(creator), QueryRecordSerializer.getInstance());
    if (record != null) {
        for (Query query : record.getQueries()) {
            if (project == null || query.getProject().equals(project))
                queries.add(query);
        }
    }
    return queries;
}
 
Example #9
Source File: QueryController.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = "/saved_queries", method = RequestMethod.POST, produces = { "application/json" })
@ResponseBody
public void saveQuery(@RequestBody SaveSqlRequest sqlRequest) throws IOException {
    String creator = SecurityContextHolder.getContext().getAuthentication().getName();
    Query newQuery = new Query(sqlRequest.getName(), sqlRequest.getProject(), sqlRequest.getSql(),
            sqlRequest.getDescription());

    queryService.saveQuery(creator, newQuery);
}
 
Example #10
Source File: QueryController.java    From kylin with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = "/saved_queries", method = RequestMethod.GET, produces = { "application/json" })
@ResponseBody
public List<Query> getQueries(@RequestParam(value = "project", required = false) String project)
        throws IOException {
    String creator = SecurityContextHolder.getContext().getAuthentication().getName();
    return queryService.getQueries(creator, project);
}
 
Example #11
Source File: QueryController.java    From kylin with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = "/saved_queries", method = RequestMethod.POST, produces = { "application/json" })
@ResponseBody
public void saveQuery(@RequestBody SaveSqlRequest sqlRequest) throws IOException {
    String creator = SecurityContextHolder.getContext().getAuthentication().getName();
    Query newQuery = new Query(sqlRequest.getName(), sqlRequest.getProject(), sqlRequest.getSql(),
            sqlRequest.getDescription());

    queryService.saveQuery(creator, newQuery);
}
 
Example #12
Source File: QueryService.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
public List<Query> getQueries(final String creator, final String project) throws IOException {
    if (null == creator) {
        return null;
    }
    List<Query> queries = new ArrayList<>();
    QueryRecord record = queryStore.getResource(getQueryKeyById(creator), QueryRecordSerializer.getInstance());
    if (record != null) {
        for (Query query : record.getQueries()) {
            if (project == null || query.getProject().equals(project))
                queries.add(query);
        }
    }
    return queries;
}
 
Example #13
Source File: QueryService.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
public void saveQuery(final String creator, final Query query) throws IOException {
    List<Query> queries = getQueries(creator);
    queries.add(query);
    Query[] queryArray = new Query[queries.size()];
    QueryRecord record = new QueryRecord(queries.toArray(queryArray));
    queryStore.putResource(getQueryKeyById(creator), record, System.currentTimeMillis(),
            QueryRecordSerializer.getInstance());
    return;
}
 
Example #14
Source File: QueryController.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = "/saved_queries", method = RequestMethod.GET, produces = { "application/json" })
@ResponseBody
public List<Query> getQueries(@RequestParam(value = "project", required = false) String project)
        throws IOException {
    String creator = SecurityContextHolder.getContext().getAuthentication().getName();
    return queryService.getQueries(creator, project);
}
 
Example #15
Source File: QueryService.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
public void setQueries(Query[] queries) {
    this.queries = queries;
}
 
Example #16
Source File: QueryService.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
public Query[] getQueries() {
    return queries;
}
 
Example #17
Source File: QueryService.java    From kylin with Apache License 2.0 4 votes vote down vote up
public List<Query> getQueries(final String creator) throws IOException {
    return getQueries(creator, null);
}
 
Example #18
Source File: QueryService.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
public QueryRecord(Query[] queries) {
    this.queries = queries;
}
 
Example #19
Source File: QueryService.java    From kylin with Apache License 2.0 4 votes vote down vote up
public QueryRecord(Query[] queries) {
    this.queries = queries;
}
 
Example #20
Source File: QueryService.java    From kylin with Apache License 2.0 4 votes vote down vote up
public Query[] getQueries() {
    return queries;
}
 
Example #21
Source File: QueryService.java    From kylin with Apache License 2.0 4 votes vote down vote up
public void setQueries(Query[] queries) {
    this.queries = queries;
}
 
Example #22
Source File: QueryService.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
public List<Query> getQueries(final String creator) throws IOException {
    return getQueries(creator, null);
}