Source: ml/util/MLWriter.js

  1. /*
  2. * Copyright 2016 IBM Corp.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. var Utils = require('../../utils.js');
  17. /**
  18. * @classdesc
  19. * :: Experimental ::
  20. *
  21. * Abstract class for utility classes that can save ML instances.
  22. * @class
  23. * @memberof module:eclairjs/ml/util
  24. */
  25. /**
  26. * @returns {Promise.<Void>} A Promise that resolves to nothing.
  27. * @constructor
  28. */
  29. function MLWriter(kernelP, refIdP) {
  30. throw "Can't instantiate abstract class - MLWriter";
  31. }
  32. /**
  33. * Saves the ML instances to the input path.
  34. * @param {string} path
  35. * @returns {Promise.<Void>} A Promise that resolves to nothing.
  36. */
  37. MLWriter.prototype.save = function(path) {
  38. var args ={
  39. target: this,
  40. method: 'save',
  41. args: Utils.wrapArguments(arguments),
  42. returnType: null
  43. };
  44. return Utils.generate(args);
  45. };
  46. /**
  47. * Overwrites if the output path already exists.
  48. * @returns {MLWriter}
  49. */
  50. MLWriter.prototype.overwrite = function() {
  51. var args ={
  52. target: this,
  53. method: 'overwrite',
  54. returnType: MLWriter
  55. };
  56. return Utils.generate(args);
  57. };
  58. /**
  59. * @param {module:eclairjs/sql.SparkSession} sparkSession
  60. * @returns {MLWriter}
  61. */
  62. MLWriter.prototype.session = function(sparkSession) {
  63. var args ={
  64. target: this,
  65. method: 'session',
  66. args: Utils.wrapArguments(arguments),
  67. returnType: MLWriter
  68. };
  69. return Utils.generate(args);
  70. };
  71. /**
  72. * @param {module:eclairjs/sql.SQLContext} sqlContext
  73. * @returns {MLWriter}
  74. */
  75. MLWriter.prototype.context = function(sqlContext) {
  76. var args ={
  77. target: this,
  78. method: 'context',
  79. args: Utils.wrapArguments(arguments),
  80. returnType: MLWriter
  81. };
  82. return Utils.generate(args);
  83. };
  84. module.exports = MLWriter;