-1

While learning Apache Gora, I have come to know the term data bean. Is it can be considered a data structure to hold the data or is something else.

Moreover, a similar term exist "Java beans". Is it same as data bean ? What's the difference between these three terms ?

Hafiz Muhammad Shafiq
  • 8,168
  • 12
  • 63
  • 121
  • 1
    You have over 5000 reputation. You have already asked many java questions. Have you not read [How much research effort is expected of Stack Overflow users?](https://meta.stackoverflow.com/questions/261592/how-much-research-effort-is-expected-of-stack-overflow-users) Searching the Internet for the term _JavaBeans_ will provide **lots** of information. – Abra Feb 25 '20 at 11:23
  • Sir, Thanks for your comment. I know what is the java Bean. I am querulous about the difference only and not their exact definition that can be found in Internet very easily. – Hafiz Muhammad Shafiq Feb 25 '20 at 11:48

2 Answers2

0
  1. Data beans are the main way to hold the data in memory and persist in Gora.

  2. Structure wise if you see Gora data beans look similar to java beans, but some AVRO specific differences as follows

    • These data beans contains Embedded Avro Schema declaration and an inner enum named Field. Theese enum will come in handy when we query the datastore for specific fields

    • Uses Utf8 class as a placeholder for string fields

After reading the Java Beans definition at wiki "JavaBeans are classes that encapsulate many objects into a single object (the bean). They are serializable, have a zero-argument constructor, and allow access to properties using getter and setter methods. The name "Bean" was given to encompass this standard, which aims to create reusable software components for Java"

I could not see any difference in data beans and java beans apart from the context in which both are used i.e. data beans as the name suggest to hold data in Gora and java beans to hold objects in java.

And data structure is nothing but a way of organizing data in programs or computer so that it can be used effectively.

Example of Data Bean Structure in GORA

public class Pageview extends PersistentBase {

private Utf8 url;
private long timestamp;
private Utf8 ip;

public static final Schema _SCHEMA = Schema.parse("{\"type\":\"record\", ... ");
  public static enum Field {
  URL(0,"url"),
  TIMESTAMP(1,"timestamp"),
  IP(2,"ip"),
  HTTP_METHOD(3,"httpMethod"),
  HTTP_STATUS_CODE(4,"httpStatusCode"),
  RESPONSE_SIZE(5,"responseSize"),
  REFERRER(6,"referrer"),
  USER_AGENT(7,"userAgent"),
  ;
  private int index;
  private String name;
  Field(int index, String name) {this.index=index;this.name=name;}
  public int getIndex() {return index;}
  public String getName() {return name;}
  public String toString() {return name;}
  };
  public static final String[] _ALL_FIELDS = {"url","timestamp","ip","httpMethod"
  ,"httpStatusCode","responseSize","referrer","userAgent",};
}
MOnkey
  • 751
  • 6
  • 13
0

There are plenty of other stackoverflow questions, but the overall naming of those terms might be unclear.

Let's try to define what could be a "bean" first.
The bean could be an instance of some object that holds some data in its state.
Bean term is also used to describe somekind of reusable software component.

The JavaBeans term refers to the standard and a convention for defining an object. This term was made, because the standard that it describes allows to have methods working on an object without knowing it exact type (eg serialization).
As this question nicely describes it, there is not much difference between JavaBean or another class. If the class follows that standard, it becomes a JavaBean.

There is also a Enterprise Java Beans (EJB), it's a part of JEE API. This API defines the way for implementation of the business logic as server-side components (EJB works in JEE web containers).
And the Spring Beans from the Spring Framework. Those beans are an objects that are instantiated, assembled and managed by Spring IoC container. They allows for taking advantage of dependency injection and inversion of control when implementing Spring applications.

Cutting to the chase.
The link you've enclosed, clearly defines the purpose of data bean in Apache Gora:

Data beans are the main way to hold the data in memory and persist in Gora.

The "bean" there refers to the general understanding of an instance of some data structure defined according to some standard. The "data" is just to indicate that it holds some values or more probably, because calling it just a "bean" would be a bit silly.

The names before "bean" in EJB, Spring Beans, JavaBeans describes the context of a particular bean. Similarly, in Apache Gora, the "data bean" tells that we are dealing with an instance of some data structure defined by the type of that "data bean".

There is no particular "data bean" term, which could refer to something else than just a structured data or values.

And in the end, almost all of the above are the data structures, as the data structure "is a data organization, management, and storage format that enables efficient access and modification". Tables, lists, stacks, rows and also an objects are types of datastructures.

itwasntme
  • 1,442
  • 4
  • 21
  • 28