Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2018 Edmunds.com, Inc.
*
* Licensed 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 com.edmunds.rest.databricks.service;
import com.edmunds.rest.databricks.DTO.DbfsReadDTO;
import com.edmunds.rest.databricks.DTO.dbfs.FileInfoDTO;
import com.edmunds.rest.databricks.DatabricksRestException;
import com.edmunds.rest.databricks.RequestMethod;
import com.edmunds.rest.databricks.restclient.DatabricksRestClient;
import com.fasterxml.jackson.core.type.TypeReference;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.net.util.Base64;
/**
* The implementation of DbfsService.
*/
public class DbfsServiceImpl extends DatabricksService implements DbfsService {
public DbfsServiceImpl(final DatabricksRestClient client) {
super(client);
}
@Override
public void rm(String path, boolean recursive) throws IOException, DatabricksRestException {
Map data = new HashMap<>();
data.put("path", path);
data.put("recursive", recursive);
client.performQuery(RequestMethod.POST, "/dbfs/delete", data);
}
@Override
public FileInfoDTO getInfo(String path) throws IOException, DatabricksRestException {
Map data = new HashMap<>();
data.put("path", path);
byte[] responseBody = client.performQuery(RequestMethod.GET, "/dbfs/get-status", data);
return mapper.readValue(responseBody, FileInfoDTO.class);
}
@Override
public FileInfoDTO[] ls(String path) throws IOException, DatabricksRestException {
Map data = new HashMap<>();
data.put("path", path);
byte[] responseBody = client.performQuery(RequestMethod.GET, "/dbfs/list", data);
Map jsonObject = this.mapper
.readValue(responseBody, new TypeReference